Merged V3.4-BUG-FIX to HEAD

28583: Merged DEV/TEMPORARY to V3.4-BUG-FIX
      28451: ALF-5601: WCM Reviewer should be able to modify 'Launch Date' of the review item.
         Allows to modify "wcmwf:launchDate" and "wcmwf:autoDeploy" property during task management.
   28591: ALF-9208: Site Service performance
   - Avoid going through protected node service to access nodes already retrieved by it! Permission checks showing up as main performance drain.
   - Optimized listMembersImpl to reduce the number of expensive calls to authorityService.getContainedAuthorities
   28592: ALF-9208: Another unnecessary secondary permission check in createSiteInfo
   28593: ALF-9208: Fix to permission evaluation in getSiteNodeRef()
   28624: Merged PATCHES/V3.1.2 to V3.4-BUG-FIX
      28622: ALF-9325: Merged V3.2 to PATCHES/V3.1.2
         17523: ETHREEOH-3337: Fix NPEs in RepoServerMgmt operations
            - Transactional cache can have entries with non-null keys and null values
   28625: Merged DEV/TEMPORARY to V3.4-BUG-FIX (with corrections)
      28621: ALF-9113: CommandServlet.java, line 179 (Header Manipulation)
         1. Reject absolute URLs
         2. Support request-relative URLs that resolve under request context root
   28635: Merged V3.4 to V3.4-BUG-FIX
      28560: ALF-9087: Missing dataTypeAnalyzers_ja.properties in V3.4
      28634: ALF-9249: Stop potential 'ping pong' between subsystems starting and stopping in a cluster
         - Regression introduced by ALF-8025 in Team / 3.4.3
         - Introduced PENDING_BROADCAST_START state, so that a start() after a successful setProperties() broadcasts only once
         - Also automatic subsystem stops aren't broadcast during subsystem export!
         - Happens if sysAdmin edits have been persisted as sysAdmin will already have been started before we get to loading its properties


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28636 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2011-06-27 23:41:56 +00:00
parent a1549380bf
commit 97f676b895
3 changed files with 183 additions and 119 deletions

View File

@@ -73,6 +73,7 @@
<bean id="siteService" class="org.alfresco.repo.site.SiteServiceImpl" init-method="init"> <bean id="siteService" class="org.alfresco.repo.site.SiteServiceImpl" init-method="init">
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="directNodeService" ref="nodeService"/>
<property name="fileFolderService" ref="FileFolderService"/> <property name="fileFolderService" ref="FileFolderService"/>
<property name="searchService" ref="SearchService"/> <property name="searchService" ref="SearchService"/>
<property name="namespaceService" ref="NamespaceService"/> <property name="namespaceService" ref="NamespaceService"/>

View File

@@ -85,8 +85,10 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
/** Resolves placeholders in the property defaults. */ /** Resolves placeholders in the property defaults. */
private DefaultResolver defaultResolver = new DefaultResolver(); private DefaultResolver defaultResolver = new DefaultResolver();
/** Has the state been started yet?. */ /** The lifecycle states. */
private boolean isStarted; private enum RuntimeState {UNINITIALIZED, STOPPED, PENDING_BROADCAST_START, STARTED};
private RuntimeState runtimeState = RuntimeState.UNINITIALIZED;
/** The state. */ /** The state. */
private PropertyBackedBeanState state; private PropertyBackedBeanState state;
@@ -280,7 +282,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
protected void doInit() protected void doInit()
{ {
boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread(); boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread();
if (this.state == null) if (this.runtimeState == RuntimeState.UNINITIALIZED)
{ {
if (!hadWriteLock) if (!hadWriteLock)
{ {
@@ -289,10 +291,11 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
try try
{ {
if (this.state == null) if (this.runtimeState == RuntimeState.UNINITIALIZED)
{ {
this.state = createInitialState(); this.state = createInitialState();
applyDefaultOverrides(this.state); applyDefaultOverrides(this.state);
this.runtimeState = RuntimeState.STOPPED;
this.registry.register(this); this.registry.register(this);
} }
} }
@@ -412,7 +415,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/ */
protected void destroy(boolean isPermanent) protected void destroy(boolean isPermanent)
{ {
if (this.state != null) if (this.runtimeState != RuntimeState.UNINITIALIZED)
{ {
boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread(); boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread();
if (!hadWriteLock) if (!hadWriteLock)
@@ -422,11 +425,12 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
try try
{ {
if (this.state != null) if (this.runtimeState != RuntimeState.UNINITIALIZED)
{ {
stop(false); stop(false);
this.registry.deregister(this, isPermanent); this.registry.deregister(this, isPermanent);
this.state = null; this.state = null;
this.runtimeState = RuntimeState.UNINITIALIZED;
} }
} }
finally finally
@@ -484,10 +488,14 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try try
{ {
if (!this.isStarted) // If we aren't started, reinitialize so that we pick up state changes from the database
switch (this.runtimeState)
{ {
// Reinitialize so that we pick up state changes from the database case PENDING_BROADCAST_START:
case STOPPED:
destroy(false); destroy(false);
// fall through
case UNINITIALIZED:
start(false); start(false);
} }
} }
@@ -502,8 +510,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
try try
{ {
// Completely destroy the state so that it will have to be reinitialized should the bean be put back in // Completely destroy the state so that it will have to be reinitialized should the bean be put back in
// to // to use by this node
// use by this node
destroy(false); destroy(false);
} }
finally finally
@@ -555,6 +562,8 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try try
{ {
// Bring down the bean. The caller may have already broadcast this across the cluster
stop(false);
doInit(); doInit();
this.state.setProperty(name, value); this.state.setProperty(name, value);
} }
@@ -569,8 +578,8 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
this.lock.writeLock().lock(); this.lock.writeLock().lock();
try try
{ {
// Bring down the bean across the cluster // Bring down the bean. The caller may have already broadcast this across the cluster
stop(true); stop(false);
doInit(); doInit();
Map<String, String> previousValues = new HashMap<String, String>(properties.size() * 2); Map<String, String> previousValues = new HashMap<String, String>(properties.size() * 2);
@@ -588,7 +597,7 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
// Attempt to start locally // Attempt to start locally
start(false); start(false);
// We still haven't broadcast the start - a persist is required first // We still haven't broadcast the start - a persist is required first so this will be done by the caller
} }
catch (Exception e) catch (Exception e)
{ {
@@ -637,12 +646,8 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/ */
protected void start(boolean broadcast) protected void start(boolean broadcast)
{ {
if (broadcast)
{
this.registry.broadcastStart(this);
}
boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread(); boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread();
if (!this.isStarted) if (this.runtimeState != RuntimeState.STARTED)
{ {
if (!hadWriteLock) if (!hadWriteLock)
{ {
@@ -651,11 +656,21 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
try try
{ {
if (!this.isStarted) switch (this.runtimeState)
{ {
case UNINITIALIZED:
doInit(); doInit();
// fall through
case STOPPED:
this.state.start(); this.state.start();
this.isStarted = true; this.runtimeState = RuntimeState.PENDING_BROADCAST_START;
// fall through
case PENDING_BROADCAST_START:
if (broadcast)
{
this.registry.broadcastStart(this);
this.runtimeState = RuntimeState.STARTED;
}
} }
} }
finally finally
@@ -693,13 +708,11 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
*/ */
protected void stop(boolean broadcast) protected void stop(boolean broadcast)
{ {
if (broadcast)
{
this.registry.broadcastStop(this);
}
boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread(); boolean hadWriteLock = this.lock.isWriteLockedByCurrentThread();
if (this.isStarted) switch (this.runtimeState)
{ {
case PENDING_BROADCAST_START:
case STARTED:
if (!hadWriteLock) if (!hadWriteLock)
{ {
this.lock.readLock().unlock(); this.lock.readLock().unlock();
@@ -707,10 +720,17 @@ public abstract class AbstractPropertyBackedBean implements PropertyBackedBean,
} }
try try
{ {
if (this.isStarted) switch (this.runtimeState)
{ {
case STARTED:
if (broadcast)
{
this.registry.broadcastStop(this);
}
// fall through
case PENDING_BROADCAST_START:
this.state.stop(); this.state.stop();
this.isStarted = false; this.runtimeState = RuntimeState.STOPPED;
} }
} }
finally finally

View File

@@ -119,6 +119,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
/* Services */ /* Services */
private NodeService nodeService; private NodeService nodeService;
private NodeService directNodeService;
private FileFolderService fileFolderService; private FileFolderService fileFolderService;
private SearchService searchService; private SearchService searchService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
@@ -158,6 +159,14 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* Set the unprotected node service
*/
public void setDirectNodeService(NodeService directNodeService)
{
this.directNodeService = directNodeService;
}
/** /**
* Set file folder service * Set file folder service
*/ */
@@ -299,6 +308,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
public void init() public void init()
{ {
PropertyCheck.mandatory(this, "nodeService", nodeService); PropertyCheck.mandatory(this, "nodeService", nodeService);
PropertyCheck.mandatory(this, "directNodeService", directNodeService);
PropertyCheck.mandatory(this, "fileFolderService", fileFolderService); PropertyCheck.mandatory(this, "fileFolderService", fileFolderService);
PropertyCheck.mandatory(this, "searchService", searchService); PropertyCheck.mandatory(this, "searchService", searchService);
PropertyCheck.mandatory(this, "namespaceService", namespaceService); PropertyCheck.mandatory(this, "namespaceService", namespaceService);
@@ -379,7 +389,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
* Check that the site does not already exist * Check that the site does not already exist
*/ */
// Check to see if we already have a site of this name // Check to see if we already have a site of this name
NodeRef existingSite = getSiteNodeRef(shortName); NodeRef existingSite = getSiteNodeRef(shortName, false);
if (existingSite != null) if (existingSite != null)
{ {
// Throw an exception since we have a duplicate site name // Throw an exception since we have a duplicate site name
@@ -429,7 +439,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
// Create the site's groups // Create the site's groups
String siteGroup = authorityService String siteGroup = authorityService
.createAuthority(AuthorityType.GROUP, getSiteGroup(shortName, false), shortName, shareZones); .createAuthority(AuthorityType.GROUP, getSiteGroup(shortName, false), shortName, shareZones);
QName siteType = nodeService.getType(siteNodeRef); QName siteType = directNodeService.getType(siteNodeRef);
Set<String> permissions = permissionService.getSettablePermissions(siteType); Set<String> permissions = permissionService.getSettablePermissions(siteType);
for (String permission : permissions) for (String permission : permissions)
{ {
@@ -519,7 +529,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
private Map<QName, Serializable> getSiteCustomProperties(NodeRef siteNodeRef) private Map<QName, Serializable> getSiteCustomProperties(NodeRef siteNodeRef)
{ {
Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(4); Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>(4);
Map<QName, Serializable> properties = nodeService.getProperties(siteNodeRef); Map<QName, Serializable> properties = directNodeService.getProperties(siteNodeRef);
for (Map.Entry<QName, Serializable> entry : properties.entrySet()) for (Map.Entry<QName, Serializable> entry : properties.entrySet())
{ {
@@ -613,7 +623,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
NodeRef result = null; NodeRef result = null;
// Get the root 'sites' folder // Get the root 'sites' folder
NodeRef rootNodeRef = nodeService.getRootNode(SITE_STORE); NodeRef rootNodeRef = directNodeService.getRootNode(SITE_STORE);
List<NodeRef> results = searchService.selectNodes( List<NodeRef> results = searchService.selectNodes(
rootNodeRef, rootNodeRef,
sitesXPath, sitesXPath,
@@ -698,7 +708,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
for (NodeRef site : results.getNodeRefs()) for (NodeRef site : results.getNodeRefs())
{ {
// Ignore any node type that is not a "site" // Ignore any node type that is not a "site"
QName siteClassName = this.nodeService.getType(site); QName siteClassName = this.directNodeService.getType(site);
if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE) == true) if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE) == true)
{ {
result.add(createSiteInfo(site)); result.add(createSiteInfo(site));
@@ -723,7 +733,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
{ {
// Ignore any node type that is not a "site" // Ignore any node type that is not a "site"
NodeRef site = assoc.getChildRef(); NodeRef site = assoc.getChildRef();
QName siteClassName = this.nodeService.getType(site); QName siteClassName = this.directNodeService.getType(site);
if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE) == true) if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE) == true)
{ {
result.add(createSiteInfo(site)); result.add(createSiteInfo(site));
@@ -811,7 +821,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
{ {
// Ignore any node that is not a "site" type // Ignore any node that is not a "site" type
NodeRef site = assoc.getChildRef(); NodeRef site = assoc.getChildRef();
QName siteClassName = this.nodeService.getType(site); QName siteClassName = this.directNodeService.getType(site);
if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE)) if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE))
{ {
result.add(createSiteInfo(site)); result.add(createSiteInfo(site));
@@ -833,10 +843,8 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
{ {
SiteInfo siteInfo = null; SiteInfo siteInfo = null;
if (this.permissionService.hasPermission(siteNodeRef, PermissionService.READ_PROPERTIES).equals(AccessStatus.ALLOWED))
{
// Get the properties // Get the properties
Map<QName, Serializable> properties = this.nodeService.getProperties(siteNodeRef); Map<QName, Serializable> properties = this.directNodeService.getProperties(siteNodeRef);
String shortName = (String) properties.get(ContentModel.PROP_NAME); String shortName = (String) properties.get(ContentModel.PROP_NAME);
String sitePreset = (String) properties.get(PROP_SITE_PRESET); String sitePreset = (String) properties.get(PROP_SITE_PRESET);
String title = (String) properties.get(ContentModel.PROP_TITLE); String title = (String) properties.get(ContentModel.PROP_TITLE);
@@ -848,7 +856,6 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
// Create and return the site information // Create and return the site information
Map<QName, Serializable> customProperties = getSiteCustomProperties(properties); Map<QName, Serializable> customProperties = getSiteCustomProperties(properties);
siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef); siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef);
}
return siteInfo; return siteInfo;
} }
@@ -865,7 +872,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
SiteVisibility visibility = SiteVisibility.PRIVATE; SiteVisibility visibility = SiteVisibility.PRIVATE;
// Get the visibility value stored in the repo // Get the visibility value stored in the repo
String visibilityValue = (String)this.nodeService.getProperty(siteNodeRef, SiteModel.PROP_SITE_VISIBILITY); String visibilityValue = (String)this.directNodeService.getProperty(siteNodeRef, SiteModel.PROP_SITE_VISIBILITY);
// To maintain backwards compatibility calculate the visibility from the permissions // To maintain backwards compatibility calculate the visibility from the permissions
// if there is no value specified on the site node // if there is no value specified on the site node
@@ -964,7 +971,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
private NodeRef getSiteNodeRef(NodeRef nodeRef) private NodeRef getSiteNodeRef(NodeRef nodeRef)
{ {
NodeRef siteNodeRef = null; NodeRef siteNodeRef = null;
QName nodeRefType = nodeService.getType(nodeRef); QName nodeRefType = directNodeService.getType(nodeRef);
if (dictionaryService.isSubClass(nodeRefType, TYPE_SITE) == true) if (dictionaryService.isSubClass(nodeRefType, TYPE_SITE) == true)
{ {
siteNodeRef = nodeRef; siteNodeRef = nodeRef;
@@ -988,13 +995,26 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
* @return NodeRef node reference * @return NodeRef node reference
*/ */
private NodeRef getSiteNodeRef(final String shortName) private NodeRef getSiteNodeRef(final String shortName)
{
return getSiteNodeRef(shortName, true);
}
/**
* Gets the site's node reference based on its short name
*
* @param shortName short name
* @param enforcePermissions should we ensure that we have access to this node?
*
* @return NodeRef node reference
*/
private NodeRef getSiteNodeRef(final String shortName, boolean enforcePermissions)
{ {
final String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName; final String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName;
NodeRef siteNodeRef = this.siteNodeRefs.get(cacheKey); NodeRef siteNodeRef = this.siteNodeRefs.get(cacheKey);
if (siteNodeRef != null) if (siteNodeRef != null)
{ {
// test for existance - and remove from cache if no longer exists // test for existance - and remove from cache if no longer exists
if (!this.nodeService.exists(siteNodeRef)) if (!this.directNodeService.exists(siteNodeRef))
{ {
this.siteNodeRefs.remove(cacheKey); this.siteNodeRefs.remove(cacheKey);
siteNodeRef = null; siteNodeRef = null;
@@ -1010,7 +1030,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
public NodeRef doWork() throws Exception public NodeRef doWork() throws Exception
{ {
// the site "short name" directly maps to the cm:name property // the site "short name" directly maps to the cm:name property
NodeRef siteNode = nodeService.getChildByName(siteRoot, ContentModel.ASSOC_CONTAINS, shortName); NodeRef siteNode = directNodeService.getChildByName(siteRoot, ContentModel.ASSOC_CONTAINS, shortName);
// cache the result if found - null results will be required to ensure new sites are found later // cache the result if found - null results will be required to ensure new sites are found later
if (siteNode != null) if (siteNode != null)
@@ -1021,8 +1041,17 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
} }
if (enforcePermissions)
{
return siteNodeRef == null
|| !this.permissionService.hasPermission(siteNodeRef, PermissionService.READ_PROPERTIES).equals(
AccessStatus.ALLOWED) ? null : siteNodeRef;
}
else
{
return siteNodeRef; return siteNodeRef;
} }
}
/** /**
* @see org.alfresco.service.cmr.site.SiteService#updateSite(org.alfresco.service.cmr.site.SiteInfo) * @see org.alfresco.service.cmr.site.SiteService#updateSite(org.alfresco.service.cmr.site.SiteInfo)
@@ -1037,7 +1066,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
} }
// Get the sites properties // Get the sites properties
Map<QName, Serializable> properties = this.nodeService.getProperties(siteNodeRef); Map<QName, Serializable> properties = this.directNodeService.getProperties(siteNodeRef);
// Update the properties of the site // Update the properties of the site
// Note: the site preset and short name should never be updated! // Note: the site preset and short name should never be updated!
@@ -1111,7 +1140,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
{ {
throw new SiteServiceException(MSG_CAN_NOT_DELETE, new Object[]{shortName}); throw new SiteServiceException(MSG_CAN_NOT_DELETE, new Object[]{shortName});
} }
final QName siteType = nodeService.getType(siteNodeRef); final QName siteType = directNodeService.getType(siteNodeRef);
// Delete the cached reference // Delete the cached reference
String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName; String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName;
@@ -1216,54 +1245,70 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
Map<String, String> members = new HashMap<String, String>(32); Map<String, String> members = new HashMap<String, String>(32);
QName siteType = nodeService.getType(siteNodeRef); QName siteType = directNodeService.getType(siteNodeRef);
Set<String> permissions = this.permissionService.getSettablePermissions(siteType); Set<String> permissions = this.permissionService.getSettablePermissions(siteType);
Map<String, String> groupsToExpand = new HashMap<String, String>(32);
for (String permission : permissions) for (String permission : permissions)
{ {
if (roleFilter == null || roleFilter.length() == 0 || roleFilter.equals(permission)) if (roleFilter == null || roleFilter.length() == 0 || roleFilter.equals(permission))
{ {
String groupName = getSiteRoleGroup(shortName, permission, true); String groupName = getSiteRoleGroup(shortName, permission, true);
Set<String> users = this.authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); Set<String> authorities = this.authorityService.getContainedAuthorities(null, groupName, true);
for (String user : users) for (String authority : authorities)
{ {
switch (AuthorityType.getAuthorityType(authority))
{
case USER:
boolean addUser = true; boolean addUser = true;
if (nameFilter != null && nameFilter.length() != 0 && !nameFilter.equals(user)) if (nameFilter != null && nameFilter.length() != 0 && !nameFilter.equals(authority))
{ {
// found a filter - does it match person first/last name? // found a filter - does it match person first/last name?
addUser = matchPerson(nameFilters, user); addUser = matchPerson(nameFilters, authority);
} }
if (addUser) if (addUser)
{ {
// Add the user and their permission to the returned map // Add the user and their permission to the returned map
members.put(user, permission); members.put(authority, permission);
// break on max size limit reached // break on max size limit reached
if (members.size() == size) break; if (members.size() == size) break;
} }
} break;
case GROUP:
Set<String> groups = this.authorityService.getContainedAuthorities(AuthorityType.GROUP, groupName, true); if (collapseGroups)
for (String group : groups)
{ {
if (collapseGroups == false) if (!groupsToExpand.containsKey(authority))
{
groupsToExpand.put(authority, permission);
}
}
else
{ {
if (nameFilter != null && nameFilter.length() != 0) if (nameFilter != null && nameFilter.length() != 0)
{ {
// found a filter - does it match Group name part? // found a filter - does it match Group name part?
if (group.substring(GROUP_PREFIX_LENGTH).toLowerCase().contains(nameFilter.toLowerCase())) if (authority.substring(GROUP_PREFIX_LENGTH).toLowerCase().contains(nameFilter.toLowerCase()))
{ {
members.put(group, permission); members.put(authority, permission);
} }
} }
else else
{ {
// No name filter add this group // No name filter add this group
members.put(group, permission); members.put(authority, permission);
} }
} }
else break;
}
}
}
}
if (collapseGroups)
{ {
Set<String> subUsers = this.authorityService.getContainedAuthorities(AuthorityType.USER, group, false); for (Map.Entry<String,String> entry : groupsToExpand.entrySet())
{
Set<String> subUsers = this.authorityService.getContainedAuthorities(AuthorityType.USER, entry.getKey(), false);
for (String subUser : subUsers) for (String subUser : subUsers)
{ {
boolean addUser = true; boolean addUser = true;
@@ -1277,7 +1322,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
// Add the collapsed user into the members list if they do not already appear in the list // Add the collapsed user into the members list if they do not already appear in the list
if (members.containsKey(subUser) == false) if (members.containsKey(subUser) == false)
{ {
members.put(subUser, permission); members.put(subUser, entry.getValue());
} }
// break on max size limit reached // break on max size limit reached
@@ -1286,8 +1331,6 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
} }
} }
} }
}
}
return members; return members;
} }
@@ -1309,8 +1352,8 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
try try
{ {
NodeRef person = personService.getPerson(username, false); NodeRef person = personService.getPerson(username, false);
String firstName = (String)nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME); String firstName = (String)directNodeService.getProperty(person, ContentModel.PROP_FIRSTNAME);
String lastName = (String)nodeService.getProperty(person, ContentModel.PROP_LASTNAME); String lastName = (String)directNodeService.getProperty(person, ContentModel.PROP_LASTNAME);
final String lowFirstName = (firstName != null ? firstName.toLowerCase() : ""); final String lowFirstName = (firstName != null ? firstName.toLowerCase() : "");
final String lowLastName = (lastName != null ? lastName.toLowerCase() : ""); final String lowLastName = (lastName != null ? lastName.toLowerCase() : "");
@@ -1399,7 +1442,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
} }
List<String> fullResult = new ArrayList<String>(5); List<String> fullResult = new ArrayList<String>(5);
QName siteType = nodeService.getType(siteNodeRef); QName siteType = directNodeService.getType(siteNodeRef);
Set<String> roles = this.permissionService.getSettablePermissions(siteType); Set<String> roles = this.permissionService.getSettablePermissions(siteType);
// First use the authority's cached recursive group memberships to answer the question quickly // First use the authority's cached recursive group memberships to answer the question quickly
@@ -1455,7 +1498,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
{ {
throw new SiteServiceException(MSG_SITE_NO_EXIST, new Object[] { shortName }); throw new SiteServiceException(MSG_SITE_NO_EXIST, new Object[] { shortName });
} }
QName siteType = nodeService.getType(siteNodeRef); QName siteType = directNodeService.getType(siteNodeRef);
return getSiteRoles(siteType); return getSiteRoles(siteType);
} }
@@ -1710,7 +1753,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
// Set the properties if they have been provided // Set the properties if they have been provided
if (containerProperties != null) if (containerProperties != null)
{ {
Map<QName, Serializable> props = this.nodeService Map<QName, Serializable> props = this.directNodeService
.getProperties(containerNodeRef); .getProperties(containerNodeRef);
props.putAll(containerProperties); props.putAll(containerProperties);
this.nodeService.setProperties(containerNodeRef, props); this.nodeService.setProperties(containerNodeRef, props);
@@ -1764,7 +1807,7 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
throw new SiteServiceException(MSG_SITE_NO_EXIST, new Object[] { shortName }); throw new SiteServiceException(MSG_SITE_NO_EXIST, new Object[] { shortName });
} }
QName siteType = nodeService.getType(siteNodeRef); QName siteType = directNodeService.getType(siteNodeRef);
Set<String> permissions = permissionService.getSettablePermissions(siteType); Set<String> permissions = permissionService.getSettablePermissions(siteType);
for (String permission : permissions) for (String permission : permissions)
{ {
@@ -1894,9 +1937,9 @@ public class SiteServiceImpl implements SiteServiceInternal, SiteModel
NodeRef person = personService.getPerson(userName); NodeRef person = personService.getPerson(userName);
if (person != null) if (person != null)
{ {
memberFN = (String) nodeService.getProperty(person, memberFN = (String) directNodeService.getProperty(person,
ContentModel.PROP_FIRSTNAME); ContentModel.PROP_FIRSTNAME);
memberLN = (String) nodeService.getProperty(person, memberLN = (String) directNodeService.getProperty(person,
ContentModel.PROP_LASTNAME); ContentModel.PROP_LASTNAME);
} }