Merged HEAD (5.2) to 5.2.N (5.2.1)

126550 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      124200 jvonka: RA-869: Remove "include" processing from "includeSource" entity for /nodes/nodeId/children endpoint


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126896 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 12:07:27 +00:00
parent 7b4e9153d4
commit 8d6a950702
4 changed files with 38 additions and 19 deletions

View File

@@ -732,15 +732,23 @@ public class NodesImpl implements Nodes
}
private Node getFolderOrDocumentFullInfo(NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, Parameters parameters)
{
return getFolderOrDocumentFullInfo(nodeRef, parentNodeRef, nodeTypeQName, parameters, null);
}
private Node getFolderOrDocumentFullInfo(NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, Parameters parameters, Map<String,UserInfo> mapUserInfo)
{
List<String> includeParam = new ArrayList<>();
if (parameters != null)
{
includeParam.addAll(parameters.getInclude());
}
// Add basic info for single get (above & beyond minimal that is used for listing collections)
includeParam.add(PARAM_INCLUDE_ASPECTNAMES);
includeParam.add(PARAM_INCLUDE_PROPERTIES);
return getFolderOrDocument(nodeRef, parentNodeRef, nodeTypeQName, includeParam, null);
return getFolderOrDocument(nodeRef, parentNodeRef, nodeTypeQName, includeParam, mapUserInfo);
}
private Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List<String> includeParam, Map<String,UserInfo> mapUserInfo)
@@ -866,7 +874,7 @@ public class NodesImpl implements Nodes
if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED)
{
Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
pathElements.add(0, new ElementInfo(childNodeRef, nameProp.toString()));
pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString()));
}
else
{
@@ -1169,10 +1177,9 @@ public class NodesImpl implements Nodes
Node sourceEntity = null;
if (parameters.includeSource())
{
sourceEntity = getFolderOrDocument(parentNodeRef, null, null, includeParam, mapUserInfo);
sourceEntity = getFolderOrDocumentFullInfo(parentNodeRef, null, null, null, mapUserInfo);
}
return CollectionWithPagingInfo.asPaged(paging, nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
}

View File

@@ -73,14 +73,14 @@ public class PathInfo
public static class ElementInfo
{
private NodeRef id;
private String id;
private String name;
public ElementInfo()
{
}
public ElementInfo(NodeRef id, String name)
public ElementInfo(String id, String name)
{
this.id = id;
this.name = name;
@@ -91,7 +91,7 @@ public class PathInfo
return name;
}
public NodeRef getId()
public String getId()
{
return id;
}

View File

@@ -478,17 +478,29 @@ public class NodeApiTest extends AbstractBaseApiTest
params = new HashMap<>();
params.put(Nodes.PARAM_RELATIVE_PATH, "User Homes/" + user1 + "/" + folder2);
params.put("includeSource", "true");
params.put("include", "path,isLink");
params.put("fields", "id");
response = getAll(rootChildrenUrl, user1, paging, params, 200);
jsonResponse = response.getJsonResponse();
nodes = RestApiUtil.parseRestApiEntries(jsonResponse, Document.class);
assertEquals(1, nodes.size());
assertEquals(contentF2_Id, nodes.get(0).getId());
Document doc = nodes.get(0);
assertEquals(contentF2_Id, doc.getId());
assertNotNull(doc.getPath());
assertEquals(Boolean.FALSE, doc.getIsLink());
assertNull(doc.getName());
jsonList = (JSONObject)jsonResponse.get("list");
assertNotNull(jsonList);
// source is not affected by include (or fields for that matter) - returns the default node response
Folder src = RestApiUtil.parsePojo("source", jsonList, Folder.class);
assertEquals(folder2_Id, src.getId());
assertNull(src.getPath());
assertNull(src.getIsLink());
assertNotNull(src.getName());
assertNotNull(src.getAspectNames());
assertNotNull(src.getProperties());
// -ve test - Invalid QName (Namespace prefix cm... is not mapped to a namespace URI) for the orderBy parameter.
params = Collections.singletonMap("orderBy", Nodes.PARAM_ISFOLDER+" DESC,cm" + System.currentTimeMillis() + ":modified DESC");
@@ -614,7 +626,7 @@ public class NodeApiTest extends AbstractBaseApiTest
HttpResponse response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_ROOT, null, 200);
Node node = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
NodeRef companyHomeNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node.getId());
String rootNodeId = node.getId();
response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_MY, null, 200);
node = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
@@ -685,11 +697,11 @@ public class NodeApiTest extends AbstractBaseApiTest
// Expected path ...
// note: the pathInfo should only include the parents (not the requested node)
List<ElementInfo> elements = new ArrayList<>(5);
elements.add(new ElementInfo(companyHomeNodeRef, "Company Home"));
elements.add(new ElementInfo(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, userHomesId), "User Homes"));
elements.add(new ElementInfo(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, myFilesNodeId), user1));
elements.add(new ElementInfo(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderA_Id), folderA));
elements.add(new ElementInfo(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderB_Id), folderB));
elements.add(new ElementInfo(rootNodeId, "Company Home"));
elements.add(new ElementInfo(userHomesId, "User Homes"));
elements.add(new ElementInfo(myFilesNodeId, user1));
elements.add(new ElementInfo(folderA_Id, folderA));
elements.add(new ElementInfo(folderB_Id, folderB));
PathInfo expectedPath = new PathInfo("/Company Home/User Homes/"+user1+"/"+folderA+"/"+folderB, true, elements);
d1.setPath(expectedPath);
@@ -1093,7 +1105,7 @@ public class NodeApiTest extends AbstractBaseApiTest
assertNotNull(elementInfos);
// /Company Home/Sites/RandomSite<timestamp>/documentLibrary/folder<timestamp>_A/X/Y/Z
assertEquals(8, elementInfos.size());
assertEquals(document.getParentId(), elementInfos.get(7).getId().getId());
assertEquals(document.getParentId(), elementInfos.get(7).getId());
assertEquals("Z", elementInfos.get(7).getName());
assertEquals("Y", elementInfos.get(6).getName());
assertEquals("X", elementInfos.get(5).getName());

View File

@@ -67,14 +67,14 @@ public class PathInfo
public static class ElementInfo
{
private NodeRef id;
private String id;
private String name;
public ElementInfo()
{
}
public ElementInfo(NodeRef id, String name)
public ElementInfo(String id, String name)
{
this.id = id;
this.name = name;
@@ -85,7 +85,7 @@ public class PathInfo
return name;
}
public NodeRef getId()
public String getId()
{
return id;
}