mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merge pull request #17 from Alfresco/feature/REPO-2983_extra_path_info
Feature/repo 2983 extra path info
This commit is contained in:
@@ -1069,7 +1069,10 @@ 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.getId(), nameProp.toString()));
|
||||
String type = getNodeType(childNodeRef).toPrefixString(namespaceService);
|
||||
Set<QName> aspects = nodeService.getAspects(childNodeRef);
|
||||
List<String> aspectNames = mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS);
|
||||
pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString(), type, aspectNames));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -81,15 +81,19 @@ public class PathInfo
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String nodeType;
|
||||
private List<String> aspectNames;
|
||||
|
||||
public ElementInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public ElementInfo(String id, String name)
|
||||
|
||||
public ElementInfo(String id, String name, String nodeType, List<String> aspectNames)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.nodeType = nodeType;
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -102,12 +106,24 @@ public class PathInfo
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(250);
|
||||
sb.append("PathElement [id=").append(id)
|
||||
.append(", name=").append(name)
|
||||
.append(", nodeType=").append(nodeType)
|
||||
.append(", aspectNames=").append(aspectNames)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@@ -608,13 +608,34 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
assertTrue(path.getName().startsWith("/Company Home"));
|
||||
List<ElementInfo> pathElements = path.getElements();
|
||||
assertEquals(7, pathElements.size());
|
||||
|
||||
// Check path element names and types, and one or two random aspects.
|
||||
assertEquals("Company Home", pathElements.get(0).getName());
|
||||
assertEquals("cm:folder", pathElements.get(0).getNodeType());
|
||||
|
||||
assertEquals("Sites", pathElements.get(1).getName());
|
||||
assertEquals("st:sites", pathElements.get(1).getNodeType());
|
||||
|
||||
assertEquals(site1Id, pathElements.get(2).getName());
|
||||
assertEquals("st:site", pathElements.get(2).getNodeType());
|
||||
assertTrue(pathElements.get(2).getAspectNames().contains("cm:titled"));
|
||||
// Check that sys:* is filtered out - to be consistent with other aspect name lists
|
||||
// e.g. /nodes/{nodeId}/children?include=aspectNames
|
||||
assertFalse(pathElements.get(2).getAspectNames().contains("sys:undeletable"));
|
||||
assertFalse(pathElements.get(2).getAspectNames().contains("sys:unmovable"));
|
||||
|
||||
assertEquals("documentLibrary", pathElements.get(3).getName());
|
||||
assertEquals("cm:folder", pathElements.get(3).getNodeType());
|
||||
assertTrue(pathElements.get(3).getAspectNames().contains("st:siteContainer"));
|
||||
|
||||
assertEquals(folderA, pathElements.get(4).getName());
|
||||
assertEquals("cm:folder", pathElements.get(4).getNodeType());
|
||||
|
||||
assertEquals(folderB, pathElements.get(5).getName());
|
||||
assertEquals("cm:folder", pathElements.get(5).getNodeType());
|
||||
|
||||
assertEquals(folderC, pathElements.get(6).getName());
|
||||
assertEquals("cm:folder", pathElements.get(6).getNodeType());
|
||||
|
||||
// Try the above tests with user2 (site consumer)
|
||||
setRequestContext(user2);
|
||||
|
@@ -67,19 +67,42 @@ public class PathInfo
|
||||
return elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(120);
|
||||
sb.append("PathInfo [name=").append(name)
|
||||
.append(", isComplete=").append(isComplete)
|
||||
.append(", elements=").append(elements)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static class ElementInfo
|
||||
{
|
||||
private String id;
|
||||
private String name;
|
||||
private String nodeType;
|
||||
private List<String> aspectNames;
|
||||
|
||||
/**
|
||||
* Required by jackson deserialisation.
|
||||
*/
|
||||
public ElementInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public ElementInfo(String id, String name)
|
||||
{
|
||||
this(id, name, null, null);
|
||||
}
|
||||
|
||||
public ElementInfo(String id, String name, String nodeType, List<String> aspectNames)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.nodeType = nodeType;
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -92,6 +115,28 @@ public class PathInfo
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(250);
|
||||
sb.append("PathElement [id=").append(id)
|
||||
.append(", name=").append(name)
|
||||
.append(", nodeType=").append(nodeType)
|
||||
.append(", aspectNames=").append(aspectNames)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void expected(Object o)
|
||||
{
|
||||
assertTrue(o instanceof ElementInfo);
|
||||
@@ -99,6 +144,7 @@ public class PathInfo
|
||||
ElementInfo other = (ElementInfo) o;
|
||||
assertEquals(id, other.getName());
|
||||
assertEquals(name, other.getName());
|
||||
assertEquals(nodeType, other.getNodeType());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user