edu.internet2.middleware.grouper
Class GrouperHelper

java.lang.Object
  extended by edu.internet2.middleware.grouper.GrouperHelper

public class GrouperHelper
extends Object

High level wrapper methods for the Grouper API, including workarounds. Primarily developed for the UI.

Occasionally takes advantage of protected access to the Grouper API, however, this access should not be required once the API is fully implemented.

Version:
$Id: GrouperHelper.java,v 1.64 2009-11-07 12:20:32 isgwb Exp $
Author:
Gary Brown.

Field Summary
static String HIER_DELIM
           
static HashMap list2privMap
           
static String NS_ROOT
           
 
Constructor Summary
GrouperHelper()
           
 
Method Summary
static void assignPrivileges(GrouperSession s, String stemOrGroupId, Subject[] members, String[] privileges, boolean forStems)
          Given a GroupeGroup or GrouperStem id, an array of subjects and an array of privileges, grant the privileges to each subject for the GrouperStem or GrouperGroup
static void assignPrivileges(GrouperSession s, String stemOrGroupId, Subject[] members, String[] privileges, boolean forStems, Field field)
          Given a GroupeGroup or GrouperStem id, an array of subjects and an array of privileges, grant the privileges to each subject for the GrouperStem or GrouperGroup
static boolean canCopyGroupToStem(Stem stem, Set<Privilege> privs)
          Returns true if the following parameters would allow a subject to copy a group to the specified stem.
static boolean canCopyOtherStemToStem(Stem stem, boolean canCopy, Set<Privilege> privs)
          Returns true if the following parameter values would allow a subject to copy a stem to the specified stem.
static boolean canCopyStem(Stem stem, boolean canCopy)
          Return true if the following parameter values would allow a subject to copy the specified stem to another location.
static boolean canMoveGroupToStem(Stem stem, Set<Privilege> privs)
          Returns true if the following parameters would allow a subject to move a group to the specified stem.
static boolean canMoveOtherStemToStem(Stem stem, boolean canMove, Set<Privilege> privs)
          Returns true if the following parameters would allow a subject to move a stem to the specified stem.
static boolean canMoveStem(Stem stem, boolean canMove, Set<Privilege> privs)
          Returns true if the following parameter values would allow a subject to move the specified stem to another location.
static boolean canRead(GrouperSession s, Field field, Group g)
          Can the current user read this field? Should probably remove, API support is there now
static boolean canUserEditAnyCustomAttribute(Group group)
          Returns whether the user associated with the active GrouperSession can edit any cuustom attribute associate with the supplied group
static boolean canWrite(GrouperSession s, Field field, Group g)
          Can the current write read this field? Should probably remove, API support is there now
static Group copyGroup(Group group, Stem destinationStem, String[] selections)
          Copy a group
static Stem copyStem(Stem stemToCopy, Stem destinationStem, String[] selections)
          Copy a stem
static Stem createIfAbsentPersonalStem(GrouperSession s, PersonalStem ps)
          Given a PersonalStem create stem in correct location - depends on configuration.
static List embellishGroupMapsWithSubjectPrivs(GrouperSession s, List groups, Subject subject)
          Supplement group maps with privilege info for provided subject assuming subject has any privileges for this group
static List filterGroupsForSubject(GrouperSession s, List groups, Subject subject)
          Filter groups according to privileges of session subject and whether provided subject has any privileges for this group
static void fixSessionFields(Map fieldList)
          When we query fields we 'accumulate' them so we can check if tere are any new ones.
static Map getAllHas(GrouperSession s, GroupOrStem groupOrStem, Member member)
          Returns all privileges, direct and indirect, that member has for group or stem
static Map getAllHas(GrouperSession s, GroupOrStem groupOrStem, Member member, Field field)
          Returns all privileges, direct and indirect, that member has for group or stem
static List getAllWaysInWhichSubjectIsMemberOFGroup(GrouperSession s, Subject subject, Group group, Field field)
          API lets you get all memberships - this filters them for a specific group
static List getChain(GrouperSession s, Membership m)
          Return the path by which this Membership is derived
static String[] getChainGroupIds(GrouperSession s, Membership list)
           
static List getChildren(GrouperSession s, String stemId)
          Given a GrouperStem id return a list of stems and groups for which the GrouperStem is an immediate parent
static Map getCompositeMap(GrouperSession grouperSession, Composite comp)
          Given a composite return a Map for use in Tiles
static Map getCompositeMap(GrouperSession grouperSession, Composite comp, Subject subj)
          Given a composite return a Map for use in Tiles.
static Map getDefaultAccessPrivsForGrouperAPI()
          Queries GrouperConfig - grouper.properties - to determine which Access privs are granted to GrouperAll on group creation
static Map getDefaultAccessPrivsForUI(ResourceBundle mediaBundle)
          Checks key groups.create.grant.all to determine pre-selected privs to be checked in the UI.
static Map getEffectiveHas(GrouperSession s, GroupOrStem groupOrStem, Member member, Field field)
          Returns indirect privileges for member on the group or stem - but not how derived
static Map getEffectiveMembershipsForGroupAndSubject(GrouperSession s, Group group, Subject subject, Field field)
          Given a Group and Subject return the effective memberships keyed on the via group
static Map getExtendedHas(GrouperSession s, GroupOrStem groupOrStem, Member member)
          Returns indirect privileges for member on the group or stem
static Map getExtendedHas(GrouperSession s, GroupOrStem groupOrStem, Member member, Field field)
          Returns indirect privileges for member on the group or stem
static Map getFieldsAsMap()
          Retrieve Map of attributes which can be searched
static Map getFieldsForGroup(GrouperSession s, Group g, String priv)
          For a group, for all its types, return fields user can read / write
static String[] getGroupPrivs(GrouperSession s)
          Return an array of all access privileges
static String[] getGroupPrivsWithMember(GrouperSession s)
          Return an array of all access privileges + member
static Set getGroupsForPrivileges(GrouperSession s, String[] privs)
          Given a GrouperSession s, and an array of privileges, get all groups where s.subject() has atleast one of the privileges
static Set getGroupsForPrivileges(GrouperSession s, String[] privs, int start, int pageSize, StringBuffer resultCount)
          Given a GrouperSession s, and an array of privileges, get subset of groups where s.subject() has atleast one of the privileges, determined by start and pageSize

resultCount is a dubious means to return a second value to allow the UI to page results

static Set getGroupsOrStemsWhereMemberHasPriv(Member member, String privilege)
          Given a privilege return all the groups or stems where member has that privilege
static Set getGroupsWhereMemberHasPriv(Member member, String privilege)
          Given a privilege return all the groups where member has that privilege
static Map getImmediateHas(GrouperSession s, GroupOrStem groupOrStem, Member member)
          Returns direct privileges for member on group or stem
static Map getImmediateHas(GrouperSession s, GroupOrStem groupOrStem, Member member, Field field)
          Returns direct privileges for member on group or stem
static List getListFieldsForGroup(GrouperSession s, Group g)
          For a group, for all its types, return fields of type LIST
static List getListFieldsForGroup(GrouperSession s, String groupId)
          For a group id, for all its types, return fields of type LIST
static List getListFieldsForSubject(GrouperSession s, Subject subject)
          For a given subject determine all the custom list fields they appear in
static String getMemberDisplayValue(Member member, ResourceBundle bundle)
           
static Map getMemberships(GrouperSession s)
          Given a GrouperSession s, determine all the GrouperGroups s.subject() is a member of and return a Map where the keys are GrouperGroup keys
static Set getMembershipsSet(GrouperSession s)
          Given a GrouperSession s, determine all the GrouperGroups s.subject() is a member of and return a Set of GrouperGroups
static Set getMembershipsSet(GrouperSession s, int start, int pageSize, StringBuffer totalCount)
          Given a GrouperSession s, return a subset of Groups where s.subject is a member, determined by start and pageSize.

totalCount is a dubious means to return a second value to allow the UI to page results

static String getMemberUuid(Membership m)
          Rather than force a client to call getMember which involves a SQL query expose the memberUuid where that is sufficient
static List<Membership> getOneMembershipPerSubjectOrGroup(Set memberships, String type, Map count, Map sources, int membersFilterLimit)
          Trims down input so that the 'same' membership does not occur twice
static List getPersonSources()
          Query Subject API for sources and determine which ones return 'people'
static List getReadableListFieldsForGroup(GrouperSession s, Group g)
          For a group id, for all its types, return fields of type LIST which the session user can read or write
static List getReadableListFieldsForGroup(GrouperSession s, String groupId)
          For a group id, for all its types, return fields of type LIST which the session user can read or write
static GrouperSession getRootGrouperSession(GrouperSession s)
           
static List getSearchableFields(ResourceBundle bundle)
          Retrieve list of attributes which can be searched
static List getSearchableStemFields(ResourceBundle bundle)
          Returns a list of Maps representing name / displayNames for stem fields Stems don't have fields in the way Groups do.
static String[] getStemPrivs(GrouperSession s)
          Return an array of all naming privileges
static Collection getStemPrivsWithLabels(ResourceBundle bundle)
          Return a Collection of all naming privileges
static Set getStemsForPrivileges(GrouperSession s, String[] privs)
          Given a GrouperSession s, and an array of privileges, get all stems where s.subject() has atleast one of the privileges
static Set getStemsForPrivileges(GrouperSession s, String[] privs, int start, int pageSize, StringBuffer resultCount)
          Given a GrouperSession s, and an array of privileges, get subset of stems where s.subject() has atleast one of the privileges, determined by start and pageSize

resultCount is a dubious means to return a second value to allow the UI to page results

static Set getStemsWhereMemberHasPriv(Member member, String privilege)
          Given a privilege return all the stems where member has that privilege
static Subject getSubjectFromIdAndType(String subjectId, String subjectType)
          Given a Subject id and SubjectType return a Subject - or null if one not found
static Set getSubjectsWithPriv(Group group, String privilege)
          Given priv name return subjects with that privilege for group
static Set getSubjectsWithPriv(Stem stem, String privilege)
          Given priv name return subjects with that privilege for stem
static List getWritableListFieldsForGroup(GrouperSession s, Group g)
          For a group id, for all its types, return fields of type LIST which the session user can write
static List getWritableListFieldsForGroup(GrouperSession s, String groupId)
          For a group id, for all its types, return fields of type LIST which the session user can write
static Map group2Map(GrouperSession s, Group group)
          Given a Group return a Map representation of it
static Map group2Map(GrouperSession s, GroupOrStem groupOrStem)
          Given a GroupOrStem return a Map representing it
static Map group2Map(GrouperSession s, Stem stem)
          Given a Stem return a Map representing it
static boolean groupDelete(GrouperSession s, GroupOrStem groupOrStem)
          Given a GrouperGroup or GroupeStem delete it.
static List groupList2SubjectsMaps(GrouperSession s, List members)
          Given a list of GrouperMembers return a list of Map representations of them
static List groupList2SubjectsMaps(GrouperSession s, List members, int start, int pageSize)
          Given a list of GrouperList objects return a sublist from start to start + pageSize of each GrouperList.member() as a Map
static List groupList2SubjectsMaps(GrouperSession s, List members, String asMemberOf)
          Given a list of GrouperMembers return a list of Map representations of them where the key asMemberOf is set to the value of the parameter asMemberOf
static List groupList2SubjectsMaps(GrouperSession s, List members, String asMemberOf, int start, int pageSize)
          Given a list of GrouperMembers return a list of Map representations of a sublist of them (from start to start + pageSize) where the key asMemberOf is set to the value of the parameter asMemberOf
static Group groupLoadById(GrouperSession s, String id)
          Given a GrouperGroup id return the GrouperGroup
static List groups2Maps(GrouperSession s, List groups)
          Given a list of GrouperAttributes, return a list of GrouperGroups which the attributes belong to, and load all atributes for these groups
static Map hasAsMap(GrouperSession s, GroupOrStem groupOrStem)
          Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that s.subject() has.
static Map hasAsMap(GrouperSession s, GroupOrStem groupOrStem, boolean isMortal)
          Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that s.subject() has.
static Map hasAsMap(GrouperSession s, GroupOrStem groupOrStem, Member member, Field field)
          Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that member.subject() has.
static boolean hasOtherReadableFields(Group g, String fieldName)
           
static boolean hasSubjectImmPrivForGroup(GrouperSession s, Subject subject, Group group, String privilege)
          Determine if a given subject has been granted an Access privilege through direct assignment
static boolean hasSubjectImmPrivForStem(GrouperSession s, Subject subject, Stem stem, String privilege)
          Determine if a given subject has been granted a Naming privilege through direct assignment
static boolean isDirect(LazySubject ls)
           
static boolean isRoot(GrouperSession s)
           
static boolean isSuperUser(GrouperSession s)
          Is s.subject() the system user?
static Map listOfFieldsToMap(List fields)
           
static void main(String[] args)
           
static List memberships2Maps(GrouperSession s, Collection memberships)
          Use to get MembershipMaps rather than SubjectMaps.
static List memberships2Maps(GrouperSession s, Collection memberships, boolean withParents)
          Use to get MembershipMaps rather than SubjectMaps.
static void moveGroup(Group group, Stem destinationStem, String[] selections)
          Move a group
static void moveStem(Stem stemToMove, Stem destinationStem, String[] selections)
          Move a stem
static List parentStemsAsMaps(GrouperSession s, GroupOrStem groupOrStem)
          Given a GrouperGroup or GrouperStem return a list of ancestor GrouperStems as Maps
static List searchGroups(GrouperSession s, String query, String from, String searchInDisplayNameOrExtension, String searchInNameOrExtension)
          Given a simple query and scoping stem search for matching groups and return as List
static List searchGroups(GrouperSession s, String query, String from, String searchInDisplayNameOrExtension, String searchInNameOrExtension, String browseMode)
          Given simple query, scoping stem and ui browseMode return list of matching groups, pruned to give results relevant to browseMode.

The browseMode filtering needs to be factored into a new Class with interface so that new browse modes can be added easily

static List searchGroupsByAttribute(GrouperSession s, String query, String from, String attr)
          Given a simple query and scoping stem search for matching groups and return as List
static List searchStems(GrouperSession s, String query, String from, String searchInDisplayNameOrExtension, String searchInNameOrExtension)
          Given a simple query and scoping stem search for matching stems and return as List
static List searchStemsByAttribute(GrouperSession s, String query, String from, String attr)
          Given a simple query and scoping stem and attribute, search for matching stems and return as List
static void setMembershipCountPerSubjectOrGroup(List membershipMaps, String type, Map count)
          Given a trimmed list of memberships which are now Maps, add noWays -> number of direct and indirect memberships
static Map stem2Map(GrouperSession s, Stem stem)
          Given a GrouperStem return a Map representing it
static List stems2Maps(GrouperSession s, List stems)
          Given a ist of GrouperList objects return a list of instantiated GrouperStems as Maps
static Map subject2Map(GrouperSession s, String subjectId, String subjectType, String sourceId)
          Given a subject id and subject type return a Map representation of it.
static Map subject2Map(GrouperSession s, String subjectId, String subjectType, String sourceId, Map addAttr)
          Given a subject id and subject type and a Map, return a Map representation of the subject and add the key/value pairs from the input Map.
static Map subject2Map(Subject subject)
          Given a Subject return a Map representation of it
static Map<Object,Object> subject2Map(Subject subject, Map addAttr)
          Given a Subject return a Map representation of it
static List subjects2Maps(Object[] objects)
          Given an array of Subjects return a List of Maps representing those subjects
static List subjects2Maps(Object[] objects, Map addAttr)
          Given an array of Subjects return a List of Maps representing those subjects
static List subjects2Maps(Subject[] subjects)
          Given an array of Subjects return a List of Maps representing those subjects
static List<Map<Object,Object>> subjects2Maps(Subject[] subjects, Map addAttr)
          Given an array of Subjects return a List of Maps representing those subjects
static List subjects2SubjectPrivilegeMaps(GrouperSession s, Collection subjects, GroupOrStem groupOrStem, String privilege)
          Use to get SubjectPrivilegeMaps rather than SubjectMaps.
static List subjects2SubjectPrivilegeMaps(GrouperSession s, Collection subjects, Group group, String privilege)
          Use to get SubjectPrivilegeMaps rather than SubjectMaps.
static List subjects2SubjectPrivilegeMaps(GrouperSession s, Collection subjects, Stem stem, String privilege)
          Use to get SubjectPrivilegeMaps rather than SubjectMaps.
static List subjects2SubjectPrivilegeMaps(GrouperSession s, Collection groupsOrStems, Subject subject, String privilege)
          Use to get SubjectPrivilegeMaps rather than SubjectMaps.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list2privMap

public static HashMap list2privMap

HIER_DELIM

public static final String HIER_DELIM
See Also:
Constant Field Values

NS_ROOT

public static final String NS_ROOT
See Also:
Constant Field Values
Constructor Detail

GrouperHelper

public GrouperHelper()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

getChildren

public static List getChildren(GrouperSession s,
                               String stemId)
                        throws StemNotFoundException
Given a GrouperStem id return a list of stems and groups for which the GrouperStem is an immediate parent

Parameters:
s - GrouperSession for authenticated user
stemId - GrouperStem id
Returns:
List of all stems and groups for stemId
Throws:
StemNotFoundException

groups2Maps

public static List groups2Maps(GrouperSession s,
                               List groups)
                        throws GroupNotFoundException
Given a list of GrouperAttributes, return a list of GrouperGroups which the attributes belong to, and load all atributes for these groups

Parameters:
s - GrouperSession for authenticated user
list - of GrouperAtributes
Returns:
List of GrouperGroups or GrouperStems
Throws:
GroupNotFoundException

stems2Maps

public static List stems2Maps(GrouperSession s,
                              List stems)
                       throws GroupNotFoundException
Given a ist of GrouperList objects return a list of instantiated GrouperStems as Maps

Parameters:
s - GrouperSession for authenticated user
stems - List of GrouperLists
Returns:
List of GrouperStems wrapped as Maps
Throws:
GroupNotFoundException

stem2Map

public static Map stem2Map(GrouperSession s,
                           Stem stem)
Given a GrouperStem return a Map representing it

Parameters:
s - GrouperSession for authenticated user
stem - GrouperStem to wrap
Returns:
GrouperStem wrapped as a Map

group2Map

public static Map group2Map(GrouperSession s,
                            Stem stem)
Given a Stem return a Map representing it

Parameters:
s - GrouperSession for authenticated user
stem - GrouperStem to wrap
Returns:
Stem wrapped as a Map

group2Map

public static Map group2Map(GrouperSession s,
                            GroupOrStem groupOrStem)
Given a GroupOrStem return a Map representing it

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GroupOrStem to wrap
Returns:
GroupOrStem wrapped as a Map

group2Map

public static Map group2Map(GrouperSession s,
                            Group group)
Given a Group return a Map representation of it

Parameters:
s - GrouperSession for authenticated user
group - Group to wrap
Returns:
Group wrapped as a Map

parentStemsAsMaps

public static List parentStemsAsMaps(GrouperSession s,
                                     GroupOrStem groupOrStem)
                              throws StemNotFoundException
Given a GrouperGroup or GrouperStem return a list of ancestor GrouperStems as Maps

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GrouperGroup or GrouperStem
Returns:
List of ancestor GrouperStems wrapped as Maps
Throws:
StemNotFoundException

hasAsMap

public static Map hasAsMap(GrouperSession s,
                           GroupOrStem groupOrStem)
                    throws MemberNotFoundException
Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that s.subject() has.

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GrouperGroup or GroupeStem for which privileges are being requested
Returns:
Map representing privileges
Throws:
MemberNotFoundException

hasAsMap

public static Map hasAsMap(GrouperSession s,
                           GroupOrStem groupOrStem,
                           boolean isMortal)
                    throws MemberNotFoundException
Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that s.subject() has. If isMortal == false and the subject is the system user, all privileges are returned.

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GrouperGroup or GroupeStem for which privileges are being requested
isMortal - if system user should they be teated as such
Returns:
Map representing privileges
Throws:
MemberNotFoundException

hasAsMap

public static Map hasAsMap(GrouperSession s,
                           GroupOrStem groupOrStem,
                           Member member,
                           Field field)
                    throws SubjectNotFoundException,
                           SchemaException
Given a GrouperGroup or GrouperStem return a Map where the keys are access or naming privileges that member.subject() has.

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GrouperGroup or GroupeStem for which privileges are being requested
member - Subject who privileges were granted to
Returns:
Map representing privileges
Throws:
SubjectNotFoundException
SchemaException

subject2Map

public static Map subject2Map(Subject subject)
Given a Subject return a Map representation of it

Parameters:
subject - to be wrapped
Returns:
Subject wrapped as a Map

subject2Map

public static Map<Object,Object> subject2Map(Subject subject,
                                             Map addAttr)
Given a Subject return a Map representation of it

Parameters:
subject - to be wrapped
addAttr - Map of additional attributes
Returns:
Subject wrapped as a Map

subject2Map

public static Map subject2Map(GrouperSession s,
                              String subjectId,
                              String subjectType,
                              String sourceId,
                              Map addAttr)
                       throws SubjectNotFoundException
Given a subject id and subject type and a Map, return a Map representation of the subject and add the key/value pairs from the input Map.

Parameters:
s - GrouperSession for authenticated user
subjectId - Subject id
subjectType - Subject type e.g. person, group
addAttr - Map of aditional attributes
Returns:
Subject wrapped as a Map
Throws:
SubjectNotFoundException

subject2Map

public static Map subject2Map(GrouperSession s,
                              String subjectId,
                              String subjectType,
                              String sourceId)
                       throws SubjectNotFoundException
Given a subject id and subject type return a Map representation of it.

Parameters:
s - GrouperSession for authenticated user
subjectId - Subject id
subjectType - Subject type e.g. person, group
Returns:
Subject wrapped as a Map
Throws:
SubjectNotFoundException

subjects2Maps

public static List subjects2Maps(Object[] objects,
                                 Map addAttr)
Given an array of Subjects return a List of Maps representing those subjects

Parameters:
objects - array of Subjects
addAttr - Map of additional attributes
Returns:
List of Subjects wrapped as Maps

subjects2Maps

public static List subjects2Maps(Object[] objects)
Given an array of Subjects return a List of Maps representing those subjects

Parameters:
objects - array of Subjects
Returns:
List of Subjects wrapped as Maps

subjects2Maps

public static List<Map<Object,Object>> subjects2Maps(Subject[] subjects,
                                                     Map addAttr)
Given an array of Subjects return a List of Maps representing those subjects

Parameters:
subjects - array of Subjects
addAttr - Map of aditional attributes
Returns:
List of Subjects wrapped as Maps

subjects2Maps

public static List subjects2Maps(Subject[] subjects)
Given an array of Subjects return a List of Maps representing those subjects

Parameters:
subjects - array of Subjects
Returns:
List of Subjects wrapped as Maps

groupList2SubjectsMaps

public static List groupList2SubjectsMaps(GrouperSession s,
                                          List members,
                                          int start,
                                          int pageSize)
                                   throws GroupNotFoundException,
                                          SubjectNotFoundException,
                                          MemberNotFoundException,
                                          SubjectNotUniqueException
Given a list of GrouperList objects return a sublist from start to start + pageSize of each GrouperList.member() as a Map

Parameters:
s - GrouperSession for authenticated user
members - List of GrouperLists or GrouperMembers
start - 0 based start index
pageSize - number of results to return
Returns:
List of Subjects wrapped as Maps
Throws:
GroupNotFoundException
SubjectNotFoundException
MemberNotFoundException
SubjectNotUniqueException

groupList2SubjectsMaps

public static List groupList2SubjectsMaps(GrouperSession s,
                                          List members)
                                   throws GroupNotFoundException,
                                          SubjectNotFoundException,
                                          MemberNotFoundException,
                                          SubjectNotUniqueException
Given a list of GrouperMembers return a list of Map representations of them

Parameters:
s - GrouperSession for authenticated user
members - List of GrouperLists or GrouperMembers
Returns:
List of Subjects wrapped as Maps
Throws:
GroupNotFoundException
SubjectNotFoundException
MemberNotFoundException
SubjectNotUniqueException

groupList2SubjectsMaps

public static List groupList2SubjectsMaps(GrouperSession s,
                                          List members,
                                          String asMemberOf)
                                   throws GroupNotFoundException,
                                          SubjectNotFoundException,
                                          MemberNotFoundException,
                                          SubjectNotUniqueException
Given a list of GrouperMembers return a list of Map representations of them where the key asMemberOf is set to the value of the parameter asMemberOf

Parameters:
s - GrouperSession for authenticated user
members - List of GrouperLists or GrouperMembers
asMemberOf - GrouperGroup id identifying context
Returns:
List of Subjects wrapped as Maps
Throws:
GroupNotFoundException
SubjectNotFoundException
MemberNotFoundException
SubjectNotUniqueException

groupList2SubjectsMaps

public static List groupList2SubjectsMaps(GrouperSession s,
                                          List members,
                                          String asMemberOf,
                                          int start,
                                          int pageSize)
                                   throws GroupNotFoundException,
                                          SubjectNotFoundException,
                                          MemberNotFoundException,
                                          SubjectNotUniqueException
Given a list of GrouperMembers return a list of Map representations of a sublist of them (from start to start + pageSize) where the key asMemberOf is set to the value of the parameter asMemberOf

Parameters:
s - GrouperSession for authenticated user
members - List of GrouperLists or GrouperMembers
asMemberOf - GrouperGroup id identifying context
start - of sublist
pageSize - number of results to return
Returns:
List of Subjects wrapped as Maps
Throws:
GroupNotFoundException
SubjectNotFoundException
MemberNotFoundException
SubjectNotUniqueException

getChainGroupIds

public static String[] getChainGroupIds(GrouperSession s,
                                        Membership list)
                                 throws MemberNotFoundException,
                                        GroupNotFoundException
Throws:
MemberNotFoundException
GroupNotFoundException

assignPrivileges

public static void assignPrivileges(GrouperSession s,
                                    String stemOrGroupId,
                                    Subject[] members,
                                    String[] privileges,
                                    boolean forStems)
                             throws SchemaException,
                                    MemberAddException,
                                    InsufficientPrivilegeException,
                                    MemberNotFoundException,
                                    GrantPrivilegeException
Given a GroupeGroup or GrouperStem id, an array of subjects and an array of privileges, grant the privileges to each subject for the GrouperStem or GrouperGroup

Parameters:
s - GrouperSession for authenticated user
stemOrGroupId - GrouperGroup or GrouperStem id
members - array of Subjects
privileges - array of privileges
forStems - indicates GrouperStem
Throws:
SchemaException
MemberAddException
InsufficientPrivilegeException
MemberNotFoundException
GrantPrivilegeException

assignPrivileges

public static void assignPrivileges(GrouperSession s,
                                    String stemOrGroupId,
                                    Subject[] members,
                                    String[] privileges,
                                    boolean forStems,
                                    Field field)
                             throws SchemaException,
                                    MemberAddException,
                                    InsufficientPrivilegeException,
                                    MemberNotFoundException,
                                    GrantPrivilegeException
Given a GroupeGroup or GrouperStem id, an array of subjects and an array of privileges, grant the privileges to each subject for the GrouperStem or GrouperGroup

Parameters:
s - GrouperSession for authenticated user
stemOrGroupId - GrouperGroup or GrouperStem id
members - array of Subjects
privileges - array of privileges
forStems - indicates GrouperStem
Throws:
SchemaException
MemberAddException
InsufficientPrivilegeException
MemberNotFoundException
GrantPrivilegeException

isSuperUser

public static boolean isSuperUser(GrouperSession s)
Is s.subject() the system user?

Parameters:
s - GrouperSession for authenticated user
Returns:
boolean

getSubjectFromIdAndType

public static Subject getSubjectFromIdAndType(String subjectId,
                                              String subjectType)
Given a Subject id and SubjectType return a Subject - or null if one not found

Parameters:
subjectId - Subject id
subjectType - Subject type
Returns:
Subject

groupLoadById

public static Group groupLoadById(GrouperSession s,
                                  String id)
                           throws GroupNotFoundException
Given a GrouperGroup id return the GrouperGroup

Parameters:
s - GrouperSession for authenticated user
id - GrouperGroup id
Returns:
GrouperGroup
Throws:
GroupNotFoundException

getGroupPrivsWithMember

public static String[] getGroupPrivsWithMember(GrouperSession s)
Return an array of all access privileges + member

Parameters:
s - GrouperSession for authenticated user
Returns:
array of privilege names

getGroupPrivs

public static String[] getGroupPrivs(GrouperSession s)
Return an array of all access privileges

Parameters:
s - GrouperSession for authenticated user
Returns:
array of privilege names

getStemPrivs

public static String[] getStemPrivs(GrouperSession s)
Return an array of all naming privileges

Parameters:
s - GrouperSession for authenticated user
Returns:
array of privilege names

getStemPrivsWithLabels

public static Collection getStemPrivsWithLabels(ResourceBundle bundle)
Return a Collection of all naming privileges

Parameters:
bundle - ResourceBundle to lookup display name
Returns:
Collection of Maps of privilege names and display names

searchGroupsByAttribute

public static List searchGroupsByAttribute(GrouperSession s,
                                           String query,
                                           String from,
                                           String attr)
                                    throws QueryException,
                                           StemNotFoundException
Given a simple query and scoping stem search for matching groups and return as List

Parameters:
s - GrouperSession for authenticated user
query - to search for
from - stem which scopes search
attr - name of attribute to search
Returns:
List of groups matched
Throws:
QueryException
StemNotFoundException

searchGroups

public static List searchGroups(GrouperSession s,
                                String query,
                                String from,
                                String searchInDisplayNameOrExtension,
                                String searchInNameOrExtension)
                         throws StemNotFoundException,
                                QueryException
Given a simple query and scoping stem search for matching groups and return as List

Parameters:
s - GrouperSession for authenticated user
query - to search for
from - stem which scopes search
searchInDisplayNameOrExtension - name=displayName / extemsion=displayExtension
searchInNameOrExtension - name=name / extemsion=extension
Returns:
List of groups matched
Throws:
StemNotFoundException
QueryException

searchGroups

public static List searchGroups(GrouperSession s,
                                String query,
                                String from,
                                String searchInDisplayNameOrExtension,
                                String searchInNameOrExtension,
                                String browseMode)
                         throws Exception
Given simple query, scoping stem and ui browseMode return list of matching groups, pruned to give results relevant to browseMode.

The browseMode filtering needs to be factored into a new Class with interface so that new browse modes can be added easily

Parameters:
s - GrouperSession for authenticated user
query - to search for
from - Stem which scopes search
searchInDisplayNameOrExtension - name=displayName / extension=displayExtension
searchInNameOrExtension - name=name / extension=extension
browseMode - UI browse mode to filter results by
Returns:
List of GrouperGroups matched
Throws:
Exception

searchStemsByAttribute

public static List searchStemsByAttribute(GrouperSession s,
                                          String query,
                                          String from,
                                          String attr)
Given a simple query and scoping stem and attribute, search for matching stems and return as List

Parameters:
s - GrouperSession for authenticated user
query - to search for
from - stem which scopes search
attr - name of attribute to search
Returns:
List of stems matched

searchStems

public static List searchStems(GrouperSession s,
                               String query,
                               String from,
                               String searchInDisplayNameOrExtension,
                               String searchInNameOrExtension)
                        throws StemNotFoundException,
                               QueryException
Given a simple query and scoping stem search for matching stems and return as List

Parameters:
s - GrouperSession for authenticated user
query - to search for
from - stem which scopes search
searchInDisplayNameOrExtension - name=displayName / extemsion=displayExtension
searchInNameOrExtension - name=name / extemsion=extension
Returns:
List of stems matched
Throws:
StemNotFoundException
QueryException

getMembershipsSet

public static Set getMembershipsSet(GrouperSession s)
Given a GrouperSession s, determine all the GrouperGroups s.subject() is a member of and return a Set of GrouperGroups

Parameters:
s - GrouperSession for authenticated user
Returns:
Set of GrouperGroups

getMemberships

public static Map getMemberships(GrouperSession s)
Given a GrouperSession s, determine all the GrouperGroups s.subject() is a member of and return a Map where the keys are GrouperGroup keys

Parameters:
s - GrouperSession for authenticated user
Returns:
Map where keys are GrouperGroup keys

getMembershipsSet

public static Set getMembershipsSet(GrouperSession s,
                                    int start,
                                    int pageSize,
                                    StringBuffer totalCount)
Given a GrouperSession s, return a subset of Groups where s.subject is a member, determined by start and pageSize.

totalCount is a dubious means to return a second value to allow the UI to page results

Parameters:
s - GrouperSession for authenticated user
start - where subset begins
pageSize - no of groups to return
totalCount - number of overall results
Returns:
Set - subset of groups

getGroupsForPrivileges

public static Set getGroupsForPrivileges(GrouperSession s,
                                         String[] privs)
                                  throws MemberNotFoundException
Given a GrouperSession s, and an array of privileges, get all groups where s.subject() has atleast one of the privileges

Parameters:
s - GrouperSession for authenticated user
privs - privileges to test
Returns:
Set of Grouper Groups
Throws:
MemberNotFoundException

getGroupsForPrivileges

public static Set getGroupsForPrivileges(GrouperSession s,
                                         String[] privs,
                                         int start,
                                         int pageSize,
                                         StringBuffer resultCount)
                                  throws MemberNotFoundException
Given a GrouperSession s, and an array of privileges, get subset of groups where s.subject() has atleast one of the privileges, determined by start and pageSize

resultCount is a dubious means to return a second value to allow the UI to page results

Parameters:
s - GrouperSession for authenticated user
privs - privileges to test
start - of subset
pageSize - number of GrouperGroups to return
resultCount - overall number of GrouperGroups
Returns:
Set - subset of GrouperGroups
Throws:
MemberNotFoundException

getStemsForPrivileges

public static Set getStemsForPrivileges(GrouperSession s,
                                        String[] privs)
                                 throws MemberNotFoundException
Given a GrouperSession s, and an array of privileges, get all stems where s.subject() has atleast one of the privileges

Parameters:
s - GrouperSession for authenticated user
privs - privileges to test
Returns:
Set of GrouperStems
Throws:
MemberNotFoundException

getStemsForPrivileges

public static Set getStemsForPrivileges(GrouperSession s,
                                        String[] privs,
                                        int start,
                                        int pageSize,
                                        StringBuffer resultCount)
                                 throws MemberNotFoundException
Given a GrouperSession s, and an array of privileges, get subset of stems where s.subject() has atleast one of the privileges, determined by start and pageSize

resultCount is a dubious means to return a second value to allow the UI to page results

Parameters:
s - GrouperSession for authenticated user
privs - privileges to test
start - where subset begins
pageSize - number of GrouperStems to return
resultCount - overall number of GrouperStems
Returns:
Set of stems where session subject has one or more of Naming privileges specified by privs
Throws:
MemberNotFoundException

groupDelete

public static boolean groupDelete(GrouperSession s,
                                  GroupOrStem groupOrStem)
                           throws InsufficientPrivilegeException,
                                  MemberNotFoundException,
                                  SubjectNotFoundException,
                                  MemberDeleteException,
                                  SessionException
Given a GrouperGroup or GroupeStem delete it. GroupeStem must not have any children.

Parameters:
s - GrouperSession for authenticated user
groupOrStem - GrouperGroup or GrouperStem to delete
Returns:
boolean indicating success
Throws:
InsufficientPrivilegeException
MemberNotFoundException
SubjectNotFoundException
MemberDeleteException
SessionException

createIfAbsentPersonalStem

public static Stem createIfAbsentPersonalStem(GrouperSession s,
                                              PersonalStem ps)
                                       throws Exception
Given a PersonalStem create stem in correct location - depends on configuration. PersonalStem is an Interface and new implemetations may be 'plugged' into the UI

Parameters:
s - GrouperSession for authenticated user
ps - PersonalStem
Returns:
GrouperStem created
Throws:
Exception

getPersonSources

public static List getPersonSources()
                             throws Exception
Query Subject API for sources and determine which ones return 'people'

Returns:
List of Sources
Throws:
Exception

getAllWaysInWhichSubjectIsMemberOFGroup

public static List getAllWaysInWhichSubjectIsMemberOFGroup(GrouperSession s,
                                                           Subject subject,
                                                           Group group,
                                                           Field field)
                                                    throws MemberNotFoundException,
                                                           GroupNotFoundException,
                                                           SchemaException,
                                                           CompositeNotFoundException
API lets you get all memberships - this filters them for a specific group

Parameters:
s -
subject -
group -
Returns:
List with one item for each different way subject is a member of the specified list for the specified group
Throws:
MemberNotFoundException
GroupNotFoundException
SchemaException
CompositeNotFoundException

getExtendedHas

public static Map getExtendedHas(GrouperSession s,
                                 GroupOrStem groupOrStem,
                                 Member member)
                          throws SchemaException
Returns indirect privileges for member on the group or stem

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on privilege name forindirect privileges for member on the group or stem, and how derived
Throws:
SchemaException

getExtendedHas

public static Map getExtendedHas(GrouperSession s,
                                 GroupOrStem groupOrStem,
                                 Member member,
                                 Field field)
                          throws SchemaException
Returns indirect privileges for member on the group or stem

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on privilege name for indirect privileges for member on the group or stem, and how derived
Throws:
SchemaException

getEffectiveHas

public static Map getEffectiveHas(GrouperSession s,
                                  GroupOrStem groupOrStem,
                                  Member member,
                                  Field field)
                           throws SchemaException
Returns indirect privileges for member on the group or stem - but not how derived

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on name of privs which are indirectly assigned
Throws:
SchemaException

getImmediateHas

public static Map getImmediateHas(GrouperSession s,
                                  GroupOrStem groupOrStem,
                                  Member member)
                           throws SchemaException
Returns direct privileges for member on group or stem

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on name of privs which are directly assigned
Throws:
SchemaException

getImmediateHas

public static Map getImmediateHas(GrouperSession s,
                                  GroupOrStem groupOrStem,
                                  Member member,
                                  Field field)
                           throws SchemaException
Returns direct privileges for member on group or stem

Parameters:
s -
groupOrStem -
member -
field -
Returns:
Map keyed on name of privs which are directly assigned
Throws:
SchemaException

getAllHas

public static Map getAllHas(GrouperSession s,
                            GroupOrStem groupOrStem,
                            Member member)
                     throws SchemaException
Returns all privileges, direct and indirect, that member has for group or stem

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on privilege names - whether direct or indirect
Throws:
SchemaException

getAllHas

public static Map getAllHas(GrouperSession s,
                            GroupOrStem groupOrStem,
                            Member member,
                            Field field)
                     throws SchemaException
Returns all privileges, direct and indirect, that member has for group or stem

Parameters:
s -
groupOrStem -
member -
Returns:
Map keyed on privilege names - whether direct or indirect
Throws:
SchemaException

getEffectiveMembershipsForGroupAndSubject

public static Map getEffectiveMembershipsForGroupAndSubject(GrouperSession s,
                                                            Group group,
                                                            Subject subject,
                                                            Field field)
                                                     throws Exception
Given a Group and Subject return the effective memberships keyed on the via group

Parameters:
s -
group -
subject -
field -
Returns:
Map keyed on via groups
Throws:
Exception

getSubjectsWithPriv

public static Set getSubjectsWithPriv(Group group,
                                      String privilege)
Given priv name return subjects with that privilege for group

Parameters:
group -
privilege -
Returns:
Set of subjects with specified privilege for specified group

getGroupsOrStemsWhereMemberHasPriv

public static Set getGroupsOrStemsWhereMemberHasPriv(Member member,
                                                     String privilege)
Given a privilege return all the groups or stems where member has that privilege

Parameters:
member -
privilege -
Returns:
Set of groups where specified member has the specified privilege

getGroupsWhereMemberHasPriv

public static Set getGroupsWhereMemberHasPriv(Member member,
                                              String privilege)
Given a privilege return all the groups where member has that privilege

Parameters:
member -
privilege -
Returns:
Set of groups where specified member has the specified privilege

getStemsWhereMemberHasPriv

public static Set getStemsWhereMemberHasPriv(Member member,
                                             String privilege)
Given a privilege return all the stems where member has that privilege

Parameters:
member -
privilege -
Returns:
Set of groups where specified member has the specified privilege

getSubjectsWithPriv

public static Set getSubjectsWithPriv(Stem stem,
                                      String privilege)
Given priv name return subjects with that privilege for stem

Parameters:
stem -
privilege -
Returns:
Set of subjects with a specified Nmaing privilege for a specified stem

hasSubjectImmPrivForGroup

public static boolean hasSubjectImmPrivForGroup(GrouperSession s,
                                                Subject subject,
                                                Group group,
                                                String privilege)
                                         throws MemberNotFoundException,
                                                SchemaException
Determine if a given subject has been granted an Access privilege through direct assignment

Parameters:
s -
subject -
group -
privilege -
Returns:
whether the specified subject has a specified privilege directly assigned for a specified group
Throws:
MemberNotFoundException
SchemaException

hasSubjectImmPrivForStem

public static boolean hasSubjectImmPrivForStem(GrouperSession s,
                                               Subject subject,
                                               Stem stem,
                                               String privilege)
                                        throws MemberNotFoundException,
                                               SchemaException
Determine if a given subject has been granted a Naming privilege through direct assignment

Parameters:
s -
subject -
stem -
privilege -
Returns:
whether the specified subject has a specified privilege directly assigned for a specified stem
Throws:
MemberNotFoundException
SchemaException

getChain

public static List getChain(GrouperSession s,
                            Membership m)
                     throws GroupNotFoundException,
                            MembershipNotFoundException,
                            MemberNotFoundException,
                            SchemaException,
                            SubjectNotFoundException
Return the path by which this Membership is derived

Parameters:
s -
m -
Returns:
List where each element represents a link in the chain of the membership
Throws:
GroupNotFoundException
MembershipNotFoundException
MemberNotFoundException
SchemaException
SubjectNotFoundException

getCompositeMap

public static Map getCompositeMap(GrouperSession grouperSession,
                                  Composite comp)
                           throws GroupNotFoundException,
                                  MemberNotFoundException,
                                  SchemaException,
                                  SubjectNotFoundException
Given a composite return a Map for use in Tiles

Parameters:
grouperSession -
comp -
Returns:
a Map representing a Composite, for use in Tiles / JSTL
Throws:
GroupNotFoundException
MemberNotFoundException
SchemaException
SubjectNotFoundException

getCompositeMap

public static Map getCompositeMap(GrouperSession grouperSession,
                                  Composite comp,
                                  Subject subj)
                           throws GroupNotFoundException,
                                  MemberNotFoundException,
                                  SchemaException,
                                  SubjectNotFoundException
Given a composite return a Map for use in Tiles. If a Subject is passed then the number of ways the Subject is a member of the left / right groups is calculated

Parameters:
grouperSession -
comp -
subj -
Returns:
a Map representing the Composite and Membership infor for specified subject
Throws:
GroupNotFoundException
MemberNotFoundException
SchemaException
SubjectNotFoundException

getOneMembershipPerSubjectOrGroup

public static List<Membership> getOneMembershipPerSubjectOrGroup(Set memberships,
                                                                 String type,
                                                                 Map count,
                                                                 Map sources,
                                                                 int membersFilterLimit)
                                                          throws MemberNotFoundException,
                                                                 GroupNotFoundException
Trims down input so that the 'same' membership does not occur twice

Parameters:
memberships -
type -
count - - keeps track of the number of times a membership occurred
sources - - keeps track of different sources providing subjects
Returns:
List with one item per subject, but also update specified Map with count of how many memberships a member has
Throws:
MemberNotFoundException
GroupNotFoundException

setMembershipCountPerSubjectOrGroup

public static void setMembershipCountPerSubjectOrGroup(List membershipMaps,
                                                       String type,
                                                       Map count)
                                                throws GroupNotFoundException,
                                                       MemberNotFoundException
Given a trimmed list of memberships which are now Maps, add noWays -> number of direct and indirect memberships

Parameters:
membershipMaps -
type -
count -
Throws:
GroupNotFoundException
MemberNotFoundException

getDefaultAccessPrivsForUI

public static Map getDefaultAccessPrivsForUI(ResourceBundle mediaBundle)
Checks key groups.create.grant.all to determine pre-selected privs to be checked in the UI. If not set, checks default assignments in the Grouper API

Parameters:
mediaBundle -
Returns:
Map keyed on Access privilege names

getDefaultAccessPrivsForGrouperAPI

public static Map getDefaultAccessPrivsForGrouperAPI()
Queries GrouperConfig - grouper.properties - to determine which Access privs are granted to GrouperAll on group creation

Returns:
Map keyed on default Access privilege names

subjects2SubjectPrivilegeMaps

public static List subjects2SubjectPrivilegeMaps(GrouperSession s,
                                                 Collection subjects,
                                                 Group group,
                                                 String privilege)
Use to get SubjectPrivilegeMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
subjects -
group -
privilege -
Returns:
List of SubjectPrivilegeAsMap's for given subjects, group and privilege

subjects2SubjectPrivilegeMaps

public static List subjects2SubjectPrivilegeMaps(GrouperSession s,
                                                 Collection subjects,
                                                 Stem stem,
                                                 String privilege)
Use to get SubjectPrivilegeMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
subjects -
stem -
privilege -
Returns:
List of SubjectPrivilegeAsMap's for given subjects, stem and privilege

subjects2SubjectPrivilegeMaps

public static List subjects2SubjectPrivilegeMaps(GrouperSession s,
                                                 Collection subjects,
                                                 GroupOrStem groupOrStem,
                                                 String privilege)
Use to get SubjectPrivilegeMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
subjects -
groupOrStem -
privilege -
Returns:
List of SubjectPrivilegeAsMap's for given subjects, GroupOrStem and privilege

subjects2SubjectPrivilegeMaps

public static List subjects2SubjectPrivilegeMaps(GrouperSession s,
                                                 Collection groupsOrStems,
                                                 Subject subject,
                                                 String privilege)
Use to get SubjectPrivilegeMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
groupsOrStems -
subject -
privilege -
Returns:
List of SubjectPrivilegeAsMap's for given subject, GroupOrStems and privilege

memberships2Maps

public static List memberships2Maps(GrouperSession s,
                                    Collection memberships)
Use to get MembershipMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
memberships -
Returns:
List of Memberships as Maps

memberships2Maps

public static List memberships2Maps(GrouperSession s,
                                    Collection memberships,
                                    boolean withParents)
Use to get MembershipMaps rather than SubjectMaps. Relevant UI now uses these objects which can be used for more fine-grained template resolution

Parameters:
s -
memberships -
withParents -
Returns:
List of Memberships as Maps

getListFieldsForSubject

public static List getListFieldsForSubject(GrouperSession s,
                                           Subject subject)
                                    throws Exception
For a given subject determine all the custom list fields they appear in

Parameters:
s -
subject -
Returns:
List of field names the subject is a member of
Throws:
Exception

listOfFieldsToMap

public static Map listOfFieldsToMap(List fields)

getWritableListFieldsForGroup

public static List getWritableListFieldsForGroup(GrouperSession s,
                                                 String groupId)
                                          throws Exception
For a group id, for all its types, return fields of type LIST which the session user can write

Parameters:
s -
groupId -
Returns:
List of list fields for group
Throws:
Exception

getWritableListFieldsForGroup

public static List getWritableListFieldsForGroup(GrouperSession s,
                                                 Group g)
                                          throws Exception
For a group id, for all its types, return fields of type LIST which the session user can write

Parameters:
s -
g -
Returns:
List of list fields for group
Throws:
Exception

getReadableListFieldsForGroup

public static List getReadableListFieldsForGroup(GrouperSession s,
                                                 String groupId)
                                          throws Exception
For a group id, for all its types, return fields of type LIST which the session user can read or write

Parameters:
s -
groupId -
Returns:
List of list fields for group
Throws:
Exception

getReadableListFieldsForGroup

public static List getReadableListFieldsForGroup(GrouperSession s,
                                                 Group g)
                                          throws Exception
For a group id, for all its types, return fields of type LIST which the session user can read or write

Parameters:
s -
g -
Returns:
List of list fields for group
Throws:
Exception

getListFieldsForGroup

public static List getListFieldsForGroup(GrouperSession s,
                                         String groupId)
                                  throws Exception
For a group id, for all its types, return fields of type LIST

Parameters:
s -
groupId -
Returns:
List of list fields for group
Throws:
Exception

getListFieldsForGroup

public static List getListFieldsForGroup(GrouperSession s,
                                         Group g)
                                  throws SchemaException
For a group, for all its types, return fields of type LIST

Parameters:
s -
g -
Returns:
List of list fields for group
Throws:
SchemaException

getFieldsForGroup

public static Map getFieldsForGroup(GrouperSession s,
                                    Group g,
                                    String priv)
                             throws SchemaException
For a group, for all its types, return fields user can read / write

Parameters:
s -
g -
priv - read / write
Returns:
Map keyed on field names
Throws:
SchemaException

canRead

public static boolean canRead(GrouperSession s,
                              Field field,
                              Group g)
                       throws SchemaException
Can the current user read this field? Should probably remove, API support is there now

Parameters:
s -
field -
g -
Returns:
whether session subject can read specified field for specified group
Throws:
SchemaException

canWrite

public static boolean canWrite(GrouperSession s,
                               Field field,
                               Group g)
                        throws SchemaException
Can the current write read this field? Should probably remove, API support is there now

Parameters:
s -
field -
g -
Returns:
whether session subject can write specified field for specified group
Throws:
SchemaException

getSearchableFields

public static List getSearchableFields(ResourceBundle bundle)
                                throws SchemaException
Retrieve list of attributes which can be searched

Returns:
List of searchable fields
Throws:
SchemaException

fixSessionFields

public static void fixSessionFields(Map fieldList)
                             throws SchemaException
When we query fields we 'accumulate' them so we can check if tere are any new ones. If there are we refresh the session list

Parameters:
fieldList - Map of FieldAsMaps from the HttpSession
Throws:
SchemaException

getFieldsAsMap

public static Map getFieldsAsMap()
                          throws SchemaException
Retrieve Map of attributes which can be searched

Returns:
Map of searchable fields
Throws:
SchemaException

canUserEditAnyCustomAttribute

public static boolean canUserEditAnyCustomAttribute(Group group)
                                             throws SchemaException
Returns whether the user associated with the active GrouperSession can edit any cuustom attribute associate with the supplied group

Parameters:
group -
Returns:
whether the user associated with the active GrouperSession can edit any cuustom attribute associate with the supplied group
Throws:
SchemaException

getSearchableStemFields

public static List getSearchableStemFields(ResourceBundle bundle)
Returns a list of Maps representing name / displayNames for stem fields Stems don't have fields in the way Groups do. This approach allows for similar code for advanced group and stem searching

Parameters:
bundle -
Returns:
a list of Maps representing name / displayNames for stem fields

filterGroupsForSubject

public static List filterGroupsForSubject(GrouperSession s,
                                          List groups,
                                          Subject subject)
Filter groups according to privileges of session subject and whether provided subject has any privileges for this group

Parameters:
s -
groups -
subject -
Returns:
filtered List

embellishGroupMapsWithSubjectPrivs

public static List embellishGroupMapsWithSubjectPrivs(GrouperSession s,
                                                      List groups,
                                                      Subject subject)
                                               throws Exception
Supplement group maps with privilege info for provided subject assuming subject has any privileges for this group

Parameters:
s -
groups -
subject -
Returns:
a List of embellished groups
Throws:
Exception

getMemberUuid

public static String getMemberUuid(Membership m)
Rather than force a client to call getMember which involves a SQL query expose the memberUuid where that is sufficient

Parameters:
m -
Returns:
memberUuid

isRoot

public static boolean isRoot(GrouperSession s)

getRootGrouperSession

public static GrouperSession getRootGrouperSession(GrouperSession s)

isDirect

public static boolean isDirect(LazySubject ls)

hasOtherReadableFields

public static boolean hasOtherReadableFields(Group g,
                                             String fieldName)

canCopyStem

public static boolean canCopyStem(Stem stem,
                                  boolean canCopy)
Return true if the following parameter values would allow a subject to copy the specified stem to another location.

Parameters:
stem -
canCopy - This is false if there's a security group limiting the subjects that can copy stems and this subject is not in the group.
Returns:
boolean

canMoveStem

public static boolean canMoveStem(Stem stem,
                                  boolean canMove,
                                  Set<Privilege> privs)
Returns true if the following parameter values would allow a subject to move the specified stem to another location.

Parameters:
stem -
canMove - This is false if there's a security group limiting the subjects that can move stems and this subject is not in the group.
privs - The naming privileges that the subject has on the stem.
Returns:
boolean

canCopyOtherStemToStem

public static boolean canCopyOtherStemToStem(Stem stem,
                                             boolean canCopy,
                                             Set<Privilege> privs)
Returns true if the following parameter values would allow a subject to copy a stem to the specified stem.

Parameters:
canCopy - This is false if there's a security group limiting the subjects that can copy stems and this subject is not in the group.
privs - The naming privileges that the subject has on the specified stem.
Returns:
boolean

canMoveOtherStemToStem

public static boolean canMoveOtherStemToStem(Stem stem,
                                             boolean canMove,
                                             Set<Privilege> privs)
Returns true if the following parameters would allow a subject to move a stem to the specified stem.

Parameters:
canMove - This is false if there's a security group limiting the subjects that can move stems and this subject is not in the group.
privs - The naming privileges that the subject has on the specified stem.
Returns:
boolean

canCopyGroupToStem

public static boolean canCopyGroupToStem(Stem stem,
                                         Set<Privilege> privs)
Returns true if the following parameters would allow a subject to copy a group to the specified stem.

Parameters:
stem -
privs - The naming privileges that the subject has on the stem.
Returns:
boolean

canMoveGroupToStem

public static boolean canMoveGroupToStem(Stem stem,
                                         Set<Privilege> privs)
Returns true if the following parameters would allow a subject to move a group to the specified stem.

Parameters:
stem -
privs - The naming privileges that the subject has on the stem.
Returns:
boolean

copyGroup

public static Group copyGroup(Group group,
                              Stem destinationStem,
                              String[] selections)
Copy a group

Parameters:
group -
destinationStem -
selections -
Returns:

moveGroup

public static void moveGroup(Group group,
                             Stem destinationStem,
                             String[] selections)
Move a group

Parameters:
group -
destinationStem -
selections -

copyStem

public static Stem copyStem(Stem stemToCopy,
                            Stem destinationStem,
                            String[] selections)
Copy a stem

Parameters:
stemToCopy -
destinationStem -
selections -
Returns:

moveStem

public static void moveStem(Stem stemToMove,
                            Stem destinationStem,
                            String[] selections)
Move a stem

Parameters:
stemToMove -
destinationStem -
selections -

getMemberDisplayValue

public static String getMemberDisplayValue(Member member,
                                           ResourceBundle bundle)