mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RINF 50: Authority Service - minor refactor
- ALF-9128 - refactor internals (to clearly split "find" from "list") git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28417 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -126,6 +126,15 @@ public interface AuthorityDAO
|
||||
*/
|
||||
void setAuthorityDisplayName(String authorityName, String authorityDisplayName);
|
||||
|
||||
/**
|
||||
* Get root authorities
|
||||
*
|
||||
* @param type
|
||||
* @param zoneName
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getRootAuthorities(AuthorityType type, String zoneName);
|
||||
|
||||
/**
|
||||
* Find authorities by display name pattern.
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -280,6 +280,17 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
return authorities;
|
||||
}
|
||||
|
||||
public Set<String> getRootAuthorities(AuthorityType type, String zoneName)
|
||||
{
|
||||
NodeRef container = (zoneName == null ? getAuthorityContainer() : getZone(zoneName));
|
||||
if (container == null)
|
||||
{
|
||||
// The zone doesn't even exist so there are no root authorities
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
return getRootAuthoritiesUnderContainer(container, type);
|
||||
}
|
||||
|
||||
public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate,
|
||||
String displayNamePattern, String zoneName)
|
||||
@@ -292,13 +303,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
Set<String> rootAuthorities = null;
|
||||
if (parentAuthority == null && immediate)
|
||||
{
|
||||
NodeRef container = zoneName == null ? getAuthorityContainer() : getZone(zoneName);
|
||||
if (container == null)
|
||||
{
|
||||
// The zone doesn't even exist so there are no root authorities
|
||||
return Collections.emptySet();
|
||||
}
|
||||
rootAuthorities = getRootAuthoritiesUnderContainer(container, type);
|
||||
rootAuthorities = getRootAuthorities(type, zoneName);
|
||||
if (pattern == null)
|
||||
{
|
||||
return rootAuthorities;
|
||||
@@ -443,7 +448,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
}
|
||||
|
||||
Set<String> authorities = new TreeSet<String>();
|
||||
findAuthorities(type, nodeRef, authorities, false, !immediate, false);
|
||||
listAuthorities(type, nodeRef, authorities, false, !immediate, false);
|
||||
return authorities;
|
||||
}
|
||||
}
|
||||
@@ -481,7 +486,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
if (authorities == null)
|
||||
{
|
||||
authorities = new TreeSet<String>();
|
||||
findAuthorities(null, name, authorities, true, true);
|
||||
listAuthorities(null, name, authorities, true, true);
|
||||
userAuthorityCache.put(name, authorities);
|
||||
}
|
||||
// If we wanted the unfiltered set we are done
|
||||
@@ -501,7 +506,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
else
|
||||
{
|
||||
Set<String> authorities = new TreeSet<String>();
|
||||
findAuthorities(type, name, authorities, true, !immediate);
|
||||
listAuthorities(type, name, authorities, true, !immediate);
|
||||
return authorities;
|
||||
}
|
||||
}
|
||||
@@ -566,7 +571,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
}
|
||||
}
|
||||
|
||||
private void findAuthorities(AuthorityType type, String name, Set<String> authorities, boolean parents, boolean recursive)
|
||||
private void listAuthorities(AuthorityType type, String name, Set<String> authorities, boolean parents, boolean recursive)
|
||||
{
|
||||
AuthorityType localType = AuthorityType.getAuthorityType(name);
|
||||
if (localType.equals(AuthorityType.GUEST))
|
||||
@@ -579,7 +584,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
|
||||
if (ref != null)
|
||||
{
|
||||
findAuthorities(type, ref, authorities, parents, recursive, false);
|
||||
listAuthorities(type, ref, authorities, parents, recursive, false);
|
||||
}
|
||||
else if (!localType.equals(AuthorityType.USER))
|
||||
{
|
||||
@@ -590,7 +595,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
}
|
||||
}
|
||||
|
||||
private void findAuthorities(AuthorityType type, NodeRef nodeRef, Set<String> authorities, boolean parents, boolean recursive, boolean includeNode)
|
||||
private void listAuthorities(AuthorityType type, NodeRef nodeRef, Set<String> authorities, boolean parents, boolean recursive, boolean includeNode)
|
||||
{
|
||||
if (includeNode)
|
||||
{
|
||||
@@ -610,7 +615,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
|
||||
for (ChildAssociationRef car : cars)
|
||||
{
|
||||
findAuthorities(type, car.getParentRef(), authorities, true, recursive, true);
|
||||
listAuthorities(type, car.getParentRef(), authorities, true, recursive, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -626,7 +631,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
||||
addAuthorityNameIfMatches(authorities, childName, type, null);
|
||||
if (recursive && childType != AuthorityType.USER)
|
||||
{
|
||||
findAuthorities(type, car.getChildRef(), authorities, false, true, false);
|
||||
listAuthorities(type, car.getChildRef(), authorities, false, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -377,7 +377,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
|
||||
|
||||
public Set<String> getAllRootAuthorities(AuthorityType type)
|
||||
{
|
||||
return authorityDAO.findAuthorities(type, null, true, null, null);
|
||||
return getAllRootAuthoritiesInZone(null, type);
|
||||
}
|
||||
|
||||
public Set<String> getContainedAuthorities(AuthorityType type, String name, boolean immediate)
|
||||
@@ -469,7 +469,7 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean
|
||||
|
||||
public Set<String> getAllRootAuthoritiesInZone(String zoneName, AuthorityType type)
|
||||
{
|
||||
return authorityDAO.findAuthorities(type, null, true, null, zoneName);
|
||||
return authorityDAO.getRootAuthorities(type, zoneName);
|
||||
}
|
||||
|
||||
public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -374,13 +374,13 @@ public interface AuthorityService
|
||||
public Set<String> getAllAuthoritiesInZone(String zoneName, AuthorityType type);
|
||||
|
||||
/**
|
||||
* Gets the names of all authorities in a zone, optionally filtered by type.
|
||||
* Gets the names of all root authorities in a zone, optionally filtered by type.
|
||||
*
|
||||
* @param zoneName
|
||||
* the zone name
|
||||
* @param type
|
||||
* the authority type to filter by or <code>null</code> for all authority types
|
||||
* @return the names of all authorities in a zone, optionally filtered by type
|
||||
* @return the names of all root authorities in a zone, optionally filtered by type
|
||||
*/
|
||||
@Auditable(parameters = {"zoneName", "type"})
|
||||
public Set<String> getAllRootAuthoritiesInZone(String zoneName, AuthorityType type);
|
||||
@@ -408,9 +408,10 @@ public interface AuthorityService
|
||||
@NotAuditable
|
||||
public Set<String> getDefaultZones();
|
||||
|
||||
|
||||
/**
|
||||
* Find authorities by pattern matching (* and ?) against the authority name.
|
||||
* Search for authorities by pattern matching (* and ?) against the authority name.
|
||||
* Note: This will use a search index to find the results (eg. via Lucene / SOLR).
|
||||
*
|
||||
* @param type
|
||||
* @param parentAuthority if non-null, will look only for authorities who are a child of the named parent
|
||||
* @param immediate if <code>true</code> then only search root groups if parentAuthority is null, or immediate children of parentAuthority if it is non-null.
|
||||
@@ -419,6 +420,5 @@ public interface AuthorityService
|
||||
* @return
|
||||
*/
|
||||
@Auditable(parameters = {"type"})
|
||||
public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate,
|
||||
String displayNamePattern, String zoneName);
|
||||
public Set<String> findAuthorities(AuthorityType type, String parentAuthority, boolean immediate, String displayNamePattern, String zoneName);
|
||||
}
|
Reference in New Issue
Block a user