ALFCOM-3110: Groups added to sites became invisible to Share client

- Root groups are now those in the default zone that are not children of groups in the same zone

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15051 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-07-01 11:39:37 +00:00
parent be07d6ca83
commit 57cd1bfd94
9 changed files with 104 additions and 69 deletions

View File

@@ -382,7 +382,7 @@
org.alfresco.service.cmr.repository.NodeService.getPaths=ACL_NODE.0.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.getPaths=ACL_NODE.0.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=ACL_NODE.0.sys:base.Read org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=ACL_NODE.0.sys:base.Read
org.alfresco.service.cmr.repository.NodeService.restoreNode=ACL_NODE.0.sys:base.DeleteNode,ACL_NODE.1.sys:base.CreateChildren org.alfresco.service.cmr.repository.NodeService.restoreNode=ACL_NODE.0.sys:base.DeleteNode,ACL_NODE.1.sys:base.CreateChildren
org.alfresco.service.cmr.repository.NodeService.getNodesWithoutParentAssocsOfType=ACL_NODE.0.sys:base.ReadProperties,AFTER_ACL_NODE.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.getChildAssocsWithoutParentAssocsOfType=ACL_NODE.0.sys:base.ReadProperties,AFTER_ACL_NODE.sys:base.ReadProperties
</value> </value>
</property> </property>
</bean> </bean>

View File

@@ -1885,11 +1885,10 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.cmr.repository.NodeService#getNodesWithoutParentAssocsOfType(org.alfresco.service.cmr.repository.StoreRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) * @see org.alfresco.service.cmr.repository.NodeService#getChildAssocsWithoutParentAssocsOfType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/ */
public Collection<NodeRef> getNodesWithoutParentAssocsOfType(StoreRef storeRef, QName nodeTypeQName, public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName)
QName assocTypeQName)
{ {
throw new UnsupportedOperationException("AVM does not support this operation."); throw new UnsupportedOperationException("AVM does not support this operation.");
} }
} }

View File

@@ -812,4 +812,42 @@
a.child_node_id IS NULL a.child_node_id IS NULL
</sql-query> </sql-query>
<sql-query name="node.GetChildAssocsWithoutParentAssocsOfType">
<return-scalar column="id" type="long"/>
<return-scalar column="type_qname_id" type="long"/>
<return-scalar column="qname_ns_id" type="long"/>
<return-scalar column="qname_localname" type="string"/>
<return-scalar column="child_node_name" type="string"/>
<return-scalar column="child_node_name_crc" type="long"/>
<return-scalar column="is_primary" type="boolean"/>
<return-scalar column="assoc_index" type="integer"/>
<return-scalar column="id" type="long"/>
<return-scalar column="protocol" type="string"/>
<return-scalar column="identifier" type="string"/>
<return-scalar column="uuid" type="string"/>
select
z1.id,
z1.type_qname_id,
z1.qname_ns_id,
z1.qname_localname,
z1.child_node_name,
z1.child_node_name_crc,
z1.is_primary,
z1.assoc_index,
n.id,
s.protocol,
s.identifier,
n.uuid
FROM
(alf_node n
JOIN alf_store s ON (s.id = n.store_id)
JOIN alf_child_assoc z1 ON (z1.parent_node_id = :parentId and z1.child_node_id = n.id))
LEFT OUTER JOIN
(alf_child_assoc a
JOIN alf_child_assoc z2 ON (z2.parent_node_id = :parentId AND z2.child_node_id = a.parent_node_id ))
ON (a.child_node_id = n.id AND a.type_qname_id = :assocTypeQNameID)
WHERE
a.child_node_id IS NULL
</sql-query>
</hibernate-mapping> </hibernate-mapping>

View File

@@ -1631,24 +1631,30 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
addMissingAspects(sourceNodePair, assocTypeQName); addMissingAspects(sourceNodePair, assocTypeQName);
return assocRef; return assocRef;
} }
public Collection<NodeRef> getNodesWithoutParentAssocsOfType(final StoreRef storeRef, final QName nodeTypeQName, public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName)
final QName assocTypeQName)
{ {
final Collection<NodeRef> results = new LinkedList<NodeRef>(); // Get the parent node
Pair<Long, NodeRef> nodePair = getNodePairNotNull(parent);
Long parentNodeId = nodePair.getFirst();
NodeDaoService.NodeRefQueryCallback callback = new NodeDaoService.NodeRefQueryCallback() final List<ChildAssociationRef> results = new ArrayList<ChildAssociationRef>(100);
NodeDaoService.ChildAssocRefQueryCallback callback = new NodeDaoService.ChildAssocRefQueryCallback()
{ {
public boolean handle(Pair<Long, NodeRef> nodePair) public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair, Pair<Long, NodeRef> parentNodePair,
Pair<Long, NodeRef> childNodePair)
{ {
results.add(nodePair.getSecond()); results.add(childAssocPair.getSecond());
return true; return true;
} }
}; };
nodeDaoService.getNodesWithoutParentAssocsOfType(storeRef, nodeTypeQName, assocTypeQName, callback); // Get the child associations that meet the criteria
nodeDaoService.getChildAssocsWithoutParentAssocsOfType(parentNodeId, assocTypeQName, callback);
// done
return results; return results;
} }

View File

@@ -364,21 +364,19 @@ public interface NodeDaoService
public void getNodesWithAspect(QName aspectQName, Long minNodeId, int count, NodeRefQueryCallback resultsCallback); public void getNodesWithAspect(QName aspectQName, Long minNodeId, int count, NodeRefQueryCallback resultsCallback);
/** /**
* Gets the set of nodes of a certain type without parent associations of a certain type. In effect the 'orphans' * Gets the set of child associations of a certain parent node without parent associations of a certain type to
* with respect to a certain association type. * other nodes with the same parent! In effect the 'orphans' with respect to a certain association type.
* *
* @param storeRef * @param parentNodeId
* the store reference * the parent node ID
* @param nodeTypeQName
* the node type QName
* @param assocTypeQName * @param assocTypeQName
* the association type QName * the association type QName
* @param resultsCallback * @param resultsCallback
* the node callback * the callback that will be called with the results
*/ */
@DirtySessionAnnotation(markDirty=false) @DirtySessionAnnotation(markDirty = false)
public void getNodesWithoutParentAssocsOfType(final StoreRef storeRef, final QName nodeTypeQName, final QName assocTypeQName, public void getChildAssocsWithoutParentAssocsOfType(final Long parentNodeId, final QName assocTypeQName,
NodeRefQueryCallback resultsCallback); ChildAssocRefQueryCallback resultsCallback);
/** /**
* @return Returns an association matching the given parent, type and child name (<b>cm:name</b>) - or <tt>null</tt> if not found * @return Returns an association matching the given parent, type and child name (<b>cm:name</b>) - or <tt>null</tt> if not found
*/ */

View File

@@ -151,7 +151,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
private static final String QUERY_GET_PRIMARY_CHILD_ASSOCS_NOT_IN_SAME_STORE = "node.GetPrimaryChildAssocsNotInSameStore"; private static final String QUERY_GET_PRIMARY_CHILD_ASSOCS_NOT_IN_SAME_STORE = "node.GetPrimaryChildAssocsNotInSameStore";
private static final String QUERY_GET_NODES_WITH_CHILDREN_IN_DIFFERENT_STORE ="node.GetNodesWithChildrenInDifferentStore"; private static final String QUERY_GET_NODES_WITH_CHILDREN_IN_DIFFERENT_STORE ="node.GetNodesWithChildrenInDifferentStore";
private static final String QUERY_GET_NODES_WITH_ASPECT ="node.GetNodesWithAspect"; private static final String QUERY_GET_NODES_WITH_ASPECT ="node.GetNodesWithAspect";
private static final String QUERY_GET_NODES_WITHOUT_PARENT_ASSOCS_OF_TYPE ="node.GetNodesWithoutParentAssocsOfType"; private static final String QUERY_GET_CHILD_ASSOCS_WITHOUT_PARENT_ASSOCS_OF_TYPE ="node.GetChildAssocsWithoutParentAssocsOfType";
private static final String QUERY_GET_PARENT_ASSOCS = "node.GetParentAssocs"; private static final String QUERY_GET_PARENT_ASSOCS = "node.GetParentAssocs";
private static final String QUERY_GET_NODE_ASSOC = "node.GetNodeAssoc"; private static final String QUERY_GET_NODE_ASSOC = "node.GetNodeAssoc";
private static final String QUERY_GET_NODE_ASSOCS_TO_AND_FROM = "node.GetNodeAssocsToAndFrom"; private static final String QUERY_GET_NODE_ASSOCS_TO_AND_FROM = "node.GetNodeAssocsToAndFrom";
@@ -2934,19 +2934,19 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
// Done // Done
} }
public void getNodesWithoutParentAssocsOfType(final StoreRef storeRef, final QName nodeTypeQName, public void getChildAssocsWithoutParentAssocsOfType(final Long parentNodeId, final QName assocTypeQName,
final QName assocTypeQName, NodeRefQueryCallback resultsCallback) ChildAssocRefQueryCallback resultsCallback)
{ {
Node parentNode = getNodeNotNull(parentNodeId);
HibernateCallback callback = new HibernateCallback() HibernateCallback callback = new HibernateCallback()
{ {
public Object doInHibernate(Session session) public Object doInHibernate(Session session)
{ {
Query query = session.getNamedQuery( Query query = session.getNamedQuery(
HibernateNodeDaoServiceImpl.QUERY_GET_NODES_WITHOUT_PARENT_ASSOCS_OF_TYPE).setString( HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOCS_WITHOUT_PARENT_ASSOCS_OF_TYPE).setLong(
"storeProtocol", storeRef.getProtocol()).setString("storeIdentifier", storeRef.getIdentifier()) "parentId", parentNodeId).setLong("assocTypeQNameID",
.setLong("nodeTypeQNameID", qnameDAO.getOrCreateQName(nodeTypeQName).getFirst()).setLong( qnameDAO.getOrCreateQName(assocTypeQName).getFirst());
"assocTypeQNameID", qnameDAO.getOrCreateQName(assocTypeQName).getFirst()).setBoolean(
"isDeleted", false);
DirtySessionMethodInterceptor.setQueryFlushMode(session, query); DirtySessionMethodInterceptor.setQueryFlushMode(session, query);
return query.scroll(ScrollMode.FORWARD_ONLY); return query.scroll(ScrollMode.FORWARD_ONLY);
} }
@@ -2955,7 +2955,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
try try
{ {
queryResults = (ScrollableResults) getHibernateTemplate().execute(callback); queryResults = (ScrollableResults) getHibernateTemplate().execute(callback);
processNodeResults(queryResults, resultsCallback); convertToChildAssocRefs(parentNode, queryResults, resultsCallback);
} }
finally finally
{ {
@@ -2964,10 +2964,9 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
queryResults.close(); queryResults.close();
} }
} }
// Done // Done
} }
/** /**
* <pre> * <pre>
Node ID = (Long) row[0]; Node ID = (Long) row[0];

View File

@@ -25,6 +25,7 @@
package org.alfresco.repo.security.authority; package org.alfresco.repo.security.authority;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -42,7 +43,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespacePrefixResolver; import org.alfresco.service.namespace.NamespacePrefixResolver;
@@ -169,16 +169,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
public Set<String> getAllRootAuthorities(AuthorityType type) public Set<String> getAllRootAuthorities(AuthorityType type)
{ {
if (type != null && type.equals(AuthorityType.USER)) return getAllRootAuthoritiesUnderContainer(getAuthorityContainer(), type);
{
return Collections.<String> emptySet();
}
Set<String> authorities = new HashSet<String>();
for (NodeRef nodeRef : nodeService.getNodesWithoutParentAssocsOfType(this.storeRef, ContentModel.TYPE_AUTHORITY_CONTAINER, ContentModel.ASSOC_MEMBER))
{
addAuthorityNameIfMatches(authorities, nodeRef, type, null);
}
return authorities;
} }
public Set<String> getAllAuthorities(AuthorityType type) public Set<String> getAllAuthorities(AuthorityType type)
@@ -299,12 +290,6 @@ public class AuthorityDAOImpl implements AuthorityDAO
} }
private void addAuthorityNameIfMatches(Set<String> authorities, NodeRef nodeRef, AuthorityType type, Pattern pattern)
{
addAuthorityNameIfMatches(authorities, DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHORITY_NAME)), type,
pattern);
}
private void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type, Pattern pattern) private void addAuthorityNameIfMatches(Set<String> authorities, String authorityName, AuthorityType type, Pattern pattern)
{ {
if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type)) if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type))
@@ -693,9 +678,22 @@ public class AuthorityDAOImpl implements AuthorityDAO
public Set<String> getAllRootAuthoritiesInZone(String zoneName, AuthorityType type) public Set<String> getAllRootAuthoritiesInZone(String zoneName, AuthorityType type)
{ {
Set<String> roots = getAllRootAuthorities(type); NodeRef zone = getZone(zoneName);
Set<String> inZone = getAllAuthoritiesInZone(zoneName, type); return zone == null ? Collections.<String> emptySet() : getAllRootAuthoritiesUnderContainer(zone, type);
roots.retainAll(inZone); }
return roots;
private Set<String> getAllRootAuthoritiesUnderContainer(NodeRef container, AuthorityType type)
{
if (type != null && type.equals(AuthorityType.USER))
{
return Collections.<String> emptySet();
}
Collection<ChildAssociationRef> childRefs = nodeService.getChildAssocsWithoutParentAssocsOfType(container, ContentModel.ASSOC_MEMBER);
Set<String> authorities = new HashSet<String>(childRefs.size() * 2);
for (ChildAssociationRef childRef : childRefs)
{
addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type, null);
}
return authorities;
} }
} }

View File

@@ -663,9 +663,8 @@ public class NodeServiceImpl implements NodeService, VersionModel
/** /**
* @throws UnsupportedOperationException always * @throws UnsupportedOperationException always
*/ */
public Collection<NodeRef> getNodesWithoutParentAssocsOfType(StoreRef storeRef, QName nodeTypeQName, public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef parent, QName assocTypeQName)
QName assocTypeQName)
{ {
throw new UnsupportedOperationException(MSG_UNSUPPORTED); throw new UnsupportedOperationException(MSG_UNSUPPORTED);
} }
} }

View File

@@ -560,21 +560,19 @@ public interface NodeService
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException; public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException;
/** /**
* Gets the set of nodes of a certain type without parent associations of a certain type. In effect the 'orphans' * Gets the set of child associations of a certain parent node without parent associations of a certain type to
* with respect to a certain association type. * other nodes with the same parent! In effect the 'orphans' with respect to a certain association type.
* *
* @param storeRef * @param parent
* the store reference * the parent node reference
* @param nodeTypeQName
* the node type QName
* @param assocTypeQName * @param assocTypeQName
* the association type QName * the association type QName
* @return the set of nodes of the required type without parent associations of the required type * @return a set of child associations
*/ */
@Auditable(key = Auditable.Key.ARG_0 ,parameters = {"storeRef", "nodeTypeQName", "assocTypeQName"}) @Auditable(key = Auditable.Key.ARG_0 ,parameters = {"parent", "assocTypeQName"})
public Collection<NodeRef> getNodesWithoutParentAssocsOfType(final StoreRef storeRef, final QName nodeTypeQName, public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(final NodeRef parent,
final QName assocTypeQName); final QName assocTypeQName);
/** /**
* *
* @param sourceRef a reference to a <b>real</b> node * @param sourceRef a reference to a <b>real</b> node