mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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/HEAD/root@126605 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());
|
Map<QName, Serializable> nodeProps = nodeService.getProperties(aNode.getNodeRef());
|
||||||
aNode.setArchivedAt((Date)nodeProps.get(ContentModel.PROP_ARCHIVED_DATE));
|
aNode.setArchivedAt((Date)nodeProps.get(ContentModel.PROP_ARCHIVED_DATE));
|
||||||
aNode.setArchivedByUser(aNode.lookupUserInfo((String)nodeProps.get(ContentModel.PROP_ARCHIVED_BY), mapUserInfo, personService));
|
aNode.setArchivedByUser(aNode.lookupUserInfo((String)nodeProps.get(ContentModel.PROP_ARCHIVED_BY), mapUserInfo, personService));
|
||||||
|
|
||||||
|
//Don't show parent id
|
||||||
|
aNode.setParentId(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -794,10 +794,14 @@ public class NodesImpl implements Nodes
|
|||||||
mapUserInfo = new HashMap<>(2);
|
mapUserInfo = new HashMap<>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node node;
|
||||||
|
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
PathInfo pathInfo = null;
|
PathInfo pathInfo = null;
|
||||||
if (includeParam.contains(PARAM_INCLUDE_PATH))
|
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)
|
if (nodeTypeQName == null)
|
||||||
@@ -810,9 +814,6 @@ public class NodesImpl implements Nodes
|
|||||||
parentNodeRef = getParentNodeRef(nodeRef);
|
parentNodeRef = getParentNodeRef(nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node node;
|
|
||||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
|
||||||
|
|
||||||
Type type = getType(nodeTypeQName, nodeRef);
|
Type type = getType(nodeTypeQName, nodeRef);
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
@@ -891,14 +892,35 @@ public class NodesImpl implements Nodes
|
|||||||
return node;
|
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<>();
|
List<ElementInfo> pathElements = new ArrayList<>();
|
||||||
Boolean isComplete = Boolean.TRUE;
|
Boolean isComplete = Boolean.TRUE;
|
||||||
// 2 => as we don't want to include the given node in the path as well.
|
final Path nodePath;
|
||||||
for (int i = nodePath.size() - 2; i >= 0; i--)
|
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);
|
Element element = nodePath.get(i);
|
||||||
if (element instanceof Path.ChildAssocElement)
|
if (element instanceof Path.ChildAssocElement)
|
||||||
@@ -940,7 +962,7 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
return new PathInfo(pathStr, isComplete, pathElements);
|
return new PathInfo(pathStr, isComplete, pathElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<QName> mapToNodeAspects(List<String> aspectNames)
|
protected Set<QName> mapToNodeAspects(List<String> aspectNames)
|
||||||
{
|
{
|
||||||
Set<QName> nodeAspects = new HashSet<>(aspectNames.size());
|
Set<QName> nodeAspects = new HashSet<>(aspectNames.size());
|
||||||
@@ -1579,7 +1601,7 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
poster.postFileFolderActivity(activityType, null, TenantUtil.getCurrentDomain(),
|
poster.postFileFolderActivity(activityType, null, TenantUtil.getCurrentDomain(),
|
||||||
activityInfo.getSiteId(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(),
|
activityInfo.getSiteId(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(),
|
||||||
activityInfo.getFileName(), Activities.APP_TOOL, Activities.RESTAPI_CLIENT,
|
activityInfo.getFileName(), Activities.APP_TOOL, Activities.RESTAPI_CLIENT,
|
||||||
activityInfo.getFileInfo());
|
activityInfo.getFileInfo());
|
||||||
|
@@ -20,6 +20,7 @@ package org.alfresco.rest;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.alfresco.rest.api.Nodes;
|
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.Document;
|
||||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
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.Node;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.PathInfo;
|
||||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests Deleting nodes and recovering
|
* Tests Deleting nodes and recovering
|
||||||
@@ -92,23 +96,36 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertNotNull(nodes);
|
assertNotNull(nodes);
|
||||||
assertEquals(numOfNodes+3,nodes.size());
|
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);
|
Document node = jacksonUtil.parseEntry(response.getJsonResponse(), Document.class);
|
||||||
assertNotNull(node);
|
assertNotNull(node);
|
||||||
assertEquals(u1.getId(), node.getArchivedByUser().getId());
|
assertEquals(u1.getId(), node.getArchivedByUser().getId());
|
||||||
assertTrue(node.getArchivedAt().after(now));
|
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);
|
Folder fNode = jacksonUtil.parseEntry(response.getJsonResponse(), Folder.class);
|
||||||
assertNotNull(fNode);
|
assertNotNull(fNode);
|
||||||
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
||||||
assertTrue(fNode.getArchivedAt().after(now));
|
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);
|
fNode = jacksonUtil.parseEntry(response.getJsonResponse(), Folder.class);
|
||||||
assertNotNull(fNode);
|
assertNotNull(fNode);
|
||||||
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
assertEquals(u1.getId(), fNode.getArchivedByUser().getId());
|
||||||
assertTrue(fNode.getArchivedAt().after(now));
|
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
|
//The list is ordered with the most recently deleted node first
|
||||||
checkDeletedNodes(now, createdFolder, createdFolderNonSite, document, nodes);
|
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("This folder was deleted most recently", createdFolderNonSite.getId(), aNode.getId());
|
||||||
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
||||||
assertTrue(aNode.getArchivedAt().after(now));
|
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);
|
Node folderNode = (Node) nodes.get(1);
|
||||||
assertNotNull(folderNode);
|
assertNotNull(folderNode);
|
||||||
@@ -222,12 +240,14 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertEquals(u1.getId(), folderNode.getArchivedByUser().getId());
|
assertEquals(u1.getId(), folderNode.getArchivedByUser().getId());
|
||||||
assertTrue(folderNode.getArchivedAt().after(now));
|
assertTrue(folderNode.getArchivedAt().after(now));
|
||||||
assertTrue("This folder was deleted before the non-site folder", folderNode.getArchivedAt().before(aNode.getArchivedAt()));
|
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);
|
aNode = (Node) nodes.get(2);
|
||||||
assertNotNull(aNode);
|
assertNotNull(aNode);
|
||||||
assertEquals(document.getId(), aNode.getId());
|
assertEquals(document.getId(), aNode.getId());
|
||||||
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
assertEquals(u1.getId(), aNode.getArchivedByUser().getId());
|
||||||
assertTrue(aNode.getArchivedAt().after(now));
|
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