本文整理汇总了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;
}
示例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
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例8: createAssociation
import org.alfresco.service.cmr.repository.AssociationExistsException; //导入依赖的package包/类
AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
throws InvalidNodeRefException, AssociationExistsException;