From 72baa4c274bd9aa217c3f4c1cc018e9f5cd5def2 Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Wed, 23 Jul 2014 16:56:36 +0000 Subject: [PATCH] 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> - 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 --- .../web/scripts/solr/NodesMetaDataGet.java | 162 ++++++------------ 1 file changed, 51 insertions(+), 111 deletions(-) diff --git a/source/java/org/alfresco/repo/web/scripts/solr/NodesMetaDataGet.java b/source/java/org/alfresco/repo/web/scripts/solr/NodesMetaDataGet.java index fd35e4d3d1..12416e0953 100644 --- a/source/java/org/alfresco/repo/web/scripts/solr/NodesMetaDataGet.java +++ b/source/java/org/alfresco/repo/web/scripts/solr/NodesMetaDataGet.java @@ -238,63 +238,68 @@ public class NodesMetaDataGet extends DeclarativeWebScript */ public static class FreemarkerNodeMetaData { - private Long nodeId; - private NodeRef nodeRef; - private QName nodeType; - private Long aclId; - private Map properties; - private Set aspects; - private List paths; - private List childAssocs; - private List parentAssocs; - private Long parentAssocsCrc; - private List childIds; - private String owner; - private Long txnId; - private Set ancestors; - private String tenantDomain; + private final Long nodeId; + private final NodeRef nodeRef; + private final QName nodeType; + private final Long aclId; + private final Map properties; + private final Set aspects; + private final List paths; + private final List namePaths; + private final List childAssocs; + private final List parentAssocs; + private final Long parentAssocsCrc; + private final List childIds; + private final String owner; + private final Long txnId; + private final Set ancestors; + private final String tenantDomain; public FreemarkerNodeMetaData(final SOLRSerializer solrSerializer, final NodeMetaData nodeMetaData) throws IOException, JSONException { - setNodeId(nodeMetaData.getNodeId()); - setTenantDomain(nodeMetaData.getTenantDomain()); - setAclId(nodeMetaData.getAclId()); - setNodeRef(nodeMetaData.getNodeRef()); - setNodeType(nodeMetaData.getNodeType()); - setTxnId(nodeMetaData.getTxnId()); + this.nodeId = nodeMetaData.getNodeId(); + this.tenantDomain = nodeMetaData.getTenantDomain(); + this.aclId = nodeMetaData.getAclId(); + this.nodeRef = nodeMetaData.getNodeRef(); + this.nodeType = nodeMetaData.getNodeType(); + this.txnId = nodeMetaData.getTxnId(); // convert Paths to Strings List paths = new ArrayList(); HashSet ancestors = new HashSet(); if(nodeMetaData.getPaths() != null) { - for(Pair pair : nodeMetaData.getPaths()) - { - JSONObject o = new JSONObject(); - o.put("path", solrSerializer.serializeValue(String.class, pair.getFirst())); - o.put("qname", solrSerializer.serializeValue(String.class, pair.getSecond())); - paths.add(o.toString(3)); - - for (NodeRef ancestor : getAncestors(pair.getFirst())) + for(Pair pair : nodeMetaData.getPaths()) { - ancestors.add(ancestor.toString()); + JSONObject o = new JSONObject(); + o.put("path", solrSerializer.serializeValue(String.class, pair.getFirst())); + o.put("qname", solrSerializer.serializeValue(String.class, pair.getSecond())); + paths.add(o.toString(3)); + + for (NodeRef ancestor : getAncestors(pair.getFirst())) + { + ancestors.add(ancestor.toString()); + } } } - } - setAncestors(ancestors); - setPaths(paths); + this.ancestors = ancestors; + this.paths = paths; + // TODO: Convert name paths to required strings + this.namePaths = null; // TODO: use a JSON-friendly string + + this.owner = nodeMetaData.getOwner(); + this.childAssocs = nodeMetaData.getChildAssocs(); + this.childIds = nodeMetaData.getChildIds(); + this.parentAssocs = nodeMetaData.getParentAssocs(); + this.parentAssocsCrc = nodeMetaData.getParentAssocsCrc(); + this.aspects = nodeMetaData.getAspects(); - setChildAssocs(nodeMetaData.getChildAssocs()); - setChildIds(nodeMetaData.getChildIds()); - setParentAssocs(nodeMetaData.getParentAssocs()); - setParentAssocsCrc(nodeMetaData.getParentAssocsCrc()); - setAspects(nodeMetaData.getAspects()); final Map props = nodeMetaData.getProperties(); - if(props != null) + if (props != null) { - final Map properties = (props != null ? new HashMap(props.size()) : null); - for(final QName propName : props.keySet()) + final Map properties = new HashMap(props.size()); + for (final QName propName : props.keySet()) { // need to run this in tenant context because types may be in a tenant-specific // dictionary registry @@ -310,139 +315,74 @@ public class NodesMetaDataGet extends DeclarativeWebScript } }, tenantDomain); } - setProperties(properties); + this.properties = properties; + } + else + { + this.properties = null; } - setOwner(nodeMetaData.getOwner()); } public NodeRef getNodeRef() { return nodeRef; } - public void setNodeRef(NodeRef nodeRef) - { - this.nodeRef = nodeRef; - } public List getPaths() { return paths; } - public void setPaths(List paths) - { - this.paths = paths; - } public QName getNodeType() { return nodeType; } - public void setNodeType(QName nodeType) - { - this.nodeType = nodeType; - } public Long getNodeId() { return nodeId; } - public void setNodeId(Long nodeId) - { - this.nodeId = nodeId; - } public Long getAclId() { return aclId; } - public void setAclId(Long aclId) - { - this.aclId = aclId; - } public Map getProperties() { return properties; } - public void setProperties(Map properties) - { - this.properties = properties; - } public Set getAspects() { return aspects; } - public void setAspects(Set aspects) - { - this.aspects = aspects; - } public List getChildAssocs() { return childAssocs; } - public void setChildAssocs(List childAssocs) - { - this.childAssocs = childAssocs; - } public List getParentAssocs() { return parentAssocs; } - public void setParentAssocs(List parentAssocs) - { - this.parentAssocs = parentAssocs; - } public Long getParentAssocsCrc() { return parentAssocsCrc; } - public void setParentAssocsCrc(Long parentAssocsCrc) - { - this.parentAssocsCrc = parentAssocsCrc; - } - public void setAncestors(Set ancestors) - { - this.ancestors = ancestors; - } public Set getAncestors() { return ancestors; } - public List getChildIds() { return childIds; } - - public void setChildIds(List childIds) - { - this.childIds = childIds; - } - public String getOwner() { return owner; } - - public void setOwner(String owner) - { - this.owner = owner; - } - public Long getTxnId() { return txnId; } - - public void setTxnId(Long txnId) - { - this.txnId = txnId; - } - public String getTenantDomain() { return tenantDomain; } - public void setTenantDomain(String tenantDomain) - { - this.tenantDomain = tenantDomain; - } - private ArrayList getAncestors(Path path) { ArrayList ancestors = new ArrayList(8);