Search in sources :

Example 11 with Folder

use of org.alfresco.rest.api.tests.client.data.Folder in project alfresco-remote-api by Alfresco.

the class NodeApiTest method testCopySite.

@Test
public void testCopySite() throws Exception {
    setRequestContext(user1);
    // create folder
    Folder folderResp = createFolder(Nodes.PATH_MY, "siteCopytarget");
    String targetId = folderResp.getId();
    Map<String, String> body = new HashMap<>();
    body.put("targetParentId", targetId);
    // test that you can't copy a site
    HttpResponse response = getSingle("sites", tSiteId, null, null, 200);
    Site siteResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Site.class);
    String siteNodeId = siteResp.getGuid();
    post("nodes/" + siteNodeId + "/copy", toJsonAsStringNonNull(body), null, 422);
    // test that you can't copy a site doclib
    post("nodes/" + tDocLibNodeId + "/copy", toJsonAsStringNonNull(body), null, 422);
}
Also used : Site(org.alfresco.rest.api.model.Site) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) Folder(org.alfresco.rest.api.tests.client.data.Folder) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Example 12 with Folder

use of org.alfresco.rest.api.tests.client.data.Folder in project alfresco-remote-api by Alfresco.

the class NodeApiTest method testUpdateOwner.

/**
 * Tests update owner (file or folder)
 * <p>PUT:</p>
 * {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>}
 */
@Test
public void testUpdateOwner() throws Exception {
    setRequestContext(user1);
    // create folder f0
    String folderName = "f0-testUpdateOwner-" + RUNID;
    Folder folderResp = createFolder(Nodes.PATH_SHARED, folderName);
    String f0Id = folderResp.getId();
    // owner is implied
    assertNull(user1, folderResp.getProperties());
    // explicitly set owner to oneself
    Map<String, Object> props = new HashMap<>();
    props.put(PROP_OWNER, user1);
    Folder fUpdate = new Folder();
    fUpdate.setProperties(props);
    HttpResponse response = put(URL_NODES, f0Id, toJsonAsStringNonNull(fUpdate), null, 200);
    folderResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Folder.class);
    assertEquals(user1, ((Map) folderResp.getProperties().get(PROP_OWNER)).get("id"));
    // create doc d1
    String d1Name = "content1 " + RUNID;
    String d1Id = createTextFile(f0Id, d1Name, "The quick brown fox jumps over the lazy dog.").getId();
    // get node info
    response = getSingle(NodesEntityResource.class, d1Id, null, 200);
    Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    // note: owner is implied
    assertEquals(2, documentResp.getProperties().size());
    assertEquals("1.0", documentResp.getProperties().get("cm:versionLabel"));
    assertEquals("MAJOR", documentResp.getProperties().get("cm:versionType"));
    props = new HashMap<>();
    props.put(PROP_OWNER, user1);
    Document dUpdate = new Document();
    dUpdate.setProperties(props);
    response = put(URL_NODES, d1Id, toJsonAsStringNonNull(dUpdate), null, 200);
    documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(user1, ((Map) documentResp.getProperties().get(PROP_OWNER)).get("id"));
    // -ve test - cannot set owner to a nonexistent user
    props = new HashMap<>();
    props.put(PROP_OWNER, "unknownusernamedoesnotexist");
    dUpdate = new Document();
    dUpdate.setProperties(props);
    put(URL_NODES, d1Id, toJsonAsStringNonNull(dUpdate), null, 400);
    setRequestContext(user2);
    response = getSingle(URL_NODES, d1Id, 200);
    documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(user1, ((Map) documentResp.getProperties().get(PROP_OWNER)).get("id"));
    // -ve test - cannot take/change ownership
    props = new HashMap<>();
    props.put(PROP_OWNER, user2);
    dUpdate = new Document();
    dUpdate.setProperties(props);
    put(URL_NODES, d1Id, toJsonAsStringNonNull(dUpdate), null, 403);
    props = new HashMap<>();
    props.put(PROP_OWNER, user1);
    dUpdate = new Document();
    dUpdate.setProperties(props);
    put(URL_NODES, d1Id, toJsonAsStringNonNull(dUpdate), null, 403);
    setRequestContext(user1);
    props = new HashMap<>();
    props.put(PROP_OWNER, user2);
    dUpdate = new Document();
    dUpdate.setProperties(props);
    response = put(URL_NODES, d1Id, toJsonAsStringNonNull(dUpdate), null, 200);
    documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(user2, ((Map) documentResp.getProperties().get(PROP_OWNER)).get("id"));
    setRequestContext(user2);
    response = getSingle(URL_NODES, d1Id, 200);
    documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(user2, ((Map) documentResp.getProperties().get(PROP_OWNER)).get("id"));
    // -ve test - user2 cannot delete the test folder/file - TODO is that expected ?
    setRequestContext(user2);
    deleteNode(f0Id, 403);
    setRequestContext(user1);
    deleteNode(f0Id);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) JSONObject(org.json.simple.JSONObject) NodesEntityResource(org.alfresco.rest.api.nodes.NodesEntityResource) Folder(org.alfresco.rest.api.tests.client.data.Folder) Document(org.alfresco.rest.api.tests.client.data.Document) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Example 13 with Folder

use of org.alfresco.rest.api.tests.client.data.Folder in project alfresco-remote-api by Alfresco.

the class NodeApiTest method testMove.

/**
 * Tests move (file or folder)
 * <p>POST:</p>
 * {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/move}
 */
@Test
public void testMove() throws Exception {
    setRequestContext(user1);
    // create folder f0
    String folder0Name = "f0-testMove-" + RUNID;
    String f0Id = createFolder(Nodes.PATH_MY, folder0Name).getId();
    // create folder f1
    Folder folderResp = createFolder(f0Id, "f1");
    String f1Id = folderResp.getId();
    // create folder f2
    folderResp = createFolder(f0Id, "f2");
    String f2Id = folderResp.getId();
    // create doc d1
    String d1Name = "content" + RUNID + "_1";
    String d1Id = createTextFile(f1Id, d1Name, "The quick brown fox jumps over the lazy dog 1.").getId();
    // create doc d2
    String d2Name = "content" + RUNID + "_2";
    String d2Id = createTextFile(f2Id, d2Name, "The quick brown fox jumps over the lazy dog 2.").getId();
    // move file (without rename)
    NodeTarget tgt = new NodeTarget();
    tgt.setTargetParentId(f2Id);
    HttpResponse response = post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 200);
    Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(d1Name, documentResp.getName());
    assertEquals(f2Id, documentResp.getParentId());
    // move file (with rename)
    String d1NewName = d1Name + " updated !!";
    tgt = new NodeTarget();
    tgt.setName(d1NewName);
    tgt.setTargetParentId(f1Id);
    response = post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 200);
    documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
    assertEquals(d1NewName, documentResp.getName());
    assertEquals(f1Id, documentResp.getParentId());
    // -ve tests
    // missing target
    tgt = new NodeTarget();
    tgt.setName("new name");
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 400);
    // name already exists
    tgt = new NodeTarget();
    tgt.setName(d2Name);
    tgt.setTargetParentId(f2Id);
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 409);
    // unknown source nodeId
    tgt = new NodeTarget();
    tgt.setTargetParentId(f2Id);
    post("nodes/" + UUID.randomUUID().toString() + "/move", toJsonAsStringNonNull(tgt), null, 404);
    // unknown target nodeId
    tgt = new NodeTarget();
    tgt.setTargetParentId(UUID.randomUUID().toString());
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 404);
    // target is not a folder
    tgt = new NodeTarget();
    tgt.setTargetParentId(d2Id);
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 400);
    String rootNodeId = getRootNodeId();
    // create folder f3 (sub-folder of f2)
    folderResp = createFolder(f2Id, "f3");
    String f3Id = folderResp.getId();
    // can't create cycle (move into own subtree)
    tgt = new NodeTarget();
    tgt.setTargetParentId(f3Id);
    post("nodes/" + f2Id + "/move", toJsonAsStringNonNull(tgt), null, 400);
    // no (write/create) permissions to move to target
    tgt = new NodeTarget();
    tgt.setTargetParentId(rootNodeId);
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(tgt), null, 403);
    setRequestContext(user2);
    String my2NodeId = getMyNodeId();
    // no (write/delete) permissions to move source
    tgt = new NodeTarget();
    tgt.setTargetParentId(my2NodeId);
    post("nodes/" + f1Id + "/move", toJsonAsStringNonNull(tgt), null, 403);
    // -ve - cannot move (delete) Company Home root node
    setRequestContext(networkAdmin);
    post("nodes/" + rootNodeId + "/move", toJsonAsStringNonNull(tgt), null, 403);
    setRequestContext(user1);
    Map params = new HashMap<>();
    params.put(Nodes.PARAM_RELATIVE_PATH, "/Sites");
    response = getSingle(NodesEntityResource.class, rootNodeId, params, 200);
    Node nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
    String sitesNodeId = nodeResp.getId();
    // -ve - cannot move (delete) Sites node
    setRequestContext(networkAdmin);
    post("nodes/" + sitesNodeId + "/move", toJsonAsStringNonNull(tgt), null, 403);
    setRequestContext(user1);
    params = new HashMap<>();
    params.put(Nodes.PARAM_RELATIVE_PATH, "/Data Dictionary");
    response = getSingle(NodesEntityResource.class, rootNodeId, params, 200);
    nodeResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
    String ddNodeId = nodeResp.getId();
    // -ve - cannot move (delete) Data Dictionary node
    setRequestContext(networkAdmin);
    post("nodes/" + ddNodeId + "/move", toJsonAsStringNonNull(tgt), null, 403);
    // -ve test - cannot move to multiple destinations in single POST call (unsupported)
    List<NodeTarget> nodeDestinations = new ArrayList<>(2);
    NodeTarget nodeTarget = new NodeTarget();
    nodeTarget.setTargetParentId(f1Id);
    nodeDestinations.add(nodeTarget);
    nodeTarget = new NodeTarget();
    nodeTarget.setTargetParentId(f2Id);
    nodeDestinations.add(nodeTarget);
    post("nodes/" + d1Id + "/move", toJsonAsStringNonNull(nodeDestinations), null, 405);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Node(org.alfresco.rest.api.tests.client.data.Node) ArrayList(java.util.ArrayList) NodeTarget(org.alfresco.rest.api.model.NodeTarget) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) NodesEntityResource(org.alfresco.rest.api.nodes.NodesEntityResource) Folder(org.alfresco.rest.api.tests.client.data.Folder) Document(org.alfresco.rest.api.tests.client.data.Document) MultiValueMap(org.apache.commons.collections.map.MultiValueMap) Map(java.util.Map) MimetypeMap(org.alfresco.repo.content.MimetypeMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Example 14 with Folder

use of org.alfresco.rest.api.tests.client.data.Folder in project alfresco-remote-api by Alfresco.

the class TestDownloads method setupTest.

@Before
public void setupTest() throws IOException, Exception {
    nodesApi = applicationContext.getBean("Nodes", org.alfresco.rest.api.Nodes.class);
    setRequestContext(user1);
    Document zippableDoc1 = createTextFile(tDocLibNodeId, ZIPPABLE_DOC1_NAME, DUMMY_CONTENT);
    zippableDocId1 = zippableDoc1.getId();
    zippableDocId2 = createTextFile(tDocLibNodeId, "docTest2", DUMMY_CONTENT).getId();
    Folder zippableFolder1 = createFolder(tDocLibNodeId, FOLDER1_NAME);
    zippableFolderId1 = zippableFolder1.getId();
    zippableDocId3_InFolder1 = createTextFile(zippableFolderId1, DOC3_NAME, DUMMY_CONTENT).getId();
    Folder zippableFolder2_InFolder1 = createFolder(zippableFolderId1, SUB_FOLDER1_NAME);
    zippableFolderId2_InFolder1 = zippableFolder2_InFolder1.getId();
    zippableDocId4_InFolder2 = createTextFile(zippableFolderId2_InFolder1, DOC4_NAME, DUMMY_CONTENT).getId();
    Folder zippableFolder3 = createFolder(tDocLibNodeId, FOLDER3_NAME);
    zippableFolderId3 = zippableFolder3.getId();
    setRequestContext(user2);
    String user2Site = createSite("TestSite B - " + RUNID, SiteVisibility.PRIVATE).getId();
    String user2DocLib = getSiteContainerNodeId(user2Site, "documentLibrary");
    zippableDoc_user2 = createTextFile(user2DocLib, "user2doc", DUMMY_CONTENT).getId();
    setRequestContext(user1);
    AssocChild secChild = new AssocChild(zippableDoc1.getId(), ASSOC_TYPE_CM_CONTAINS);
    post(format(NODES_SECONDARY_CHILDREN, zippableFolder3.getId()), toJsonAsStringNonNull(secChild), HttpServletResponse.SC_CREATED);
}
Also used : AssocChild(org.alfresco.rest.api.model.AssocChild) Document(org.alfresco.rest.api.tests.client.data.Document) Folder(org.alfresco.rest.api.tests.client.data.Folder) Before(org.junit.Before)

Example 15 with Folder

use of org.alfresco.rest.api.tests.client.data.Folder 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) FavouriteDocument(org.alfresco.rest.api.tests.client.data.FavouriteDocument) 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)

Aggregations

Folder (org.alfresco.rest.api.tests.client.data.Folder)37 Test (org.junit.Test)34 HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)31 Document (org.alfresco.rest.api.tests.client.data.Document)29 AbstractSingleNetworkSiteTest (org.alfresco.rest.AbstractSingleNetworkSiteTest)28 HashMap (java.util.HashMap)20 LinkedHashMap (java.util.LinkedHashMap)19 NodesEntityResource (org.alfresco.rest.api.nodes.NodesEntityResource)12 Node (org.alfresco.rest.api.tests.client.data.Node)12 JSONObject (org.json.simple.JSONObject)10 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)8 ContentInfo (org.alfresco.rest.api.tests.client.data.ContentInfo)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 PublicApiClient (org.alfresco.rest.api.tests.client.PublicApiClient)6 UserInfo (org.alfresco.rest.api.tests.client.data.UserInfo)6 Date (java.util.Date)5 MultiValueMap (org.apache.commons.collections.map.MultiValueMap)5 RandomAccessFile (java.io.RandomAccessFile)4 Map (java.util.Map)4