org.alfresco.service.cmr.repository.ChildAssociationRef

Here are the examples of the java api class org.alfresco.service.cmr.repository.ChildAssociationRef taken from open source projects.

1. RenditionNodeManagerTest#testHasOldRenditionCorrectParentWrongNameSpecified()

Project: community-edition
File: RenditionNodeManagerTest.java
// Check findOrCreateRenditionNode() works when there is 
// an old rendition which has the correct parent folder
// but the wrong name
public void testHasOldRenditionCorrectParentWrongNameSpecified() {
    NodeRef parent = new NodeRef("http://test/parentId");
    ChildAssociationRef parentAssoc = makeAssoc(parent, oldRendition, false);
    ChildAssociationRef renditionAssoc = makeAssoc(source, oldRendition, true);
    String newName = "newName";
    QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, newName);
    when(renditionService.getRenditionByName(source, renditionName)).thenReturn(renditionAssoc);
    when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
    when(nodeService.moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, assocName)).thenReturn(parentAssoc);
    when(nodeService.getProperty(oldRendition, ContentModel.PROP_NAME)).thenReturn("oldName");
    RenditionLocationImpl location = new RenditionLocationImpl(parent, null, newName);
    RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
    ChildAssociationRef result = manager.findOrCreateRenditionNode();
    assertEquals(parentAssoc, result);
    verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, assocName);
}

2. RenditionNodeManagerTest#testHasOldRenditionCorrectParentCorrectNameSpecified()

Project: community-edition
File: RenditionNodeManagerTest.java
// Check findOrCreateRenditionNode() works when there is 
// an old rendition which has the specified parent folder.
// If the correct name is specified and the parent folder is correct then the location should match.
public void testHasOldRenditionCorrectParentCorrectNameSpecified() {
    String rendName = "Rendition Name";
    NodeRef parent = new NodeRef("http://test/parentId");
    ChildAssociationRef renditionAssoc = makeAssoc(source, oldRendition, true);
    when(renditionService.getRenditionByName(source, renditionName)).thenReturn(renditionAssoc);
    QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, rendName);
    ChildAssociationRef parentAssoc = makeAssoc(parent, oldRendition, assocName, false);
    when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
    when(nodeService.getProperty(oldRendition, ContentModel.PROP_NAME)).thenReturn(rendName);
    RenditionLocationImpl location = new RenditionLocationImpl(parent, null, rendName);
    RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
    ChildAssociationRef result = manager.findOrCreateRenditionNode();
    assertEquals(parentAssoc, result);
    verify(nodeService, times(2)).getPrimaryParent(oldRendition);
}

3. RenditionNodeManagerTest#testHasOldRenditionCorrectParentNoNameSpecified()

Project: community-edition
File: RenditionNodeManagerTest.java
// Check findOrCreateRenditionNode() works when there is 
// an old rendition which has the specified parent folder.
// If no name is specified and the parent folder is correct then the location should match.
public void testHasOldRenditionCorrectParentNoNameSpecified() {
    NodeRef parent = new NodeRef("http://test/parentId");
    ChildAssociationRef renditionAssoc = makeAssoc(source, oldRendition, true);
    when(renditionService.getRenditionByName(source, renditionName)).thenReturn(renditionAssoc);
    ChildAssociationRef parentAssoc = makeAssoc(parent, oldRendition, false);
    when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
    RenditionLocation location = new RenditionLocationImpl(parent, null, null);
    RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
    ChildAssociationRef result = manager.findOrCreateRenditionNode();
    assertEquals(parentAssoc, result);
    verify(nodeService, times(2)).getPrimaryParent(oldRendition);
}

4. TemporaryNodes#createNode()

Project: community-edition
File: TemporaryNodes.java
private NodeRef createNode(String cmName, NodeRef parentNode, QName nodeType) {
    final NodeService nodeService = (NodeService) appContextRule.getApplicationContext().getBean("nodeService");
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, cmName);
    ChildAssociationRef childAssoc = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, nodeType, props);
    return childAssoc.getChildRef();
}

5. BaseAlfrescoSpringTest#createNode()

Project: community-edition
File: BaseAlfrescoSpringTest.java
protected NodeRef createNode(NodeRef parentNode, String name, QName type) {
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    String fullName = name + System.currentTimeMillis();
    props.put(ContentModel.PROP_NAME, fullName);
    QName childName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, fullName);
    ChildAssociationRef childAssoc = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, childName, type, props);
    return childAssoc.getChildRef();
}

6. SiteServiceTest#createRepoFile()

Project: community-edition
File: SiteServiceTest.java
private NodeRef createRepoFile() {
    NodeRef rootNodeRef = this.nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    // create temporary folder
    NodeRef workingRootNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.ALFRESCO_URI, "working root"), ContentModel.TYPE_FOLDER).getChildRef();
    String fName = GUID.generate();
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
    properties.put(ContentModel.PROP_NAME, (Serializable) fName);
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(fName));
    // create empy file
    ChildAssociationRef assocRef = nodeService.createNode(workingRootNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CONTENT, properties);
    return assocRef.getChildRef();
}

7. DownloadRestApiTest#createNode()

Project: community-edition
File: DownloadRestApiTest.java
private NodeRef createNode(NodeRef parentNode, String nodeCmName, QName nodeType, String ownerUserName) {
    QName childName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, nodeCmName);
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, nodeCmName);
    ChildAssociationRef childAssoc = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, childName, nodeType, props);
    return childAssoc.getChildRef();
}

8. VersionServiceImpl#createVersionHistory()

Project: community-edition
File: VersionServiceImpl.java
/**
     * 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();
}

9. Version2ServiceImpl#createVersionHistory()

Project: community-edition
File: Version2ServiceImpl.java
/**
     * Creates a new version history node, applying the root version aspect is required
     *
     * @param nodeRef   the node ref
     * @return          the version history node reference
     */
protected NodeRef createVersionHistory(NodeRef nodeRef) {
    long start = System.currentTimeMillis();
    HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, nodeRef.getId());
    props.put(Version2Model.PROP_QNAME_VERSIONED_NODE_ID, nodeRef.getId());
    // Create a new version history node
    ChildAssociationRef childAssocRef = this.dbNodeService.createNode(getRootNode(), Version2Model.CHILD_QNAME_VERSION_HISTORIES, QName.createQName(Version2Model.NAMESPACE_URI, nodeRef.getId()), Version2Model.TYPE_QNAME_VERSION_HISTORY, props);
    if (logger.isTraceEnabled()) {
        logger.trace("created version history nodeRef: " + childAssocRef.getChildRef() + " for " + nodeRef + " in " + (System.currentTimeMillis() - start) + " ms");
    }
    return childAssocRef.getChildRef();
}

10. TransferSummaryReportImpl#createTransferRecord()

Project: community-edition
File: TransferSummaryReportImpl.java
private NodeRef createTransferRecord(String transferId) {
    log.debug("TransferSummaryReport createTransferRecord");
    NodeRef reportParentFolder = getParentFolder();
    String name = getReportFileName(reportParentFolder);
    QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name);
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, name);
    props.put(TransferModel.PROP_PROGRESS_POSITION, 0);
    props.put(TransferModel.PROP_PROGRESS_ENDPOINT, 1);
    props.put(TransferModel.PROP_TRANSFER_STATUS, TransferProgress.Status.PRE_COMMIT.toString());
    log.debug("Creating transfer summary report with name: " + name);
    ChildAssociationRef assoc = nodeService.createNode(reportParentFolder, ContentModel.ASSOC_CONTAINS, recordName, TransferModel.TYPE_TRANSFER_RECORD, props);
    log.debug("<-createTransferSummartReportRecord: " + assoc.getChildRef());
    return assoc.getChildRef();
}

11. ReplicationServiceIntegrationTest#makeNode()

Project: community-edition
File: ReplicationServiceIntegrationTest.java
private NodeRef makeNode(NodeRef parent, QName nodeType, String name) {
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    QName newName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name);
    NodeRef existing = nodeService.getChildByName(parent, ContentModel.ASSOC_CONTAINS, name);
    if (existing != null) {
        System.err.println("Zapped existing node " + existing + " for name " + name);
        try {
            lockService.unlock(existing, true);
        } catch (UnableToReleaseLockException e) {
        }
        nodeService.deleteNode(existing);
    }
    props.put(ContentModel.PROP_NAME, name);
    ChildAssociationRef assoc = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, newName, nodeType, props);
    return assoc.getChildRef();
}

12. RenditionNodeManagerTest#testNoOldRenditionAndNoDestinationSpecifiedAndParentIsNotSource()

Project: community-edition
File: RenditionNodeManagerTest.java
// Check findOrCreateRenditionNode() works when there is 
// no old rendition and a destination node is not specified.
// the parent node is not the source node.
public void testNoOldRenditionAndNoDestinationSpecifiedAndParentIsNotSource() {
    String localName = "Foo";
    QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, localName);
    NodeRef parent = new NodeRef("http://test/parentId");
    ChildAssociationRef parentAssoc = makeAssoc(parent, destination, assocName, false);
    Map<QName, Serializable> indexProps = Collections.singletonMap(ContentModel.PROP_IS_INDEXED, (Serializable) Boolean.FALSE);
    when(nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, assocName, ContentModel.TYPE_CONTENT, indexProps)).thenReturn(parentAssoc);
    RenditionLocation location = new RenditionLocationImpl(parent, null, localName);
    RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService, behaviourFilter);
    ChildAssociationRef result = manager.findOrCreateRenditionNode();
    assertEquals(parentAssoc, result);
    // Check the rendition association is created.
    verify(nodeService).addChild(source, destination, RenditionModel.ASSOC_RENDITION, renditionName);
}

13. RenditionNodeManagerTest#testNoOldRenditionAndNoDestinationSpecifiedAndParentIsSource()

Project: community-edition
File: RenditionNodeManagerTest.java
// Check findOrCreateRenditionNode() works when there is 
// no old rendition and a destination node is not specified.
// the parent node is the source node.
public void testNoOldRenditionAndNoDestinationSpecifiedAndParentIsSource() {
    Map<QName, Serializable> indexProps = Collections.singletonMap(ContentModel.PROP_IS_INDEXED, (Serializable) Boolean.FALSE);
    ChildAssociationRef parentAssoc = makeAssoc(source, destination, true);
    when(nodeService.createNode(source, RenditionModel.ASSOC_RENDITION, renditionName, ContentModel.TYPE_CONTENT, indexProps)).thenReturn(parentAssoc);
    RenditionLocation location = new RenditionLocationImpl(source, null, renditionName.getLocalName());
    RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService, behaviourFilter);
    ChildAssociationRef result = manager.findOrCreateRenditionNode();
    assertEquals(parentAssoc, result);
}

14. BaseNodeServiceTest#testNonDuplicateAssocsWithSuppliedName()

Project: community-edition
File: BaseNodeServiceTest.java
/**
     * Create some nodes that have the same <b>cm:name</b> but use associations that don't
     * enforce uniqueness.
     */
public void testNonDuplicateAssocsWithSuppliedName() throws Throwable {
    Map<QName, Serializable> properties = Collections.singletonMap(ContentModel.PROP_NAME, (Serializable) getName());
    NodeRef parentRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("parent_child"), ContentModel.TYPE_CONTAINER).getChildRef();
    ChildAssociationRef pathARef = nodeService.createNode(parentRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), ContentModel.TYPE_CONTENT, properties);
    ChildAssociationRef pathBRef = nodeService.createNode(parentRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathB"), ContentModel.TYPE_CONTENT, properties);
}

15. CopyServiceImplTest#testCopyWorkingCopyForAlf8863()

Project: community-edition
File: CopyServiceImplTest.java
public void testCopyWorkingCopyForAlf8863() throws Exception {
    // Test that TopLevelNodeNewName is null for not working copies
    ChildAssociationRef assocRef = nodeService.getPrimaryParent(sourceNodeRef);
    String newNameAfterCopy = copyService.getTopLevelNodeNewName(sourceNodeRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, assocRef.getQName());
    assertNull(newNameAfterCopy);
    // Test that TopLevelNodeNewName is NOT null for working copies
    NodeRef workingCopyRef = cociService.checkout(sourceNodeRef);
    ChildAssociationRef assocWCRef = nodeService.getPrimaryParent(workingCopyRef);
    newNameAfterCopy = copyService.getTopLevelNodeNewName(workingCopyRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, assocWCRef.getQName());
    assertNotNull(newNameAfterCopy);
    assertTrue(newNameAfterCopy.startsWith(TEST_NAME));
    assertFalse(newNameAfterCopy.contains("(Working Copy)"));
    // Test copyAndRename call
    NodeRef copyRef = copyService.copyAndRename(workingCopyRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, null, false);
    String copyofWCName = (String) nodeService.getProperty(copyRef, ContentModel.PROP_NAME);
    assertTrue(copyofWCName.startsWith(TEST_NAME));
    assertFalse(copyofWCName.contains("(Working Copy)"));
}

16. NodeChangeTest#testOnMoveNode()

Project: community-edition
File: NodeChangeTest.java
@Test
public final void testOnMoveNode() {
    ChildAssociationRef fromChildAssocRef = mock(ChildAssociationRef.class);
    // correct as the move has taken place
    when(fromChildAssocRef.getChildRef()).thenReturn(content1);
    when(fromChildAssocRef.getParentRef()).thenReturn(folder2);
    when(fromChildAssocRef.getQName()).thenReturn(QName.createQName("URI", "content1"));
    ChildAssociationRef toChildAssocRef = mock(ChildAssociationRef.class);
    when(toChildAssocRef.getChildRef()).thenReturn(content1);
    when(toChildAssocRef.getParentRef()).thenReturn(folder1);
    when(toChildAssocRef.getQName()).thenReturn(QName.createQName("URI", "content1"));
    nodeChange.onMoveNode(fromChildAssocRef, toChildAssocRef);
    Map<String, Serializable> auditMap = nodeChange.getAuditData(false);
    assertStandardData(auditMap, "MOVE", "moveNode");
    assertEquals("/cm:homeFolder/cm:folder2/cm:content1", auditMap.get("move/from/path"));
    assertEquals(content1, auditMap.get("move/from/node"));
    assertEquals("cm:content", auditMap.get("move/from/type"));
}

17. VirtualNodeServiceExtension#revertVirtualAssociation()

Project: community-edition
File: VirtualNodeServiceExtension.java
private List<ChildAssociationRef> revertVirtualAssociation(ChildAssociationRef childAssocRef, NodeServiceTrait theTrait, NodeRef childRef) {
    childRef = smartStore.materialize(Reference.fromNodeRef(childRef));
    ChildAssociationRef parent = theTrait.getPrimaryParent(childRef);
    final QName assocName = childAssocRef.getQName();
    List<ChildAssociationRef> assocsToRemove = theTrait.getChildAssocs(parent.getParentRef(), childAssocRef.getTypeQName(), new QNamePattern() {

        @Override
        public boolean isMatch(QName qname) {
            return assocName.getLocalName().equals(qname.getLocalName());
        }
    });
    return assocsToRemove;
}

18. VersionServiceImpl#getCurrentVersionNodeRef()

Project: community-edition
File: VersionServiceImpl.java
/**
     * Gets a reference to the node for the current version of the passed node ref.
     *
     * This uses the version label as a mechanism for looking up the version node in
     * the version history.
     *
     * @param nodeRef  a node reference
     * @return         a reference to a version reference
     */
private NodeRef getCurrentVersionNodeRef(NodeRef versionHistory, NodeRef nodeRef) {
    NodeRef result = null;
    String versionLabel = (String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
    Collection<ChildAssociationRef> versions = this.dbNodeService.getChildAssocs(versionHistory);
    for (ChildAssociationRef version : versions) {
        String tempLabel = (String) this.dbNodeService.getProperty(version.getChildRef(), VersionModel.PROP_QNAME_VERSION_LABEL);
        if (tempLabel != null && tempLabel.equals(versionLabel) == true) {
            result = version.getChildRef();
            break;
        }
    }
    return result;
}

19. VersionServiceImpl#freezeChildAssociations()

Project: community-edition
File: VersionServiceImpl.java
/**
     * Freeze child associations
     *
     * @param versionNodeRef       the version node reference
     * @param childAssociations    the child associations
     */
private void freezeChildAssociations(NodeRef versionNodeRef, List<ChildAssociationRef> childAssociations) {
    for (ChildAssociationRef childAssocRef : childAssociations) {
        HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
        // Set the qname, isPrimary and nthSibling properties
        properties.put(PROP_QNAME_ASSOC_QNAME, childAssocRef.getQName());
        properties.put(PROP_QNAME_ASSOC_TYPE_QNAME, childAssocRef.getTypeQName());
        properties.put(PROP_QNAME_IS_PRIMARY, Boolean.valueOf(childAssocRef.isPrimary()));
        properties.put(PROP_QNAME_NTH_SIBLING, Integer.valueOf(childAssocRef.getNthSibling()));
        // Set the reference property to point to the child node
        properties.put(ContentModel.PROP_REFERENCE, childAssocRef.getChildRef());
        // Create child version reference
        this.dbNodeService.createNode(versionNodeRef, CHILD_QNAME_VERSIONED_CHILD_ASSOCS, CHILD_QNAME_VERSIONED_CHILD_ASSOCS, TYPE_QNAME_VERSIONED_CHILD_ASSOC, properties);
    }
}

20. VersionServiceImpl#getVersionMetaData()

Project: community-edition
File: VersionServiceImpl.java
protected Map<String, Serializable> getVersionMetaData(NodeRef versionNodeRef) {
    // Get the meta data
    List<ChildAssociationRef> metaData = this.dbNodeService.getChildAssocs(versionNodeRef, RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSION_META_DATA);
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(metaData.size());
    for (ChildAssociationRef ref : metaData) {
        NodeRef metaDataValue = (NodeRef) ref.getChildRef();
        String name = (String) this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_NAME);
        Serializable value = this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_VALUE);
        versionProperties.put(name, value);
    }
    return versionProperties;
}

21. Version2ServiceImpl#getAllVersions()

Project: community-edition
File: Version2ServiceImpl.java
/**
     * Gets all versions in version history
     * 
     * @param versionHistoryRef the version history nodeRef
     * @return list of all versions
     */
protected List<Version> getAllVersions(NodeRef versionHistoryRef) {
    List<ChildAssociationRef> versionAssocs = getVersionAssocs(versionHistoryRef, true);
    List<Version> versions = new ArrayList<Version>(versionAssocs.size());
    for (ChildAssociationRef versionAssoc : versionAssocs) {
        versions.add(getVersion(versionAssoc.getChildRef()));
    }
    return versions;
}

22. Version2ServiceImpl#freezeChildAssociations()

Project: community-edition
File: Version2ServiceImpl.java
/**
     * Freeze child associations
     *
     * @param versionNodeRef       the version node reference
     * @param childAssociations    the child associations
     */
private void freezeChildAssociations(NodeRef versionNodeRef, List<ChildAssociationRef> childAssociations) {
    for (ChildAssociationRef childAssocRef : childAssociations) {
        HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
        NodeRef childRef = childAssocRef.getChildRef();
        QName sourceTypeRef = nodeService.getType(childRef);
        // Set the reference property to point to the child node
        properties.put(ContentModel.PROP_REFERENCE, childRef);
        // Create child version reference
        dbNodeService.createNode(versionNodeRef, childAssocRef.getTypeQName(), childAssocRef.getQName(), sourceTypeRef, properties);
    }
}

23. TransferServiceImpl2#getTransferTargets()

Project: community-edition
File: TransferServiceImpl2.java
/**
     * Given the noderef of a group of transfer targets, return all the contained transfer targets.
     * @param groupNode NodeRef
     * @return Set<TransferTarget>
     */
private Set<TransferTarget> getTransferTargets(NodeRef groupNode) {
    Set<TransferTarget> result = new HashSet<TransferTarget>();
    List<ChildAssociationRef> children = nodeService.getChildAssocs(groupNode, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
    for (ChildAssociationRef child : children) {
        if (nodeService.getType(child.getChildRef()).equals(TransferModel.TYPE_TRANSFER_TARGET)) {
            TransferTargetImpl newTarget = new TransferTargetImpl();
            mapTransferTarget(child.getChildRef(), newTarget);
            result.add(newTarget);
        }
    }
    return result;
}

24. TransferServiceImpl2#getTransferTargets()

Project: community-edition
File: TransferServiceImpl2.java
/**
     * Get all transfer targets
     */
public Set<TransferTarget> getTransferTargets() {
    NodeRef home = getTransferHome();
    Set<TransferTarget> ret = new HashSet<TransferTarget>();
    // get all groups
    List<ChildAssociationRef> groups = nodeService.getChildAssocs(home);
    // for each group
    for (ChildAssociationRef group : groups) {
        NodeRef groupNode = group.getChildRef();
        ret.addAll(getTransferTargets(groupNode));
    }
    return ret;
}

25. TransferManifestNodeHelper#getPrimaryParentAssoc()

Project: community-edition
File: TransferManifestNodeHelper.java
/**
     * Gets the primary parent association 
     * @param node the node to process
     * @return the primary parent association or null if this is a root node
     */
public static ChildAssociationRef getPrimaryParentAssoc(TransferManifestNormalNode node) {
    List<ChildAssociationRef> assocs = node.getParentAssocs();
    for (ChildAssociationRef assoc : assocs) {
        if (assoc.isPrimary()) {
            return assoc;
        }
    }
    return null;
}

26. ChildAssociatedNodeFinder#processExcludedSet()

Project: community-edition
File: ChildAssociatedNodeFinder.java
/**
     * @param thisNode NodeRef
     * @return Set<NodeRef>
     */
private Set<NodeRef> processExcludedSet(NodeRef thisNode) {
    Set<NodeRef> results = new HashSet<NodeRef>(89);
    NodeService nodeService = serviceRegistry.getNodeService();
    // Find all the child nodes (filtering as necessary).
    List<ChildAssociationRef> children = nodeService.getChildAssocs(thisNode);
    boolean filterChildren = !childAssociationTypes.isEmpty();
    for (ChildAssociationRef child : children) {
        if (!filterChildren || !childAssociationTypes.contains(child.getTypeQName())) {
            results.add(child.getChildRef());
        }
    }
    return results;
}

27. TemplateNode#getChildAssocsByType()

Project: community-edition
File: TemplateNode.java
/**
     * @return The list of children of this Node that match a specific object type.
     */
public List<TemplateNode> getChildAssocsByType(String type) {
    Set<QName> types = new HashSet<QName>(1, 1.0f);
    types.add(createQName(type));
    List<ChildAssociationRef> refs = this.services.getNodeService().getChildAssocs(this.nodeRef, types);
    List<TemplateNode> nodes = new ArrayList<TemplateNode>(refs.size());
    for (ChildAssociationRef ref : refs) {
        String qname = ref.getTypeQName().toString();
        nodes.add(new TemplateNode(ref.getChildRef(), this.services, this.imageResolver));
    }
    return nodes;
}

28. TaggingServiceImpl#getTags()

Project: community-edition
File: TaggingServiceImpl.java
/**
     * @see org.alfresco.service.cmr.tagging.TaggingService#getTags(StoreRef)
     */
public List<String> getTags(StoreRef storeRef) {
    ParameterCheck.mandatory("storeRef", storeRef);
    Collection<ChildAssociationRef> rootCategories = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE);
    List<String> result = new ArrayList<String>(rootCategories.size());
    for (ChildAssociationRef rootCategory : rootCategories) {
        String name = (String) this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
        result.add(name);
    }
    return result;
}

29. RefreshTagScopeActionExecuter#countTags()

Project: community-edition
File: RefreshTagScopeActionExecuter.java
private void countTags(NodeRef nodeRef, List<TagDetails> tagDetailsList) {
    // Add the tags of passed node
    List<String> tags = this.taggingService.getTags(nodeRef);
    for (String tag : tags) {
        addDetails(tag, tagDetailsList);
    }
    // Iterate over the children of the node
    List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(nodeRef);
    for (ChildAssociationRef assoc : assocs) {
        if (assoc.isPrimary() == true) {
            countTags(assoc.getChildRef(), tagDetailsList);
        }
    }
}

30. SiteServiceImpl#listSites()

Project: community-edition
File: SiteServiceImpl.java
public List<SiteInfo> listSites(Set<String> siteNames) {
    List<ChildAssociationRef> assocs = this.nodeService.getChildrenByName(getSiteRoot(), ContentModel.ASSOC_CONTAINS, siteNames);
    List<SiteInfo> result = new ArrayList<SiteInfo>(assocs.size());
    for (ChildAssociationRef assoc : assocs) {
        // Ignore any node that is not a "site" type
        NodeRef site = assoc.getChildRef();
        QName siteClassName = this.nodeService.getType(site);
        if (dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE)) {
            result.add(createSiteInfo(site));
        }
    }
    return result;
}

31. PersonServiceImpl#beforeDeleteNodeValidation()

Project: community-edition
File: PersonServiceImpl.java
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() + ")");
    }
}

32. PersonServiceImpl#beforeDeleteNode()

Project: community-edition
File: PersonServiceImpl.java
public void beforeDeleteNode(NodeRef nodeRef) {
    String userName = (String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME);
    if (this.authorityService.isGuestAuthority(userName) && !this.tenantService.isTenantUser(userName)) {
        throw new AlfrescoRuntimeException("The " + userName + " user cannot be deleted.");
    }
    NodeRef parentRef = null;
    ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
    if (parentAssocRef != null) {
        parentRef = parentAssocRef.getParentRef();
        if (getPeopleContainer().equals(parentRef)) {
            // Remove the cache entry.
            // Note that the associated node has not been deleted and is therefore still
            // visible to any other code that attempts to see it.  We therefore need to
            // prevent the value from being added back before the node is actually
            // deleted.
            removeFromCache(userName, true);
        }
    }
}

33. AuthorityDAOImpl#getRootAuthoritiesUnderContainer()

Project: community-edition
File: AuthorityDAOImpl.java
private Set<String> getRootAuthoritiesUnderContainer(NodeRef container, AuthorityType type) {
    if (type != null && type.equals(AuthorityType.USER)) {
        return Collections.<String>emptySet();
    }
    Collection<ChildAssociationRef> childRefs = nodeService.getChildAssocsWithoutParentAssocsOfType(container, ContentModel.ASSOC_MEMBER);
    Set<String> authorities = new TreeSet<String>();
    for (ChildAssociationRef childRef : childRefs) {
        addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type);
    }
    return authorities;
}

34. AuthorityDAOImpl#removeParentsFromChildAuthorityCache()

Project: community-edition
File: AuthorityDAOImpl.java
/**
     * 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);
            }
        }
    }
}

35. SolrFacetServiceImpl#getPersistedFacetProperties()

Project: community-edition
File: SolrFacetServiceImpl.java
/** Gets the persisted {@link SolrFacetProperties} if there are any, else an empty map. */
private Map<String, SolrFacetProperties> getPersistedFacetProperties() {
    final NodeRef facetsRoot = getFacetsRoot();
    Map<String, SolrFacetProperties> facets = new HashMap<>();
    final List<ChildAssociationRef> list = facetsRoot == null ? new ArrayList<ChildAssociationRef>() : nodeService.getChildAssocs(facetsRoot);
    for (ChildAssociationRef associationRef : list) {
        // MNT-13812 Check that child has facetField type
        if (nodeService.getType(associationRef.getChildRef()).equals(SolrFacetModel.TYPE_FACET_FIELD)) {
            SolrFacetProperties fp = getFacetProperties(associationRef.getChildRef());
            facets.put(fp.getFilterID(), fp);
        }
    }
    return facets;
}

36. DBResultSet#getChildAssocRef()

Project: community-edition
File: DBResultSet.java
/* (non-Javadoc)
     * @see org.alfresco.service.cmr.search.ResultSetSPI#getChildAssocRef(int)
     */
@Override
public ChildAssociationRef getChildAssocRef(int n) {
    ChildAssociationRef primaryParentAssoc = nodeService.getPrimaryParent(getNodeRef(n));
    if (primaryParentAssoc != null) {
        return primaryParentAssoc;
    } else {
        return null;
    }
}

37. SolrJSONResultSet#getChildAssocRef()

Project: community-edition
File: SolrJSONResultSet.java
/*
     * (non-Javadoc)
     * @see org.alfresco.service.cmr.search.ResultSetSPI#getChildAssocRef(int)
     */
@Override
public ChildAssociationRef getChildAssocRef(int n) {
    ChildAssociationRef primaryParentAssoc = nodeService.getPrimaryParent(getNodeRef(n));
    if (primaryParentAssoc != null) {
        return primaryParentAssoc;
    } else {
        return null;
    }
}

38. LuceneCategoryServiceImpl#createCategoryInternal()

Project: community-edition
File: LuceneCategoryServiceImpl.java
private ChildAssociationRef createCategoryInternal(NodeRef parent, String name) {
    if (!nodeService.exists(parent)) {
        throw new AlfrescoRuntimeException("Missing category?");
    }
    String uri = nodeService.getPrimaryParent(parent).getQName().getNamespaceURI();
    String validLocalName = QName.createValidLocalName(name);
    ChildAssociationRef newCategory = publicNodeService.createNode(parent, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(uri, validLocalName), ContentModel.TYPE_CATEGORY);
    publicNodeService.setProperty(newCategory.getChildRef(), ContentModel.PROP_NAME, name);
    return newCategory;
}

39. DocumentNavigator#getChildAxisIterator()

Project: community-edition
File: DocumentNavigator.java
public Iterator getChildAxisIterator(Object contextNode, String localName, String namespacePrefix, String namespaceURI) throws UnsupportedAxisException {
    // decode the localname
    localName = ISO9075.decode(localName);
    // MNT-10730
    if (localName != null && (localName.equalsIgnoreCase("true") || localName.equalsIgnoreCase("false"))) {
        return Collections.singletonList(new Boolean(Boolean.parseBoolean(localName))).iterator();
    }
    ChildAssociationRef assocRef = (ChildAssociationRef) contextNode;
    NodeRef childRef = assocRef.getChildRef();
    QName qName = QName.createQName(namespaceURI, localName);
    List<? extends ChildAssociationRef> list = null;
    list = nodeService.getChildAssocs(childRef, RegexQNamePattern.MATCH_ALL, qName);
    // done
    return list.iterator();
}

40. RuleServiceImpl#getSavedRuleFolderAssoc()

Project: community-edition
File: RuleServiceImpl.java
/**
     * Gets the saved rule folder reference
     * 
     * @param nodeRef    the node reference
     * @return            the node reference
     */
public ChildAssociationRef getSavedRuleFolderAssoc(NodeRef nodeRef) {
    ChildAssociationRef result = null;
    List<ChildAssociationRef> assocs = this.runtimeNodeService.getChildAssocs(nodeRef, RuleModel.ASSOC_RULE_FOLDER, RuleModel.ASSOC_RULE_FOLDER);
    if (assocs.size() > 1) {
        throw new ActionServiceException("There is more than one rule folder, which is invalid.");
    } else if (assocs.size() == 1) {
        result = assocs.get(0);
    }
    return result;
}

41. ReplicationDefinitionPersisterImpl#loadReplicationDefinitions()

Project: community-edition
File: ReplicationDefinitionPersisterImpl.java
public List<ReplicationDefinition> loadReplicationDefinitions() {
    checkReplicationActionRootNodeExists();
    // Note that in the call to getChildAssocs below, only the specified
    // types are included.
    // Subtypes of the type action:action will not be returned.
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(REPLICATION_ACTION_ROOT_NODE_REF, ACTION_TYPES);
    List<ReplicationDefinition> replicationActions = new ArrayList<ReplicationDefinition>(childAssocs.size());
    for (ChildAssociationRef actionAssoc : childAssocs) {
        Action nextAction = runtimeActionService.createAction(actionAssoc.getChildRef());
        replicationActions.add(new ReplicationDefinitionImpl(nextAction));
    }
    return replicationActions;
}

42. ScriptRenditionService#render()

Project: community-edition
File: ScriptRenditionService.java
public ScriptNode render(ScriptNode sourceNode, ScriptRenditionDefinition scriptRenditionDef) {
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Rendering source node '").append(sourceNode).append("' with renditionDefQName '").append(scriptRenditionDef).append("'");
        logger.debug(msg.toString());
    }
    ChildAssociationRef chAssRef = this.renditionService.render(sourceNode.getNodeRef(), scriptRenditionDef.getRenditionDefinition());
    NodeRef renditionNode = chAssRef.getChildRef();
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Rendition: ").append(renditionNode);
        logger.debug(msg.toString());
    }
    return new ScriptNode(renditionNode, serviceRegistry);
}

43. ScriptRenditionService#render()

Project: community-edition
File: ScriptRenditionService.java
/**
     * This method renders the specified source node using the specified saved
     * rendition definition.
     * @param sourceNode the source node to be rendered.
     * @param renditionDefQName the rendition definition to be used e.g. "cm:doclib" or
     *                          "{http://www.alfresco.org/model/content/1.0}imgpreview"
     * @return the rendition scriptnode.
     * @see org.alfresco.service.cmr.rendition.RenditionService#render(org.alfresco.service.cmr.repository.NodeRef, RenditionDefinition)
     */
public ScriptNode render(ScriptNode sourceNode, String renditionDefQName) {
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Rendering source node '").append(sourceNode).append("' with renditionDef '").append(renditionDefQName).append("'");
        logger.debug(msg.toString());
    }
    RenditionDefinition rendDef = loadRenditionDefinitionImpl(renditionDefQName);
    ChildAssociationRef result = this.renditionService.render(sourceNode.getNodeRef(), rendDef);
    NodeRef renditionNode = result.getChildRef();
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Rendition: ").append(renditionNode);
        logger.debug(msg.toString());
    }
    return new ScriptNode(renditionNode, serviceRegistry);
}

44. RenditionServiceImpl#removeArchivedRenditionsFrom()

Project: community-edition
File: RenditionServiceImpl.java
private List<ChildAssociationRef> removeArchivedRenditionsFrom(List<ChildAssociationRef> renditionAssocs) {
    // This is a workaround for a bug in the NodeService (no JIRA number yet) whereby a call to
    // nodeService.getChildAssocs can return all children, including children in the archive store.
    List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>();
    for (ChildAssociationRef chAssRef : renditionAssocs) {
        // If the rendition has *not* been deleted, then it should remain in the result list.
        if (chAssRef.getChildRef().getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE) == false) {
            result.add(chAssRef);
        }
    }
    return result;
}

45. RenditionServiceImpl#executeRenditionAction()

Project: community-edition
File: RenditionServiceImpl.java
/**
     * This method delegates the execution of the specified RenditionDefinition
     * to the {@link ActionService action service}.
     * 
     * @param sourceNode the source node which is to be rendered.
     * @param definition the rendition definition to be used.
     * @param asynchronous <code>true</code> for asynchronous execution,
     *                     <code>false</code> for synchronous.
     * @return the ChildAssociationRef whose child is the rendition node.
     */
private ChildAssociationRef executeRenditionAction(NodeRef sourceNode, RenditionDefinition definition, boolean asynchronous) {
    if (log.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        if (asynchronous) {
            msg.append("Asynchronously");
        } else {
            msg.append("Synchronously");
        }
        msg.append(" rendering node ").append(sourceNode).append(" with ").append(definition.getRenditionName());
        log.debug(msg.toString());
    }
    final boolean checkConditions = true;
    actionService.executeAction(definition, sourceNode, checkConditions, asynchronous);
    ChildAssociationRef result = (ChildAssociationRef) definition.getParameterValue(ActionExecuter.PARAM_RESULT);
    return result;
}

46. RenditionServiceImpl#render()

Project: community-edition
File: RenditionServiceImpl.java
/*
     * (non-Javadoc)
     * @see org.alfresco.service.cmr.rendition.RenditionService#render(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rendition.RenditionDefinition)
     */
public ChildAssociationRef render(NodeRef sourceNode, RenditionDefinition definition) {
    checkSourceNodeForPreventionClass(sourceNode);
    ChildAssociationRef result = executeRenditionAction(sourceNode, definition, false);
    if (log.isDebugEnabled()) {
        log.debug("Produced rendition " + result);
    }
    return result;
}

47. RenditionNodeManager#getExistingRendition()

Project: community-edition
File: RenditionNodeManager.java
/**
     * This method returns the rendition on the given sourceNode with the given renditionDefinition, if such
     * a rendition exists.
     * 
     * @return the rendition node if one exists, else null.
     */
private NodeRef getExistingRendition() {
    QName renditionName = renditionDefinition.getRenditionName();
    ChildAssociationRef renditionAssoc = renditionService.getRenditionByName(sourceNode, renditionName);
    NodeRef result = (renditionAssoc == null) ? null : renditionAssoc.getChildRef();
    if (logger.isDebugEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Existing rendition with name ").append(renditionName).append(": ").append(result);
        logger.debug(msg.toString());
    }
    return result;
}

48. RenditionNodeManager#checkDestinationNodeIsAcceptable()

Project: community-edition
File: RenditionNodeManager.java
private void checkDestinationNodeIsAcceptable(NodeRef destination) {
    if (!nodeService.exists(destination)) {
        return;
    }
    if (!renditionService.isRendition(destination)) {
        throw new RenditionServiceException("Cannot perform a rendition to an existing node that is not a rendition.");
    }
    ChildAssociationRef sourceAssoc = renditionService.getSourceNode(destination);
    if (!sourceAssoc.getParentRef().equals(sourceNode)) {
        throw new RenditionServiceException("Cannot perform a rendition to an existing rendition node whose source is different.");
    }
    if (!sourceAssoc.getQName().equals(renditionDefinition.getRenditionName())) {
        throw new RenditionServiceException("Cannot perform a rendition to an existing rendition node whose rendition name is different.");
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Using destination node " + destination + " with existing srcNode: " + sourceAssoc);
    }
}

49. RenditionNodeManager#isOldRenditionInCorrectLocationWithoutLog()

Project: community-edition
File: RenditionNodeManager.java
private boolean isOldRenditionInCorrectLocationWithoutLog() {
    NodeRef destination = location.getChildRef();
    if (destination != null) {
        return destination.equals(existingLinkedRendition);
    }
    ChildAssociationRef oldParentAssoc = nodeService.getPrimaryParent(existingLinkedRendition);
    NodeRef oldParent = oldParentAssoc.getParentRef();
    if (oldParent.equals(location.getParentRef())) {
        String childName = location.getChildName();
        if (childName == null)
            return true;
        else {
            Serializable oldName = nodeService.getProperty(existingLinkedRendition, ContentModel.PROP_NAME);
            return childName.equals(oldName);
        }
    }
    return false;
}

50. RenditionNodeManager#moveOldRendition()

Project: community-edition
File: RenditionNodeManager.java
/**
     * This method moves the old rendition to the required location giving it the correct parent-assoc type and
     * the specified association name.
     * 
     * @param renditionName the name to put on the newly created association.
     * @return the ChildAssociationRef of the moved nodeRef.
     */
private ChildAssociationRef moveOldRendition(QName renditionName) {
    NodeRef parent = location.getParentRef();
    QName assocName = getAssociationName(parent.equals(sourceNode), renditionName);
    QName assocType = sourceNode.equals(parent) ? RenditionModel.ASSOC_RENDITION : ContentModel.ASSOC_CONTAINS;
    ChildAssociationRef result = nodeService.moveNode(existingLinkedRendition, parent, assocType, assocName);
    if (logger.isDebugEnabled()) {
        logger.debug("The old rendition was moved to " + result);
    }
    return result;
}

51. RenditionDefinitionPersisterImpl#loadRenditionDefinitions()

Project: community-edition
File: RenditionDefinitionPersisterImpl.java
public List<RenditionDefinition> loadRenditionDefinitions() {
    checkRenderingActionRootNodeExists();
    // Note that in the call to getChildAssocs below, only the specified
    // types are included.
    // Subtypes of the type action:action will not be returned.
    Set<QName> actionTypes = new HashSet<QName>();
    actionTypes.add(ActionModel.TYPE_ACTION);
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(RENDERING_ACTION_ROOT_NODE_REF, actionTypes);
    List<RenditionDefinition> renderingActions = new ArrayList<RenditionDefinition>(childAssocs.size());
    for (ChildAssociationRef actionAssoc : childAssocs) {
        Action nextAction = runtimeActionService.createAction(actionAssoc.getChildRef());
        renderingActions.add(new RenditionDefinitionImpl(nextAction));
    }
    return renderingActions;
}

52. CompositeRenderingEngine#executeSubDefinition()

Project: community-edition
File: CompositeRenderingEngine.java
/**
     * Executes the specified subdefinition. Note that each of these component rendition definitions
     * will be executed with the {@link RenditionService#PARAM_IS_COMPONENT_RENDITION is-component-rendition}
     * flag set to true. This is so that the common pre- and post-rendition code in
     * {@link AbstractRenderingEngine#executeImpl(Action, NodeRef)} will only be executed at the start
     * and at the end of the chain of components.
     */
private //
ChildAssociationRef executeSubDefinition(//
NodeRef source, //
RenditionDefinition subDefinition, //
NodeRef parent, QName assocType) {
    subDefinition.setRenditionParent(parent);
    subDefinition.setRenditionAssociationType(assocType);
    subDefinition.setParameterValue(RenditionService.PARAM_IS_COMPONENT_RENDITION, true);
    actionService.executeAction(subDefinition, source);
    ChildAssociationRef newResult = (ChildAssociationRef) subDefinition.getParameterValue(PARAM_RESULT);
    return newResult;
}

53. CompositeRenderingEngine#executeCompositeRendition()

Project: community-edition
File: CompositeRenderingEngine.java
private ChildAssociationRef executeCompositeRendition(CompositeRenditionDefinition definition, NodeRef sourceNode) {
    NodeRef source = sourceNode;
    ChildAssociationRef result = null;
    QName assocType = definition.getRenditionAssociationType();
    NodeRef parent = definition.getRenditionParent();
    for (RenditionDefinition subDefinition : definition.getActions()) {
        ChildAssociationRef nextResult = executeSubDefinition(source, subDefinition, parent, assocType);
        if (result != null) {
            // Clean up temporary renditions.
            nodeService.removeChild(parent, result.getChildRef());
            if (logger.isDebugEnabled()) {
                logger.debug("removeChild parentRef:" + parent + ", childRef;" + result.getChildRef());
            }
        }
        result = nextResult;
        source = nextResult.getChildRef();
    }
    return result;
}

54. RepoRemoteService#getRoot()

Project: community-edition
File: RepoRemoteService.java
/* (non-Javadoc)
     * @see org.alfresco.service.cmr.remote.RepoRemote#getRoot()
     */
public NodeRef getRoot() {
    NodeRef storeRoot = fNodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
    List<ChildAssociationRef> listing = fNodeService.getChildAssocs(storeRoot);
    for (ChildAssociationRef child : listing) {
        fgLogger.error(child.getQName().getLocalName());
        if (child.getQName().getLocalName().equals("company_home")) {
            return child.getChildRef();
        }
    }
    throw new AlfrescoRuntimeException("Root Not Found!");
}

55. RatingServiceImpl#getRatingFrom()

Project: community-edition
File: RatingServiceImpl.java
/**
     * This method returns a {@link Rating} object for the specified cm:rating node.
     * @param ratingNode NodeRef
     * @return Rating
     */
Rating getRatingFrom(NodeRef ratingNode) {
    // The appliedBy is encoded in the parent assoc qname.
    // It will be the same user for all ratings in this node.
    ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(ratingNode);
    String appliedBy = parentAssoc.getQName().getLocalName();
    Map<QName, Serializable> properties = nodeService.getProperties(ratingNode);
    final String schemeName = (String) properties.get(ContentModel.PROP_RATING_SCHEME);
    final Float score = (Float) properties.get(ContentModel.PROP_RATING_SCORE);
    final Date ratedAt = (Date) properties.get(ContentModel.PROP_RATED_AT);
    RatingScheme scheme = getRatingScheme(schemeName);
    Rating result = new Rating(scheme, score, appliedBy, ratedAt);
    return result;
}

56. RatingServiceImpl#getRating()

Project: community-edition
File: RatingServiceImpl.java
/**
     * This method gets the rating for the specified node, in the specified scheme by the specified user.
     * @param targetNode the node whose rating we are looking for.
     * @param ratingSchemeName the rating scheme name in which we are looking for a rating.
     * @param user the user name of the user whose rating we are looking for.
     * @return the {@link Rating} if there is one.
     */
private Rating getRating(NodeRef targetNode, String ratingSchemeName, String user) {
    List<ChildAssociationRef> ratingChildren = getRatingNodeChildren(targetNode, ratingSchemeName, user);
    // If there are none, return null
    if (ratingChildren.isEmpty()) {
        return null;
    }
    // Take the node pertaining to the current user & scheme.
    ChildAssociationRef ratingNodeAssoc = ratingChildren.get(0);
    return convertNodeRefToRating(user, ratingNodeAssoc.getChildRef());
}

57. RatingServiceImpl#getRatingsByCurrentUser()

Project: community-edition
File: RatingServiceImpl.java
/*
     * (non-Javadoc)
     * @see org.alfresco.service.cmr.rating.RatingService#getRatingsByCurrentUser(org.alfresco.service.cmr.repository.NodeRef)
     */
@Extend(traitAPI = RatingServiceTrait.class, extensionAPI = RatingServiceExtension.class)
public List<Rating> getRatingsByCurrentUser(NodeRef targetNode) {
    final String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
    List<ChildAssociationRef> children = getRatingNodeChildren(targetNode, null, fullyAuthenticatedUser);
    List<Rating> result = new ArrayList<Rating>(children.size());
    for (ChildAssociationRef child : children) {
        result.add(convertNodeRefToRating(fullyAuthenticatedUser, child.getChildRef()));
    }
    return result;
}

58. PublishingEventHelper#createNode()

Project: community-edition
File: PublishingEventHelper.java
public NodeRef createNode(NodeRef queueNode, PublishingDetails details) throws Exception {
    checkChannelAccess(details.getPublishChannelId());
    Set<String> statusChannelIds = details.getStatusUpdateChannels();
    if (isEmpty(statusChannelIds) == false)
        for (String statusChannelId : statusChannelIds) {
            checkChannelAccess(statusChannelId);
        }
    String name = GUID.generate();
    Map<QName, Serializable> props = buildPublishingEventProperties(details, name);
    ChildAssociationRef newAssoc = nodeService.createNode(queueNode, ASSOC_PUBLISHING_EVENT, QName.createQName(NAMESPACE, name), TYPE_PUBLISHING_EVENT, props);
    NodeRef eventNode = newAssoc.getChildRef();
    serializePublishNodes(eventNode, details);
    return eventNode;
}

59. ChannelImpl#createPublishedNode()

Project: community-edition
File: ChannelImpl.java
private NodeRef createPublishedNode(NodeRef root, NodeSnapshot snapshot) {
    QName type = snapshot.getType();
    Map<QName, Serializable> actualProps = getPropertiesToPublish(snapshot);
    String name = (String) actualProps.get(ContentModel.PROP_NAME);
    if (name == null) {
        name = GUID.generate();
    }
    QName assocName = QName.createQName(NAMESPACE, name);
    ChildAssociationRef publishedAssoc = nodeService.createNode(root, PublishingModel.ASSOC_PUBLISHED_NODES, assocName, type, actualProps);
    NodeRef publishedNode = publishedAssoc.getChildRef();
    return publishedNode;
}

60. ChannelImpl#updatePublishedNode()

Project: community-edition
File: ChannelImpl.java
private void updatePublishedNode(NodeRef publishedNode, PublishingPackageEntry entry) {
    NodeSnapshot snapshot = entry.getSnapshot();
    Set<QName> newAspects = snapshot.getAspects();
    removeUnwantedAspects(publishedNode, newAspects);
    Map<QName, Serializable> snapshotProps = snapshot.getProperties();
    removeUnwantedProperties(publishedNode, snapshotProps);
    // Add new properties
    Map<QName, Serializable> newProps = new HashMap<QName, Serializable>(snapshotProps);
    newProps.remove(ContentModel.PROP_NODE_UUID);
    nodeService.setProperties(publishedNode, snapshotProps);
    // Add new aspects
    addAspects(publishedNode, newAspects);
    List<ChildAssociationRef> assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL);
    for (ChildAssociationRef assoc : assocs) {
        nodeService.removeChildAssociation(assoc);
    }
}

61. ChannelHelper#createChannelNode()

Project: community-edition
File: ChannelHelper.java
public NodeRef createChannelNode(NodeRef parent, ChannelType channelType, String channelName, Map<QName, Serializable> props) {
    QName channelQName = getChannelQName(channelName);
    QName channelNodeType = channelType.getChannelNodeType();
    ChildAssociationRef channelAssoc = nodeService.createNode(parent, ASSOC_CONTAINS, channelQName, channelNodeType, props);
    NodeRef channelNode = channelAssoc.getChildRef();
    // Allow any user to read Channel permissions.
    permissionService.setPermission(channelNode, PermissionService.ALL_AUTHORITIES, PermissionService.READ_ASSOCIATIONS, true);
    return channelNode;
}

62. DbNodeServiceImpl#getPrimaryParent()

Project: community-edition
File: DbNodeServiceImpl.java
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException {
    // Get the node
    Pair<Long, NodeRef> nodePair = getNodePairNotNull(nodeRef);
    Long nodeId = nodePair.getFirst();
    // get the primary parent assoc
    Pair<Long, ChildAssociationRef> assocPair = nodeDAO.getPrimaryParentAssoc(nodeId);
    // done - the assoc may be null for a root node
    ChildAssociationRef assocRef = null;
    if (assocPair == null) {
        assocRef = new ChildAssociationRef(null, null, null, nodeRef);
    } else {
        assocRef = assocPair.getSecond();
    }
    return assocRef;
}

63. DbNodeServiceImpl#getParents()

Project: community-edition
File: DbNodeServiceImpl.java
public Collection<NodeRef> getParents(NodeRef nodeRef) throws InvalidNodeRefException {
    List<ChildAssociationRef> parentAssocs = getParentAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL);
    // Copy into the set to avoid duplicates
    Set<NodeRef> parentNodeRefs = new HashSet<NodeRef>(parentAssocs.size());
    for (ChildAssociationRef parentAssoc : parentAssocs) {
        NodeRef parentNodeRef = parentAssoc.getParentRef();
        parentNodeRefs.add(parentNodeRef);
    }
    // Done
    return new ArrayList<NodeRef>(parentNodeRefs);
}

64. DbNodeServiceImpl#deleteStore()

Project: community-edition
File: DbNodeServiceImpl.java
/**
     * @throws UnsupportedOperationException        Always
     */
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public void deleteStore(StoreRef storeRef) throws InvalidStoreRefException {
    // Delete the index
    nodeIndexer.indexDeleteStore(storeRef);
    // Cannot delete the root node but we can delete, without archive, all immediate children
    NodeRef rootNodeRef = nodeDAO.getRootNode(storeRef).getSecond();
    List<ChildAssociationRef> childAssocRefs = getChildAssocs(rootNodeRef);
    for (ChildAssociationRef childAssocRef : childAssocRefs) {
        NodeRef childNodeRef = childAssocRef.getChildRef();
        // We do NOT want to archive these, so mark them as temporary
        deleteNode(childNodeRef, false);
    }
    // Rename the store.  This takes all the nodes with it.
    StoreRef deletedStoreRef = new StoreRef(StoreRef.PROTOCOL_DELETED, GUID.generate());
    nodeDAO.moveStore(storeRef, deletedStoreRef);
    // Done
    if (logger.isDebugEnabled()) {
        logger.debug("Marked store for deletion: " + storeRef + " --> " + deletedStoreRef);
    }
}

65. DbNodeServiceImpl#createStore()

Project: community-edition
File: DbNodeServiceImpl.java
/**
     * Defers to the typed service
     */
@Extend(traitAPI = NodeServiceTrait.class, extensionAPI = NodeServiceExtension.class)
public StoreRef createStore(String protocol, String identifier) {
    StoreRef storeRef = new StoreRef(protocol, identifier);
    // invoke policies
    invokeBeforeCreateStore(ContentModel.TYPE_STOREROOT, storeRef);
    // create a new one
    Pair<Long, NodeRef> rootNodePair = nodeDAO.newStore(storeRef);
    NodeRef rootNodeRef = rootNodePair.getSecond();
    // invoke policies
    invokeOnCreateStore(rootNodeRef);
    // Index
    ChildAssociationRef assocRef = new ChildAssociationRef(null, null, null, rootNodeRef);
    nodeIndexer.indexCreateNode(assocRef);
    // Done
    return storeRef;
}

66. ScriptNode#checkout()

Project: community-edition
File: ScriptNode.java
/**
     * Perform a check-out of this document into the specified destination space.
     * 
     * @param destination
     *            Destination for the checked out document working copy Node.
     * @return the working copy Node for the checked out document
     */
public ScriptNode checkout(ScriptNode destination) {
    ParameterCheck.mandatory("Destination Node", destination);
    ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(destination.getNodeRef());
    NodeRef workingCopyRef = this.services.getCheckOutCheckInService().checkout(this.nodeRef, destination.getNodeRef(), ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
    ScriptNode workingCopy = newInstance(workingCopyRef, this.services, this.scope);
    // reset the aspect and properties as checking out a document causes changes
    this.properties = null;
    this.aspects = null;
    return workingCopy;
}

67. CategoryTemplateNode#buildMixedNodeList()

Project: community-edition
File: CategoryTemplateNode.java
private List<TemplateNode> buildMixedNodeList(Collection<ChildAssociationRef> cars) {
    List<TemplateNode> nodes = new ArrayList<TemplateNode>(cars.size());
    int i = 0;
    for (ChildAssociationRef car : cars) {
        QName type = services.getNodeService().getType(car.getChildRef());
        if (services.getDictionaryService().isSubClass(type, ContentModel.TYPE_CATEGORY)) {
            nodes.add(new CategoryTemplateNode(car.getChildRef(), this.services, this.imageResolver));
        } else {
            nodes.add(new TemplateNode(car.getChildRef(), this.services, this.imageResolver));
        }
    }
    return nodes;
}

68. CategoryNode#buildMixedNodes()

Project: community-edition
File: CategoryNode.java
/**
     * Build script nodes and category nodes from a mixed collection of association references.
     * 
     * @param cars Collection<ChildAssociationRef>
     * @return ScriptNode[]
     */
private ScriptNode[] buildMixedNodes(Collection<ChildAssociationRef> cars) {
    ScriptNode[] nodes = new ScriptNode[cars.size()];
    int i = 0;
    for (ChildAssociationRef car : cars) {
        QName type = services.getNodeService().getType(car.getChildRef());
        if (services.getDictionaryService().isSubClass(type, ContentModel.TYPE_CATEGORY)) {
            nodes[i++] = new CategoryNode(car.getChildRef(), this.services, this.scope);
        } else {
            nodes[i++] = new ScriptNode(car.getChildRef(), this.services, this.scope);
        }
    }
    return nodes;
}

69. CategoryNode#rename()

Project: community-edition
File: CategoryNode.java
/**
     * Renames the category.
     * 
     * @param name  new cateogory name
     */
public void rename(String name) {
    // Rename the category node
    services.getNodeService().setProperty(getNodeRef(), ContentModel.PROP_NAME, name);
    // ALF-1788 Need to rename the association
    ChildAssociationRef assocRef = services.getNodeService().getPrimaryParent(nodeRef);
    if (assocRef != null) {
        QName qname = QName.createQName(assocRef.getQName().getNamespaceURI(), QName.createValidLocalName(name));
        services.getNodeService().moveNode(assocRef.getChildRef(), assocRef.getParentRef(), assocRef.getTypeQName(), qname);
    }
}

70. NodeFormProcessor#getAssociationValues()

Project: community-edition
File: NodeFormProcessor.java
@Override
protected Map<QName, Serializable> getAssociationValues(NodeRef item) {
    HashMap<QName, Serializable> assocs = new HashMap<QName, Serializable>();
    List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(item, RegexQNamePattern.MATCH_ALL);
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(item);
    for (ChildAssociationRef childAssoc : childAssocs) {
        QName name = childAssoc.getTypeQName();
        NodeRef target = childAssoc.getChildRef();
        addAssocToMap(name, target, assocs);
    }
    for (AssociationRef associationRef : targetAssocs) {
        QName name = associationRef.getTypeQName();
        NodeRef target = associationRef.getTargetRef();
        if (nodeService.exists(target) && (permissionService.hasPermission(target, PermissionService.READ) == AccessStatus.ALLOWED)) {
            addAssocToMap(name, target, assocs);
        }
    }
    return assocs;
}

71. ContentModelFormProcessor#updateAssociations()

Project: community-edition
File: ContentModelFormProcessor.java
@Override
protected void updateAssociations(NodeService nodeService) {
    List<ChildAssociationRef> existingChildren = nodeService.getChildAssocs(sourceNodeRef);
    for (ChildAssociationRef assoc : existingChildren) {
        if (assoc.getChildRef().equals(targetNodeRef)) {
            if (logger.isWarnEnabled()) {
                logger.warn("Attempt to add existing child association prevented. " + assoc);
            }
            return;
        }
    }
    // We are following the behaviour of the JSF client here in using the same
    // QName value for the 3rd and 4th parameters in the below call.
    nodeService.addChild(sourceNodeRef, targetNodeRef, assocQName, assocQName);
}

72. BlogIntegrationServiceImpl#getBlogDetailsImpl()

Project: community-edition
File: BlogIntegrationServiceImpl.java
/**
     * Helper method that recurses up the primary parent hierarchy checking for 
     * blog details
     * 
     * @param nodeRef       the node reference
     * @param blogDetails   list of blog details
     */
private void getBlogDetailsImpl(NodeRef nodeRef, List<BlogDetails> blogDetails) {
    // Check the parent assoc
    ChildAssociationRef parentAssoc = this.nodeService.getPrimaryParent(nodeRef);
    if (parentAssoc != null) {
        // Check for the blog details
        NodeRef parent = parentAssoc.getParentRef();
        if (parent != null) {
            if (this.nodeService.hasAspect(parent, ASPECT_BLOG_DETAILS) == true) {
                blogDetails.add(BlogDetails.createBlogDetails(this.nodeService, parent));
            }
            // Recurse
            getBlogDetailsImpl(parent, blogDetails);
        }
    }
}

73. ScheduledPersistedActionServiceImpl#listSchedules()

Project: community-edition
File: ScheduledPersistedActionServiceImpl.java
private List<ScheduledPersistedAction> listSchedules(NodeService nodeService) {
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(SCHEDULED_ACTION_ROOT_NODE_REF, ACTION_TYPES);
    List<ScheduledPersistedAction> scheduledActions = new ArrayList<ScheduledPersistedAction>(childAssocs.size());
    for (ChildAssociationRef actionAssoc : childAssocs) {
        ScheduledPersistedActionImpl scheduleImpl = loadPersistentSchedule(actionAssoc.getChildRef());
        scheduledActions.add(scheduleImpl);
    }
    return scheduledActions;
}

74. ActionServiceImpl#populateCompositeAction()

Project: community-edition
File: ActionServiceImpl.java
/**
     * Populates a composite action from a composite action node reference
     * 
     * @param compositeNodeRef the composite action node reference
     * @param compositeAction the composite action
     */
public void populateCompositeAction(NodeRef compositeNodeRef, CompositeAction compositeAction) {
    populateAction(compositeNodeRef, compositeAction);
    List<ChildAssociationRef> actions = this.nodeService.getChildAssocs(compositeNodeRef, RegexQNamePattern.MATCH_ALL, ActionModel.ASSOC_ACTIONS);
    for (ChildAssociationRef action : actions) {
        NodeRef actionNodeRef = action.getChildRef();
        compositeAction.addAction(createAction(actionNodeRef));
    }
}

75. ActionServiceImpl#populateParameters()

Project: community-edition
File: ActionServiceImpl.java
/**
     * Populate the parameters of a parameterized item from the parameterized
     * item node reference
     * 
     * @param parameterizedItemNodeRef the parameterized item node reference
     * @param parameterizedItem the parameterized item
     */
private void populateParameters(NodeRef parameterizedItemNodeRef, ParameterizedItem parameterizedItem) {
    List<ChildAssociationRef> parameters = this.nodeService.getChildAssocs(parameterizedItemNodeRef, RegexQNamePattern.MATCH_ALL, ActionModel.ASSOC_PARAMETERS);
    for (ChildAssociationRef parameter : parameters) {
        NodeRef parameterNodeRef = parameter.getChildRef();
        Map<QName, Serializable> properties = this.nodeService.getProperties(parameterNodeRef);
        parameterizedItem.setParameterValue((String) properties.get(ActionModel.PROP_PARAMETER_NAME), properties.get(ActionModel.PROP_PARAMETER_VALUE));
    }
}

76. DocumentEmailMessageHandler#addForumNode()

Project: community-edition
File: DocumentEmailMessageHandler.java
/**
     * Adds forum node
     * 
     * @param nodeRef Paren node
     * @return Reference to created node
     */
private NodeRef addForumNode(NodeRef nodeRef) {
    NodeService nodeService = getNodeService();
    //        //Add discussable aspect to content node
    //        if (!nodeService.hasAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE))
    //        {
    //            nodeService.addAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
    //        }
    //Create forum node and associate it with content node
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
    properties.put(ContentModel.PROP_NAME, forumNodeName);
    ChildAssociationRef childAssoc = nodeService.createNode(nodeRef, ForumModel.ASSOC_DISCUSSION, ForumModel.ASSOC_DISCUSSION, ForumModel.TYPE_FORUM, properties);
    NodeRef forumNode = childAssoc.getChildRef();
    //Add necessary aspects to forum node
    properties.clear();
    properties.put(ApplicationModel.PROP_ICON, "forum");
    nodeService.addAspect(forumNode, ApplicationModel.ASPECT_UIFACETS, properties);
    return forumNode;
}

77. RenditionsImpl#getRenditionByName()

Project: community-edition
File: RenditionsImpl.java
protected NodeRef getRenditionByName(NodeRef nodeRef, String renditionId, Parameters parameters) {
    if (StringUtils.isEmpty(renditionId)) {
        throw new InvalidArgumentException("renditionId can't be null or empty.");
    }
    // Thumbnails have a cm: prefix.
    QName renditionQName = QName.resolveToQName(namespaceService, renditionId);
    ChildAssociationRef nodeRefRendition = renditionService.getRenditionByName(nodeRef, renditionQName);
    if (nodeRefRendition == null) {
        return null;
    }
    return tenantService.getName(nodeRef, nodeRefRendition.getChildRef());
}

78. FileTransferReceiverTest#modifyParentNode()

Project: community-edition
File: FileTransferReceiverTest.java
private void modifyParentNode(NodeRef parentFolder, TransferManifestNormalNode nodeToMove) throws Exception {
    String nodeName = (String) nodeToMove.getProperties().get(ContentModel.PROP_NAME);
    List<ChildAssociationRef> parents = new ArrayList<ChildAssociationRef>();
    ChildAssociationRef primaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentFolder, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), nodeToMove.getNodeRef(), true, -1);
    parents.add(primaryAssoc);
    nodeToMove.setParentAssocs(parents);
    nodeToMove.setParentPath(null);
    nodeToMove.setPrimaryParentAssoc(primaryAssoc);
}

79. Child#getValue()

Project: community-edition
File: Child.java
/*
     * (non-Javadoc)
     * 
     * @see org.alfresco.repo.search.impl.querymodel.Function#getValue(java.util.Set)
     */
public Serializable getValue(Map<String, Argument> args, FunctionEvaluationContext context) {
    Argument selectorArgument = args.get(ARG_SELECTOR);
    String selectorName = DefaultTypeConverter.INSTANCE.convert(String.class, selectorArgument.getValue(context));
    Argument parentArgument = args.get(ARG_PARENT);
    NodeRef parent = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, parentArgument.getValue(context));
    NodeRef child = context.getNodeRefs().get(selectorName);
    for (ChildAssociationRef car : context.getNodeService().getParentAssocs(child)) {
        if (car.getParentRef().equals(parent)) {
            return Boolean.TRUE;
        }
    }
    return Boolean.FALSE;
}

80. AlfrescoMeetingServiceHandlerTest#removeMeeting()

Project: community-edition
File: AlfrescoMeetingServiceHandlerTest.java
private void removeMeeting(int day) {
    meetingServiceHandler.removeMeeting(CALENDAR_SITE.getShortName(), day, "OutLookUID!", 0, null, true);
    Set<QName> childNodeTypeQNames = new HashSet<QName>();
    childNodeTypeQNames.add(CalendarModel.TYPE_IGNORE_EVENT);
    List<ChildAssociationRef> ignoreEventList = nodeService.getChildAssocs(RECURRENCE.getNodeRef(), childNodeTypeQNames);
    Date ignoredDate = null;
    for (ChildAssociationRef ignoreEvent : ignoreEventList) {
        ignoredDate = (Date) nodeService.getProperty(ignoreEvent.getChildRef(), CalendarModel.PROP_IGNORE_EVENT_DATE);
    }
    SimpleDateFormat sdt = new SimpleDateFormat("yyyyMMdd");
    // check a date of removed occurrence
    assertNotNull(ignoredDate);
    assertTrue(sdt.format(ignoredDate).equals(String.valueOf(day)));
}

81. AlfrescoListServiceHandlerTest#primeMocks()

Project: community-edition
File: AlfrescoListServiceHandlerTest.java
private void primeMocks() {
    when(siteService.getSite("marketing-site")).thenReturn(siteInfo);
    NodeRef siteNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "node-id");
    when(siteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(siteInfo.getShortName()).thenReturn("marketing");
    when(siteInfo.getTitle()).thenReturn("marketing-site");
    when(nodeService.exists(listNodeRef)).thenReturn(true);
    ChildAssociationRef parentAssoc = new ChildAssociationRef(null, siteNodeRef, null, listNodeRef);
    when(nodeService.getPrimaryParent(listNodeRef)).thenReturn(parentAssoc);
    when(nodeService.getProperty(listNodeRef, ContentModel.PROP_NAME)).thenReturn("documentLibrary");
    @SuppressWarnings("unchecked") PagingResults<FileInfo> paging = (PagingResults<FileInfo>) mock(PagingResults.class);
    when(paging.getTotalResultCount()).thenReturn(new Pair<Integer, Integer>(1, 1));
    when(fileFolderService.list(eq(listNodeRef), eq(true), eq(false), eq((Set<QName>) null), eq((List<Pair<QName, Boolean>>) null), any(PagingRequest.class))).thenReturn(paging);
}

82. HomeFolderProviderSynchronizerTest#deleteNonAdminGuestFolders()

Project: community-edition
File: HomeFolderProviderSynchronizerTest.java
private void deleteNonAdminGuestFolders(final Set<NodeRef> adminGuestUserHomeFolders) {
    // double check.
    for (ChildAssociationRef childAssocs : nodeService.getChildAssocs(rootNodeRef)) {
        NodeRef nodeRef = childAssocs.getChildRef();
        if (!adminGuestUserHomeFolders.contains(nodeRef)) {
            System.out.println("TearDown remove '" + childAssocs.getQName().getLocalName() + "' from under the home folder root.");
            nodeService.deleteNode(nodeRef);
        }
    }
}

83. PermissionServiceTest#printPermissions()

Project: community-edition
File: PermissionServiceTest.java
@SuppressWarnings("unused")
private void printPermissions(NodeRef nodeRef, String path) {
    Long id = nodeDAO.getNodePair(nodeRef).getFirst();
    System.out.println(path + " has " + id);
    for (AccessControlEntry entry : aclDaoComponent.getAccessControlList(id).getEntries()) {
        System.out.println("\t\t " + id + "  " + entry);
    }
    List<ChildAssociationRef> children = nodeService.getChildAssocs(nodeRef);
    for (ChildAssociationRef child : children) {
        String newPath = path + "/" + child.getQName();
        printPermissions(child.getChildRef(), newPath);
    }
}

84. AbstractRenderingEngineTest#testRenderingContext()

Project: community-edition
File: AbstractRenderingEngineTest.java
@SuppressWarnings("unchecked")
public void testRenderingContext() {
    when(nodeService.exists(source)).thenReturn(true);
    ChildAssociationRef renditionAssoc = makeRenditionAssoc();
    RenditionDefinition definition = makeRenditionDefinition(renditionAssoc);
    // Stub the createNode() method to return renditionAssoc.
    when(nodeService.createNode(eq(source), eq(renditionAssoc.getTypeQName()), any(QName.class), any(QName.class), anyMap())).thenReturn(renditionAssoc);
    engine.execute(definition, source);
    RenderingContext context = engine.getContext();
    assertEquals(definition, context.getDefinition());
    assertEquals(renditionAssoc.getChildRef(), context.getDestinationNode());
    assertEquals(source, context.getSourceNode());
}

85. PublishingRootObjectTest#testGetPublishingQueue()

Project: community-edition
File: PublishingRootObjectTest.java
@Test
public void testGetPublishingQueue() throws Exception {
    PublishingQueueImpl theQueue = rootObject.getPublishingQueue();
    assertNotNull(theQueue);
    NodeRef queueNode = theQueue.getNodeRef();
    assertTrue(nodeService.exists(queueNode));
    assertEquals(PublishingModel.TYPE_PUBLISHING_QUEUE, nodeService.getType(queueNode));
    ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(queueNode);
    assertEquals(PublishingModel.ASSOC_PUBLISHING_QUEUE, parentAssoc.getTypeQName());
    assertEquals(rootObject.getEnvironment().getNodeRef(), parentAssoc.getParentRef());
}

86. BaseNodeServiceTest#testCreateNodeWithProperties()

Project: community-edition
File: BaseNodeServiceTest.java
/**
     * @see #ASPECT_QNAME_TEST_TITLED
     */
public void testCreateNodeWithProperties() throws Exception {
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
    // fill properties
    fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
    fillProperties(ASPECT_QNAME_TEST_TITLED, properties);
    // create node for real
    ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("MyContent"), TYPE_QNAME_TEST_CONTENT, properties);
    NodeRef nodeRef = assocRef.getChildRef();
    // check that the titled aspect is present
    assertTrue("Titled aspect not present", nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_TITLED));
}

87. BaseNodeServiceTest#testGetType()

Project: community-edition
File: BaseNodeServiceTest.java
public void testGetType() throws Exception {
    ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), ContentModel.TYPE_CONTAINER);
    NodeRef nodeRef = assocRef.getChildRef();
    // get the type
    QName type = nodeService.getType(nodeRef);
    assertEquals("Type mismatch", ContentModel.TYPE_CONTAINER, type);
}

88. BaseNodeServiceTest#testCreateNodeWithId()

Project: community-edition
File: BaseNodeServiceTest.java
/**
     * Tests node creation with a pre-determined {@link ContentModel#PROP_NODE_UUID uuid}.
     */
public void testCreateNodeWithId() throws Exception {
    String uuid = GUID.generate();
    // create a node with an explicit UUID
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
    properties.put(ContentModel.PROP_NODE_UUID, uuid);
    ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), ContentModel.TYPE_CONTAINER, properties);
    // check it
    NodeRef expectedNodeRef = new NodeRef(rootNodeRef.getStoreRef(), uuid);
    NodeRef checkNodeRef = assocRef.getChildRef();
    assertEquals("Failed to create node with a chosen ID", expectedNodeRef, checkNodeRef);
}

89. BaseNodeServiceTest#testCreateNode()

Project: community-edition
File: BaseNodeServiceTest.java
public void testCreateNode() throws Exception {
    ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, QName.createQName("pathA"), ContentModel.TYPE_CONTAINER);
    assertEquals("Assoc type qname not set", ASSOC_TYPE_QNAME_TEST_CHILDREN, assocRef.getTypeQName());
    assertEquals("Assoc qname not set", QName.createQName("pathA"), assocRef.getQName());
    NodeRef childRef = assocRef.getChildRef();
    QName checkType = nodeService.getType(childRef);
    assertEquals("Child node type incorrect", ContentModel.TYPE_CONTAINER, checkType);
}

90. ArchiveAndRestoreTest#testArchiveAndRestoreNodeBB()

Project: community-edition
File: ArchiveAndRestoreTest.java
public void testArchiveAndRestoreNodeBB() throws Exception {
    // delete a child
    nodeService.deleteNode(bb);
    // check
    verifyNodeExistence(b, true);
    verifyNodeExistence(bb, false);
    //        verifyChildAssocExistence(childAssocAtoBB, false);
    //        verifyChildAssocExistence(childAssocBtoBB, false);
    verifyNodeExistence(b_, false);
    verifyNodeExistence(bb_, true);
    // flush
    //AlfrescoTransactionSupport.flush();
    // check that the required properties are present and correct
    Map<QName, Serializable> bb_Properties = nodeService.getProperties(bb_);
    ChildAssociationRef bb_originalParent = (ChildAssociationRef) bb_Properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
    assertNotNull("Original parent not stored", bb_originalParent);
    // restore the node
    nodeService.restoreNode(bb_, null, null, null);
    // check
    verifyAll();
}

91. ComponentsTest#getLoadedCategoryRoot()

Project: community-edition
File: ComponentsTest.java
private NodeRef getLoadedCategoryRoot() {
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
    CategoryService categoryService = serviceRegistry.getCategoryService();
    // Check if the categories exist
    Collection<ChildAssociationRef> assocRefs = categoryService.getRootCategories(storeRef, ContentModel.ASPECT_GEN_CLASSIFIABLE);
    // Find it
    for (ChildAssociationRef assocRef : assocRefs) {
        NodeRef nodeRef = assocRef.getChildRef();
        if (nodeRef.getId().equals("test:xyz-root")) {
            // Found it
            return nodeRef;
        }
    }
    return null;
}

92. ScriptBehaviourTest#test2ClasspathLocationBehaviour()

Project: community-edition
File: ScriptBehaviourTest.java
public void test2ClasspathLocationBehaviour() {
    // Register the onCreateNode behaviour script
    ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/jscript/test_onCreateNode_cmContent.js");
    ScriptBehaviour behaviour = new ScriptBehaviour(this.serviceRegistry, location);
    this.policyComponent.bindClassBehaviour(QName.createQName(NodeServicePolicies.OnCreateNodePolicy.NAMESPACE, "onCreateNode"), ContentModel.TYPE_CONTENT, behaviour);
    // Create a content node
    Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
    props.put(ContentModel.PROP_NAME, "myDoc.txt");
    ChildAssociationRef childAssoc = this.nodeService.createNode(this.folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props);
    // Since the behavoiour will have been run check that the titled aspect has been applied
    assertTrue(this.nodeService.hasAspect(childAssoc.getChildRef(), ContentModel.ASPECT_TITLED));
}

93. MessageServiceImplTest#addMessageResource()

Project: community-edition
File: MessageServiceImplTest.java
private void addMessageResource(NodeRef rootNodeRef, String name, InputStream resourceStream) throws Exception {
    Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
    contentProps.put(ContentModel.PROP_NAME, name);
    ChildAssociationRef association = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps);
    NodeRef content = association.getChildRef();
    ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    writer.setEncoding("UTF-8");
    writer.putContent(resourceStream);
    resourceStream.close();
}

94. ExporterComponentTest#testRoundTripLosesCategoriesImportingToDifferentStore()

Project: community-edition
File: ExporterComponentTest.java
/**
     * If the source and destination stores are not the same, then a round-trip of export then import
     * will result in the imported content not having the categories assigned to it that were present
     * on the exported content.
     */
@SuppressWarnings("unchecked")
public void testRoundTripLosesCategoriesImportingToDifferentStore() throws Exception {
    // Use a store ref that has the bootstrapped categories
    StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
    NodeRef rootNode = nodeService.getRootNode(storeRef);
    ChildAssociationRef contentChildAssocRef = createContentWithCategories(storeRef, rootNode);
    // Export
    File acpFile = exportContent(contentChildAssocRef.getParentRef());
    // Import - destination store is different from export store.
    NodeRef destRootNode = nodeService.getRootNode(this.storeRef);
    FileInfo importFolderFileInfo = importContent(acpFile, destRootNode);
    // Check categories
    NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "test.txt");
    assertNotNull("Couldn't find imported file: test.txt", importedFileNode);
    assertTrue(nodeService.hasAspect(importedFileNode, ContentModel.ASPECT_GEN_CLASSIFIABLE));
    List<NodeRef> importedFileCategories = (List<NodeRef>) nodeService.getProperty(importedFileNode, ContentModel.PROP_CATEGORIES);
    assertEquals("No categories should have been imported for the content", 0, importedFileCategories.size());
}

95. ExporterComponentTest#testRoundTripKeepsCategoriesWhenWithinSameStore()

Project: community-edition
File: ExporterComponentTest.java
/**
     * Round-trip of export then import will result in the imported content having the same categories
     * assigned to it as for the exported content -- provided the source and destination stores are the same.
     */
@SuppressWarnings("unchecked")
public void testRoundTripKeepsCategoriesWhenWithinSameStore() throws Exception {
    // Use a store ref that has the bootstrapped categories
    StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
    NodeRef rootNode = nodeService.getRootNode(storeRef);
    ChildAssociationRef contentChildAssocRef = createContentWithCategories(storeRef, rootNode);
    // Export/import
    File acpFile = exportContent(contentChildAssocRef.getParentRef());
    FileInfo importFolderFileInfo = importContent(acpFile, rootNode);
    // Check categories
    NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "test.txt");
    assertNotNull("Couldn't find imported file: test.txt", importedFileNode);
    assertTrue(nodeService.hasAspect(importedFileNode, ContentModel.ASPECT_GEN_CLASSIFIABLE));
    List<NodeRef> importedFileCategories = (List<NodeRef>) nodeService.getProperty(importedFileNode, ContentModel.PROP_CATEGORIES);
    assertCategoriesEqual(importedFileCategories, "Regions", "Software Document Classification");
}

96. CopyServiceImplTest#testCopiedFromAspect_NonObject()

Project: community-edition
File: CopyServiceImplTest.java
/**
     * Test the behaviour of the aspect when copying types not derived from <b>cm:object</b>
     */
public void testCopiedFromAspect_NonObject() {
    // Create the node used for copying
    ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}test"), ContentModel.TYPE_BASE, createTypePropertyBag());
    NodeRef nodeRef = childAssocRef.getChildRef();
    // If we copy this, there should not be a cm:source association
    NodeRef copyNodeRef = copyService.copy(nodeRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copyAssoc"));
    assertFalse("cm:copiedfrom should not be present", nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
}

97. CheckOutCheckInServiceImplTest#testVersionAspectNotSetOnCheckIn()

Project: community-edition
File: CheckOutCheckInServiceImplTest.java
/**
     * Test when the aspect is not set when check-in is performed
     */
public void testVersionAspectNotSetOnCheckIn() {
    // Create a bag of props
    Map<QName, Serializable> bagOfProps = createTypePropertyBag();
    bagOfProps.put(ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8"));
    // Create a new node 
    ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test"), ContentModel.TYPE_CONTENT, bagOfProps);
    NodeRef noVersionNodeRef = childAssocRef.getChildRef();
    // Check out and check in
    NodeRef workingCopy = cociService.checkout(noVersionNodeRef);
    cociService.checkin(workingCopy, new HashMap<String, Serializable>());
    // Check that the origional node has no version history dispite sending verion props
    assertNull(this.versionService.getVersionHistory(noVersionNodeRef));
}

98. AuditableAspectTest#testAudit()

Project: community-edition
File: AuditableAspectTest.java
public void testAudit() {
    // Create a folder
    ChildAssociationRef childAssocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testfolder"), ContentModel.TYPE_FOLDER);
    // Assert auditable properties exist on folder
    assertAuditableProperties(childAssocRef.getChildRef());
    System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
}

99. VirtualStoreImpl#getChildAssocsByPropertyValue()

Project: community-edition
File: VirtualStoreImpl.java
@Override
public List<ChildAssociationRef> getChildAssocsByPropertyValue(Reference parentReference, QName propertyQName, Serializable value) {
    List<ChildAssociationRef> allAssociations = getChildAssocs(parentReference, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, Integer.MAX_VALUE, false);
    List<ChildAssociationRef> associations = new LinkedList<>();
    for (ChildAssociationRef childAssociationRef : allAssociations) {
        Serializable propertyValue = environment.getProperty(childAssociationRef.getChildRef(), propertyQName);
        if ((value == null && propertyValue == null) || (value != null && value.equals(propertyValue))) {
            associations.add(childAssociationRef);
        }
    }
    return associations;
}

100. VirtualStoreImpl#getChildAssocs()

Project: community-edition
File: VirtualStoreImpl.java
@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;
}