Merged BRANCHES/DEV/V4.1-BUG-FIX to HEAD

47670: ALF-18245 - BM-0013: Soak: Run 06: Search population of ScriptNode is expensive
          - Optimizations to improve the performance of the repository when retrieving the populating data needed for Share Search results
          - Additional service method to PersonService to allow retrieval of a person or null in a single operation - rather than exists() followed get()
          - Improvements to generate of full name strings for a Person - only retrieve minimum needed properties rather than allprops from cm:person
          - Improvements to generation of DisplayPath to avoid multiple permission checks

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47674 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2013-03-06 16:52:09 +00:00
parent 6652e37815
commit 80887b8462
7 changed files with 122 additions and 25 deletions

View File

@@ -837,23 +837,41 @@ public final class People extends BaseScopableProcessorExtension implements Init
peopleRefs.toArray(people);
return people;
}
}
/**
* Gets the Person given the username
*
* @param username the username of the person to get
* @return the person node (type cm:person) or null if no such person exists
*/
public ScriptNode getPerson(String username)
public ScriptNode getPerson(final String username)
{
ParameterCheck.mandatoryString("Username", username);
ScriptNode person = null;
if (personService.personExists(username))
final NodeRef personRef = personService.getPerson(username, false);
return new ScriptNode(personRef, services, getScope());
}
/**
* Faster helper when the script just wants to build the Full name for a person.
* Avoids complete getProperties() retrieval for a cm:person.
*
* @param username the username of the person to get Full name for
* @return full name for a person or null if the user does not exist in the system.
*/
public String getPersonFullName(final String username)
{
String name = null;
ParameterCheck.mandatoryString("Username", username);
final NodeRef personRef = personService.getPersonOrNull(username);
if (personRef != null)
{
NodeRef personRef = personService.getPerson(username);
person = new ScriptNode(personRef, services, getScope());
final NodeService nodeService = services.getNodeService();
final String firstName = (String)nodeService.getProperty(personRef, ContentModel.PROP_FIRSTNAME);
final String lastName = (String)nodeService.getProperty(personRef, ContentModel.PROP_LASTNAME);
name = (firstName != null ? firstName + " " : "") + (lastName != null ? lastName : "");
}
return person;
return name;
}
/**