Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

77259: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      76447: SOLR node metadata includes getNamePaths, which is a Collection<Collection<String>>
       - JSON serialization stubbed out; fix TODOs in NodesMetaDataGet to transfer serialize to specification
       - The name paths are the largest list of names of nodes that culminate in the target node.
       - The top parent is the last highest parent with a cm:name property
       - ALL paths are introspected but it does not mean that the node path count will always equal the name path count


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@78115 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-07-23 16:56:36 +00:00
parent 1edab772b1
commit ec8137e8dc
3 changed files with 83 additions and 12 deletions

View File

@@ -55,6 +55,7 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeRef.Status;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.Path.ChildAssocElement;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PermissionService;
@@ -841,6 +842,50 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
}
nodeMetaData.setPaths(paths);
// Calculate name path
Collection<Collection<String>> namePaths = new ArrayList<Collection<String>>(2);
nodeMetaData.setNamePaths(namePaths);
for (Path path : directPaths)
{
boolean added = false;
List<String> namePath = new ArrayList<String>(path.size());
for (Path.Element pathElement : path)
{
if (!(pathElement instanceof ChildAssocElement))
{
// This is some path element that is terminal to a cm:name path
break;
}
ChildAssocElement pathChildAssocElement = (ChildAssocElement) pathElement;
NodeRef childNodeRef = pathChildAssocElement.getRef().getChildRef();
Pair<Long, NodeRef> childNodePair = nodeDAO.getNodePair(childNodeRef);
if (childNodePair == null)
{
// Gone
break;
}
Long childNodeId = childNodePair.getFirst();
String childNodeName = (String) nodeDAO.getNodeProperty(childNodeId, ContentModel.PROP_NAME);
if (childNodeName == null)
{
// We have hit a non-name node, which acts as a root for cm:name
// DH: There is no particular constraint here. This is just a decision made.
namePath.clear();
// We have to continue down the path as there could be a name path lower down
continue;
}
// We can finally add the name to the path
namePath.add(childNodeName);
// Add the path if this is the first entry in the name path
if (!added)
{
namePaths.add(namePath);
added = true;
}
}
}
}
nodeMetaData.setTenantDomain(tenantService.getDomain(nodeRef.getStoreRef().getIdentifier()));