Java Code Examples for org.alfresco.service.cmr.repository.ChildAssociationRef#getParentRef()
The following examples show how to use
org.alfresco.service.cmr.repository.ChildAssociationRef#getParentRef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthorityDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Remove entries for the parents of the given node. * * @param lock <tt>true</tt> if the cache modifications need to be locked * i.e. if the caller is handling a <b>beforeXYZ</b> callback. */ private void removeParentsFromChildAuthorityCache(NodeRef nodeRef, boolean lock) { // Get the transactional version of the cache if we need locking TransactionalCache<NodeRef, Pair<Map<NodeRef,String>, List<NodeRef>>> childAuthorityCacheTxn = null; if (lock && childAuthorityCache instanceof TransactionalCache) { childAuthorityCacheTxn = (TransactionalCache<NodeRef, Pair<Map<NodeRef,String>, List<NodeRef>>>) childAuthorityCache; } // Iterate over all relevant parents of the given node for (ChildAssociationRef car: nodeService.getParentAssocs(nodeRef)) { NodeRef parentRef = car.getParentRef(); if (dictionaryService.isSubClass(nodeService.getType(parentRef), ContentModel.TYPE_AUTHORITY_CONTAINER)) { TransactionalResourceHelper.getSet(PARENTS_OF_DELETING_CHILDREN_SET_RESOURCE).add(parentRef); childAuthorityCache.remove(parentRef); if (childAuthorityCacheTxn != null) { childAuthorityCacheTxn.lockValue(parentRef); } } } }
Example 2
Source File: AbstractNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see NodeServicePolicies.OnDeleteChildAssociationPolicy#onDeleteChildAssociation(ChildAssociationRef) */ protected void invokeOnDeleteChildAssociation(ChildAssociationRef childAssocRef) { NodeRef parentNodeRef = childAssocRef.getParentRef(); if (ignorePolicy(parentNodeRef)) { return; } QName assocTypeQName = childAssocRef.getTypeQName(); // get qnames to invoke against Set<QName> qnames = getTypeAndAspectQNames(parentNodeRef); // execute policy for node type and aspects NodeServicePolicies.OnDeleteChildAssociationPolicy policy = onDeleteChildAssociationDelegate.get(parentNodeRef, qnames, assocTypeQName); policy.onDeleteChildAssociation(childAssocRef); }
Example 3
Source File: RepoTransferReceiverImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * When an alien node is moved it may un-invade its old location and invade a new * location. The node may also cease to be alien. */ public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) { log.debug("onMoveNode"); log.debug("oldChildAssocRef:" + oldChildAssocRef); log.debug("newChildAssocRef:" + newChildAssocRef); NodeRef oldParentRef = oldChildAssocRef.getParentRef(); NodeRef newParentRef = newChildAssocRef.getParentRef(); if(newParentRef.equals(oldParentRef)) { log.debug("old parent and new parent are the same - this is a rename, do nothing"); } else { if(log.isDebugEnabled()) { log.debug("moving node from oldParentRef:" + oldParentRef +" to:" + newParentRef); } alienProcessor.beforeDeleteAlien(newChildAssocRef.getChildRef(), oldChildAssocRef); alienProcessor.afterMoveAlien(newChildAssocRef); } }
Example 4
Source File: MultilingualContentServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get the ML Container of the given node, allowing null * @param mlDocumentNodeRef the translation * @param allowNull true if a null value may be returned * @return Returns the <b>cm:mlContainer</b> or null if there isn't one * @throws AlfrescoRuntimeException if there is no container */ private NodeRef getMLContainer(NodeRef mlDocumentNodeRef, boolean allowNull) { NodeRef mlContainerNodeRef = null; List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs( mlDocumentNodeRef, ContentModel.ASSOC_MULTILINGUAL_CHILD, RegexQNamePattern.MATCH_ALL); if (parentAssocRefs.size() == 0) { if (!allowNull) { throw new AlfrescoRuntimeException( "No multilingual container exists for document node: " + mlDocumentNodeRef); } mlContainerNodeRef = null; } else if (parentAssocRefs.size() >= 1) { // Just get it ChildAssociationRef toKeepAssocRef = parentAssocRefs.get(0); mlContainerNodeRef = toKeepAssocRef.getParentRef(); } // Done return mlContainerNodeRef; }
Example 5
Source File: SiteAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Deny renames. */ public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) { NodeRef oldParent = oldChildAssocRef.getParentRef(); NodeRef newParent = newChildAssocRef.getParentRef(); // Deny renames if (oldParent.equals(newParent)) { QName type = nodeService.getType((oldChildAssocRef.getChildRef())); if (dictionaryService.isSubClass(type, SiteModel.TYPE_SITE)) { throw new SiteServiceException("Sites can not be renamed."); } else { throw new SiteServiceException("Site containers can not be renamed."); } } }
Example 6
Source File: PersonServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void beforeDeleteNodeValidation(NodeRef nodeRef) { NodeRef parentRef = null; ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef); if (parentAssocRef != null) { parentRef = parentAssocRef.getParentRef(); } if (getPeopleContainer().equals(parentRef)) { throw new AlfrescoRuntimeException("beforeDeleteNode: use PersonService to delete person"); } else { logger.info("Person node that is being deleted is not under the parent people container (actual="+parentRef+", expected="+getPeopleContainer()+")"); } }
Example 7
Source File: IntegrityChecker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see AssocSourceMultiplicityIntegrityEvent * @see AssocTargetMultiplicityIntegrityEvent */ public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) { if (! storesToIgnore.contains(tenantService.getBaseName(childAssocRef.getChildRef().getStoreRef()).toString())) { IntegrityEvent event = null; // check source multiplicity event = new AssocSourceMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getChildRef(), childAssocRef.getTypeQName(), true); save(event); // check target multiplicity event = new AssocTargetMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), true); save(event); } }
Example 8
Source File: EventsServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void secondaryAssociationCreated(final ChildAssociationRef secAssociation) { NodeInfo nodeInfo = getNodeInfo(secAssociation.getChildRef(), NodeAddedEvent.EVENT_TYPE); if(nodeInfo.checkNodeInfo()) { String username = AuthenticationUtil.getFullyAuthenticatedUser(); String networkId = TenantUtil.getCurrentDomain(); String name = nodeInfo.getName(); String objectId = nodeInfo.getNodeId(); String siteId = nodeInfo.getSiteId(); String txnId = AlfrescoTransactionSupport.getTransactionId(); NodeRef secParentNodeRef = secAssociation.getParentRef(); String secParentNodeName = (String)nodeService.getProperty(secAssociation.getParentRef(), ContentModel.PROP_NAME); List<Path> secParentPath = nodeService.getPaths(secParentNodeRef, true); List<String> nodePaths = getPaths(secParentPath, Arrays.asList(secParentNodeName, name)); List<List<String>> pathNodeIds = this.getNodeIds(secParentPath); long timestamp = System.currentTimeMillis(); Long modificationTime = nodeInfo.getModificationTimestamp(); String nodeType = nodeInfo.getType().toPrefixString(namespaceService); Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient()); Set<String> aspects = nodeInfo.getAspectsAsStrings(); Map<String, Serializable> properties = nodeInfo.getProperties(); Event event = new NodeAddedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, alfrescoClient, aspects, properties); sendEvent(event); } }
Example 9
Source File: Node2ServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Child Assocs translation for version store */ public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException { // Get the child assoc references from the version store List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs( VersionUtil.convertNodeRef(nodeRef), typeQNamePattern, qnamePattern); List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { if (! childAssocRef.getTypeQName().equals(Version2Model.CHILD_QNAME_VERSIONED_ASSOCS)) { // Get the child reference NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode)) { // Build a child assoc ref to add to the returned list ChildAssociationRef newChildAssocRef = new ChildAssociationRef( childAssocRef.getTypeQName(), childAssocRef.getParentRef(), childAssocRef.getQName(), referencedNode, childAssocRef.isPrimary(), childAssocRef.getNthSibling()); result.add(newChildAssocRef); } } } // sort the results so that the order appears to be exactly as it was originally Collections.sort(result); return result; }
Example 10
Source File: AuthorityDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public Set<String> getAuthorityZones(String name) { Set<String> zones = new TreeSet<String>(); NodeRef childRef = getAuthorityOrNull(name); if (childRef == null) { return null; } List<ChildAssociationRef> results = nodeService.getParentAssocs(childRef, ContentModel.ASSOC_IN_ZONE, RegexQNamePattern.MATCH_ALL); if (results.isEmpty()) { return zones; } for (ChildAssociationRef current : results) { NodeRef zoneRef = current.getParentRef(); Serializable value = nodeService.getProperty(zoneRef, ContentModel.PROP_NAME); if (value == null) { continue; } else { String zone = DefaultTypeConverter.INSTANCE.convert(String.class, value); zones.add(zone); } } return zones; }
Example 11
Source File: CreateNodeRuleTrigger.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ public void onCreateNode(ChildAssociationRef childAssocRef) { // Break out early if rules are not enabled if (!areRulesEnabled()) { return; } NodeRef nodeRef = childAssocRef.getChildRef(); // Keep track of new nodes to prevent firing of updates in the same transaction Set<NodeRef> newNodeRefSet = TransactionalResourceHelper.getSet(RULE_TRIGGER_NEW_NODES); newNodeRefSet.add(nodeRef); if (nodeRef != null && nodeService.exists(nodeRef) == true && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT) == false) { NodeRef parentNodeRef = childAssocRef.getParentRef(); if (logger.isDebugEnabled() == true) { logger.debug( "Create node rule trigger fired for parent node " + this.nodeService.getType(parentNodeRef).toString() + " " + parentNodeRef + " and child node " + this.nodeService.getType(nodeRef).toString() + " " + nodeRef); } triggerRules(parentNodeRef, nodeRef); } }
Example 12
Source File: EventsServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void secondaryAssociationDeleted(final ChildAssociationRef secAssociation) { NodeInfo nodeInfo = getNodeInfo(secAssociation.getChildRef(), NodeRemovedEvent.EVENT_TYPE); if(nodeInfo.checkNodeInfo()) { String username = AuthenticationUtil.getFullyAuthenticatedUser(); String networkId = TenantUtil.getCurrentDomain(); String name = nodeInfo.getName(); String objectId = nodeInfo.getNodeId(); String siteId = nodeInfo.getSiteId(); String txnId = AlfrescoTransactionSupport.getTransactionId(); NodeRef secParentNodeRef = secAssociation.getParentRef(); String secParentNodeName = (String)nodeService.getProperty(secAssociation.getParentRef(), ContentModel.PROP_NAME); List<Path> secParentPath = nodeService.getPaths(secParentNodeRef, true); List<String> nodePaths = getPaths(secParentPath, Arrays.asList(secParentNodeName, name)); List<List<String>> pathNodeIds = this.getNodeIds(secParentPath); long timestamp = System.currentTimeMillis(); Long modificationTime = nodeInfo.getModificationTimestamp(); String nodeType = nodeInfo.getType().toPrefixString(namespaceService); Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient()); Set<String> aspects = nodeInfo.getAspectsAsStrings(); Map<String, Serializable> properties = nodeInfo.getProperties(); Event event = new NodeRemovedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, alfrescoClient, aspects, properties); sendEvent(event); } }
Example 13
Source File: NodeUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static Function<ChildAssociationRef, NodeRef> toParentRef() { return new Function<ChildAssociationRef, NodeRef>() { public NodeRef apply(ChildAssociationRef value) { return value.getParentRef(); } }; }
Example 14
Source File: ThumbnailServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @see org.alfresco.service.cmr.thumbnail.ThumbnailService#updateThumbnail(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.TransformationOptions) */ public void updateThumbnail(final NodeRef thumbnail, final TransformationOptions transformationOptions) { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail (thumbnail=" + thumbnail.toString() + ")"); } // First check that we are dealing with a rendition object if (renditionService.isRendition(thumbnail)) { // Get the node that is the source of the thumbnail ChildAssociationRef parentAssoc = renditionService.getSourceNode(thumbnail); if (parentAssoc == null) { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail: The thumbnails parent cannot be found (thumbnail=" + thumbnail.toString() + ")"); } throw new ThumbnailException(ERR_NO_PARENT); } final QName renditionAssociationName = parentAssoc.getQName(); NodeRef sourceNode = parentAssoc.getParentRef(); // Get the content property QName contentProperty = (QName)nodeService.getProperty(thumbnail, ContentModel.PROP_CONTENT_PROPERTY_NAME); // Set the basic detail of the transformation options transformationOptions.setSourceNodeRef(sourceNode); transformationOptions.setSourceContentProperty(contentProperty); transformationOptions.setTargetContentProperty(ContentModel.PROP_CONTENT); // Do the thumbnail transformation. Rendition Definitions are persisted underneath the Data Dictionary for which Group ALL // has Consumer access by default. However, we cannot assume that that access level applies for all deployments. See ALF-7334. RenditionDefinition rendDefn = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<RenditionDefinition>() { @Override public RenditionDefinition doWork() throws Exception { return renditionService.loadRenditionDefinition(renditionAssociationName); } }, AuthenticationUtil.getSystemUserName()); if (rendDefn == null) { String renderingEngineName = getRenderingEngineNameFor(transformationOptions); rendDefn = renditionService.createRenditionDefinition(parentAssoc.getQName(), renderingEngineName); } Map<String, Serializable> params = thumbnailRegistry.getThumbnailRenditionConvertor().convert(transformationOptions, null); for (String key : params.keySet()) { rendDefn.setParameterValue(key, params.get(key)); } renditionService.render(sourceNode, rendDefn); } else { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail: cannot update a thumbnail node that isn't the correct thumbnail type (thumbnail=" + thumbnail.toString() + ")"); } } }
Example 15
Source File: EventsServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void nodeMoved(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) { NodeRef nodeRef = newChildAssocRef.getChildRef(); NodeInfo nodeInfo = getNodeInfo(nodeRef, NodeMovedEvent.EVENT_TYPE); if(nodeInfo.checkNodeInfo()) { String username = AuthenticationUtil.getFullyAuthenticatedUser(); String networkId = TenantUtil.getCurrentDomain(); String objectId = nodeInfo.getNodeId(); String siteId = nodeInfo.getSiteId(); String txnId = AlfrescoTransactionSupport.getTransactionId(); long timestamp = System.currentTimeMillis(); Long modificationTime = nodeInfo.getModificationTimestamp(); String nodeType = nodeInfo.getType().toPrefixString(namespaceService); NodeRef oldParentNodeRef = oldChildAssocRef.getParentRef(); NodeRef newParentNodeRef = newChildAssocRef.getParentRef(); NodeRef oldNodeRef = oldChildAssocRef.getChildRef(); NodeRef newNodeRef = newChildAssocRef.getChildRef(); String oldParentNodeName = (String)nodeService.getProperty(oldParentNodeRef, ContentModel.PROP_NAME); String newParentNodeName = (String)nodeService.getProperty(newParentNodeRef, ContentModel.PROP_NAME); String oldNodeName = (String)nodeService.getProperty(oldNodeRef, ContentModel.PROP_NAME); String newNodeName = (String)nodeService.getProperty(newNodeRef, ContentModel.PROP_NAME); List<Path> newParentPaths = nodeService.getPaths(newParentNodeRef, false); List<String> newPaths = getPaths(newParentPaths, Arrays.asList(newParentNodeName, newNodeName)); // renames are handled by an onUpdateProperties callback, we just deal with real moves here. if(!oldParentNodeRef.equals(newParentNodeRef)) { List<List<String>> toParentNodeIds = getNodeIds(newParentPaths); List<Path> oldParentPaths = nodeService.getPaths(oldParentNodeRef, false); List<String> previousPaths = getPaths(oldParentPaths, Arrays.asList(oldParentNodeName, oldNodeName)); List<List<String>> previousParentNodeIds = getNodeIds(oldParentPaths); Set<String> aspects = nodeInfo.getAspectsAsStrings(); Map<String, Serializable> properties = nodeInfo.getProperties(); Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient()); Event event = new NodeMovedEvent(nextSequenceNumber(), oldNodeName, newNodeName, txnId, timestamp, networkId, siteId, objectId, nodeType, previousPaths, previousParentNodeIds, username, modificationTime, newPaths, toParentNodeIds, alfrescoClient, aspects, properties); sendEvent(event); } } }
Example 16
Source File: CommentServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public NodeRef getDiscussableAncestor(NodeRef descendantNodeRef) { // For "Share comments" i.e. fm:post nodes created via the Share commenting UI, the containment structure is as follows: // fm:discussable // - fm:forum // - fm:topic // - fm:post // For other fm:post nodes the ancestor structure may be slightly different. (cf. Share discussions, which don't have 'forum') // // In order to ensure that we only return the discussable ancestor relevant to Share comments, we'll climb the // containment tree in a controlled manner. // We could navigate up looking for the first fm:discussable ancestor, but that might not find the correct node - it could, // for example, find a parent folder which was discussable. NodeRef result = null; if (nodeService.getType(descendantNodeRef).equals(ForumModel.TYPE_POST)) { NodeRef topicNode = nodeService.getPrimaryParent(descendantNodeRef).getParentRef(); if (nodeService.getType(topicNode).equals(ForumModel.TYPE_TOPIC)) { ChildAssociationRef forumToTopicChildAssocRef = nodeService.getPrimaryParent(topicNode); if (forumToTopicChildAssocRef.getQName().equals(FORUM_TO_TOPIC_ASSOC_QNAME)) { NodeRef forumNode = forumToTopicChildAssocRef.getParentRef(); if (nodeService.getType(forumNode).equals(ForumModel.TYPE_FORUM)) { NodeRef discussableNode = nodeService.getPrimaryParent(forumNode).getParentRef(); if (nodeService.hasAspect(discussableNode, ForumModel.ASPECT_DISCUSSABLE)) { result = discussableNode; } } } } } return result; }
Example 17
Source File: LocalFeedTaskProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private boolean canReadImpl(final String connectedUser, final NodeRef nodeRef) throws Exception { // check for read permission long start = System.currentTimeMillis(); try { // note: deleted node does not exist (hence no permission, although default permission check would return true which is problematic) final NodeRef checkNodeRef; NodeRef parentToCheckNodeRef = null; if (nodeService.exists(nodeRef)) { checkNodeRef = nodeRef; } else { // TODO: require ghosting - this is temp workaround (we should not rely on archive - may be permanently deleted, ie. not archived or already purged) NodeRef archiveNodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, nodeRef.getId()); if (!nodeService.exists(archiveNodeRef)) { return false; } // MNT-10023 if (permissionService.getInheritParentPermissions(archiveNodeRef)) { ChildAssociationRef originalParentAssoc = (ChildAssociationRef) nodeService.getProperty(archiveNodeRef, ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); if (originalParentAssoc != null) { parentToCheckNodeRef = originalParentAssoc.getParentRef(); } } checkNodeRef = archiveNodeRef; } if (connectedUser.equals("")) { // site feed (public site) Set<AccessPermission> perms = permissionService.getAllSetPermissions(checkNodeRef); for (AccessPermission perm : perms) { if (perm.getAuthority().equals(PermissionService.ALL_AUTHORITIES) && perm.getAuthorityType().equals(AuthorityType.EVERYONE) && perm.getPermission().equals(PermissionService.READ_PERMISSIONS) && perm.getAccessStatus().equals(AccessStatus.ALLOWED)) { return true; } } if (parentToCheckNodeRef != null) { return canReadImpl(connectedUser, parentToCheckNodeRef); } return false; } else { // user feed boolean allow = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Boolean>() { public Boolean doWork() throws Exception { return (permissionService.hasPermission(checkNodeRef, PermissionService.READ) == AccessStatus.ALLOWED); } }, connectedUser); if (!allow && parentToCheckNodeRef != null) { allow = canReadImpl(connectedUser, parentToCheckNodeRef); } return allow; } } finally { if (logger.isDebugEnabled()) { logger.debug("canRead: " + nodeRef + " in " + (System.currentTimeMillis() - start) + " msecs"); } } }
Example 18
Source File: SiteRoutingFileContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef) { // only act on active nodes which can actually be in a site // only act on active nodes which can actually be in a site final NodeRef movedNode = oldChildAssocRef.getChildRef(); final NodeRef oldParent = oldChildAssocRef.getParentRef(); final NodeRef newParent = newChildAssocRef.getParentRef(); if (StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.equals(movedNode.getStoreRef()) && !EqualsHelper.nullSafeEquals(oldParent, newParent)) { LOGGER.debug("Processing onMoveNode for {} from {} to {}", movedNode, oldChildAssocRef, newChildAssocRef); // check for actual move-relevant site move final Boolean moveRelevant = AuthenticationUtil.runAsSystem(() -> { final NodeRef sourceSite = this.resolveSiteForNode(oldParent); final NodeRef targetSite = this.resolveSiteForNode(newParent); final SiteAwareFileContentStore sourceStore = this.resolveStoreForSite(sourceSite); final SiteAwareFileContentStore targetStore = this.resolveStoreForSite(targetSite); boolean moveRelevantB = sourceStore != targetStore; if (!moveRelevantB && !EqualsHelper.nullSafeEquals(sourceSite, targetSite) && targetStore.isUseSiteFolderInGenericDirectories()) { moveRelevantB = true; } return Boolean.valueOf(moveRelevantB); }); if (Boolean.TRUE.equals(moveRelevant)) { LOGGER.debug("Node {} was moved to a location for which content should be stored in a different store", movedNode); this.checkAndProcessContentPropertiesMove(movedNode); } else { LOGGER.debug("Node {} was not moved into a location for which content should be stored in a different store", movedNode); } } }
Example 19
Source File: RepoSecondaryManifestProcessorImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private void processParentChildAssociations(List<ChildAssociationRef> requiredAssocs, List<ChildAssociationRef> currentAssocs, NodeRef nodeRef, boolean isParent) { if (requiredAssocs == null) { requiredAssocs = new ArrayList<ChildAssociationRef>(); } if (currentAssocs == null) { currentAssocs = new ArrayList<ChildAssociationRef>(); } List<ChildAssociationRef> assocsToAdd = new ArrayList<ChildAssociationRef>(); List<ChildAssociationRef> assocsToRemove = new ArrayList<ChildAssociationRef>(); Map<NodeRef, ChildAssociationRef> currentAssocMap = new HashMap<NodeRef, ChildAssociationRef>(); for (ChildAssociationRef currentAssoc : currentAssocs) { if (!currentAssoc.isPrimary()) { NodeRef key = isParent ? currentAssoc.getChildRef() : currentAssoc.getParentRef(); currentAssocMap.put(key, currentAssoc); } } for (ChildAssociationRef requiredAssoc : requiredAssocs) { // We skip the primary parent, since this has already been handled if (!requiredAssoc.isPrimary()) { NodeRef otherNode = isParent ? requiredAssoc.getChildRef() : requiredAssoc.getParentRef(); ChildAssociationRef existingAssociation = currentAssocMap.remove(otherNode); if (existingAssociation != null) { //We already have an association with the required parent. //Check whether it is correct if (!existingAssociation.getQName().equals(requiredAssoc.getQName()) || !existingAssociation.getTypeQName().equals(requiredAssoc.getTypeQName())) { //No, the existing one doesn't match the required one assocsToRemove.add(existingAssociation); assocsToAdd.add(requiredAssoc); } } else { //We don't have an existing association with this required parent //Check that the requiredParent exists in this repo, and record it for adding //if it does if (nodeService.exists(otherNode)) { assocsToAdd.add(requiredAssoc); } } } } //Once we get here, any entries remaining in currentParentMap are associations that need to be deleted. assocsToRemove.addAll(currentAssocMap.values()); //Deal with associations to be removed for (ChildAssociationRef assocToRemove : assocsToRemove) { nodeService.removeChildAssociation(assocToRemove); } //Deal with associations to be added for (ChildAssociationRef assocToAdd : assocsToAdd) { NodeRef parent = isParent ? nodeRef : assocToAdd.getParentRef(); NodeRef child = isParent ? assocToAdd.getChildRef() : nodeRef; nodeService.addChild(parent, child, assocToAdd.getTypeQName(), assocToAdd.getQName()); } }
Example 20
Source File: IntegrityChecker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * This handles the creation of secondary child associations. * * @see AssocSourceTypeIntegrityEvent * @see AssocTargetTypeIntegrityEvent * @see AssocSourceMultiplicityIntegrityEvent * @see AssocTargetMultiplicityIntegrityEvent * @see AssocTargetRoleIntegrityEvent */ public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNew) { if (isNew) { return; } if (! storesToIgnore.contains(tenantService.getBaseName(childAssocRef.getChildRef().getStoreRef()).toString())) { IntegrityEvent event = null; // check source type event = new AssocSourceTypeIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName()); save(event); // check target type event = new AssocTargetTypeIntegrityEvent( nodeService, dictionaryService, childAssocRef.getChildRef(), childAssocRef.getTypeQName()); save(event); // check source multiplicity event = new AssocSourceMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getChildRef(), childAssocRef.getTypeQName(), false); save(event); // check target multiplicity event = new AssocTargetMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), false); save(event); // check target role event = new AssocTargetRoleIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName()); save(event); } }