当前位置: 首页>>代码示例>>Java>>正文


Java AssociationExistsException类代码示例

本文整理汇总了Java中org.alfresco.service.cmr.repository.AssociationExistsException的典型用法代码示例。如果您正苦于以下问题:Java AssociationExistsException类的具体用法?Java AssociationExistsException怎么用?Java AssociationExistsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AssociationExistsException类属于org.alfresco.service.cmr.repository包,在下文中一共展示了AssociationExistsException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAssociation

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
@Override
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class)
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
        throws InvalidNodeRefException, AssociationExistsException
{
    // The node(s) involved may not be pending deletion
    checkPendingDelete(sourceRef);
    checkPendingDelete(targetRef);
    
    Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef);
    long sourceNodeId = sourceNodePair.getFirst();
    Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef);
    long targetNodeId = targetNodePair.getFirst();

    // we are sure that the association doesn't exist - make it
    Long assocId = nodeDAO.newNodeAssoc(sourceNodeId, targetNodeId, assocTypeQName, -1);
    AssociationRef assocRef = new AssociationRef(assocId, sourceRef, assocTypeQName, targetRef);

    // Invoke policy behaviours
    invokeOnCreateAssociation(assocRef);
    
    // Add missing aspects
    addAspectsAndPropertiesAssoc(sourceNodePair, assocTypeQName, null, null, null, null, false);

    return assocRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:DbNodeServiceImpl.java

示例2: testDuplicateAssociationDetection

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
public void testDuplicateAssociationDetection() throws Exception
{
    AssociationRef assocRef = createAssociation();
    NodeRef sourceRef = assocRef.getSourceRef();
    NodeRef targetRef = assocRef.getTargetRef();
    QName qname = assocRef.getTypeQName();
    try
    {
        // attempt repeat
        nodeService.createAssociation(sourceRef, targetRef, qname);
        fail("Duplicate assocation not detected");
    }
    catch (AssociationExistsException e)
    {
        // expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:BaseNodeServiceTest.java

示例3: createAssociation

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
/**
 * @throws UnsupportedOperationException always
 */
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
        throws InvalidNodeRefException, AssociationExistsException
{
    // This operation is not supported for a version store
    throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:NodeServiceImpl.java

示例4: addChildren

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
public List<AssocChild> addChildren(String parentNodeId, List<AssocChild> entities)
{
    NodeRef parentNodeRef = validateNode(parentNodeId);

    List<AssocChild> result = new ArrayList<>(entities.size());

    for (AssocChild assoc : entities)
    {
        String childId = assoc.getChildId();
        if (childId == null)
        {
            throw new InvalidArgumentException("Missing childId");
        }

        QName assocTypeQName = getAssocType(assoc.getAssocType());

        try
        {
            NodeRef childNodeRef = validateNode(childId);

            String nodeName = (String)nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
            QName assocChildQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName));

            nodeService.addChild(parentNodeRef, childNodeRef, assocTypeQName, assocChildQName);
        }
        catch (AssociationExistsException aee)
        {
            throw new ConstraintViolatedException(aee.getMessage());
        }
        catch (DuplicateChildNodeNameException dcne)
        {
            throw new ConstraintViolatedException(dcne.getMessage());
        }

        result.add(assoc);
    }

    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:40,代码来源:NodesImpl.java

示例5: addTargets

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
public List<AssocTarget> addTargets(String sourceNodeId, List<AssocTarget> entities)
{
    List<AssocTarget> result = new ArrayList<>(entities.size());

    NodeRef srcNodeRef = validateNode(sourceNodeId);

    for (AssocTarget assoc : entities)
    {
        String targetNodeId = assoc.getTargetId();
        if (targetNodeId == null)
        {
            throw new InvalidArgumentException("Missing targetId");
        }

        String assocTypeStr = assoc.getAssocType();
        QName assocTypeQName = getAssocType(assocTypeStr);
        try
        {
            NodeRef tgtNodeRef = validateNode(targetNodeId);
            nodeAssocService.createAssociation(srcNodeRef, tgtNodeRef, assocTypeQName);
        }
        catch (AssociationExistsException aee)
        {
            throw new ConstraintViolatedException("Node association '"+assocTypeStr+"' already exists from "+sourceNodeId+" to "+targetNodeId);
        }
        catch (IllegalArgumentException iae)
        {
            // note: for now, we assume it is invalid assocType - alternatively, we could attempt to pre-validate via dictionary.getAssociation
            throw new InvalidArgumentException(sourceNodeId+","+assocTypeStr+","+targetNodeId);
        }

        result.add(assoc);
    }
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:36,代码来源:NodesImpl.java

示例6: newNodeAssoc

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
@Override
public Long newNodeAssoc(Long sourceNodeId, Long targetNodeId, QName assocTypeQName, int assocIndex)
{
    if (assocIndex == 0)
    {
        throw new IllegalArgumentException("Index is 1-based, or -1 to indicate 'next value'.");
    }
    
    // Touch the node; all caches are fine
    touchNode(sourceNodeId, null, null, false, false, false);

    // Resolve type QName
    Long assocTypeQNameId = qnameDAO.getOrCreateQName(assocTypeQName).getFirst();

    // Get the current max; we will need this no matter what
    if (assocIndex <= 0)
    {
        int maxIndex = selectNodeAssocMaxIndex(sourceNodeId, assocTypeQNameId);        
        assocIndex = maxIndex + 1;
    }
    
    Long result = null;
    Savepoint savepoint = controlDAO.createSavepoint("NodeService.newNodeAssoc");
    try
    {
        result = insertNodeAssoc(sourceNodeId, targetNodeId, assocTypeQNameId, assocIndex);
        controlDAO.releaseSavepoint(savepoint);
        return result;
    }
    catch (Throwable e)
    {
        controlDAO.rollbackToSavepoint(savepoint);
        if (isDebugEnabled)
        {
            logger.debug(
                    "Failed to insert node association: \n" +
                    "   sourceNodeId:   " + sourceNodeId + "\n" +
                    "   targetNodeId:   " + targetNodeId + "\n" +
                    "   assocTypeQName: " + assocTypeQName + "\n" +
                    "   assocIndex:     " + assocIndex,
                    e);
        }
        throw new AssociationExistsException(sourceNodeId, targetNodeId, assocTypeQName);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:46,代码来源:AbstractNodeDAOImpl.java

示例7: createAssociation

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
        throws InvalidNodeRefException, AssociationExistsException

{
    return nodeService.createAssociation(sourceRef, targetRef, assocTypeQName);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:7,代码来源:NodeAssocServiceImpl.java

示例8: createAssociation

import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
throws InvalidNodeRefException, AssociationExistsException;
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:3,代码来源:NodeAssocService.java


注:本文中的org.alfresco.service.cmr.repository.AssociationExistsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。