use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class PeerAssociatedNodeFinder method processIncludedSet.
private Set<NodeRef> processIncludedSet(NodeRef startingNode) {
NodeService nodeService = serviceRegistry.getNodeService();
Set<NodeRef> foundNodes = new HashSet<NodeRef>(89);
for (QName assocType : peerAssociationTypes) {
List<AssociationRef> targets = nodeService.getTargetAssocs(startingNode, assocType);
for (AssociationRef target : targets) {
foundNodes.add(target.getTargetRef());
}
}
return foundNodes;
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class XMLTransferManifestWriter method writeSourceAssocs.
private void writeSourceAssocs(List<AssociationRef> refs) throws SAXException {
if (refs != null) {
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS, EMPTY_ATTRIBUTES);
for (AssociationRef assoc : refs) {
writeAssoc(assoc);
}
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_SOURCE_ASSOCS);
}
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class XMLTransferManifestWriter method writeTargetAssocs.
private void writeTargetAssocs(List<AssociationRef> refs) throws SAXException {
if (refs != null) {
writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS, EMPTY_ATTRIBUTES);
for (AssociationRef assoc : refs) {
writeAssoc(assoc);
}
writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_TARGET_ASSOCS);
}
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class RepoSecondaryManifestProcessorImpl method processNode.
protected void processNode(TransferManifestNormalNode node) {
logComment("Seconday Processing incoming node: " + node.getNodeRef());
log.debug("Seconday Processing incoming node: " + node.getNodeRef());
NodeRef correspondingNodeRef = nodeResolver.resolveCorrespondingNode(node.getNodeRef(), TransferManifestNodeHelper.getPrimaryParentAssoc(node), node.getParentPath()).resolvedChild;
if (correspondingNodeRef == null) {
correspondingNodeRef = node.getNodeRef();
}
// Process parent assocs...
List<ChildAssociationRef> requiredAssocs = node.getParentAssocs();
List<ChildAssociationRef> currentAssocs = nodeService.getParentAssocs(correspondingNodeRef);
processParentChildAssociations(requiredAssocs, currentAssocs, correspondingNodeRef, false);
// Process child assocs...
requiredAssocs = node.getChildAssocs();
currentAssocs = nodeService.getChildAssocs(correspondingNodeRef);
processParentChildAssociations(requiredAssocs, currentAssocs, correspondingNodeRef, true);
// Process "target" peer associations (associations *from* this node)
List<AssociationRef> requiredTargetAssocs = node.getTargetAssocs();
List<AssociationRef> currentTargetAssocs = nodeService.getTargetAssocs(correspondingNodeRef, RegexQNamePattern.MATCH_ALL);
processPeerAssociations(requiredTargetAssocs, currentTargetAssocs, correspondingNodeRef, true);
// Process "source" peer associations (associations *to* this node)
List<AssociationRef> requiredSourceAssocs = node.getSourceAssocs();
List<AssociationRef> currentSourceAssocs = nodeService.getSourceAssocs(correspondingNodeRef, RegexQNamePattern.MATCH_ALL);
processPeerAssociations(requiredSourceAssocs, currentSourceAssocs, correspondingNodeRef, false);
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class CopyServiceImpl method copyPendingAssociations.
/**
* Copy any remaining associations that could not be copied or ignored during the copy process.
* See <a href=http://issues.alfresco.com/jira/browse/ALF-958>ALF-958: Target associations aren't copied</a>.
*/
private void copyPendingAssociations(Map<NodeRef, NodeRef> copiedNodeRefs) {
// Prepare storage for post-copy association handling
List<Pair<AssociationRef, AssocCopyTargetAction>> postCopyAssocs = TransactionalResourceHelper.getList(KEY_POST_COPY_ASSOCS);
for (Pair<AssociationRef, AssocCopyTargetAction> pair : postCopyAssocs) {
AssociationRef assocRef = pair.getFirst();
AssocCopyTargetAction action = pair.getSecond();
// Was the original target copied?
NodeRef newSourceForAssoc = copiedNodeRefs.get(assocRef.getSourceRef());
if (newSourceForAssoc == null) {
// Developer #fail
throw new IllegalStateException("Post-copy association has a source that was NOT copied.");
}
NodeRef oldTargetForAssoc = assocRef.getTargetRef();
// May be null
NodeRef newTargetForAssoc = copiedNodeRefs.get(oldTargetForAssoc);
QName assocTypeQName = assocRef.getTypeQName();
switch(action) {
case USE_ORIGINAL_TARGET:
internalNodeService.createAssociation(newSourceForAssoc, oldTargetForAssoc, assocTypeQName);
break;
case USE_COPIED_TARGET:
// Do nothing if the target was not copied
if (newTargetForAssoc != null) {
internalNodeService.createAssociation(newSourceForAssoc, newTargetForAssoc, assocTypeQName);
}
break;
case USE_COPIED_OTHERWISE_ORIGINAL_TARGET:
if (newTargetForAssoc == null) {
internalNodeService.createAssociation(newSourceForAssoc, oldTargetForAssoc, assocTypeQName);
} else {
internalNodeService.createAssociation(newSourceForAssoc, newTargetForAssoc, assocTypeQName);
}
break;
default:
throw new IllegalStateException("Unknown association action: " + action);
}
}
}
Aggregations