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);
// 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
// parent node as parentId)
Node node = getFolderOrDocument(fInfo.getNodeRef(), null, fInfo.getType(), includeParam, mapUserInfo);
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
{
// get the path elements
@@ -1350,9 +1355,6 @@ public class NodesImpl implements Nodes
}
}
return node;
}
@Override
public int size()
{

View File

@@ -4346,11 +4346,10 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
/**
* Test upload using relativePath
* @throws Exception
*
*/
@Test
public void testUploadUsingRelativePath() throws Exception{
public void testUploadUsingRelativePath() throws Exception
{
setRequestContext(user1);
// 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");
// /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_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_Id = createFolder(folderA_Id, folderB).getId();
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_Id = createFolder(folderB_Id, folderC).getId();
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_Id = createTextFile(folderC_Id, content, "The quick brown fox jumps over the lazy dog.").getId();
Map<String, String> params = new HashMap<>();
params.put("include", "path");
params.put("relativePath", folderA + "/" + folderB + "/" + folderC);
//call get with relativePathParam
// call get with relativePathParam
HttpResponse response = getAll(getNodeChildrenUrl(site1DocLibNodeId), null, params, 200);
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
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
*
@@ -4822,6 +4823,5 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
return "public";
}
}