Search in sources :

Example 1 with UUID_BINDING

use of org.alfresco.service.cmr.view.ImporterBinding.UUID_BINDING in project alfresco-repository by Alfresco.

the class ImporterComponentTest method testImportFoldersUuidBindingNullUuidNullLocationPath.

@Test
public void testImportFoldersUuidBindingNullUuidNullLocationPath() throws Exception {
    Location location = new Location(storeRef);
    InputStream test1 = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/import_folders.xml");
    InputStreamReader testReader1 = new InputStreamReader(test1, "UTF-8");
    try {
        importerService.importView(testReader1, location, new ImporterBinding() {

            @Override
            public String getValue(String key) {
                return null;
            }

            @Override
            public UUID_BINDING getUUIDBinding() {
                return UUID_BINDING.UPDATE_EXISTING;
            }

            @Override
            public ImporterContentCache getImportConentCache() {
                return null;
            }

            @Override
            public QName[] getExcludedClasses() {
                return null;
            }

            @Override
            public boolean allowReferenceWithinTransaction() {
                return true;
            }
        }, new ImportTimerProgress());
    } finally {
        testReader1.close();
    }
    // - root
    // - Main folder
    // - sub folder
    // - sub folder 1
    // - sub folder 2
    // - Archive folder
    NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL, new RegexQNamePattern(NamespaceService.CONTENT_MODEL_1_0_URI, "main folder"));
    assertEquals("'main folder' path not found", 1, childAssocs.size());
    NodeRef mainFolderNode = childAssocs.get(0).getChildRef();
    childAssocs = nodeService.getChildAssocs(mainFolderNode);
    assertEquals("'sub folder' path not found", 1, childAssocs.size());
    NodeRef subFolderNode = childAssocs.get(0).getChildRef();
    childAssocs = nodeService.getChildAssocs(subFolderNode);
    assertEquals("'subsub folder' path not found", 2, childAssocs.size());
    childAssocs = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL, new RegexQNamePattern(NamespaceService.CONTENT_MODEL_1_0_URI, "ArchiveFolder"));
    assertEquals("'ArchiveFolder' path not found", 1, childAssocs.size());
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ImporterContentCache(org.alfresco.service.cmr.view.ImporterContentCache) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) UUID_BINDING(org.alfresco.service.cmr.view.ImporterBinding.UUID_BINDING) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) Location(org.alfresco.service.cmr.view.Location) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 ImporterBinding (org.alfresco.service.cmr.view.ImporterBinding)1 UUID_BINDING (org.alfresco.service.cmr.view.ImporterBinding.UUID_BINDING)1 ImporterContentCache (org.alfresco.service.cmr.view.ImporterContentCache)1 Location (org.alfresco.service.cmr.view.Location)1 RegexQNamePattern (org.alfresco.service.namespace.RegexQNamePattern)1 BaseSpringTest (org.alfresco.util.BaseSpringTest)1 Test (org.junit.Test)1