org.alfresco.service.cmr.repository.ChildAssociationRef Java Examples
The following examples show how to use
org.alfresco.service.cmr.repository.ChildAssociationRef.
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: TemplateNode.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return The display name for the node */ public String getName() { if (this.name == null) { // try and get the name from the properties first this.name = (String)getProperties().get("cm:name"); // if we didn't find it as a property get the name from the association name if (this.name == null) { ChildAssociationRef parentRef = this.services.getNodeService().getPrimaryParent(this.nodeRef); if (parentRef != null && parentRef.getQName() != null) { this.name = parentRef.getQName().getLocalName(); } else { this.name = ""; } } } return this.name; }
Example #2
Source File: XMLTransferReportWriter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void writePrimaryParent(ChildAssociationRef parentAssoc, Path parentPath) throws SAXException { writer.startElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PARENT, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PARENT, EMPTY_ATTRIBUTES); writeParentAssoc(parentAssoc); writer.startElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PATH, PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PATH, EMPTY_ATTRIBUTES); if(parentPath != null) { String path = parentPath.toString(); writer.characters(path.toCharArray(), 0, path.length()); } writer.endElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PATH, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PRIMARY_PATH); writer.endElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_PRIMARY_PARENT, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PRIMARY_PARENT); }
Example #3
Source File: RulesAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Force copy recursion after copying a rules folder * * @return Returns {@link ChildAssocRecurseAction#FORCE_RECURSE} * for {@link RuleModel#ASSOC_RULE_FOLDER} */ @Override public ChildAssocRecurseAction getChildAssociationRecurseAction( QName classQName, CopyDetails copyDetails, CopyChildAssociationDetails childAssocCopyDetails) { ChildAssociationRef childAssocRef = childAssocCopyDetails.getChildAssocRef(); if (childAssocRef.getTypeQName().equals(RuleModel.ASSOC_RULE_FOLDER)) { return ChildAssocRecurseAction.FORCE_RECURSE; } else { super.throwExceptionForUnexpectedBehaviour(copyDetails, childAssocCopyDetails.toString()); return null; // Never reached } }
Example #4
Source File: CachingCorrespondingNodeResolverImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public ResolvedParentChildPair resolveCorrespondingNode(NodeRef sourceNodeRef, ChildAssociationRef primaryAssoc, Path parentPath) { ResolvedParentChildPair result = cache.get(sourceNodeRef); if (result != null) { if (log.isDebugEnabled()) { log.debug("Found fully-resolved entry in cache for node " + sourceNodeRef); } return result; } result = delegateResolver.resolveCorrespondingNode(sourceNodeRef, primaryAssoc, parentPath); //If we have fully resolved the parent and child nodes then stick it in the cache... if (result.resolvedChild != null && result.resolvedParent != null) { cache.put(sourceNodeRef, result); } return result; }
Example #5
Source File: ImporterComponent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public NodeRef importNode(ImportNode node) { // replace existing node, if node to import has a UUID and an existing node of the same // uuid already exists String uuid = node.getUUID(); if (uuid != null && uuid.length() > 0) { NodeRef existingNodeRef = new NodeRef(rootRef.getStoreRef(), uuid); if (nodeService.exists(existingNodeRef)) { // remove primary parent link forcing deletion ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(existingNodeRef); nodeService.removeChild(childAssocRef.getParentRef(), childAssocRef.getChildRef()); // update the parent context of the node being imported to the parent of the node just deleted node.getParentContext().setParentRef(childAssocRef.getParentRef()); node.getParentContext().setAssocType(childAssocRef.getTypeQName()); } } // import as if a new node return createNewStrategy.importNode(node); }
Example #6
Source File: HasChildEvaluator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef) */ public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef) { boolean result = false; if (this.nodeService.exists(actionedUponNodeRef) == true) { // Default match pattern is to match all. QNamePattern matchAll = RegexQNamePattern.MATCH_ALL; // Retrieve any specified parameter values. QName assocTypeParam = (QName)ruleCondition.getParameterValue(PARAM_ASSOC_TYPE); QName assocNameParam = (QName)ruleCondition.getParameterValue(PARAM_ASSOC_NAME); // Use the specified QNames if there are any, else default to match_all. QNamePattern assocType = assocTypeParam == null ? matchAll : assocTypeParam; QNamePattern assocName = assocNameParam == null ? matchAll : assocNameParam; // Are there any children which match these association name/type patterns? List<ChildAssociationRef> children = nodeService.getChildAssocs(actionedUponNodeRef, assocType, assocName); result = !children.isEmpty(); } return result; }
Example #7
Source File: VersionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Creates a new version history node, applying the root version aspect is required * * @param nodeRef the node ref * @return the version history node reference */ private NodeRef createVersionHistory(NodeRef nodeRef) { HashMap<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, nodeRef.getId()); props.put(PROP_QNAME_VERSIONED_NODE_ID, nodeRef.getId()); // Create a new version history node ChildAssociationRef childAssocRef = this.dbNodeService.createNode( getRootNode(), CHILD_QNAME_VERSION_HISTORIES, QName.createQName(VersionModel.NAMESPACE_URI, nodeRef.getId()), TYPE_QNAME_VERSION_HISTORY, props); return childAssocRef.getChildRef(); }
Example #8
Source File: AuthorityDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void onCreateNode(ChildAssociationRef childAssocRef) { // Restrict creation of group name that contain invalid characters. NodeRef authorityRef = childAssocRef.getChildRef(); String authorityName = (String) this.nodeService.getProperty(authorityRef, ContentModel.PROP_AUTHORITY_NAME); if (authorityName != null) { for (char illegalCharacter : ILLEGAL_CHARACTERS) { if (authorityName.indexOf(illegalCharacter) != -1) { throw new IllegalArgumentException("Group name contains characters that are not permitted: "+authorityName.charAt(authorityName.indexOf(illegalCharacter))); } } } }
Example #9
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 #10
Source File: XMLTransferManifestWriter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void writeParentAssocs(List<ChildAssociationRef> refs) throws SAXException { if (refs != null) { writer.startElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS, EMPTY_ATTRIBUTES); for (ChildAssociationRef assoc : refs) { writeParentAssoc(assoc); } writer.endElement(TransferModel.TRANSFER_MODEL_1_0_URI, ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS, PREFIX + ":" + ManifestModel.LOCALNAME_ELEMENT_PARENT_ASSOCS); } }
Example #11
Source File: VirtualStoreImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public List<ChildAssociationRef> getChildAssocs(Reference parentReference, Set<QName> childNodeTypeQNames) { List<ChildAssociationRef> allAssociations = getChildAssocs(parentReference, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, Integer.MAX_VALUE, false); List<ChildAssociationRef> associations = new LinkedList<>(); for (ChildAssociationRef childAssociationRef : allAssociations) { QName childType = environment.getType(childAssociationRef.getChildRef()); if (childNodeTypeQNames.contains(childType)) { associations.add(childAssociationRef); } } return associations; }
Example #12
Source File: SiteServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * This method gets the <code>st:site</code> NodeRef for the Share Site which contains the given NodeRef. * If the given NodeRef is not contained within a Share Site, then <code>null</code> is returned. * * @param nodeRef the node whose containing site is to be found. * @return NodeRef site node reference or null if node is not in a site */ private NodeRef getSiteNodeRef(NodeRef nodeRef) { NodeRef siteNodeRef = null; QName nodeRefType = directNodeService.getType(nodeRef); if (dictionaryService.isSubClass(nodeRefType, TYPE_SITE) == true) { siteNodeRef = nodeRef; } else { ChildAssociationRef primaryParent = nodeService.getPrimaryParent(nodeRef); if (primaryParent != null && primaryParent.getParentRef() != null) { siteNodeRef = getSiteNodeRef(primaryParent.getParentRef()); } } return siteNodeRef; }
Example #13
Source File: ScriptBehaviourTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { // Get the required services this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); this.policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent"); this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean("ServiceRegistry"); AuthenticationComponent authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create the store and get the root node reference this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); NodeRef rootNodeRef = this.nodeService.getRootNode(storeRef); // Create folder node Map<QName, Serializable> props = new HashMap<QName, Serializable>(1); props.put(ContentModel.PROP_NAME, "TestFolder"); ChildAssociationRef childAssocRef = this.nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}TestFolder"), ContentModel.TYPE_FOLDER, props); this.folderNodeRef = childAssocRef.getChildRef(); }
Example #14
Source File: RepoTransferReceiverImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * move transfer node to new parent. * @param childNode * @param newParent */ private void moveNode(TransferManifestNormalNode childNode, TransferManifestNormalNode newParent) { List<ChildAssociationRef> currentParents = childNode.getParentAssocs(); List<ChildAssociationRef> newParents = new ArrayList<ChildAssociationRef>(); for (ChildAssociationRef parent : currentParents) { if (!parent.isPrimary()) { newParents.add(parent); } else { ChildAssociationRef newPrimaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, newParent .getNodeRef(), parent.getQName(), parent.getChildRef(), true, -1); newParents.add(newPrimaryAssoc); childNode.setPrimaryParentAssoc(newPrimaryAssoc); Path newParentPath = new Path(); newParentPath.append(newParent.getParentPath()); newParentPath.append(new Path.ChildAssocElement(newParent.getPrimaryParentAssoc())); childNode.setParentPath(newParentPath); } } childNode.setParentAssocs(newParents); }
Example #15
Source File: AuthorityDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return the system container for the specified assoc name. * The containers are cached in a thread safe Tenant aware cache. * * @return System container, <b>which must exist</b> */ private NodeRef getSystemContainer(QName assocQName) { final String cacheKey = KEY_SYSTEMCONTAINER_NODEREF + "." + assocQName.toString(); NodeRef systemContainerRef = (NodeRef)singletonCache.get(cacheKey); if (systemContainerRef == null) { NodeRef rootNodeRef = nodeService.getRootNode(this.storeRef); List<ChildAssociationRef> results = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL, qnameAssocSystem, false); if (results.size() == 0) { throw new AlfrescoRuntimeException("Required system path not found: " + qnameAssocSystem); } NodeRef sysNodeRef = results.get(0).getChildRef(); results = nodeService.getChildAssocs(sysNodeRef, RegexQNamePattern.MATCH_ALL, assocQName, false); if (results.size() == 0) { throw new AlfrescoRuntimeException("Required path not found: " + assocQName); } systemContainerRef = results.get(0).getChildRef(); singletonCache.put(cacheKey, systemContainerRef); } return systemContainerRef; }
Example #16
Source File: NodeChange.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onCreateNode(ChildAssociationRef childAssocRef) { NodeRef nodeRef = childAssocRef.getChildRef(); Map<QName, Serializable> fromProperties = Collections.<QName, Serializable>emptyMap(); Map<QName, Serializable> toProperties = nodeInfoFactory.getProperties(nodeRef); this.fromProperties = null; // Sometimes onCreateNode policy is out of order (e.g. create a person) setFromProperties(fromProperties); setToProperties(toProperties); appendSubAction(new NodeChange(nodeInfoFactory, namespaceService, nodeRef). setAction(CREATE_NODE). setFromProperties(fromProperties). setToProperties(toProperties)); }
Example #17
Source File: ACLEntryVoterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void testDenyParentAssocNode() throws Exception { runAs("andy"); permissionService.setPermission(new SimplePermissionEntry(systemNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED)); Object o = new ClassWithMethods(); Method method = o.getClass().getMethod("testOneChildAssociationRef", new Class[] { ChildAssociationRef.class }); AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_PARENT.0.sys:base.Read"))); proxyFactory.setTargetSource(new SingletonTargetSource(o)); Object proxy = proxyFactory.getProxy(); try { method.invoke(proxy, new Object[] { nodeService.getPrimaryParent(systemNodeRef) }); assertNotNull(null); } catch (InvocationTargetException e) { } }
Example #18
Source File: MultiTDemoTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private NodeRef addContent(NodeRef spaceRef, String name, InputStream is, String mimeType) { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); ChildAssociationRef association = nodeService.createNode(spaceRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); // add titled aspect (for Web Client display) Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(); titledProps.put(ContentModel.PROP_TITLE, name); titledProps.put(ContentModel.PROP_DESCRIPTION, name); this.nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimeType); writer.setEncoding("UTF-8"); writer.putContent(is); return content; }
Example #19
Source File: HomeFolderProviderSynchronizerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test @SuppressWarnings("deprecation") public void test22Version1HomeFolderProvider() throws Exception { // Should just log a message to say it can't do anything final String name = "v1Provider"; HomeFolderProvider v1Provider = new HomeFolderProvider() { @Override public void onCreateNode(ChildAssociationRef childAssocRef) { } @Override public String getName() { return name; } }; homeFolderManager.addProvider(v1Provider); createUser("a/b/c", "fred"); homeFolderProviderSynchronizer.setOverrideHomeFolderProviderName(name); moveUserHomeFolders(); assertHomeFolderLocation("fred", "a/b/c/fred"); }
Example #20
Source File: ArchiveAndRestoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void verifyChildAssocExistence(ChildAssociationRef childAssocRef, boolean exists) { List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs( childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName()); if (exists) { assertEquals("Expected exactly one match for child association: " + childAssocRef, 1, childAssocs.size()); } else { assertEquals("Expected zero matches for child association: " + childAssocRef, 0, childAssocs.size()); } }
Example #21
Source File: VirtualNodeServiceExtension.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public List<ChildAssociationRef> getChildAssocsByPropertyValue(NodeRef nodeRef, QName propertyQName, Serializable value) { NodeServiceTrait theTrait = getTrait(); boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef); if (canVirtualize) { Reference reference = smartStore.virtualize(nodeRef); List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocsByPropertyValue(reference, propertyQName, value); List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations); if (smartStore.canMaterialize(reference)) { NodeRef materialReference = smartStore.materialize(reference); List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocsByPropertyValue(materialReference, propertyQName, value); associations.addAll(actualAssociations); } return associations; } else { return theTrait.getChildAssocsByPropertyValue(nodeRef, propertyQName, value); } }
Example #22
Source File: PerformRenditionActionExecuter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void executeImpl(final Action containingAction, final NodeRef actionedUponNodeRef) { final RenditionDefinition renditionDefinition = getRenditionDefinition(containingAction); if (log.isDebugEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Rendering node ").append(actionedUponNodeRef).append(" with rendition definition ").append( renditionDefinition.getRenditionName()); msg.append("\n").append(" parameters:").append("\n"); if (renditionDefinition.getParameterValues().isEmpty() == false) { for (String paramKey : renditionDefinition.getParameterValues().keySet()) { msg.append(" ").append(paramKey).append("=").append(renditionDefinition.getParameterValue(paramKey)).append("\n"); } } else { msg.append(" [None]"); } log.debug(msg.toString()); } ChildAssociationRef result = executeRendition(actionedUponNodeRef, renditionDefinition); containingAction.setParameterValue(PARAM_RESULT, result); }
Example #23
Source File: ThumbnailServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see org.alfresco.service.cmr.thumbnail.ThumbnailService#getThumbnailByName(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.lang.String) */ public NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName) { // // NOTE: // // Since there is not an easy alternative and for clarity the node service is being used to retrieve the thumbnails. // If retrieval performance becomes an issue then this code can be replaced // if (logger.isDebugEnabled() == true) { logger.debug("Getting thumbnail by name (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; thumbnailName=" + thumbnailName + ")"); } // Thumbnails have a cm: prefix. QName namespacedThumbnailName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, thumbnailName); ChildAssociationRef existingRendition = renditionService.getRenditionByName(node, namespacedThumbnailName); NodeRef thumbnail = null; // Check the child to see if it matches the content property we are concerned about. // We can assume there will only ever be one per content property since createThumbnail enforces this. if (existingRendition != null) { NodeRef child = existingRendition.getChildRef(); Serializable contentPropertyName = this.nodeService.getProperty(child, ContentModel.PROP_CONTENT_PROPERTY_NAME); if (contentProperty.equals(contentPropertyName) == true) { if (validateThumbnail(child)) { thumbnail = child; } } } return thumbnail; }
Example #24
Source File: NodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @throws UnsupportedOperationException always */ public ChildAssociationRef createNode( NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName) throws InvalidNodeRefException { // This operation is not supported for a version store throw new UnsupportedOperationException(MSG_UNSUPPORTED); }
Example #25
Source File: SiteRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef) { // 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); ContentStore sourceStore = this.resolveStoreForSite(sourceSite); sourceStore = sourceStore != null ? sourceStore : this.fallbackStore; ContentStore targetStore = this.resolveStoreForSite(targetSite); targetStore = targetStore != null ? targetStore : this.fallbackStore; final boolean differentStores = sourceStore != targetStore; return Boolean.valueOf(differentStores); }); 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 #26
Source File: SolrJSONResultSet.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ChildAssociationRef getChildAssocRef(int n) { ChildAssociationRef primaryParentAssoc = nodeService.getPrimaryParent(getNodeRef(n)); if(primaryParentAssoc != null) { return primaryParentAssoc; } else { return null; } }
Example #27
Source File: ViewXMLExporter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper to convert a path into an indexed path which uniquely identifies a node * * @param nodeRef NodeRef * @param path Path * @return Path */ private Path createIndexedPath(NodeRef nodeRef, Path path) { // Add indexes for same name siblings // TODO: Look at more efficient approach for (int i = path.size() - 1; i >= 0; i--) { Path.Element pathElement = path.get(i); if (i > 0 && pathElement instanceof Path.ChildAssocElement) { int index = 1; // for xpath index compatibility String searchPath = path.subPath(i).toPrefixString(namespaceService); List<NodeRef> siblings = searchService.selectNodes(nodeRef, searchPath, null, namespaceService, false); if (siblings.size() > 1) { ChildAssociationRef childAssoc = ((Path.ChildAssocElement)pathElement).getRef(); NodeRef childRef = childAssoc.getChildRef(); for (NodeRef sibling : siblings) { if (sibling.equals(childRef)) { childAssoc.setNthSibling(index); break; } index++; } } } } return path; }
Example #28
Source File: IncompleteNodeTagger.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} * <p> * This only saves the node for checking if it is <i>not</i> new. The create of the * node will handle it. */ public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNew) { if (! storesToIgnore.contains(childAssocRef.getChildRef().getStoreRef().toString())) { if (!isNew) { saveAssoc(childAssocRef.getParentRef(), childAssocRef.getTypeQName()); } } }
Example #29
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 #30
Source File: BaseNodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Checks that the unique constraint doesn't break delete and create within the same * transaction. */ @Test public void testDeleteAndAddSameName() throws Exception { NodeRef parentRef = nodeService.createNode( rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("parent_child"), ContentModel.TYPE_CONTAINER).getChildRef(); // create node ABC Map<QName, Serializable> props = new HashMap<QName, Serializable>(5); props.put(ContentModel.PROP_NAME, "ABC"); ChildAssociationRef pathAbcRef = nodeService.createNode( parentRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, QName.createQName("ABC"), ContentModel.TYPE_CONTENT, props); NodeRef abcRef = pathAbcRef.getChildRef(); // delete ABC nodeService.deleteNode(abcRef); // create it again pathAbcRef = nodeService.createNode( parentRef, ASSOC_TYPE_QNAME_TEST_CONTAINS, QName.createQName("ABC"), ContentModel.TYPE_CONTENT, props); // there should not be any failure when doing this in the same transaction }