use of org.alfresco.service.cmr.repository.Path.Element in project records-management by Alfresco.
the class FilePlanComponentsApiUtils method lookupPathInfo.
protected PathInfo lookupPathInfo(NodeRef nodeRefIn) {
List<ElementInfo> pathElements = new ArrayList<>();
Boolean isComplete = Boolean.TRUE;
final Path nodePath = nodeService.getPath(nodeRefIn);
;
final int pathIndex = 2;
for (int i = nodePath.size() - pathIndex; i >= 0; i--) {
Element element = nodePath.get(i);
if (element instanceof Path.ChildAssocElement) {
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
if (elementRef.getParentRef() != null) {
NodeRef childNodeRef = elementRef.getChildRef();
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()));
} else {
// Just return the pathInfo up to the location where the user has access
isComplete = Boolean.FALSE;
break;
}
}
}
}
String pathStr = null;
if (!pathElements.isEmpty()) {
StringBuilder sb = new StringBuilder(120);
for (PathInfo.ElementInfo e : pathElements) {
sb.append("/").append(e.getName());
}
pathStr = sb.toString();
} else {
// There is no path element, so set it to null in order to be
// ignored by Jackson during serialisation
isComplete = null;
}
return new PathInfo(pathStr, isComplete, pathElements);
}
use of org.alfresco.service.cmr.repository.Path.Element in project alfresco-remote-api by Alfresco.
the class NodesImpl method lookupPathInfo.
@Override
public PathInfo lookupPathInfo(NodeRef nodeRefIn, ChildAssociationRef archivedParentAssoc) {
List<ElementInfo> pathElements = new ArrayList<>();
Boolean isComplete = Boolean.TRUE;
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());
// 1 => we want to include the given node in the path as well.
pathIndex = 1;
} else {
// We can't return a valid path
return null;
}
} else {
nodePath = nodeService.getPath(nodeRefIn);
// 2 => as we don't want to include the given node in the path as well.
pathIndex = 2;
}
for (int i = nodePath.size() - pathIndex; i >= 0; i--) {
Element element = nodePath.get(i);
if (element instanceof Path.ChildAssocElement) {
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
if (elementRef.getParentRef() != null) {
NodeRef childNodeRef = elementRef.getChildRef();
if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED) {
Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
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 {
// Just return the pathInfo up to the location where the user has access
isComplete = Boolean.FALSE;
break;
}
}
}
}
String pathStr = null;
if (pathElements.size() > 0) {
StringBuilder sb = new StringBuilder(120);
for (PathInfo.ElementInfo e : pathElements) {
sb.append("/").append(e.getName());
}
pathStr = sb.toString();
} else {
// There is no path element, so set it to null in order to be
// ignored by Jackson during serialisation
isComplete = null;
}
return new PathInfo(pathStr, isComplete, pathElements);
}
Aggregations