mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -44,6 +44,7 @@ public class NodeMetaData
|
|||||||
private Map<QName, Serializable> properties;
|
private Map<QName, Serializable> properties;
|
||||||
private Set<QName> aspects;
|
private Set<QName> aspects;
|
||||||
private Collection<Pair<Path, QName>> paths;
|
private Collection<Pair<Path, QName>> paths;
|
||||||
|
private Collection<Collection<String>> namePaths;
|
||||||
private List<ChildAssociationRef> childAssocs;
|
private List<ChildAssociationRef> childAssocs;
|
||||||
private List<ChildAssociationRef> parentAssocs;
|
private List<ChildAssociationRef> parentAssocs;
|
||||||
private Long parentAssocsCrc;
|
private Long parentAssocsCrc;
|
||||||
@@ -75,6 +76,14 @@ public class NodeMetaData
|
|||||||
{
|
{
|
||||||
this.paths = paths;
|
this.paths = paths;
|
||||||
}
|
}
|
||||||
|
public Collection<Collection<String>> getNamePaths()
|
||||||
|
{
|
||||||
|
return namePaths;
|
||||||
|
}
|
||||||
|
public void setNamePaths(Collection<Collection<String>> namePaths)
|
||||||
|
{
|
||||||
|
this.namePaths = namePaths;
|
||||||
|
}
|
||||||
public QName getNodeType()
|
public QName getNodeType()
|
||||||
{
|
{
|
||||||
return nodeType;
|
return nodeType;
|
||||||
|
@@ -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;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef.Status;
|
import org.alfresco.service.cmr.repository.NodeRef.Status;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
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.repository.datatype.DefaultTypeConverter;
|
||||||
import org.alfresco.service.cmr.security.OwnableService;
|
import org.alfresco.service.cmr.security.OwnableService;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
@@ -841,6 +842,50 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeMetaData.setPaths(paths);
|
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()));
|
nodeMetaData.setTenantDomain(tenantService.getDomain(nodeRef.getStoreRef().getIdentifier()));
|
||||||
|
@@ -21,7 +21,6 @@ package org.alfresco.repo.solr;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -243,6 +242,7 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Call {@link SOLRTrackingComponent#getAcls(List, Long, int)} in a transaction
|
* Call {@link SOLRTrackingComponent#getAcls(List, Long, int)} in a transaction
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private List<Acl> getAcls(final List<Long> aclChangeSetIds, final Long minAclId, final int maxResults)
|
private List<Acl> getAcls(final List<Long> aclChangeSetIds, final Long minAclId, final int maxResults)
|
||||||
{
|
{
|
||||||
RetryingTransactionCallback<List<Acl>> callback = new RetryingTransactionCallback<List<Acl>>()
|
RetryingTransactionCallback<List<Acl>> callback = new RetryingTransactionCallback<List<Acl>>()
|
||||||
@@ -959,7 +959,8 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleNodeMetaData(NodeMetaData nodeMetaData) {
|
public boolean handleNodeMetaData(NodeMetaData nodeMetaData)
|
||||||
|
{
|
||||||
actualNodeMetaDataCount++;
|
actualNodeMetaDataCount++;
|
||||||
|
|
||||||
if(doMetaDataChecks)
|
if(doMetaDataChecks)
|
||||||
@@ -1009,6 +1010,32 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
// List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
|
// List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
|
||||||
// assertEquals("Paths are incorrect", expectedPaths, actualPaths);
|
// assertEquals("Paths are incorrect", expectedPaths, actualPaths);
|
||||||
|
|
||||||
|
// Include negative checks i.e. make sure we get null if we do NOT expect paths
|
||||||
|
boolean expectPaths = assertions.isExpectPaths();
|
||||||
|
assertTrue("Expecting paths but didn't get any.", expectPaths == (nodeMetaData.getPaths() != null));
|
||||||
|
assertTrue("Expecting name path but didn't get it.", expectPaths == (nodeMetaData.getNamePaths() != null));
|
||||||
|
if (expectPaths)
|
||||||
|
{
|
||||||
|
// Check QName paths
|
||||||
|
// TODO: Check paths
|
||||||
|
// Check name paths
|
||||||
|
Collection<Collection<String>> namePaths = nodeMetaData.getNamePaths();
|
||||||
|
if (nodeService.getProperty(nodeRef, ContentModel.PROP_NAME) == null)
|
||||||
|
{
|
||||||
|
assertEquals("Expect an empty list where there is no cm:name on the node. ", 0, namePaths.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assertTrue("Expect some name paths for the node. ", namePaths.size() > 0);
|
||||||
|
// Check that the last entry is the name of the current node
|
||||||
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
|
String namePathStr = namePaths.toString();
|
||||||
|
assertTrue(
|
||||||
|
"Did not find node name at end. Have " + namePathStr + " and wanted to see " + name,
|
||||||
|
namePathStr.endsWith(name + "]]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean expectAspects = assertions.isExpectAspects();
|
boolean expectAspects = assertions.isExpectAspects();
|
||||||
if(expectAspects && nodeMetaData.getAspects() == null)
|
if(expectAspects && nodeMetaData.getAspects() == null)
|
||||||
{
|
{
|
||||||
@@ -1049,16 +1076,6 @@ public class SOLRTrackingComponentTest extends TestCase
|
|||||||
fail("Not expecting acl id but got acl id");
|
fail("Not expecting acl id but got acl id");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean expectPaths = assertions.isExpectPaths();
|
|
||||||
if(expectPaths && nodeMetaData.getPaths() == null)
|
|
||||||
{
|
|
||||||
fail("Expecting paths but got no paths");
|
|
||||||
}
|
|
||||||
else if(!expectPaths && nodeMetaData.getPaths() != null)
|
|
||||||
{
|
|
||||||
fail("Not expecting paths but got paths");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean expectAssociations = assertions.isExpectAssociations();
|
boolean expectAssociations = assertions.isExpectAssociations();
|
||||||
if(expectAssociations && nodeMetaData.getChildAssocs() == null)
|
if(expectAssociations && nodeMetaData.getChildAssocs() == null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user