diff --git a/source/java/org/alfresco/rest/api/impl/NodesImpl.java b/source/java/org/alfresco/rest/api/impl/NodesImpl.java index ab40e8c5b4..f909907454 100644 --- a/source/java/org/alfresco/rest/api/impl/NodesImpl.java +++ b/source/java/org/alfresco/rest/api/impl/NodesImpl.java @@ -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 mapUserInfo) { List includeParam = new ArrayList<>(); - includeParam.addAll(parameters.getInclude()); + 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 includeParam, Map 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); } diff --git a/source/java/org/alfresco/rest/api/model/PathInfo.java b/source/java/org/alfresco/rest/api/model/PathInfo.java index 145afda598..2b93bef852 100644 --- a/source/java/org/alfresco/rest/api/model/PathInfo.java +++ b/source/java/org/alfresco/rest/api/model/PathInfo.java @@ -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; } diff --git a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java index e36ae90712..35f394d8ec 100644 --- a/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/NodeApiTest.java @@ -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 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/documentLibrary/folder_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()); diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java b/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java index 104d6b3126..f086e6dfce 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/PathInfo.java @@ -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; }