mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
JavaScript People API improvement, added getContainerGroups() useful method as requested on forums.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5779 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -225,6 +225,7 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
*
|
*
|
||||||
* @param group the group to retrieve members for
|
* @param group the group to retrieve members for
|
||||||
* @param recurse recurse into sub-groups
|
* @param recurse recurse into sub-groups
|
||||||
|
*
|
||||||
* @return the members of the group
|
* @return the members of the group
|
||||||
*/
|
*/
|
||||||
public Node[] getMembers(Node group)
|
public Node[] getMembers(Node group)
|
||||||
@@ -238,6 +239,7 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
*
|
*
|
||||||
* @param group the group to retrieve members for
|
* @param group the group to retrieve members for
|
||||||
* @param recurse recurse into sub-groups
|
* @param recurse recurse into sub-groups
|
||||||
|
*
|
||||||
* @return the members of the group
|
* @return the members of the group
|
||||||
*/
|
*/
|
||||||
public Node[] getMembers(Node group, boolean recurse)
|
public Node[] getMembers(Node group, boolean recurse)
|
||||||
@@ -246,13 +248,42 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
return getContainedAuthorities(group, AuthorityType.USER, recurse);
|
return getContainedAuthorities(group, AuthorityType.USER, recurse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the groups that contain the specified authority
|
||||||
|
*
|
||||||
|
* @param person the user (cm:person) to get the containing groups for
|
||||||
|
*
|
||||||
|
* @return the containing groups, can be null
|
||||||
|
*/
|
||||||
|
public Node[] getContainerGroups(Node person)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("Person", person);
|
||||||
|
Node[] parents = null;
|
||||||
|
Set<String> authorities = this.authorityService.getContainingAuthorities(
|
||||||
|
AuthorityType.GROUP,
|
||||||
|
(String)person.getProperties().get(ContentModel.PROP_USERNAME),
|
||||||
|
false);
|
||||||
|
parents = new Node[authorities.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (String authority : authorities)
|
||||||
|
{
|
||||||
|
Node group = getGroup(authority);
|
||||||
|
if (group != null)
|
||||||
|
{
|
||||||
|
parents[i++] = group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parents;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Contained Authorities
|
* Get Contained Authorities
|
||||||
*
|
*
|
||||||
* @param container authority containers
|
* @param container authority containers
|
||||||
* @param type authority type to filter by
|
* @param type authority type to filter by
|
||||||
* @param recurse recurse into sub-containers
|
* @param recurse recurse into sub-containers
|
||||||
* @return contained authorities
|
*
|
||||||
|
* @return contained authorities or null if none found
|
||||||
*/
|
*/
|
||||||
private Node[] getContainedAuthorities(Node container, AuthorityType type, boolean recurse)
|
private Node[] getContainedAuthorities(Node container, AuthorityType type, boolean recurse)
|
||||||
{
|
{
|
||||||
@@ -286,5 +317,4 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user