mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for MOB-1029: Read operations for zones should not create zones
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14859 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -710,6 +710,7 @@
|
||||
org.alfresco.service.cmr.security.AuthorityService.setAuthorityDisplayName=ACL_METHOD.ROLE_ADMINISTRATOR
|
||||
org.alfresco.service.cmr.security.AuthorityService.getAuthorityDisplayName=ACL_ALLOW
|
||||
org.alfresco.service.cmr.security.AuthorityService.getOrCreateZone=ACL_METHOD.ROLE_ADMINISTRATOR
|
||||
org.alfresco.service.cmr.security.AuthorityService.getZone=ACL_ALLOW
|
||||
org.alfresco.service.cmr.security.AuthorityService.getAuthorityZones=ACL_ALLOW
|
||||
org.alfresco.service.cmr.security.AuthorityService.getAllAuthoritiesInZone=ACL_ALLOW
|
||||
org.alfresco.service.cmr.security.AuthorityService.getAllRootAuthoritiesInZone=ACL_ALLOW
|
||||
|
@@ -159,6 +159,15 @@ public interface AuthorityDAO
|
||||
*/
|
||||
public NodeRef getOrCreateZone(String zoneName);
|
||||
|
||||
/**
|
||||
* Gets an authority zone node with the specified name
|
||||
*
|
||||
* @param zoneName
|
||||
* the zone name
|
||||
* @return reference to the zone node ot null if the zone does not exists
|
||||
*/
|
||||
public NodeRef getZone(String zoneName);
|
||||
|
||||
/**
|
||||
* Gets the name of the zone containing the specified authority.
|
||||
*
|
||||
|
@@ -224,7 +224,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
{
|
||||
for (String zone : zones)
|
||||
{
|
||||
NodeRef container = getOrCreateZone(zone);
|
||||
NodeRef container = getZone(zone);
|
||||
if (container != null)
|
||||
{
|
||||
if (container != null)
|
||||
@@ -500,15 +500,27 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
}
|
||||
|
||||
public NodeRef getOrCreateZone(String zoneName)
|
||||
{
|
||||
return getOrCreateZone(zoneName, true);
|
||||
}
|
||||
|
||||
private NodeRef getOrCreateZone(String zoneName, boolean create)
|
||||
{
|
||||
NodeRef zoneContainerRef = getZoneContainer();
|
||||
QName zoneQName = QName.createQName("cm", zoneName, namespacePrefixResolver);
|
||||
List<ChildAssociationRef> results = nodeService.getChildAssocs(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName);
|
||||
if (results.isEmpty())
|
||||
{
|
||||
HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
props.put(ContentModel.PROP_NAME, zoneName);
|
||||
return nodeService.createNode(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, ContentModel.TYPE_ZONE, props).getChildRef();
|
||||
if (create)
|
||||
{
|
||||
HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
props.put(ContentModel.PROP_NAME, zoneName);
|
||||
return nodeService.createNode(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, ContentModel.TYPE_ZONE, props).getChildRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -516,6 +528,11 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
}
|
||||
}
|
||||
|
||||
public NodeRef getZone(String zoneName)
|
||||
{
|
||||
return getOrCreateZone(zoneName, false);
|
||||
}
|
||||
|
||||
public Set<String> getAuthorityZones(String name)
|
||||
{
|
||||
HashSet<String> zones = new HashSet<String>();
|
||||
@@ -550,10 +567,13 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
public Set<String> getAllAuthoritiesInZone(String zoneName, AuthorityType type)
|
||||
{
|
||||
HashSet<String> authorities = new HashSet<String>();
|
||||
NodeRef zoneRef = getOrCreateZone(zoneName);
|
||||
for (ChildAssociationRef childRef : nodeService.getChildAssocs(zoneRef))
|
||||
NodeRef zoneRef = getZone(zoneName);
|
||||
if (zoneRef != null)
|
||||
{
|
||||
addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type, null);
|
||||
for (ChildAssociationRef childRef : nodeService.getChildAssocs(zoneRef))
|
||||
{
|
||||
addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type, null);
|
||||
}
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
@@ -397,6 +397,11 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
|
||||
{
|
||||
return authorityDAO.getOrCreateZone(zoneName);
|
||||
}
|
||||
|
||||
public NodeRef getZone(String zoneName)
|
||||
{
|
||||
return authorityDAO.getZone(zoneName);
|
||||
}
|
||||
|
||||
public Set<String> getAllAuthoritiesInZone(String zoneName, AuthorityType type)
|
||||
{
|
||||
|
@@ -340,4 +340,9 @@ public class SimpleAuthorityServiceImpl implements AuthorityService
|
||||
{
|
||||
return Collections.<String>emptySet();
|
||||
}
|
||||
|
||||
public NodeRef getZone(String zoneName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -322,6 +322,16 @@ public interface AuthorityService
|
||||
@Auditable(parameters = {"zoneName"})
|
||||
public NodeRef getOrCreateZone(String zoneName);
|
||||
|
||||
/**
|
||||
* Gets an authority zone node with the specified name
|
||||
*
|
||||
* @param zoneName
|
||||
* the zone name
|
||||
* @return reference to the zone node or null
|
||||
*/
|
||||
@Auditable(parameters = {"zoneName"})
|
||||
public NodeRef getZone(String zoneName);
|
||||
|
||||
/**
|
||||
* Gets the name of the zone containing the specified authority.
|
||||
*
|
||||
|
Reference in New Issue
Block a user