Search in sources :

Example 1 with PathInfo

use of org.alfresco.rest.api.model.PathInfo in project alfresco-remote-api by Alfresco.

the class SharedLinkApiTest method testGetSharedLinksIncludePath.

/**
 * Tests for get /shared-links?include=path
 *
 * <p>GET:</p>
 * {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/shared-links?include=path}
 */
@Test
@Category({ LuceneTests.class, RedundantTests.class })
public void testGetSharedLinksIncludePath() throws Exception {
    String contentText = "includePathTest" + RUNID;
    Paging paging = getPaging(0, 100);
    Map<String, String> queryParams = new HashMap<>();
    queryParams.put("include", "path");
    // As user 1: Test the backward compatibility by checking response with and without path is consistent when no shared-links
    setRequestContext(user1);
    // Get all shared links visible to user 1
    HttpResponse response = getAll(URL_SHARED_LINKS, paging, 200);
    List<QuickShareLink> sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    // Check that the same no of items is returned with include=path
    response = getAll(URL_SHARED_LINKS, paging, queryParams, 200);
    List<QuickShareLink> sharedLinksWithPath = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    assertEquals("get /shared-links/ API returns same no of shared-links with or without include=path, when there are no shared-links", sharedLinks, sharedLinksWithPath);
    // Create Files in various locations: My Files, SharedFiles, Sites with different visibility
    // Create doc in "My Files"
    Document myFile = createTextFile(getMyNodeId(), "MyFile" + RUNID + ".txt", contentText);
    // Create doc in "Shared" folder
    Document sharedFile = createTextFile(getSharedNodeId(), "SharedFile" + RUNID + ".txt", contentText);
    // Create Sites
    Site publicSite = createSite("TestSite-Public-" + RUNID, SiteVisibility.PUBLIC);
    Site modSite = createSite("TestSite-Moderate-" + RUNID, SiteVisibility.MODERATED);
    Site privateSite = createSite("TestSite-Private-" + RUNID, SiteVisibility.PRIVATE);
    // Create file in Site Public > DocumentLibrary
    String docLibPub = getSiteContainerNodeId(publicSite.getId(), "documentLibrary");
    Document filePublic = createTextFile(docLibPub, "filePublic.txt", contentText);
    // Create files in Site Moderated > DocumentLibrary > Folder 1 and Folder 2
    String docLibMod = getSiteContainerNodeId(modSite.getId(), "documentLibrary");
    Folder folder1 = createFolder(docLibMod, "1");
    Folder folder2 = createFolder(docLibMod, "2");
    Document fileMod = createTextFile(folder1.getId(), "fileMod.txt", contentText);
    Document fileMod2 = createTextFile(folder2.getId(), "fileMod2.txt", contentText);
    // Create file in Site Private > DocumentLibrary
    String docLibPvt = getSiteContainerNodeId(privateSite.getId(), "documentLibrary");
    Document filePrivate = createTextFile(docLibPvt, "filePrivate.txt", contentText);
    // Share the files above in: My Files, SharedFiles, Sites with different visibility
    String myFileLinkId = postSharedLink(myFile);
    String sharedLinkId = postSharedLink(sharedFile);
    String filePublicLinkId = postSharedLink(filePublic);
    String fileModLinkId = postSharedLink(fileMod);
    String fileMod2LinkId = postSharedLink(fileMod2);
    String filePrivateLinkId = postSharedLink(filePrivate);
    // Grant user2: Consumer Permission for Moderated Site > File1
    List<NodePermissions.NodePermission> locallySetPermissions = new ArrayList<>();
    locallySetPermissions.add(new NodePermissions.NodePermission(user2, PermissionService.CONSUMER, AccessStatus.ALLOWED.toString()));
    NodePermissions nodePermissions = new NodePermissions();
    nodePermissions.setIsInheritanceEnabled(false);
    nodePermissions.setLocallySet(locallySetPermissions);
    Document docPermissions = new Document();
    docPermissions.setPermissions(nodePermissions);
    put(URL_NODES, fileMod.getId(), toJsonAsStringNonNull(docPermissions), null, 200);
    // Grant user2: Consumer Permission for Moderated Site > Folder 2, File2
    put(URL_NODES, fileMod2.getId(), toJsonAsStringNonNull(docPermissions), null, 200);
    Folder folderPermissions = new Folder();
    folderPermissions.setPermissions(nodePermissions);
    put(URL_NODES, folder2.getId(), toJsonAsStringNonNull(folderPermissions), null, 200);
    // Get links For User1
    setRequestContext(user1);
    response = getSingle(QuickShareLinkEntityResource.class, myFileLinkId, null, 200);
    QuickShareLink link = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
    assertNull("get /shared-links/<id> API does not return Path info by default", link.getPath());
    // Path info is not included for get shared-links/<id>
    response = getSingle(QuickShareLinkEntityResource.class, myFileLinkId, queryParams, 200);
    link = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
    assertNull("get /shared-links/<id> API ignores Path info when requested as it is a noAuth API.", link.getPath());
    response = getAll(URL_SHARED_LINKS, paging, 200);
    sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    assertEquals("API returns correct shared-links as expected: without path info", 6, sharedLinks.size());
    sharedLinks.forEach(sharedLink -> assertNull("API does not return Path info for any shared-links by default", sharedLink.getPath()));
    // Path info is included for get shared-links when requested
    response = getAll(URL_SHARED_LINKS, paging, queryParams, 200);
    sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    // Complete path info is retrieved for the user with access to the complete path
    assertEquals("API returns correct shared-links as expected: with path info", 6, sharedLinks.size());
    sharedLinks.forEach(sharedLink -> assertTrue("API returns Complete Path info for each link when requested by content owner", sharedLink.getPath().getIsComplete()));
    // Get links For User2
    setRequestContext(user2);
    response = getAll(URL_SHARED_LINKS, paging, 200);
    sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    // Path info is not included when not requested
    assertEquals("API returns correct shared-links as expected for user2: without path info", 4, sharedLinks.size());
    sharedLinks.forEach(sharedLink -> assertNull("get /shared-links/ API does not return Path info for any shared-links by default", sharedLink.getPath()));
    response = getAll(URL_SHARED_LINKS, paging, queryParams, 200);
    sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    // Path info is retrieved for the user with access to the complete path: Sorted as LIFO
    assertEquals("API returns correct shared-links as expected for user2: with path info", 4, sharedLinks.size());
    sharedLinks.forEach(sharedLink -> assertNotNull("API returns Path info for each link when requested by user2", sharedLink.getPath()));
    // Moderated Site > fileMod2: Path only includes elements where user2 has access
    QuickShareLink sharedLink = sharedLinks.get(0);
    assertEquals("Incorrect sort order or SharedLink ID for fileMod2: " + sharedLink, fileMod2LinkId, sharedLink.getId());
    PathInfo path = sharedLink.getPath();
    assertEquals("Complete Path is returned even when user2 does not have appropriate permissions. SharedLink Path: " + path, false, path.getIsComplete());
    assertEquals("Path omits immediate Parent folder Name when user has access to it. SharedLink Path: " + path, "/" + folder2.getName(), path.getName());
    assertEquals("Path omits immediate Parent folder ID when user has access to it. SharedLink Path: " + path, folder2.getId(), path.getElements().get(0).getId());
    // Moderated Site > fileMod: Path empty when user2 does not have access to the immediate parent
    sharedLink = sharedLinks.get(1);
    assertEquals("Incorrect sort order or SharedLink ID for fileMod: " + sharedLink, fileModLinkId, sharedLink.getId());
    path = sharedLink.getPath();
    assertNotNull("Path info is not included in the response when user does not have right permissions. SharedLink Path: " + path, path);
    assertNull("Path Name is returned when user does not have right permissions. SharedLink Path: " + path, path.getName());
    assertNull("Path info is returned when user does not have right permissions. SharedLink Path: " + path, path.getIsComplete());
    assertNull("Path Elements are returned when user does not have right permissions. SharedLink Path: " + path, path.getElements());
    // Public Site > filePublic: Path includes all the elements when user2 has appropriate access
    sharedLink = sharedLinks.get(2);
    assertEquals("Incorrect sort order or SharedLink ID for filePublic: " + sharedLink, filePublicLinkId, sharedLink.getId());
    path = sharedLink.getPath();
    assertEquals("Complete Path is not returned for user2 for public files. SharedLink Path: " + path, true, path.getIsComplete());
    assertEquals("Incorrect Path Name for Public Site Files. SharedLink Path: " + path, "/Company Home/Sites/" + publicSite.getId() + "/documentLibrary", path.getName());
    assertEquals("Incorrect Path Elements for Public Site Files. SharedLink Path: " + path, 4, path.getElements().size());
    assertEquals("Incorrect ID in the Path for Company Home. SharedLink Path: " + path, getRootNodeId(), path.getElements().get(0).getId());
    assertEquals("Incorrect ID in the Path for Public Site. SharedLink Path: " + path, publicSite.getGuid(), path.getElements().get(2).getId());
    assertEquals("Incorrect ID in the Path for Public Site DocLib. SharedLink Path: " + path, docLibPub, path.getElements().get(3).getId());
    // Shared Files > shared: Path includes all the elements when user2 has appropriate access
    sharedLink = sharedLinks.get(3);
    assertEquals("Incorrect sort order or SharedLink ID for sharedFiles: " + sharedLink, sharedLinkId, sharedLink.getId());
    path = sharedLink.getPath();
    assertEquals("Complete Path is not returned for user2 for shared files. SharedLink Path: " + path, true, path.getIsComplete());
    assertEquals("Incorrect Path Name for Shared Files. SharedLink Path: " + path, "/Company Home/Shared", path.getName());
    assertEquals("Incorrect Path Elements for Shared Files. SharedLink Path: " + path, 2, path.getElements().size());
    assertEquals("Incorrect ID in the Path for Company Home. SharedLink Path: " + path, getRootNodeId(), path.getElements().get(0).getId());
    assertEquals("Incorrect ID in the path for Shared Files. SharedLink Path: " + path, getSharedNodeId(), path.getElements().get(1).getId());
    // Unauthorized request returns 401
    setRequestContext(null, "UserNotKnown", DEFAULT_ADMIN_PWD);
    queryParams = new HashMap<>();
    getAll(URL_SHARED_LINKS, paging, queryParams, 401);
    // Unauthenticated request returns 401
    setRequestContext(user2, null, null);
    getAll(URL_SHARED_LINKS, paging, queryParams, 401);
    // Delete the shared links
    setRequestContext(user1);
    deleteSharedLink(myFileLinkId);
    deleteSharedLink(sharedLinkId);
    deleteSharedLink(filePublicLinkId);
    deleteSharedLink(fileModLinkId);
    deleteSharedLink(fileMod2LinkId);
    deleteSharedLink(filePrivateLinkId);
}
Also used : Site(org.alfresco.rest.api.model.Site) NodePermissions(org.alfresco.rest.api.model.NodePermissions) HashMap(java.util.HashMap) Paging(org.alfresco.rest.api.tests.client.PublicApiClient.Paging) ArrayList(java.util.ArrayList) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) Document(org.alfresco.rest.api.tests.client.data.Document) Folder(org.alfresco.rest.api.tests.client.data.Folder) QuickShareLinkEntityResource(org.alfresco.rest.api.quicksharelinks.QuickShareLinkEntityResource) PathInfo(org.alfresco.rest.api.model.PathInfo) QuickShareLink(org.alfresco.rest.api.model.QuickShareLink) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with PathInfo

use of org.alfresco.rest.api.model.PathInfo in project alfresco-remote-api by Alfresco.

the class SharedLinkApiTest method testCreateSharedLinkWithIncludeParam.

/**
 * Tests create shared-links with 'include' parameter.
 *
 * <p>POST:</p>
 * {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/shared-links?include=path}
 * {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/shared-links?include=allowableOperations}
 * {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/shared-links?include=path,allowableOperations}
 */
@Test
@Category({ LuceneTests.class, RedundantTests.class })
public void testCreateSharedLinkWithIncludeParam() throws Exception {
    String content = "The quick brown fox jumps over the lazy dog.";
    String fileName1 = "fileOne_" + RUNID + ".txt";
    String fileName2 = "fileTwo_" + RUNID + ".txt";
    String fileName3 = "fileThree_" + RUNID + ".txt";
    // As user 1 create 3 text files in -my- folder (i.e. User's Home)
    setRequestContext(user1);
    String doc1Id = createTextFile(getMyNodeId(), fileName1, content).getId();
    String doc2Id = createTextFile(getMyNodeId(), fileName2, content).getId();
    String doc3Id = createTextFile(getMyNodeId(), fileName3, content).getId();
    // Share the 'fileName1' doc and use the query parameter 'include=path' to return path information
    QuickShareLink body = new QuickShareLink();
    body.setNodeId(doc1Id);
    HttpResponse response = post(URL_SHARED_LINKS, RestApiUtil.toJsonAsString(body), "?include=path", 201);
    QuickShareLink quickShareLinkResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
    PathInfo pathInfo = quickShareLinkResponse.getPath();
    assertNotNull("API returns Path info when requested upon creation.", pathInfo);
    assertTrue("IsComplete should have been true for user1.", pathInfo.getIsComplete());
    assertEquals("Incorrect number of path elements.", 3, pathInfo.getElements().size());
    assertEquals("Incorrect path name.", "/Company Home/User Homes/" + user1, pathInfo.getName());
    assertEquals("Incorrect path element.", getRootNodeId(), pathInfo.getElements().get(0).getId());
    assertEquals("Incorrect path element.", "Company Home", pathInfo.getElements().get(0).getName());
    assertEquals("Incorrect path element", "User Homes", pathInfo.getElements().get(1).getName());
    assertEquals("Incorrect path element.", getMyNodeId(), pathInfo.getElements().get(2).getId());
    assertEquals("Incorrect path element.", user1, pathInfo.getElements().get(2).getName());
    // Share the 'fileName2' doc and use the query parameter 'include=allowableOperations' to return allowableOperations information
    body.setNodeId(doc2Id);
    response = post(URL_SHARED_LINKS, RestApiUtil.toJsonAsString(body), "?include=allowableOperations", 201);
    quickShareLinkResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
    List<String> allowableOperations = quickShareLinkResponse.getAllowableOperations();
    assertNotNull("'allowableOperations' should have been returned.", allowableOperations);
    assertEquals("allowableOperations should only have 'Delete' as allowable operation.", 1, allowableOperations.size());
    assertEquals("Incorrect allowable operation.", "delete", allowableOperations.get(0));
    // Share the 'fileName3' doc and use the query parameter 'include=path,allowableOperations' to return path and allowableOperations information
    body.setNodeId(doc3Id);
    response = post(URL_SHARED_LINKS, RestApiUtil.toJsonAsString(body), "?include=path,allowableOperations", 201);
    quickShareLinkResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), QuickShareLink.class);
    // Check Path info
    pathInfo = quickShareLinkResponse.getPath();
    assertNotNull("'path' should have been returned.", pathInfo);
    assertTrue("IsComplete should have been true for user1.", pathInfo.getIsComplete());
    assertEquals("Incorrect number of path elements.", 3, pathInfo.getElements().size());
    assertEquals("Incorrect path name.", "/Company Home/User Homes/" + user1, pathInfo.getName());
    // Check allowableOperations (i.e. the shared link)
    allowableOperations = quickShareLinkResponse.getAllowableOperations();
    assertNotNull("'allowableOperations' should have been returned.", allowableOperations);
    assertEquals("allowableOperations should only have 'Delete' as allowable operation.", 1, allowableOperations.size());
    assertEquals("Incorrect allowable operation.", "delete", allowableOperations.get(0));
    // Check allowableOperationsOnTarget (i.e. for the actual file being shared)
    allowableOperations = quickShareLinkResponse.getAllowableOperationsOnTarget();
    assertNotNull("'allowableOperationsOnTarget' should have been returned.", allowableOperations);
    Collection<String> expectedOps = Arrays.asList("delete", "update", "updatePermissions");
    assertTrue(allowableOperations.containsAll(expectedOps));
    assertEquals(expectedOps.size(), allowableOperations.size());
    assertEquals("Incorrect allowable operation.", "delete", allowableOperations.get(0));
    // Test that listing shared links also support the include parameter.
    Paging paging = getPaging(0, 100);
    response = getAll(URL_SHARED_LINKS, paging, Collections.singletonMap("include", "path,allowableOperations"), 200);
    List<QuickShareLink> sharedLinks = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), QuickShareLink.class);
    assertEquals("Incorrect number of shared-links returned.", 3, sharedLinks.size());
    sharedLinks.forEach(sharedLink -> {
        // Check Path info
        PathInfo path = sharedLink.getPath();
        assertNotNull("'path' should have been returned.", path);
        assertTrue("IsComplete should have been true for user1.", path.getIsComplete());
        assertEquals("Incorrect number of path elements.", 3, path.getElements().size());
        assertEquals("Incorrect path name.", "/Company Home/User Homes/" + user1, path.getName());
        // Check allowableOperations
        List<String> operations = sharedLink.getAllowableOperations();
        assertNotNull("'allowableOperations' should have been returned.", operations);
        assertEquals("allowableOperations should only have 'Delete' as allowable operation.", 1, operations.size());
        assertEquals("Incorrect allowable operation.", "delete", operations.get(0));
        // Check allowableOperationsOnTarget (i.e. for the actual file being shared)
        operations = sharedLink.getAllowableOperationsOnTarget();
        assertNotNull("'allowableOperationsOnTarget' should have been returned.", operations);
        assertTrue(operations.containsAll(expectedOps));
        assertEquals(expectedOps.size(), operations.size());
        assertEquals("Incorrect allowable operation.", "delete", operations.get(0));
        // Quick check that some extended info is present.
        assertEquals("The quick brown fox jumps over the lazy dog", sharedLink.getTitle());
        assertEquals("Gym class featuring a brown fox and lazy dog", sharedLink.getDescription());
    });
}
Also used : Paging(org.alfresco.rest.api.tests.client.PublicApiClient.Paging) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) PathInfo(org.alfresco.rest.api.model.PathInfo) QuickShareLink(org.alfresco.rest.api.model.QuickShareLink) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 3 with PathInfo

use of org.alfresco.rest.api.model.PathInfo in project records-management by Alfresco.

the class FilePlanComponentsApiUtils method lookupPathInfo.

protected PathInfo lookupPathInfo(NodeRef nodeRefIn) {
    List<ElementInfo> pathElements = new ArrayList<>();
    Boolean isComplete = Boolean.TRUE;
    final Path nodePath = nodeService.getPath(nodeRefIn);
    ;
    final int pathIndex = 2;
    for (int i = nodePath.size() - pathIndex; i >= 0; i--) {
        Element element = nodePath.get(i);
        if (element instanceof Path.ChildAssocElement) {
            ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
            if (elementRef.getParentRef() != null) {
                NodeRef childNodeRef = elementRef.getChildRef();
                if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED) {
                    Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
                    pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString()));
                } else {
                    // Just return the pathInfo up to the location where the user has access
                    isComplete = Boolean.FALSE;
                    break;
                }
            }
        }
    }
    String pathStr = null;
    if (!pathElements.isEmpty()) {
        StringBuilder sb = new StringBuilder(120);
        for (PathInfo.ElementInfo e : pathElements) {
            sb.append("/").append(e.getName());
        }
        pathStr = sb.toString();
    } else {
        // There is no path element, so set it to null in order to be
        // ignored by Jackson during serialisation
        isComplete = null;
    }
    return new PathInfo(pathStr, isComplete, pathElements);
}
Also used : Path(org.alfresco.service.cmr.repository.Path) Serializable(java.io.Serializable) ElementInfo(org.alfresco.rest.api.model.PathInfo.ElementInfo) Element(org.alfresco.service.cmr.repository.Path.Element) ElementInfo(org.alfresco.rest.api.model.PathInfo.ElementInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) PathInfo(org.alfresco.rest.api.model.PathInfo) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean)

Example 4 with PathInfo

use of org.alfresco.rest.api.model.PathInfo in project alfresco-remote-api by Alfresco.

the class FavouritesImpl method setPathInfo.

private void setPathInfo(Node node, List<String> includeParam) {
    if (includeParam.contains(PARAM_INCLUDE_PATH)) {
        PathInfo pathInfo = nodes.lookupPathInfo(node.getNodeRef(), null);
        node.setPath(pathInfo);
    }
}
Also used : PathInfo(org.alfresco.rest.api.model.PathInfo)

Example 5 with PathInfo

use of org.alfresco.rest.api.model.PathInfo in project alfresco-remote-api by Alfresco.

the class NodesImpl method lookupPathInfo.

@Override
public PathInfo lookupPathInfo(NodeRef nodeRefIn, ChildAssociationRef archivedParentAssoc) {
    List<ElementInfo> pathElements = new ArrayList<>();
    Boolean isComplete = Boolean.TRUE;
    final Path nodePath;
    final int pathIndex;
    if (archivedParentAssoc != null) {
        if (permissionService.hasPermission(archivedParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED) && nodeService.exists(archivedParentAssoc.getParentRef())) {
            nodePath = nodeService.getPath(archivedParentAssoc.getParentRef());
            // 1 => we want to include the given node in the path as well.
            pathIndex = 1;
        } else {
            // We can't return a valid path
            return null;
        }
    } else {
        nodePath = nodeService.getPath(nodeRefIn);
        // 2 => as we don't want to include the given node in the path as well.
        pathIndex = 2;
    }
    for (int i = nodePath.size() - pathIndex; i >= 0; i--) {
        Element element = nodePath.get(i);
        if (element instanceof Path.ChildAssocElement) {
            ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
            if (elementRef.getParentRef() != null) {
                NodeRef childNodeRef = elementRef.getChildRef();
                if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED) {
                    Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
                    String type = getNodeType(childNodeRef).toPrefixString(namespaceService);
                    Set<QName> aspects = nodeService.getAspects(childNodeRef);
                    List<String> aspectNames = mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS);
                    pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString(), type, aspectNames));
                } else {
                    // Just return the pathInfo up to the location where the user has access
                    isComplete = Boolean.FALSE;
                    break;
                }
            }
        }
    }
    String pathStr = null;
    if (pathElements.size() > 0) {
        StringBuilder sb = new StringBuilder(120);
        for (PathInfo.ElementInfo e : pathElements) {
            sb.append("/").append(e.getName());
        }
        pathStr = sb.toString();
    } else {
        // There is no path element, so set it to null in order to be
        // ignored by Jackson during serialisation
        isComplete = null;
    }
    return new PathInfo(pathStr, isComplete, pathElements);
}
Also used : Path(org.alfresco.service.cmr.repository.Path) Serializable(java.io.Serializable) ElementInfo(org.alfresco.rest.api.model.PathInfo.ElementInfo) QName(org.alfresco.service.namespace.QName) Element(org.alfresco.service.cmr.repository.Path.Element) ElementInfo(org.alfresco.rest.api.model.PathInfo.ElementInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) PathInfo(org.alfresco.rest.api.model.PathInfo) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean)

Aggregations

PathInfo (org.alfresco.rest.api.model.PathInfo)6 ArrayList (java.util.ArrayList)4 Serializable (java.io.Serializable)3 FilterPropBoolean (org.alfresco.repo.node.getchildren.FilterPropBoolean)3 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)3 HashMap (java.util.HashMap)2 NodePermissions (org.alfresco.rest.api.model.NodePermissions)2 ElementInfo (org.alfresco.rest.api.model.PathInfo.ElementInfo)2 QuickShareLink (org.alfresco.rest.api.model.QuickShareLink)2 HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)2 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 Path (org.alfresco.service.cmr.repository.Path)2 Element (org.alfresco.service.cmr.repository.Path.Element)2 QName (org.alfresco.service.namespace.QName)2 Test (org.junit.Test)2 Category (org.junit.experimental.categories.Category)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ActivityType (org.alfresco.repo.activities.ActivityType)1 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)1