org.alfresco.service.cmr.repository.NodeRef

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

1. IntegrityTest#testExcessTargetsOfOneToOneAssocs()

View license
public void testExcessTargetsOfOneToOneAssocs() throws Exception {
    NodeRef source = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
    NodeRef target1 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null);
    NodeRef target2 = createNode("target2", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(source, target1, TEST_ASSOC_NODE_ONE_ONE);
    nodeService.createAssociation(source, target2, TEST_ASSOC_NODE_ONE_ONE);
    NodeRef parent = createNode("parent", TEST_TYPE_WITH_CHILD_ASSOCS, null);
    NodeRef child1 = createNode("child1", TEST_TYPE_WITHOUT_ANYTHING, null);
    NodeRef child2 = createNode("child2", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addChild(parent, child1, TEST_ASSOC_CHILD_ONE_ONE, QName.createQName(NAMESPACE, "one-to-one-first"));
    nodeService.addChild(parent, child2, TEST_ASSOC_CHILD_ONE_ONE, QName.createQName(NAMESPACE, "one-to-one-second"));
    NodeRef aspectSource = createNode("aspectSource", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addAspect(aspectSource, TEST_ASPECT_WITH_ASSOC, null);
    NodeRef aspectTarget1 = createNode("aspectTarget1", TEST_TYPE_WITHOUT_ANYTHING, null);
    NodeRef aspectTarget2 = createNode("aspectTarget2", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(aspectSource, aspectTarget1, TEST_ASSOC_ASPECT_ONE_ONE);
    nodeService.createAssociation(aspectSource, aspectTarget2, TEST_ASSOC_ASPECT_ONE_ONE);
    checkIntegrityExpectFailure("Failed to detect excess target cardinality for one-to-one assocs", 3);
}

2. IntegrityTest#testCreateSourceOfAssocsWithMandatoryTargetsPresent()

View license
public void testCreateSourceOfAssocsWithMandatoryTargetsPresent() throws Exception {
    NodeRef source = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
    NodeRef target = createNode("target", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(source, target, TEST_ASSOC_NODE_ONE_ONE);
    NodeRef parent = createNode("parent", TEST_TYPE_WITH_CHILD_ASSOCS, null);
    NodeRef child = createNode("child", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addChild(parent, child, TEST_ASSOC_CHILD_ONE_ONE, QName.createQName(NAMESPACE, "one-to-one"));
    NodeRef aspectSource = createNode("aspectSource", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addAspect(aspectSource, TEST_ASPECT_WITH_ASSOC, null);
    NodeRef aspectTarget = createNode("aspectTarget", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(aspectSource, aspectTarget, TEST_ASSOC_ASPECT_ONE_ONE);
    checkIntegrityNoFailure();
}

3. IntegrityTest#testRemoveTargetsOfMandatoryAssocs()

View license
public void testRemoveTargetsOfMandatoryAssocs() throws Exception {
    NodeRef source = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
    NodeRef target = createNode("target", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(source, target, TEST_ASSOC_NODE_ONE_ONE);
    NodeRef parent = createNode("parent", TEST_TYPE_WITH_CHILD_ASSOCS, null);
    NodeRef child = createNode("child", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addChild(parent, child, TEST_ASSOC_CHILD_ONE_ONE, QName.createQName(NAMESPACE, "one-to-one"));
    NodeRef aspectSource = createNode("aspectSource", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addAspect(aspectSource, TEST_ASPECT_WITH_ASSOC, null);
    NodeRef aspectTarget = createNode("aspectTarget", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(aspectSource, aspectTarget, TEST_ASSOC_ASPECT_ONE_ONE);
    checkIntegrityNoFailure();
    // remove target nodes
    nodeService.deleteNode(target);
    nodeService.deleteNode(child);
    nodeService.deleteNode(aspectTarget);
    checkIntegrityExpectFailure("Failed to detect removal of mandatory assoc targets", 3);
}

4. CopyServiceImplTest#testCopyAndRename()

View license
public void testCopyAndRename() {
    // Check a normal copy with no dup restrictions
    NodeRef copy = copyService.copyAndRename(sourceNodeRef, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copyAssoc"), false);
    checkCopiedNode(sourceNodeRef, copy, true, true, false);
    assertTrue(TEST_NAME.equals(nodeService.getProperty(copy, ContentModel.PROP_NAME)));
    // Create a folder and content node        
    Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
    propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
    NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
    Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
    props.put(ContentModel.PROP_NAME, TEST_NAME);
    NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}renametest"), ContentModel.TYPE_CONTENT, props).getChildRef();
    // Now copy the content node with the duplicate name restriction
    NodeRef contentCopy = copyService.copy(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}bobbins"), false);
    assertFalse(TEST_NAME.equals(nodeService.getProperty(contentCopy, ContentModel.PROP_NAME)));
}

5. MultilingualContentServiceImplTest#testAddTranslationUsingContent()

View license
public void testAddTranslationUsingContent() throws Exception {
    // Make a container with a single translation
    NodeRef chineseContentNodeRef = createContent();
    multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
    NodeRef mlContainerNodeRef = multilingualContentService.getTranslationContainer(chineseContentNodeRef);
    // Create some more content
    NodeRef frenchContentNodeRef = createContent();
    // Make this a translation of the Chinese
    multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
    NodeRef newMLContainerNodeRef = multilingualContentService.getTranslationContainer(frenchContentNodeRef);
    // Make sure that the original container was used
    assertEquals("Existing container should have been used", mlContainerNodeRef, newMLContainerNodeRef);
    // Check the container child count
    assertEquals("Incorrect number of child nodes", 2, nodeService.getChildAssocs(mlContainerNodeRef).size());
}

6. MultilingualContentServiceImplTest#testUnmakeTranslation()

View license
/**
     * Testing unmakeTranslation
     * @throws Exception
     */
public void testUnmakeTranslation() throws Exception {
    NodeRef frenchContentNodeRef = createContent();
    multilingualContentService.makeTranslation(frenchContentNodeRef, Locale.FRENCH);
    NodeRef mlContainerNodeRef = multilingualContentService.getTranslationContainer(frenchContentNodeRef);
    NodeRef englishContentNodeRef = createContent();
    multilingualContentService.addTranslation(englishContentNodeRef, frenchContentNodeRef, Locale.ENGLISH);
    NodeRef germanContentNodeRef = createContent();
    multilingualContentService.addTranslation(germanContentNodeRef, frenchContentNodeRef, Locale.GERMAN);
    multilingualContentService.unmakeTranslation(englishContentNodeRef);
    multilingualContentService.unmakeTranslation(germanContentNodeRef);
    //multilingualContentService.unmakeTranslation(frenchContentNodeRef);
    //calling unmakeTranslation() dissolves the multiligual document.
    //none of the documents composing the multilingual document
    assertTrue("The document should not be multilingual!", !multilingualContentService.isTranslation(englishContentNodeRef) && !multilingualContentService.isTranslation(germanContentNodeRef));
}

7. MultilingualContentServiceImplTest#testUnmakeTranslationOnPivot()

View license
/**
     * Testing unmakeTranslation() on pivot
     * @throws Exception
     */
public void testUnmakeTranslationOnPivot() throws Exception {
    NodeRef frenchContentNodeRef = createContent();
    multilingualContentService.makeTranslation(frenchContentNodeRef, Locale.FRENCH);
    NodeRef mlContainerNodeRef = multilingualContentService.getTranslationContainer(frenchContentNodeRef);
    NodeRef englishContentNodeRef = createContent();
    multilingualContentService.addTranslation(englishContentNodeRef, frenchContentNodeRef, Locale.ENGLISH);
    NodeRef germanContentNodeRef = createContent();
    multilingualContentService.addTranslation(germanContentNodeRef, frenchContentNodeRef, Locale.GERMAN);
    multilingualContentService.unmakeTranslation(frenchContentNodeRef);
    //calling unmakeTranslation() dissolves the multiligual document.
    //none of the documents composing the multilingual document
    assertTrue("The document should not be multilingual!", !multilingualContentService.isTranslation(frenchContentNodeRef) && !multilingualContentService.isTranslation(englishContentNodeRef) && !multilingualContentService.isTranslation(germanContentNodeRef));
}

8. IntegrityTest#testCreateTargetOfAssocsWithMandatorySourcesPresent()

View license
public void testCreateTargetOfAssocsWithMandatorySourcesPresent() throws Exception {
    // this is the target of 3 assoc types where the source cardinality is 1..1
    NodeRef targetAndChild = createNode("targetAndChild", TEST_TYPE_WITHOUT_ANYTHING, null);
    NodeRef source = createNode("source", TEST_TYPE_WITH_ASSOCS, null);
    nodeService.createAssociation(source, targetAndChild, TEST_ASSOC_NODE_ONE_ONE);
    NodeRef parent = createNode("parent", TEST_TYPE_WITH_CHILD_ASSOCS, null);
    nodeService.addChild(parent, targetAndChild, TEST_ASSOC_CHILD_ONE_ONE, QName.createQName(NAMESPACE, "mandatoryChild"));
    NodeRef aspected = createNode("aspectNode", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.addAspect(aspected, TEST_ASPECT_WITH_ASSOC, null);
    nodeService.createAssociation(aspected, targetAndChild, TEST_ASSOC_ASPECT_ONE_ONE);
    checkIntegrityNoFailure();
}

9. IntegrityTest#testSourceAssocAfterDeletion()

View license
public void testSourceAssocAfterDeletion() throws Exception {
    NodeRef source1 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
    NodeRef source2 = createNode("abc", TEST_TYPE_WITH_ASSOCS, null);
    NodeRef target1 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null);
    NodeRef target2 = createNode("target1", TEST_TYPE_WITHOUT_ANYTHING, null);
    nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_ONE);
    nodeService.createAssociation(source2, target2, TEST_ASSOC_NODE_ONE_ONE);
    checkIntegrityNoFailure();
    nodeService.createAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY);
    nodeService.createAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY);
    // Both (or either of) the associations are in violation
    checkIntegrityExpectFailure("Failed to detect excess source cardinality for one-to-many assocs", 1);
    // Now remove one of the associations
    nodeService.removeAssociation(source2, target1, TEST_ASSOC_NODE_ONE_MANY);
    checkIntegrityNoFailure();
    // Now remove the last association
    nodeService.removeAssociation(source1, target1, TEST_ASSOC_NODE_ONE_MANY);
    checkIntegrityNoFailure();
}

10. ThumbnailServiceImplTest#testJSAPI()

View license
// == Test the JavaScript API ==
public void testJSAPI() throws Exception {
    NodeRef jpgOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
    NodeRef gifOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_GIF);
    NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF);
    NodeRef docOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_WORD);
    Map<String, Object> model = new HashMap<String, Object>(2);
    model.put("jpgOrig", jpgOrig);
    model.put("gifOrig", gifOrig);
    model.put("pdfOrig", pdfOrig);
    model.put("docOrig", docOrig);
    ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/thumbnail/script/test_thumbnailAPI.js");
    this.scriptService.executeScript(location, model);
}

11. DeletedNodesImpl#getDeletedNode()

View license
@Override
public Node getDeletedNode(String originalId, Parameters parameters) {
    //First check the node is valid and has been archived.
    NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, originalId);
    //Now get the Node
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, validatedNodeRef.getId());
    NodeRef archivedNodeRef = nodeArchiveService.getArchivedNode(nodeRef);
    //Turn it into a JSON Node (FULL version)
    Node foundNode = nodes.getFolderOrDocumentFullInfo(archivedNodeRef, null, null, parameters, null);
    if (foundNode != null)
        mapArchiveInfo(foundNode, null);
    return foundNode;
}

12. ErrorProneActionExecutor#executeImpl()

View license
/**
     * Send an email message
     * 
     * @throws AlfrescoRuntimeException
     */
@Override
protected void executeImpl(final Action ruleAction, final NodeRef actionedUponNodeRef) {
    NodeRef failingPersonNodeRef = (NodeRef) ruleAction.getParameterValue(PARAM_FAILING_PERSON_NODEREF);
    NodeRef personNodeRef = (NodeRef) ruleAction.getParameterValue(PARAM_PERSON_NODEREF);
    String userName = (String) ruleAction.getParameterValue(PARAM_USERNAME);
    System.out.println("userName = " + userName);
    if (personNodeRef.equals(failingPersonNodeRef)) {
        numFailed.incrementAndGet();
        throw new AlfrescoRuntimeException("");
    }
    numSuccessful.incrementAndGet();
}

13. RenditionNodeManager#isOldRenditionInCorrectLocationWithoutLog()

View license
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;
}

14. SiteAspect#onMoveNode()

Project: community-edition
Source File: SiteAspect.java
View license
/**
    * 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.");
        }
    }
}

15. RepoTransferReceiverImpl#onMoveNode()

View license
/**
     * When an alien node is moved it may un-invade its old location and invade a new
     * location.   The node may also cease to be alien.
     */
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) {
    log.debug("onMoveNode");
    log.debug("oldChildAssocRef:" + oldChildAssocRef);
    log.debug("newChildAssocRef:" + newChildAssocRef);
    NodeRef oldParentRef = oldChildAssocRef.getParentRef();
    NodeRef newParentRef = newChildAssocRef.getParentRef();
    if (newParentRef.equals(oldParentRef)) {
        log.debug("old parent and new parent are the same - this is a rename, do nothing");
    } else {
        if (log.isDebugEnabled()) {
            log.debug("moving node from oldParentRef:" + oldParentRef + " to:" + newParentRef);
        }
        alienProcessor.beforeDeleteAlien(newChildAssocRef.getChildRef(), oldChildAssocRef);
        alienProcessor.afterMoveAlien(newChildAssocRef);
    }
}

16. VirtualCheckOutCheckInServiceExtension#checkout()

View license
@Override
public NodeRef checkout(NodeRef nodeRef, NodeRef destinationParentNodeRef, QName destinationAssocTypeQName, QName destinationAssocQName) {
    CheckOutCheckInServiceTrait theTrait = getTrait();
    NodeRef materialNodeRef = smartStore.materializeIfPossible(nodeRef);
    NodeRef materialDestination = smartStore.materializeIfPossible(destinationParentNodeRef);
    NodeRef workingCopy = theTrait.checkout(materialNodeRef, materialDestination, destinationAssocTypeQName, destinationAssocQName);
    if (Reference.isReference(destinationParentNodeRef)) {
        Reference parentReference = Reference.fromNodeRef(destinationParentNodeRef);
        Reference workingCopyReference = NodeProtocol.newReference(workingCopy, parentReference);
        return workingCopyReference.toNodeRef(workingCopy.getStoreRef());
    } else {
        return workingCopy;
    }
}

17. CheckOutCheckInServiceImplTest#testDeleteOfWorkingCopy()

View license
/**
     * MNT-2641 
     * The working copy delete is equivalent to "cancelCheckout". This should fail for everyone except the lock owner.
     */
public void testDeleteOfWorkingCopy() {
    // Create a FolderA
    final NodeRef folderA = createFolder("DeleteOfWorkingCopy_" + GUID.generate());
    // Create content in FolderA
    final NodeRef orig = createContent("original_" + GUID.generate(), folderA);
    // Check out the document
    NodeRef workingCopy = this.cociService.checkout(orig);
    assertNotNull(workingCopy);
    // deleting of working copy
    fileFolderService.delete(workingCopy);
    assertFalse(nodeService.exists(workingCopy));
    assertNull(cociService.getWorkingCopy(orig));
    assertFalse(cociService.isCheckedOut(orig));
}

18. CheckOutCheckInServiceImplTest#testCancelCheckoutUnlockedWCopy()

View license
/**
     * <br>
     * Creating node - CheckOut - Add write lock to working copy - Unlock working copy - CancelCheckOut
     */
public void testCancelCheckoutUnlockedWCopy() {
    ServiceRegistry serviceRegistry = (ServiceRegistry) this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    CheckOutCheckInService securityCOCIService = serviceRegistry.getCheckOutCheckInService();
    NodeRef folderA = createFolder(rootNodeRef, "testMnt9502_" + System.currentTimeMillis());
    assertNotNull(folderA);
    NodeRef clucc = createContent("checkout_lock_unlock_cancelCO", folderA);
    assertNotNull(clucc);
    NodeRef wc = securityCOCIService.checkout(clucc);
    lockService.lock(wc, LockType.WRITE_LOCK, 60 * 60);
    lockService.unlock(wc);
    securityCOCIService.cancelCheckout(wc);
}

19. CopyServiceImplTest#testETWOONE_244()

View license
/**
     * https://issues.alfresco.com/jira/browse/ETWOONE-224
     */
public void testETWOONE_244() {
    // Create a folder and content node        
    Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
    propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
    NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
    Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
    props.put(ContentModel.PROP_NAME, "myDoc.txt");
    NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
    NodeRef copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
    assertEquals("Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
    QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
    assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
    copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
    assertEquals("Copy of Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
    copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of myDoc.txt");
    assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
    copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
    assertEquals("Copy of Copy of Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
    copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of Copy of myDoc.txt");
    assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
}

20. DocumentLinkServiceImplTest#testCreateFileLink()

View license
/**
     * Tests the creation of a file link
     * 
     * @throws Exception
     */
public void testCreateFileLink() throws Exception {
    // create a link of file site1File1_1 in folder site1Folder2
    NodeRef linkNodeRef = documentLinkService.createDocumentLink(site1File1, site1Folder2);
    assertNotNull(linkNodeRef);
    // test if the link node is listed as a child of site1Folder2
    NodeRef linkNodeRef2 = fileFolderService.searchSimple(site1Folder2, site1File1Name);
    assertNotNull(linkNodeRef2);
    assertEquals(linkNodeRef, linkNodeRef2);
    // check the type of the link
    assertEquals(nodeService.getType(linkNodeRef), ApplicationModel.TYPE_FILELINK);
    // check if the link destination is site1File1_1
    NodeRef linkDestination = documentLinkService.getLinkDestination(linkNodeRef);
    assertNotNull(linkDestination);
    assertEquals(linkDestination, site1File1);
}

21. DocumentLinkServiceImplTest#testCreateFolderLink()

View license
/**
     * Tests the creation of a folder link
     * 
     * @throws Exception
     */
public void testCreateFolderLink() throws Exception {
    // create a link of file site1File1_1 in folder site1Folder2
    NodeRef linkNodeRef = documentLinkService.createDocumentLink(site1Folder1, site1Folder2);
    assertNotNull(linkNodeRef);
    // test if the link node is listed as a child of site1Folder2
    NodeRef linkNodeRef2 = fileFolderService.searchSimple(site1Folder2, site1Folder1Name);
    assertNotNull(linkNodeRef2);
    assertEquals(linkNodeRef, linkNodeRef2);
    // check the type of the link
    assertEquals(nodeService.getType(linkNodeRef), ApplicationModel.TYPE_FOLDERLINK);
    // check if the link destination is site1File1_1
    NodeRef linkDestination = documentLinkService.getLinkDestination(linkNodeRef);
    assertNotNull(linkDestination);
    assertEquals(linkDestination, site1Folder1);
}

22. ExporterComponentTest#testRoundTripLosesCategoriesImportingToDifferentStore()

View license
/**
     * 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());
}

23. AbstractLockStoreTestBase#testContains()

View license
@Test
public void testContains() {
    NodeRef nodeRef1 = new NodeRef("workspace://SpacesStore/12345");
    LockState lock1 = LockState.createLock(nodeRef1, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
    NodeRef nodeRef2 = new NodeRef("workspace://SpacesStore/5838743");
    LockState lock2 = LockState.createLock(nodeRef2, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
    NodeRef nodeRef3 = new NodeRef("workspace://SpacesStore/65752323");
    lockStore.set(nodeRef1, lock1);
    lockStore.set(nodeRef2, lock2);
    assertNotNull(lockStore.get(nodeRef1));
    assertNotNull(lockStore.get(nodeRef2));
    assertNull(lockStore.get(nodeRef3));
}

24. FileFolderServiceImplTest#testSearchSimple()

View license
public void testSearchSimple() throws Exception {
    FileInfo folderInfo = getByName(NAME_L0_FOLDER_A, true);
    assertNotNull(folderInfo);
    NodeRef folderNodeRef = folderInfo.getNodeRef();
    // search for a file that is not there
    NodeRef phantomNodeRef = fileFolderService.searchSimple(folderNodeRef, "aaaaaaa");
    assertNull("Found non-existent node by name", phantomNodeRef);
    // search for a file that is there
    NodeRef fileNodeRef = fileFolderService.searchSimple(folderNodeRef, NAME_L1_FILE_A);
    assertNotNull("Didn't find file", fileNodeRef);
    // double check
    FileInfo checkInfo = getByName(NAME_L1_FILE_A, false);
    assertEquals("Incorrect node found", checkInfo.getNodeRef(), fileNodeRef);
}

25. EditionServiceImplTest#createMLContainerWithContent()

View license
private NodeRef createMLContainerWithContent() {
    NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "_1.0");
    NodeRef frenchContentNodeRef = createContent(FRENCH_CONTENT + "_1.0");
    NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "_1.0");
    multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
    multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
    multilingualContentService.addTranslation(japaneseContentNodeRef, chineseContentNodeRef, Locale.JAPANESE);
    return multilingualContentService.getTranslationContainer(chineseContentNodeRef);
}

26. EditionServiceImplTest#createMLContainerWithContent()

View license
private NodeRef createMLContainerWithContent(String editionSuffix) {
    NodeRef chineseContentNodeRef = createContent(CHINESE_CONTENT + "-" + Locale.CHINESE + "-" + editionSuffix + "-1.0");
    NodeRef frenchContentNodeRef = createContent(FRENCH_CONTENT + "-" + Locale.FRENCH + "-" + editionSuffix + "-1.0");
    NodeRef japaneseContentNodeRef = createContent(JAPANESE_CONTENT + "-" + Locale.JAPANESE + "-" + editionSuffix + "-1.0");
    multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
    multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
    multilingualContentService.addTranslation(japaneseContentNodeRef, chineseContentNodeRef, Locale.JAPANESE);
    return multilingualContentService.getTranslationContainer(chineseContentNodeRef);
}

27. MultilingualContentServiceImplTest#testGetPivotTranslation()

View license
public void testGetPivotTranslation() throws Exception {
    NodeRef chineseContentNodeRef = createContent();
    multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
    NodeRef mlContainerNodeRef = multilingualContentService.getTranslationContainer(chineseContentNodeRef);
    //  make sure that the pivot language is set
    assertNotNull("Pivot language not set", nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE));
    //  make sure that the pivot language is correctly set
    assertEquals("Pivot language not correctly set", Locale.CHINESE, nodeService.getProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE));
    NodeRef frenchContentNodeRef = createContent();
    multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
    //  make sure that the pivot noderef is correct
    assertEquals("Unable to get pivot from container", chineseContentNodeRef, multilingualContentService.getPivotTranslation(mlContainerNodeRef));
    assertEquals("Unable to get pivot from translation", chineseContentNodeRef, multilingualContentService.getPivotTranslation(frenchContentNodeRef));
    // modify the pivot language
    nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE, Locale.FRENCH);
    //  make sure that the modified pivot noderef is correct
    assertEquals("Pivot node ref not correct", frenchContentNodeRef, multilingualContentService.getPivotTranslation(mlContainerNodeRef));
}

28. MultilingualDocumentAspectTest#testCopy()

View license
public void testCopy() throws Exception {
    NodeRef original = createContent();
    multilingualContentService.makeTranslation(original, Locale.FRENCH);
    NodeRef mlContainer = multilingualContentService.getTranslationContainer(original);
    NodeRef copy = fileFolderService.copy(original, nodeService.getPrimaryParent(original).getParentRef(), "COPY" + System.currentTimeMillis()).getNodeRef();
    // Ensure that the copy removes the mlDocument aspect
    assertFalse("The copy of a mlDocument can't have the multilingual aspect", nodeService.hasAspect(copy, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
    // Ensure that the copy removes the association between the mlConatiner and the new node
    assertEquals("The copy of a mlDocument can't be a children of the mlContainer", 1, multilingualContentService.getTranslations(mlContainer).size());
}

29. MultilingualDocumentAspectTest#testDeletePivot()

View license
public void testDeletePivot() throws Exception {
    NodeRef pivot = createContent();
    NodeRef trans1 = createContent();
    multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
    NodeRef mlContainer = multilingualContentService.getTranslationContainer(pivot);
    multilingualContentService.addTranslation(trans1, pivot, Locale.KOREAN);
    //nodeService.deleteNode(trans1);
    nodeService.deleteNode(pivot);
    // Ensure that pivot is removed
    assertFalse("The pivot would be removed", nodeService.exists(pivot));
    // Ensure that the mlContainer is removed
    assertFalse("The mlContainer must be removed if the pivot is removed", nodeService.exists(mlContainer));
    // Ensure that trans1 is NOT removed
    assertTrue("The last translation would not be removed", nodeService.exists(trans1));
    // Ensure that trans1 has no mlDocument aspect
    assertFalse("The last translation can't keep the multilingual aspect", nodeService.hasAspect(trans1, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
}

30. BaseNodeServiceTest#testPrimaryPathCascadeDelete()

View license
public void testPrimaryPathCascadeDelete() throws Exception {
    Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
    NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
    NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
    NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
    // delete n1
    nodeService.deleteNode(n1Ref);
    // check that the rest disappeared
    assertFalse("n6 not cascade deleted", nodeService.exists(n6Ref));
    assertFalse("n8 not cascade deleted", nodeService.exists(n8Ref));
}

31. NodeRefPropertyMethodInterceptorTest#testCreateNodeNull()

View license
public void testCreateNodeNull() {
    NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode");
    NodeRef cat = mlAwareNodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}cat"), ContentModel.TYPE_CATEGORY).getChildRef();
    NodeRef n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER, null).getChildRef();
    assertNull(mlAwareNodeService.getProperty(n1, aspectCategoryProp));
    assertNull(mlAwareNodeService.getProperty(n1, aspectCategoriesProp));
    assertNull(mlAwareNodeService.getProperty(n1, aspectNoderefProp));
    assertNull(mlAwareNodeService.getProperty(n1, aspectNoderefsProp));
    assertNull(mlAwareNodeService.getProperties(n1).get(aspectCategoryProp));
    assertNull(mlAwareNodeService.getProperties(n1).get(aspectCategoriesProp));
    assertNull(mlAwareNodeService.getProperties(n1).get(aspectNoderefProp));
    assertNull(mlAwareNodeService.getProperties(n1).get(aspectNoderefsProp));
    assertNull(nodeService.getProperty(n1, aspectCategoryProp));
    assertNull(nodeService.getProperty(n1, aspectCategoriesProp));
    assertNull(nodeService.getProperty(n1, aspectNoderefProp));
    assertNull(nodeService.getProperty(n1, aspectNoderefsProp));
    assertNull(nodeService.getProperties(n1).get(aspectCategoryProp));
    assertNull(nodeService.getProperties(n1).get(aspectCategoriesProp));
    assertNull(nodeService.getProperties(n1).get(aspectNoderefProp));
    assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp));
}

32. PermissionServiceTest#test_DefiningShared_AclUpdatePerformance()

View license
public void test_DefiningShared_AclUpdatePerformance() {
    runAs("admin");
    NodeRef one = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
    permissionService.setPermission(one, "andy", PermissionService.READ, true);
    NodeRef two = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"), ContentModel.TYPE_FOLDER).getChildRef();
    permissionService.setPermission(two, "andy", PermissionService.WRITE, true);
    NodeRef test = nodeService.createNode(one, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}test"), ContentModel.TYPE_FOLDER).getChildRef();
    // test has shared acl
    long start = System.nanoTime();
    for (int i = 0; i < 1000; i++) {
        nodeService.moveNode(test, two, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}test"));
        nodeService.moveNode(test, one, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}test"));
    }
    long end = System.nanoTime();
//assertTrue("Time was "+(end - start)/1000000000.0f, end == start);
}

33. ThumbnailServiceImplTest#testDuplicationNames()

View license
public void testDuplicationNames() throws Exception {
    checkTransformer();
    NodeRef jpgOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
    ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
    imageResizeOptions.setWidth(64);
    imageResizeOptions.setHeight(64);
    imageResizeOptions.setResizeToThumbnail(true);
    ImageTransformationOptions imageTransformationOptions = new ImageTransformationOptions();
    imageTransformationOptions.setResizeOptions(imageResizeOptions);
    // ThumbnailDetails createOptions = new ThumbnailDetails();
    NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, MimetypeMap.MIMETYPE_IMAGE_JPEG, imageTransformationOptions, "small");
    assertNotNull(thumbnail1);
    checkRenditioned(jpgOrig, "small");
    checkRendition("small", thumbnail1);
    // the origional thumbnail is returned if we are attempting to create a duplicate
    NodeRef duplicate = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, MimetypeMap.MIMETYPE_IMAGE_JPEG, imageTransformationOptions, "small");
    assertNotNull(duplicate);
    assertEquals(duplicate, thumbnail1);
}

34. NodeServiceImplTest#testGetParentAssocs()

View license
/**
     * Test getParentAssocs
     */
public void testGetParentAssocs() {
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    NodeRef nodeRef = version.getFrozenStateNodeRef();
    List<ChildAssociationRef> results = this.versionStoreNodeService.getParentAssocs(nodeRef);
    assertNotNull(results);
    assertEquals(1, results.size());
    ChildAssociationRef childAssoc = results.get(0);
    assertEquals(nodeRef, childAssoc.getChildRef());
    NodeRef versionStoreRoot = this.dbNodeService.getRootNode(this.versionService.getVersionStoreReference());
    assertEquals(versionStoreRoot, childAssoc.getParentRef());
}

35. NodeServiceImplTest#testGetPrimaryParent()

View license
/**
     * Test getPrimaryParent
     */
public void testGetPrimaryParent() {
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    NodeRef nodeRef = version.getFrozenStateNodeRef();
    ChildAssociationRef childAssoc = this.versionStoreNodeService.getPrimaryParent(nodeRef);
    assertNotNull(childAssoc);
    assertEquals(nodeRef, childAssoc.getChildRef());
    NodeRef versionStoreRoot = this.dbNodeService.getRootNode(this.versionService.getVersionStoreReference());
    assertEquals(versionStoreRoot, childAssoc.getParentRef());
}

36. VirtualCheckOutCheckInServiceExtensionTest#testGetCheckedOut()

View license
@Test
public void testGetCheckedOut() throws Exception {
    checkOutCheckInService.checkout(originalContentNodeRef);
    NodeRef workingCopyVirtualContext = nodeService.getChildByName(node, ContentModel.ASSOC_CONTAINS, PROP_WORKING_COPY_NAME);
    assertNotNull(workingCopyVirtualContext);
    NodeRef checkedOut = checkOutCheckInService.getCheckedOut(workingCopyVirtualContext);
    assertNotNull(checkedOut);
    assertEquals(originalContentNodeRef, checkedOut);
    checkOutCheckInService.cancelCheckout(workingCopyVirtualContext);
    NodeRef checkedOut2 = checkOutCheckInService.getCheckedOut(originalContentNodeRef);
    assertNull(checkedOut2);
}

37. VirtualFileFolderServiceExtensionTest#testCreateTempFile()

View license
@Test
public void testCreateTempFile() throws Exception {
    NodeRef vf = createVirtualizedFolder(testRootFolder.getNodeRef(), "TestVirtualFileFolderService_testVirtualFolderVirtualChild", TEST_TEMPLATE_3_JSON_SYS_PATH);
    NodeRef node2 = nodeService.getChildByName(vf, ContentModel.ASSOC_CHILDREN, "Node2");
    String contentName = "ContentVirtualChild";
    createContent(node2, contentName);
    NodeRef childByName = nodeService.getChildByName(node2, ContentModel.ASSOC_CHILDREN, contentName);
    // TODO to test with minimized nodeRef id when minimisation is finished
    File file = File.createTempFile("dedededede", ".tmp", TempFileProvider.getTempDir());
    assertNotNull(file);
}

38. VirtualNodeServiceExtensionTest#testCreateNode_CM_528_folder_filing_type()

View license
@Test
public void testCreateNode_CM_528_folder_filing_type() throws Exception {
    NodeRef testTemplate5 = createVirtualizedFolder(testRootFolder.getNodeRef(), "aVFTestTemplate5", TEST_TEMPLATE_5_JSON_SYS_PATH);
    NodeRef folderFilingTypeNode = nodeService.getChildByName(testTemplate5, ContentModel.ASSOC_CONTAINS, "FolderFilingType");
    ChildAssociationRef forcedCmContentAssocRef = createContent(folderFilingTypeNode, "forcedCmContent");
    NodeRef forcedCmContent = forcedCmContentAssocRef.getChildRef();
    QName actualType = nodeService.getType(forcedCmContent);
    assertEquals(ContentModel.TYPE_CONTENT, actualType);
}

39. HashStringifierTest#testStringifyNodeReference_actualNodeRef()

View license
@Test
public void testStringifyNodeReference_actualNodeRef() {
    NodeRef templateNodeRef = new NodeRef("workspace://SpacesStore/0d3b26ff-c4c1-4680-8622-8608ea7ab4b2");
    NodeRef actualTemplateNode = new NodeRef("workspace://SpacesStore/67c8f11d-0936-4295-88a0-12b85764c76f");
    Reference virtualReference = ((VirtualProtocol) Protocols.VIRTUAL.protocol).newReference(templateNodeRef, "/1/2/3", actualTemplateNode);
    NodeRef actualNode = new NodeRef("workspace://SpacesStore/00c8f11d-0936-4295-88a0-12b85764c76f");
    Reference nodeReference = NodeProtocol.newReference(actualNode, virtualReference);
    Reference spReference = stringifyParse(nodeReference);
    assertEquals(nodeReference, spReference);
}

40. TemplateFilingRuleTest#testFilingPath_specialCharacters()

View license
@Test
public void testFilingPath_specialCharacters() throws Exception {
    NodeRef vfNodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), "Template 6 With Spaces", TEST_TEMPLATE_5_JSON_SYS_PATH);
    NodeRef sfpNodeRef = nodeService.getChildByName(vfNodeRef, ContentModel.ASSOC_CONTAINS, "SpecialFilingPath4");
    Reference sfpReference = Reference.fromNodeRef(sfpNodeRef);
    ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment);
    VirtualFolderDefinition structure = sfpReference.execute(applyTemplateMethod);
    FilingRule filingRule = structure.getFilingRule();
    assertTrue(filingRule instanceof TemplateFilingRule);
    NodeRef fn = filingRule.filingNodeRefFor(new FilingParameters(sfpReference));
    assertNotNull(fn);
}

41. VtiPathHelper#getUserHomeLocation()

View license
/**
     * Get home space for current user
     * 
     * @return String url to home space
     */
public String getUserHomeLocation() {
    NodeRef currentUser = personService.getPerson(authenticationComponent.getCurrentUserName());
    if (currentUser == null) {
        throw new AuthenticationException("No user have been authorized.");
    }
    NodeRef homeSpace = (NodeRef) nodeService.getProperty(currentUser, ContentModel.PROP_HOMEFOLDER);
    if (homeSpace == null) {
        throw new RuntimeException("No home space was found.");
    }
    return toUrlPath(fileFolderService.getFileInfo(homeSpace));
}

42. VtiPathHelper#findList()

View license
/** 
     * For a given node, looks up the parent tree to find the List
     *  (Site Container) that it is part of.
     *  
     * @param itemInList the nodeRef of item to look parent container for
     * @return the nodeRef of the list this item is part of, or the node itself if it isn't in one
     */
public NodeRef findList(NodeRef itemInList) {
    NodeRef result = null;
    NodeRef nodeToCheck = itemInList;
    while (result == null && nodeToCheck != null) {
        if (nodeService.hasAspect(nodeToCheck, SiteModel.ASPECT_SITE_CONTAINER)) {
            result = nodeToCheck;
            break;
        } else {
            nodeToCheck = nodeService.getPrimaryParent(nodeToCheck).getParentRef();
        }
    }
    if (result == null) {
        return itemInList;
    }
    return result;
}

43. Child#getValue()

Project: community-edition
Source File: Child.java
View license
/*
     * (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;
}

44. ADMRemoteStore#getGlobalComponentsNodeRef()

View license
/**
     * @return NodeRef to the shared components config folder
     */
protected NodeRef getGlobalComponentsNodeRef() {
    NodeRef result = null;
    NodeRef surfRef = getSurfConfigNodeRef(siteService.getSiteRoot());
    if (surfRef != null) {
        result = nodeService.getChildByName(surfRef, ContentModel.ASSOC_CONTAINS, PATH_COMPONENTS);
    }
    return result;
}

45. ADMRemoteStore#getGlobalUserFolderNodeRef()

View license
/**
     * @return NodeRef to the shared user config folder
     */
protected NodeRef getGlobalUserFolderNodeRef() {
    NodeRef result = null;
    NodeRef surfRef = getSurfConfigNodeRef(siteService.getSiteRoot());
    if (surfRef != null) {
        NodeRef pagesRef = nodeService.getChildByName(surfRef, ContentModel.ASSOC_CONTAINS, PATH_PAGES);
        if (pagesRef != null) {
            result = nodeService.getChildByName(pagesRef, ContentModel.ASSOC_CONTAINS, PATH_USER);
        }
    }
    return result;
}

46. DeletedNodesImpl#listDeleted()

View license
@Override
public CollectionWithPagingInfo<Node> listDeleted(Parameters parameters) {
    PagingRequest pagingRequest = Util.getPagingRequest(parameters.getPaging());
    NodeRef archiveStoreRootNodeRef = nodeService.getStoreArchiveNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    // Create canned query
    ArchivedNodesCannedQueryBuilder queryBuilder = new ArchivedNodesCannedQueryBuilder.Builder(archiveStoreRootNodeRef, pagingRequest).sortOrderAscending(false).build();
    // Query the DB
    PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);
    List<Node> nodesFound = new ArrayList<Node>(result.getPage().size());
    Map mapUserInfo = new HashMap<>();
    for (NodeRef nRef : result.getPage()) {
        Node foundNode = nodes.getFolderOrDocument(nRef, null, null, parameters.getInclude(), mapUserInfo);
        mapArchiveInfo(foundNode, mapUserInfo);
        nodesFound.add(foundNode);
    }
    return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodesFound);
}

47. NodesImpl#moveOrCopyNode()

Project: community-edition
Source File: NodesImpl.java
View license
@Override
public Node moveOrCopyNode(String sourceNodeId, String targetParentId, String name, Parameters parameters, boolean isCopy) {
    if ((sourceNodeId == null) || (sourceNodeId.isEmpty())) {
        throw new InvalidArgumentException("Missing sourceNodeId");
    }
    if ((targetParentId == null) || (targetParentId.isEmpty())) {
        throw new InvalidArgumentException("Missing targetParentId");
    }
    final NodeRef parentNodeRef = validateOrLookupNode(targetParentId, null);
    final NodeRef sourceNodeRef = validateOrLookupNode(sourceNodeId, null);
    FileInfo fi = moveOrCopyImpl(sourceNodeRef, parentNodeRef, name, isCopy);
    return getFolderOrDocument(fi.getNodeRef().getId(), parameters);
}

48. LinksRestApiTest#pushLinkCreatedDateBack()

View license
/**
     * Monkeys with the created date on a link
     */
private void pushLinkCreatedDateBack(String name, int daysAgo) throws Exception {
    NodeRef container = siteService.getContainer(SITE_SHORT_NAME_LINKS, "links");
    NodeRef node = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, name);
    Date created = (Date) nodeService.getProperty(node, ContentModel.PROP_CREATED);
    Date newCreated = new Date(created.getTime() - daysAgo * 24 * 60 * 60 * 1000);
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
    internalNodeService.setProperty(node, ContentModel.PROP_CREATED, newCreated);
    this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
    txn.commit();
    // Now chance something else on the node to have it re-indexed
    nodeService.setProperty(node, ContentModel.PROP_CREATED, newCreated);
    nodeService.setProperty(node, ContentModel.PROP_DESCRIPTION, "Forced change");
}

49. NodeLocatorWebScriptTest#testUserHomeNodeLocator()

View license
public void testUserHomeNodeLocator() throws Exception {
    String url = baseURL + UserHomeNodeLocator.NAME;
    // Run as System User, no User Home.
    AuthenticationUtil.setRunAsUser(AuthenticationUtil.getSystemUserName());
    checkNodeLocator(url, null);
    //Run as Admin User
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    NodeRef admin = repositoryHelper.getPerson();
    NodeRef userHome = repositoryHelper.getUserHome(admin);
    checkNodeLocator(url, userHome);
}

50. SiteServiceTest#createRepoFile()

View license
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();
}

51. TestEnterpriseAtomPubTCK#getCompanyHome()

View license
private static NodeRef getCompanyHome(NodeService nodeService, SearchService searchService, NamespaceService namespaceService) {
    NodeRef storeRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    List<NodeRef> results = searchService.selectNodes(storeRootNodeRef, "/app:company_home", null, namespaceService, false, SearchService.LANGUAGE_XPATH);
    if (results.size() == 0) {
        throw new AlfrescoRuntimeException("Didn't find Company Home");
    }
    NodeRef companyHomeNodeRef = results.get(0);
    return companyHomeNodeRef;
}

52. CMISResultSet#allNodeRefsEqual()

View license
private boolean allNodeRefsEqual(Map<String, NodeRef> selected) {
    NodeRef last = null;
    for (NodeRef current : selected.values()) {
        if (last == null) {
            last = current;
        } else {
            if (!last.equals(current)) {
                return false;
            }
        }
    }
    return true;
}

53. CMISResultSetRow#allNodeRefsEqual()

View license
private boolean allNodeRefsEqual(Map<String, NodeRef> selected) {
    NodeRef last = null;
    for (NodeRef current : selected.values()) {
        if (last == null) {
            last = current;
        } else {
            if (!last.equals(current)) {
                return false;
            }
        }
    }
    return true;
}

54. CalendarServiceImpl#getCalendarEntry()

View license
@Override
public CalendarEntry getCalendarEntry(String siteShortName, String entryName) {
    NodeRef container = getSiteCalendarContainer(siteShortName, false);
    if (container == null) {
        // No events
        return null;
    }
    NodeRef event = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, entryName);
    return getCalendarEntry(event, entryName, container);
}

55. InviteSender#sendMail()

Project: community-edition
Source File: InviteSender.java
View license
/**
     * Sends an invitation email.
     * 
     * @param emailTemplateXpath the XPath to the email template in the repository
     * @param emailSubjectKey the subject of the email
     * @param properties A Map containing the properties needed to send the email.
     */
public void sendMail(String emailTemplateXpath, String emailSubjectKey, Map<String, String> properties) {
    checkProperties(properties);
    ParameterCheck.mandatory("Properties", properties);
    NodeRef inviter = personService.getPerson(properties.get(wfVarInviterUserName));
    String inviteeName = properties.get(wfVarInviteeUserName);
    NodeRef invitee = personService.getPerson(inviteeName);
    Action mail = actionService.createAction(MailActionExecuter.NAME);
    mail.setParameterValue(MailActionExecuter.PARAM_FROM, getEmail(inviter));
    mail.setParameterValue(MailActionExecuter.PARAM_TO, getEmail(invitee));
    mail.setParameterValue(MailActionExecuter.PARAM_SUBJECT, emailSubjectKey);
    mail.setParameterValue(MailActionExecuter.PARAM_SUBJECT_PARAMS, new Object[] { ModelUtil.getProductName(repoAdminService), getSiteName(properties) });
    mail.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, getEmailTemplateNodeRef(emailTemplateXpath));
    mail.setParameterValue(MailActionExecuter.PARAM_TEMPLATE_MODEL, (Serializable) buildMailTextModel(properties, inviter, invitee));
    mail.setParameterValue(MailActionExecuter.PARAM_IGNORE_SEND_FAILURE, true);
    actionService.executeAction(mail, getWorkflowPackage(properties));
}

56. LinksServiceImpl#getLink()

View license
@Override
public LinkInfo getLink(String siteShortName, String linkName) {
    NodeRef container = getSiteLinksContainer(siteShortName, false);
    if (container == null) {
        // No links
        return null;
    }
    NodeRef link = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, linkName);
    if (link != null) {
        return buildLink(link, container, linkName);
    }
    return null;
}

57. MultilingualContentServiceImpl#getMLContainerRoot()

View license
/**
     * @return Returns a reference to the node that will hold all the <b>cm:mlContainer</b> nodes.
     */
private NodeRef getMLContainerRoot() {
    NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(rootNodeRef, ContentModel.ASSOC_CHILDREN, QNAME_ASSOC_ML_ROOT);
    if (assocRefs.size() != 1) {
        throw new AlfrescoRuntimeException("Unable to find bootstrap location for ML Root using query: " + QNAME_ASSOC_ML_ROOT);
    }
    NodeRef mlRootNodeRef = assocRefs.get(0).getChildRef();
    // Done
    return mlRootNodeRef;
}

58. SystemNodeUtils#getSystemContainer()

View license
/**
     * Returns the System Container for the current tenant
     */
public static NodeRef getSystemContainer(final NodeService nodeService, final Repository repositoryHelper) {
    // Grab the root of the repository, for the current tennant
    final NodeRef root = repositoryHelper.getRootHome();
    // Locate the system folder, in the root 
    List<ChildAssociationRef> sysRefs = nodeService.getChildAssocs(root, ContentModel.ASSOC_CHILDREN, SYSTEM_FOLDER_QNAME);
    if (sysRefs.size() != 1) {
        throw new IllegalStateException("System folder missing / duplicated! Found " + sysRefs);
    }
    final NodeRef system = sysRefs.get(0).getChildRef();
    return system;
}

59. SystemNodeUtils#getSystemChildContainer()

View license
/**
     * Returns the NodeRef of a given Child Container within the current Tenant's 
     *  System Container, if found
     */
public static NodeRef getSystemChildContainer(final QName childName, final NodeService nodeService, final Repository repositoryHelper) {
    NodeRef system = getSystemContainer(nodeService, repositoryHelper);
    // Find the container, under system
    List<ChildAssociationRef> containerRefs = nodeService.getChildAssocs(system, ContentModel.ASSOC_CHILDREN, childName);
    NodeRef container = null;
    if (containerRefs.size() > 0) {
        container = containerRefs.get(0).getChildRef();
        if (containerRefs.size() > 1)
            logger.warn("Duplicate Shared Credentials Containers found: " + containerRefs);
    }
    return container;
}

60. ChannelServiceImpl#createChannel()

View license
/**
     * {@inheritDoc}
     */
public Channel createChannel(String channelTypeId, String name, Map<QName, Serializable> properties) {
    NodeRef channelContainer = getChannelContainer();
    ChannelType channelType = channelTypes.get(channelTypeId);
    if (channelType == null) {
        String message = "Channel Type: " + channelTypeId + " does not exist!";
        throw new IllegalArgumentException(message);
    }
    Map<QName, Serializable> actualProps = new HashMap<QName, Serializable>();
    if (properties != null) {
        actualProps.putAll(properties);
    }
    actualProps.put(ContentModel.PROP_NAME, name);
    actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId());
    actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE);
    actualProps = encryptor.encrypt(actualProps);
    NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps);
    return channelHelper.buildChannelObject(channelNode, this);
}

61. ChannelServiceImpl#getChannelNodeByName()

View license
private NodeRef getChannelNodeByName(String channelName) {
    ParameterCheck.mandatory("channelName", channelName);
    NodeRef channelContainer = getChannelContainer();
    if (channelContainer == null) {
        return null;
    }
    NodeRef child = nodeService.getChildByName(channelContainer, ContentModel.ASSOC_CONTAINS, channelName);
    if (child != null) {
        QName type = nodeService.getType(child);
        if (dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) {
            return child;
        }
    }
    return null;
}

62. RemoteCredentialsServiceImpl#listAllCredentials()

View license
@Override
public PagingResults<? extends BaseCredentialsInfo> listAllCredentials(String remoteSystem, QName credentialsType, PagingRequest paging) {
    NodeRef personContainer = getPersonContainer(remoteSystem, false);
    NodeRef systemContainer = getSharedContainer(remoteSystem, false);
    if (personContainer == null && systemContainer == null) {
        return new EmptyPagingResults<BaseCredentialsInfo>();
    }
    return listCredentials(new NodeRef[] { personContainer, systemContainer }, remoteSystem, credentialsType, paging);
}

63. CompositeRenderingEngine#executeCompositeRendition()

View license
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;
}

64. RuleServiceImpl#getOwningNodeRefActionImpl()

View license
private NodeRef getOwningNodeRefActionImpl(NodeRef actionNodeRef) {
    NodeRef result = null;
    NodeRef parentNodeRef = this.nodeService.getPrimaryParent(actionNodeRef).getParentRef();
    if (parentNodeRef != null) {
        QName parentType = this.nodeService.getType(parentNodeRef);
        if (RuleModel.TYPE_RULE.equals(parentType) == true) {
            result = getOwningNodeRefRuleImpl(parentNodeRef);
        } else if (ActionModel.TYPE_COMPOSITE_ACTION.equals(parentType) == true) {
            result = getOwningNodeRefActionImpl(parentNodeRef);
        }
    }
    return result;
}

65. LuceneResultSetRow#getChildAssocRef()

View license
@Override
public ChildAssociationRef getChildAssocRef() {
    Field field = getDocument().getField("PRIMARYPARENT");
    String primaryParent = null;
    if (field != null) {
        primaryParent = field.stringValue();
    }
    NodeRef childNodeRef = getNodeRef();
    NodeRef parentNodeRef = primaryParent == null ? null : tenantService.getBaseName(new NodeRef(primaryParent));
    return new ChildAssociationRef(getPrimaryAssocTypeQName(), parentNodeRef, getQName(), childNodeRef);
}

66. AuthorityDAOImpl#createAuthority()

View license
public void createAuthority(String name, String authorityDisplayName, Set<String> authorityZones) {
    HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
    /* MNT-11749 : Alfresco allows to create authorities with different char cases, but disallow duplicates */
    props.put(ContentModel.PROP_NAME, DigestUtils.md5Hex(name));
    props.put(ContentModel.PROP_AUTHORITY_NAME, name);
    props.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, authorityDisplayName);
    NodeRef childRef;
    NodeRef authorityContainerRef = getAuthorityContainer();
    childRef = nodeService.createNode(authorityContainerRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", name, namespacePrefixResolver), ContentModel.TYPE_AUTHORITY_CONTAINER, props).getChildRef();
    if (authorityZones != null) {
        Set<NodeRef> zoneRefs = new HashSet<NodeRef>(authorityZones.size() * 2);
        String currentUserDomain = tenantService.getCurrentUserDomain();
        for (String authorityZone : authorityZones) {
            zoneRefs.add(getOrCreateZone(authorityZone));
            zoneAuthorityCache.remove(new Pair<String, String>(currentUserDomain, authorityZone));
        }
        zoneAuthorityCache.remove(new Pair<String, String>(currentUserDomain, null));
        nodeService.addChild(zoneRefs, childRef, ContentModel.ASSOC_IN_ZONE, QName.createQName("cm", name, namespacePrefixResolver));
    }
    authorityLookupCache.put(cacheKey(name), childRef);
}

67. SiteServiceImpl#getContainer()

View license
/**
     * @see org.alfresco.service.cmr.site.SiteService#getContainer(java.lang.String, String)
     */
public NodeRef getContainer(String shortName, String componentId) {
    ParameterCheck.mandatoryString("componentId", componentId);
    // retrieve site
    NodeRef siteNodeRef = getSiteNodeRef(shortName);
    if (siteNodeRef == null) {
        throw new SiteDoesNotExistException(shortName);
    }
    // retrieve component folder within site
    // NOTE: component id is used for folder name
    NodeRef containerNodeRef = null;
    try {
        containerNodeRef = findContainer(siteNodeRef, componentId);
    } catch (FileNotFoundException e) {
    }
    return containerNodeRef;
}

68. TaggingServiceImpl#deleteTag()

View license
/**
     * @see org.alfresco.service.cmr.tagging.TaggingService#deleteTag(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)
     */
public void deleteTag(StoreRef storeRef, String tag) {
    // Lower the case of the tag
    tag = tag.toLowerCase();
    // Find nodes which are tagged with the 'soon to be deleted' tag.
    List<NodeRef> taggedNodes = this.findTaggedNodes(storeRef, tag);
    // Clear the tag from the found nodes
    for (NodeRef taggedNode : taggedNodes) {
        this.removeTag(taggedNode, tag);
    }
    NodeRef tagNodeRef = getTagNodeRef(storeRef, tag);
    if (tagNodeRef != null) {
        this.categoryService.deleteCategory(tagNodeRef);
    }
}

69. TransferServiceImpl2#getTransferTargets()

View license
/**
     * Get all transfer targets in the specified group
     */
public Set<TransferTarget> getTransferTargets(String groupName) {
    NodeRef home = getTransferHome();
    // get group with assoc groupName
    NodeRef groupNode = nodeService.getChildByName(home, ContentModel.ASSOC_CONTAINS, groupName);
    if (groupNode == null) {
        // No transfer group.
        throw new TransferException(MSG_NO_GROUP, new Object[] { groupName });
    }
    return getTransferTargets(groupNode);
}

70. VirtualCheckOutCheckInServiceExtension#checkin()

View license
@Override
public NodeRef checkin(NodeRef workingCopyNodeRef, Map<String, Serializable> versionProperties, String contentUrl, boolean keepCheckedOut) {
    CheckOutCheckInServiceTrait theTrait = getTrait();
    NodeRef materialWorkingCopy = smartStore.materializeIfPossible(workingCopyNodeRef);
    NodeRef materialOriginalNode = theTrait.checkin(materialWorkingCopy, versionProperties, contentUrl, keepCheckedOut);
    return virtualizeOriginalIfNeeded(workingCopyNodeRef, materialOriginalNode);
}

71. VirtualCheckOutCheckInServiceExtension#checkin()

View license
@Override
public NodeRef checkin(NodeRef workingCopyNodeRef, Map<String, Serializable> versionProperties, String contentUrl) {
    CheckOutCheckInServiceTrait theTrait = getTrait();
    NodeRef materialWorkingCopy = smartStore.materializeIfPossible(workingCopyNodeRef);
    NodeRef materialOriginalNode = theTrait.checkin(materialWorkingCopy, versionProperties, contentUrl);
    return virtualizeOriginalIfNeeded(workingCopyNodeRef, materialOriginalNode);
}

72. VirtualNodeServiceExtension#cleanUpDownloadTargetAssocs()

View license
private void cleanUpDownloadTargetAssocs(NodeRef sourceNodeRef) {
    NodeRef tempFolderNodeRef = downloadAssociationsFolder.resolve();
    if (tempFolderNodeRef == null) {
        return;
    }
    String tempFileName = sourceNodeRef.getId();
    NodeRef tempFileNodeRef = environment.getChildByName(tempFolderNodeRef, ContentModel.ASSOC_CONTAINS, tempFileName);
    if (tempFileNodeRef == null) {
        return;
    }
    environment.delete(tempFileNodeRef);
}

73. WorkflowPackageImpl#createSystemWorkflowContainer()

View license
/**
     * Creates the System Workflow Container
     * 
     * @return the system workflow container
     */
public NodeRef createSystemWorkflowContainer() {
    NodeRef systemContainer = findSystemContainer();
    NodeRef systemWfContainer = findSystemWorkflowContainer(systemContainer);
    if (systemWfContainer == null) {
        String name = bootstrap.getConfiguration().getProperty("system.workflow_container.childname");
        QName qname = QName.createQName(name, namespaceService);
        ChildAssociationRef childRef = nodeService.createNode(systemContainer, ContentModel.ASSOC_CHILDREN, qname, ContentModel.TYPE_CONTAINER);
        systemWfContainer = childRef.getChildRef();
    }
    return systemWfContainer;
}

74. TransitionSimpleWorkflowActionExecuterTest#testExecutionApproveWhenDestinationSameAsSource()

View license
/** Test for MNT-14730*/
public void testExecutionApproveWhenDestinationSameAsSource() {
    addWorkflowAspect(node, sourceFolder, Boolean.FALSE, Boolean.FALSE);
    assertTrue(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    NodeRef pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);
    ActionImpl action = new ActionImpl(null, ID, "accept-simpleworkflow", null);
    acceptExecuter.execute(action, node);
    String copyName = QName.createValidLocalName("Copy of my node.txt");
    NodeRef nodeRef = nodeService.getChildByName(sourceFolder, ContentModel.ASSOC_CONTAINS, copyName);
    assertNotNull(nodeRef);
}

75. TransitionSimpleWorkflowActionExecuterTest#testExecutionRejectWhenDestinationSameAsSource()

View license
/** Test for MNT-14730*/
public void testExecutionRejectWhenDestinationSameAsSource() {
    addWorkflowAspect(node, sourceFolder, Boolean.FALSE, Boolean.FALSE);
    assertTrue(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    NodeRef pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);
    assertEquals(0, nodeService.getChildAssocs(destinationFolder).size());
    ActionImpl action = new ActionImpl(null, ID, "reject-simpleworkflow", null);
    rejectExecuter.execute(action, node);
    assertFalse(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);
    assertEquals(0, nodeService.getChildAssocs(destinationFolder).size());
    String copyName = QName.createValidLocalName("Copy of my node.txt");
    NodeRef nodeRef = nodeService.getChildByName(sourceFolder, ContentModel.ASSOC_CONTAINS, copyName);
    assertNotNull(nodeRef);
}

76. CheckOutCheckInServiceImplTest#testCheckInWithNameChange()

View license
public void testCheckInWithNameChange() {
    // Check out the file
    NodeRef fileWorkingCopyNodeRef = cociService.checkout(fileNodeRef);
    // Make sure we can get the checked out node
    NodeRef fileWorkingCopyNodeRefCheck = cociService.getWorkingCopy(fileNodeRef);
    assertEquals("Working copy not found ", fileWorkingCopyNodeRef, fileWorkingCopyNodeRefCheck);
    // Rename the working copy
    nodeService.setProperty(fileWorkingCopyNodeRef, ContentModel.PROP_NAME, "renamed");
    // Check in
    cociService.checkin(fileWorkingCopyNodeRef, null);
}

77. CheckOutCheckInServiceImplTest#testCheckOutCheckInWithTranslatableAspect()

View license
public void testCheckOutCheckInWithTranslatableAspect() {
    // Create a node to be used as the translation
    NodeRef translationNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("translation"), ContentModel.TYPE_CONTENT).getChildRef();
    nodeService.addAspect(this.nodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translatable"), null);
    nodeService.createAssociation(this.nodeRef, translationNodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translations"));
    // Check it out
    NodeRef workingCopy = cociService.checkout(this.nodeRef, this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("workingCopy"));
    // Check it back in again
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
    cociService.checkin(workingCopy, versionProperties);
}

78. CheckOutCheckInServiceImplTest#testVersionAspectNotSetOnCheckIn()

View license
/**
     * 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));
}

79. CheckOutCheckInServiceImplTest#testCancelCheckOut()

View license
/**
     * Test cancel checkOut
     */
public void testCancelCheckOut() {
    NodeRef workingCopy = checkout();
    assertNotNull(workingCopy);
    try {
        this.lockService.checkForLock(this.nodeRef);
        fail("The origional should be locked now.");
    } catch (Throwable exception) {
    }
    NodeRef origNodeRef = cociService.cancelCheckout(workingCopy);
    assertEquals(this.nodeRef, origNodeRef);
    // The origional should no longer be locked
    this.lockService.checkForLock(origNodeRef);
}

80. CopyServiceImplTest#testCopiedFromAspect_NonObject()

View license
/**
     * 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));
}

81. CopyServiceImplTest#testCopyResidualProperties()

View license
public void testCopyResidualProperties() throws Exception {
    QName nodeOneAssocName = QName.createQName("{test}nodeOne");
    NodeRef nodeOne = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, nodeOneAssocName, TEST_TYPE_QNAME).getChildRef();
    nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_NODE_REF, nodeOne);
    nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_ANY, nodeOne);
    NodeRef nodeOneCopy = copyService.copy(nodeOne, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copiedNodeOne"));
    // Check the node ref property
    Serializable propNodeRef = nodeService.getProperty(nodeOneCopy, PROP_QNAME_RESIDUAL_NODE_REF);
    assertEquals("Residual d:noderef not copied", nodeOne, propNodeRef);
    // Check the any property
    Serializable propAny = nodeService.getProperty(nodeOneCopy, PROP_QNAME_RESIDUAL_ANY);
    assertEquals("Residual d:any not copied", nodeOne, propAny);
}

82. CopyServiceImplTest#testCopyWorkingCopyForAlf8863()

View license
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)"));
}

83. DownloadServiceIntegrationTest#deleteBefore()

View license
@Test
public void deleteBefore() throws InterruptedException {
    NodeRef beforeNodeRef;
    NodeRef afterNodeRef;
    Date beforeTime;
    beforeNodeRef = DOWNLOAD_SERVICE.createDownload(new NodeRef[] { level1Folder1 }, true);
    testNodes.addNodeRef(beforeNodeRef);
    waitForDownload(beforeNodeRef);
    beforeTime = new Date();
    afterNodeRef = DOWNLOAD_SERVICE.createDownload(new NodeRef[] { level1Folder2 }, true);
    testNodes.addNodeRef(afterNodeRef);
    waitForDownload(afterNodeRef);
    DOWNLOAD_SERVICE.deleteDownloads(beforeTime);
    Assert.assertFalse(NODE_SERVICE.exists(beforeNodeRef));
    Assert.assertTrue(NODE_SERVICE.exists(afterNodeRef));
}

84. ExporterComponentTest#testRoundTripKeepsCategoriesWhenWithinSameStore()

View license
/**
     * 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");
}

85. AbstractLockStoreTestBase#testSetAndGet()

View license
@Test
public void testSetAndGet() {
    NodeRef ephemeralNodeRef = new NodeRef("workspace://SpacesStore/12345");
    LockState ephemeralLock = LockState.createLock(ephemeralNodeRef, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
    NodeRef persistentNodeRef = new NodeRef("workspace://SpacesStore/5838743");
    LockState persistentLock = LockState.createLock(persistentNodeRef, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
    lockStore.set(ephemeralNodeRef, ephemeralLock);
    lockStore.set(persistentNodeRef, persistentLock);
    LockState newLockState = lockStore.get(ephemeralNodeRef);
    assertEquals(ephemeralLock, newLockState);
    newLockState = lockStore.get(persistentNodeRef);
    assertEquals(persistentLock, newLockState);
}

86. AbstractLockStoreTestBase#testClear()

View license
@Test
public void testClear() {
    NodeRef nodeRef1 = new NodeRef("workspace://SpacesStore/12345");
    LockState lock1 = LockState.createLock(nodeRef1, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
    NodeRef nodeRef2 = new NodeRef("workspace://SpacesStore/5838743");
    LockState lock2 = LockState.createLock(nodeRef2, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
    lockStore.set(nodeRef1, lock1);
    lockStore.set(nodeRef2, lock2);
    assertNotNull(lockStore.get(nodeRef1));
    assertNotNull(lockStore.get(nodeRef2));
    lockStore.clear();
    assertNull(lockStore.get(nodeRef1));
    assertNull(lockStore.get(nodeRef2));
}

87. FileFolderPerformanceTester#getOrCreateRootFolder()

View license
protected NodeRef getOrCreateRootFolder() {
    // find the company home folder
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
    NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
    List<NodeRef> results = searchService.selectNodes(storeRootNodeRef, "/app:company_home", null, namespaceService, false, SearchService.LANGUAGE_XPATH);
    if (results.size() == 0) {
        throw new AlfrescoRuntimeException("Didn't find Company Home");
    }
    NodeRef companyHomeNodeRef = results.get(0);
    return fileFolderService.create(companyHomeNodeRef, getName() + "_" + System.currentTimeMillis(), ContentModel.TYPE_FOLDER).getNodeRef();
}

88. FileFolderServiceImplTest#testRenameWithoutAssocQNameChange()

View license
public void testRenameWithoutAssocQNameChange() throws Exception {
    FileInfo folderInfo = getByName(NAME_L0_FOLDER_A, true);
    assertNotNull(folderInfo);
    NodeRef folderNodeRef = folderInfo.getNodeRef();
    // Create a child file
    QName assocQName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "abc");
    NodeRef newFileNodeRef = fileFolderService.create(folderNodeRef, "AnotherFile.txt", ContentModel.TYPE_CONTENT, assocQName).getNodeRef();
    // Make sure that the correct association QName was used
    QName checkQName = nodeService.getPrimaryParent(newFileNodeRef).getQName();
    assertEquals("The given assoc QName was not used for the path", assocQName, checkQName);
    // Rename
    String newName = "AnotherFile-new.txt";
    folderInfo = fileFolderService.rename(newFileNodeRef, newName);
    // Make sure that the association QName did not change
    checkQName = nodeService.getPrimaryParent(newFileNodeRef).getQName();
    assertEquals("The given assoc QName was not used for the path after a rename", assocQName, nodeService.getPrimaryParent(newFileNodeRef).getQName());
}

89. FileFolderServiceImplTest#testCopyOfWorkingCopy_ALF_8863()

View license
public void testCopyOfWorkingCopy_ALF_8863() throws Exception {
    // create test node to checkout
    NodeRef testNodeRef = fileFolderService.create(workingRootNodeRef, "" + System.currentTimeMillis() + ".txt", ContentModel.TYPE_CONTENT).getNodeRef();
    // create folder to copy to
    FileInfo destDirInfo = fileFolderService.create(workingRootNodeRef, "destDir", ContentModel.TYPE_FOLDER);
    NodeRef workingCopyRef = cociService.checkout(testNodeRef);
    String workingCopyName = (String) nodeService.getProperty(workingCopyRef, ContentModel.PROP_NAME);
    FileInfo copyInfo = fileFolderService.copy(workingCopyRef, destDirInfo.getNodeRef(), null);
    String checkedOutName = (String) nodeService.getProperty(testNodeRef, ContentModel.PROP_NAME);
    int origExtIndex = checkedOutName.lastIndexOf('.');
    int copyExtIndex = copyInfo.getName().lastIndexOf('.');
    assertFalse(workingCopyName.equals(copyInfo.getName()));
    assertFalse(copyInfo.getName().contains("(Working Copy)"));
    assertTrue(copyInfo.getName().substring(0, copyExtIndex).startsWith(checkedOutName.substring(0, origExtIndex)));
}

90. EmptyTranslationAspectTest#testDeleteNode()

View license
public void testDeleteNode() throws Exception {
    NodeRef pivot = createContent();
    NodeRef empty = null;
    multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
    empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
    nodeService.getParentAssocs(empty);
    nodeService.deleteNode(empty);
    // Ensure that the empty translation is removed from the workspace
    assertFalse("The empty translation must be removed from the wokspace", nodeService.exists(empty));
    // Ensure that the empty translation is not archived
    assertFalse("The empty translation must be removed from the wokspace", nodeService.exists(nodeArchiveService.getArchivedNode(empty)));
}

91. MultilingualContentServiceImplTest#testGetTranslationForLocale()

View license
public void testGetTranslationForLocale() throws Exception {
    NodeRef chineseContentNodeRef = createContent();
    multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
    NodeRef frenchContentNodeRef = createContent();
    multilingualContentService.addTranslation(frenchContentNodeRef, chineseContentNodeRef, Locale.FRENCH);
    // Get the chinese translation
    assertEquals("Chinese translation should be present", chineseContentNodeRef, multilingualContentService.getTranslationForLocale(chineseContentNodeRef, Locale.CHINESE));
    // Get the french translation
    assertEquals("French translation should be present", frenchContentNodeRef, multilingualContentService.getTranslationForLocale(chineseContentNodeRef, Locale.FRENCH));
    // The Italian should return the pivot
    assertEquals("French translation should be present", chineseContentNodeRef, multilingualContentService.getTranslationForLocale(chineseContentNodeRef, Locale.ITALIAN));
}

92. MultilingualDocumentAspectTest#testDeleteLastNode()

View license
public void testDeleteLastNode() throws Exception {
    NodeRef pivot = createContent();
    multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
    NodeRef mlContainer = multilingualContentService.getTranslationContainer(pivot);
    nodeService.deleteNode(pivot);
    // Ensure that the mlContainer is removed too
    assertFalse("The mlContainer must be removed if the last translation is removed", nodeService.exists(mlContainer));
}

93. BaseNodeServiceTest#testCreateNodeWithId()

View license
/**
     * 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);
}

94. BaseNodeServiceTest#testDuplicateAssociationDetection()

View license
public void testDuplicateAssociationDetection() throws Exception {
    AssociationRef assocRef = createAssociation();
    NodeRef sourceRef = assocRef.getSourceRef();
    NodeRef targetRef = assocRef.getTargetRef();
    QName qname = assocRef.getTypeQName();
    try {
        // attempt repeat
        nodeService.createAssociation(sourceRef, targetRef, qname);
        fail("Duplicate assocation not detected");
    } catch (AssociationExistsException e) {
    }
}

95. BaseNodeServiceTest#testGetTargetAssocs()

View license
public void testGetTargetAssocs() throws Exception {
    AssociationRef assocRef = createAssociation();
    NodeRef sourceRef = assocRef.getSourceRef();
    NodeRef targetRef = assocRef.getTargetRef();
    QName qname = assocRef.getTypeQName();
    // get the target assocs
    List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(sourceRef, qname);
    assertEquals("Incorrect number of targets", 1, targetAssocs.size());
    assertTrue("Target not found", targetAssocs.contains(assocRef));
    // Check that IDs are present
    for (AssociationRef targetAssoc : targetAssocs) {
        assertNotNull("Association does not have ID", targetAssoc.getId());
    }
}

96. BaseNodeServiceTest#testGetSourceAssocs()

View license
public void testGetSourceAssocs() throws Exception {
    AssociationRef assocRef = createAssociation();
    NodeRef sourceRef = assocRef.getSourceRef();
    NodeRef targetRef = assocRef.getTargetRef();
    QName qname = assocRef.getTypeQName();
    // get the source assocs
    List<AssociationRef> sourceAssocs = nodeService.getSourceAssocs(targetRef, qname);
    assertEquals("Incorrect number of source assocs", 1, sourceAssocs.size());
    assertTrue("Source not found", sourceAssocs.contains(assocRef));
    // Check that IDs are present
    for (AssociationRef sourceAssoc : sourceAssocs) {
        assertNotNull("Association does not have ID", sourceAssoc.getId());
    }
}

97. PublishEventActionTest#testChannelTypePublishIsCalledOnPublish()

View license
@SuppressWarnings("unchecked")
@Test
public void testChannelTypePublishIsCalledOnPublish() throws Exception {
    // Create content node with appropriate aspects added.
    NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN);
    // Enable publishing on ChannelType.
    when(channelType.canPublish()).thenReturn(true);
    publishNode(source);
    NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode);
    // Check publish was called
    verify(channelType, times(1)).publish(eq(publishedNode), anyMap());
}

98. RenditionServiceIntegrationTest#testAutoRotateImage()

View license
/**
     * This test method takes an image with Exif Orientation information and checks if it is automatially rotated.
     */
public void testAutoRotateImage() throws Exception {
    NodeRef companyHome = repositoryHelper.getCompanyHome();
    //Check image is there
    String imageSource = "images/rotated_gray21.512.jpg";
    File imageFile = retrieveValidImageFile(imageSource);
    //Create node and save contents
    final NodeRef newNodeForRotate = createNode(companyHome, "rotateImageNode", ContentModel.TYPE_CONTENT);
    setImageContentOnNode(newNodeForRotate, MimetypeMap.MIMETYPE_IMAGE_JPEG, imageFile);
    //Test auto rotates
    final Map<String, Serializable> parameterValues = new HashMap<String, Serializable>();
    resizeImageAndCheckOrientation(newNodeForRotate, parameterValues, BLACK, WHITE);
    //Test doesn't auto rotate
    parameterValues.clear();
    parameterValues.put(ImageRenderingEngine.PARAM_AUTO_ORIENTATION, false);
    resizeImageAndCheckOrientation(newNodeForRotate, parameterValues, WHITE, BLACK);
    //Clean up
    nodeService.deleteNode(newNodeForRotate);
}

99. RuleServiceImplTest#createNothingToDoScript()

View license
private void createNothingToDoScript(String scriptName) {
    NodeRef storeRootNodeRef = nodeService.getRootNode(new StoreRef("workspace://SpacesStore"));
    NodeRef scriptFolderRef = searchService.selectNodes(storeRootNodeRef, "/app:company_home/app:dictionary/app:scripts", null, namespaceService, false).get(0);
    try {
        FileInfo fileInfo = fileFolderService.create(scriptFolderRef, scriptName, ContentModel.TYPE_CONTENT);
        ContentWriter writer = fileFolderService.getWriter(fileInfo.getNodeRef());
        assertNotNull("Writer is null", writer);
        // write some content
        String content = "function main(){}\nmain();";
        writer.putContent(content);
    } catch (FileExistsException exc) {
    }
}

100. RuleServiceImplTest#createScriptAction()

View license
private Action createScriptAction() {
    // get script nodeRef
    NodeRef storeRootNodeRef = nodeService.getRootNode(new StoreRef("workspace://SpacesStore"));
    NodeRef scriptRef = searchService.selectNodes(storeRootNodeRef, "/app:company_home/app:dictionary/app:scripts/cm:nothingToDo.js", null, namespaceService, false).get(0);
    assertNotNull("NodeRef script is null", scriptRef);
    // create action
    CompositeAction compositeAction = actionService.createCompositeAction();
    // add the action to the rule
    Action action = actionService.createAction("script");
    Map<String, Serializable> repoActionParams = new HashMap<String, Serializable>();
    repoActionParams.put("script-ref", scriptRef);
    action.setParameterValues(repoActionParams);
    compositeAction.addAction(action);
    return compositeAction;
}