REPO-1742 : changes after review

This commit is contained in:
Andreea Nechifor
2018-02-14 10:32:55 +02:00
parent e101421284
commit 42ff904ec8
2 changed files with 53 additions and 51 deletions

View File

@@ -1311,15 +1311,20 @@ public class NodesImpl implements Nodes
FileInfo fInfo = page.get(index); FileInfo fInfo = page.get(index);
// minimal info by default (unless "include"d otherwise) // minimal info by default (unless "include"d otherwise)
// (pass in null as parentNodeRef to force loading of primary
// parent node as parentId)
// (pass in null as parentNodeRef to force loading of primary // (pass in null as parentNodeRef to force loading of primary
// parent node as parentId) // parent node as parentId)
Node node = getFolderOrDocument(fInfo.getNodeRef(), null, fInfo.getType(), includeParam, mapUserInfo); Node node = getFolderOrDocument(fInfo.getNodeRef(), null, fInfo.getType(), includeParam, mapUserInfo);
if (node.getPath() != null) if (node.getPath() != null)
{ {
NodeRef rootNodeRef = validateOrLookupNode(parentFolderNodeId,null); calculateRelativePath(parentFolderNodeId, node);
}
return node;
}
private void calculateRelativePath(String parentFolderNodeId, Node node)
{
NodeRef rootNodeRef = validateOrLookupNode(parentFolderNodeId, null);
try try
{ {
// get the path elements // get the path elements
@@ -1350,9 +1355,6 @@ public class NodesImpl implements Nodes
} }
} }
return node;
}
@Override @Override
public int size() public int size()
{ {

View File

@@ -4346,11 +4346,10 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
/** /**
* Test upload using relativePath * Test upload using relativePath
* @throws Exception
*
*/ */
@Test @Test
public void testUploadUsingRelativePath() throws Exception{ public void testUploadUsingRelativePath() throws Exception
{
setRequestContext(user1); setRequestContext(user1);
// user1 creates a private site and adds user2 as a site consumer // user1 creates a private site and adds user2 as a site consumer
@@ -4360,38 +4359,40 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
String site1DocLibNodeId = getSiteContainerNodeId(site1Id, "documentLibrary"); String site1DocLibNodeId = getSiteContainerNodeId(site1Id, "documentLibrary");
// /Company Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A // /Company
// Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A
String folderA = "folder" + RUNID + "_A"; String folderA = "folder" + RUNID + "_A";
String folderA_Id = createFolder(site1DocLibNodeId, folderA).getId(); String folderA_Id = createFolder(site1DocLibNodeId, folderA).getId();
// /Company Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B // /Company
// Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B
String folderB = "folder" + RUNID + "_B"; String folderB = "folder" + RUNID + "_B";
String folderB_Id = createFolder(folderA_Id, folderB).getId(); String folderB_Id = createFolder(folderA_Id, folderB).getId();
NodeRef folderB_Ref = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderB_Id); NodeRef folderB_Ref = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderB_Id);
// /Company Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B/folder<timestamp>_C // /Company
// Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B/folder<timestamp>_C
String folderC = "folder" + RUNID + "_C"; String folderC = "folder" + RUNID + "_C";
String folderC_Id = createFolder(folderB_Id, folderC).getId(); String folderC_Id = createFolder(folderB_Id, folderC).getId();
NodeRef folderC_Ref = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderC_Id); NodeRef folderC_Ref = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderC_Id);
// /Company Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B/folder<timestamp>_C/content<timestamp> // /Company
// Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/folder<timestamp>_B/folder<timestamp>_C/content<timestamp>
String content = "content" + RUNID; String content = "content" + RUNID;
String content_Id = createTextFile(folderC_Id, content, "The quick brown fox jumps over the lazy dog.").getId(); String content_Id = createTextFile(folderC_Id, content, "The quick brown fox jumps over the lazy dog.").getId();
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("include", "path"); params.put("include", "path");
params.put("relativePath", folderA + "/" + folderB + "/" + folderC); params.put("relativePath", folderA + "/" + folderB + "/" + folderC);
//call get with relativePathParam // call get with relativePathParam
HttpResponse response = getAll(getNodeChildrenUrl(site1DocLibNodeId), null, params, 200); HttpResponse response = getAll(getNodeChildrenUrl(site1DocLibNodeId), null, params, 200);
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class); List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
assertEquals(1, nodes.size()); assertEquals(1, nodes.size());
assertEquals("/" + folderA + "/" + folderB + "/" + folderC,((Node)(nodes.get(0))).getPath().getRelativePath()); assertEquals("/" + folderA + "/" + folderB + "/" + folderC, ((Node) (nodes.get(0))).getPath().getRelativePath());
} }
/** /**
* Test update permission on a node * Test update permission on a node
* *
@@ -4822,6 +4823,5 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
return "public"; return "public";
} }
} }