mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126605 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124992 gjames: RA-847, RA-848: Showing orignal parent path but not parentid git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126950 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -94,6 +94,9 @@ public class DeletedNodesImpl implements DeletedNodes
|
||||
Map<QName, Serializable> nodeProps = nodeService.getProperties(aNode.getNodeRef());
|
||||
aNode.setArchivedAt((Date)nodeProps.get(ContentModel.PROP_ARCHIVED_DATE));
|
||||
aNode.setArchivedByUser(aNode.lookupUserInfo((String)nodeProps.get(ContentModel.PROP_ARCHIVED_BY), mapUserInfo, personService));
|
||||
|
||||
//Don't show parent id
|
||||
aNode.setParentId(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -801,10 +801,14 @@ public class NodesImpl implements Nodes
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
|
||||
Node node;
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||
|
||||
PathInfo pathInfo = null;
|
||||
if (includeParam.contains(PARAM_INCLUDE_PATH))
|
||||
{
|
||||
pathInfo = lookupPathInfo(nodeRef);
|
||||
ChildAssociationRef archivedParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
|
||||
pathInfo = lookupPathInfo(nodeRef, archivedParentAssoc);
|
||||
}
|
||||
|
||||
if (nodeTypeQName == null)
|
||||
@@ -817,9 +821,6 @@ public class NodesImpl implements Nodes
|
||||
parentNodeRef = getParentNodeRef(nodeRef);
|
||||
}
|
||||
|
||||
Node node;
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||
|
||||
Type type = getType(nodeTypeQName, nodeRef);
|
||||
|
||||
if (type == null)
|
||||
@@ -898,14 +899,35 @@ public class NodesImpl implements Nodes
|
||||
return node;
|
||||
}
|
||||
|
||||
protected PathInfo lookupPathInfo(NodeRef nodeRefIn)
|
||||
protected PathInfo lookupPathInfo(NodeRef nodeRefIn, ChildAssociationRef archivedParentAssoc)
|
||||
{
|
||||
final Path nodePath = nodeService.getPath(nodeRefIn);
|
||||
|
||||
List<ElementInfo> pathElements = new ArrayList<>();
|
||||
Boolean isComplete = Boolean.TRUE;
|
||||
// 2 => as we don't want to include the given node in the path as well.
|
||||
for (int i = nodePath.size() - 2; i >= 0; i--)
|
||||
final Path nodePath;
|
||||
final int pathIndex;
|
||||
|
||||
if (archivedParentAssoc != null)
|
||||
{
|
||||
if (permissionService.hasPermission(archivedParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED)
|
||||
&& nodeService.exists(archivedParentAssoc.getParentRef()))
|
||||
{
|
||||
nodePath = nodeService.getPath(archivedParentAssoc.getParentRef());
|
||||
pathIndex = 1;// 1 => we want to include the given node in the path as well.
|
||||
}
|
||||
else
|
||||
{
|
||||
//We can't return a valid path
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nodePath = nodeService.getPath(nodeRefIn);
|
||||
pathIndex = 2; // 2 => as we don't want to include the given node in the path as well.
|
||||
}
|
||||
|
||||
for (int i = nodePath.size() - pathIndex; i >= 0; i--)
|
||||
{
|
||||
Element element = nodePath.get(i);
|
||||
if (element instanceof Path.ChildAssocElement)
|
||||
|
@@ -20,6 +20,7 @@ package org.alfresco.rest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
@@ -30,12 +31,15 @@ import org.alfresco.rest.api.tests.client.RequestContext;
|
||||
import org.alfresco.rest.api.tests.client.data.Document;
|
||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
||||
import org.alfresco.rest.api.tests.client.data.Node;
|
||||
import org.alfresco.rest.api.tests.client.data.PathInfo;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import org.junit.Test;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Tests Deleting nodes and recovering
|
||||
@@ -92,23 +96,36 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
assertNotNull(nodes);
|
||||
assertEquals(numOfNodes+3,nodes.size());
|
||||
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), document.getId(), 200);
|
||||
Map<String, String> params = Collections.singletonMap("include", "path");
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), document.getId(), params, 200);
|
||||
Document node = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||
assertNotNull(node);
|
||||
assertEquals(u1.getId(), node.getArchivedByUser().getId());
|
||||
assertTrue(node.getArchivedAt().after(now));
|
||||
PathInfo path = node.getPath();
|
||||
assertNull("Path should be null because its parent has been deleted",path);
|
||||
assertNull("We don't show the parent id for a deleted node",node.getParentId());
|
||||
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), createdFolder.getId(), 200);
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), createdFolder.getId(), params, 200);
|
||||
Folder fNode = jacksonUtil.parseEntry(response.getJsonResponse(), Folder.class);
|
||||
assertNotNull(fNode);
|
||||
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
||||
assertTrue(fNode.getArchivedAt().after(now));
|
||||
path = fNode.getPath();
|
||||
assertNotNull(path);
|
||||
assertEquals("/Company Home/Sites/"+tSite.getSiteId()+"/documentLibrary", path.getName());
|
||||
assertTrue(path.getIsComplete());
|
||||
assertNull("We don't show the parent id for a deleted node",fNode.getParentId());
|
||||
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), createdFolderNonSite.getId(), 200);
|
||||
response = getSingle(URL_DELETED_NODES, u1.getId(), createdFolderNonSite.getId(), params, 200);
|
||||
fNode = jacksonUtil.parseEntry(response.getJsonResponse(), Folder.class);
|
||||
assertNotNull(fNode);
|
||||
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
||||
assertTrue(fNode.getArchivedAt().after(now));
|
||||
path = fNode.getPath();
|
||||
assertNotNull(path);
|
||||
assertEquals("/Company Home/User Homes/"+u1.getId(), path.getName());
|
||||
assertTrue(path.getIsComplete());
|
||||
|
||||
//The list is ordered with the most recently deleted node first
|
||||
checkDeletedNodes(now, createdFolder, createdFolderNonSite, document, nodes);
|
||||
@@ -215,6 +232,7 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
assertEquals("This folder was deleted most recently", createdFolderNonSite.getId(), aNode.getId());
|
||||
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
||||
assertTrue(aNode.getArchivedAt().after(now));
|
||||
assertNull("We don't show the parent id for a deleted node",aNode.getParentId());
|
||||
|
||||
Node folderNode = (Node) nodes.get(1);
|
||||
assertNotNull(folderNode);
|
||||
@@ -222,12 +240,14 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
assertEquals(u1.getId(), folderNode.getArchivedByUser().getId());
|
||||
assertTrue(folderNode.getArchivedAt().after(now));
|
||||
assertTrue("This folder was deleted before the non-site folder", folderNode.getArchivedAt().before(aNode.getArchivedAt()));
|
||||
assertNull("We don't show the parent id for a deleted node",folderNode.getParentId());
|
||||
|
||||
aNode = (Node) nodes.get(2);
|
||||
assertNotNull(aNode);
|
||||
assertEquals(document.getId(), aNode.getId());
|
||||
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
||||
assertTrue(aNode.getArchivedAt().after(now));
|
||||
assertNull("We don't show the parent id for a deleted node",aNode.getParentId());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user