Package com.xpn.xwiki.user.impl.xwiki
Class XWikiGroupServiceImpl
- java.lang.Object
-
- com.xpn.xwiki.user.impl.xwiki.XWikiGroupServiceImpl
-
- All Implemented Interfaces:
XWikiGroupService,org.xwiki.observation.EventListener
public class XWikiGroupServiceImpl extends Object implements XWikiGroupService, org.xwiki.observation.EventListener
Default implementation ofXWikiGroupServiceusers and groups manager.- Version:
- $Id: 61853acf8e11d95f8cb5b36393dc084d62c91963 $
-
-
Field Summary
Fields Modifier and Type Field Description static EntityReferenceGROUPCLASS_REFERENCE
-
Constructor Summary
Constructors Constructor Description XWikiGroupServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddUserToGroup(String username, String database, String group, XWikiContext context)Deprecated.intcountAllGroupsNamesForMember(String member, XWikiContext context)Return the number of groups containing provided member.intcountAllMatchedGroups(Object[][] matchFields, XWikiContext context)Return number of groups with provided constraints.intcountAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext)Filters the members of the specified group using the given text and counts the results.intcountAllMatchedUsers(Object[][] matchFields, XWikiContext context)Return number of users with provided constraints.protected intcountAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context)Return number of users or groups with provided constraints.intcountAllMembersNamesForGroup(String group, XWikiContext context)Return the number of members provided group contains.protected StringcreateMatchGroupMembersWhereClause(String groupFullName, String matchField, Boolean orderAsc, Map<String,Object> parameterValues)Create a query to filter provided group members.protected StringcreateMatchUserOrGroupWhereClause(boolean user, Object[][] matchFields, Object[][] order, List<Object> parameterValues)Create a "where clause" to use withXWikiStoreInterfacesearchDocuments and searchDocumentsNames methods.voidflushCache()Collection<String>getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context)Get all groups containing provided member in the provided member wiki.Collection<DocumentReference>getAllGroupsReferencesForMember(DocumentReference memberReference, int limit, int offset, XWikiContext context)Get all groups containing provided member in the current wiki.List<?>getAllMatchedGroups(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context)Search for all groups with provided constraints and in a provided order.Collection<String>getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context)Get members of provided group.List<?>getAllMatchedUsers(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context)Search for all users with provided constraints and in a provided order.protected List<?>getAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context)Search for all users or group with provided constraints and in a provided order.Collection<String>getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context)Get all members provided group contains.List<Event>getEvents()StringgetName()voidinit(XWiki xwiki, XWikiContext context)voidinitCache(int iCapacity, XWikiContext context)voidinitCache(XWikiContext context)protected booleanisAllGroupImplicit(XWikiContext context)Check whether the configuration specifies that every user is implicitly in XWikiAllGroup.List<String>listAllGroups(XWikiContext context)Deprecated.Collection<String>listGroupsForUser(String member, XWikiContext context)Deprecated.List<String>listMemberForGroup(String group, XWikiContext context)Deprecated.voidonEvent(Event event, Object source, Object data)voidremoveUserOrGroupFromAllGroups(String memberWiki, String memberSpace, String memberName, XWikiContext context)Remove user or group name from all groups.voidreplaceMemberInAllGroups(DocumentReference memberSourceReference, DocumentReference memberTargetReference, XWikiContext context)Replace a given member reference by another one in all groups of the wiki.
-
-
-
Field Detail
-
GROUPCLASS_REFERENCE
public static final EntityReference GROUPCLASS_REFERENCE
-
-
Method Detail
-
init
public void init(XWiki xwiki, XWikiContext context) throws XWikiException
- Specified by:
initin interfaceXWikiGroupService- Throws:
XWikiException
-
initCache
public void initCache(XWikiContext context) throws XWikiException
- Specified by:
initCachein interfaceXWikiGroupService- Throws:
XWikiException
-
initCache
public void initCache(int iCapacity, XWikiContext context) throws XWikiException- Specified by:
initCachein interfaceXWikiGroupService- Throws:
XWikiException
-
flushCache
public void flushCache()
- Specified by:
flushCachein interfaceXWikiGroupService
-
isAllGroupImplicit
protected boolean isAllGroupImplicit(XWikiContext context)
Check whether the configuration specifies that every user is implicitly in XWikiAllGroup. Configured by thexwiki.authentication.group.allgroupimplicitparameter inxwiki.cfg.- Parameters:
context- the current XWiki context- Returns:
trueif the group is implicit and all users should be by default in it,falseif the group behaves as all other groups, containing only the users/subgroups that are explicitly listed inside the document.
-
listGroupsForUser
@Deprecated public Collection<String> listGroupsForUser(String member, XWikiContext context) throws XWikiException
Deprecated.- Specified by:
listGroupsForUserin interfaceXWikiGroupService- Throws:
XWikiException
-
addUserToGroup
@Deprecated public void addUserToGroup(String username, String database, String group, XWikiContext context) throws XWikiException
Deprecated.- Specified by:
addUserToGroupin interfaceXWikiGroupService- Throws:
XWikiException
-
replaceMemberInAllGroups
public void replaceMemberInAllGroups(DocumentReference memberSourceReference, DocumentReference memberTargetReference, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceReplace a given member reference by another one in all groups of the wiki.- Specified by:
replaceMemberInAllGroupsin interfaceXWikiGroupService- Parameters:
memberSourceReference- the reference of the member that should be replacedmemberTargetReference- the reference of the member that is used as replacementcontext- the current context- Throws:
XWikiException- in case of problem when doing the replacement
-
removeUserOrGroupFromAllGroups
public void removeUserOrGroupFromAllGroups(String memberWiki, String memberSpace, String memberName, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceRemove user or group name from all groups.- Specified by:
removeUserOrGroupFromAllGroupsin interfaceXWikiGroupService- Parameters:
memberWiki- the name of the wiki of the member.memberSpace- the name of the space of the member.memberName- the name of the member.context- the XWiki context.- Throws:
XWikiException- error when browsing groups.
-
listMemberForGroup
@Deprecated public List<String> listMemberForGroup(String group, XWikiContext context) throws XWikiException
Deprecated.- Specified by:
listMemberForGroupin interfaceXWikiGroupService- Throws:
XWikiException
-
listAllGroups
@Deprecated public List<String> listAllGroups(XWikiContext context) throws XWikiException
Deprecated.- Specified by:
listAllGroupsin interfaceXWikiGroupService- Throws:
XWikiException
-
getName
public String getName()
- Specified by:
getNamein interfaceorg.xwiki.observation.EventListener
-
getEvents
public List<Event> getEvents()
- Specified by:
getEventsin interfaceorg.xwiki.observation.EventListener
-
onEvent
public void onEvent(Event event, Object source, Object data)
- Specified by:
onEventin interfaceorg.xwiki.observation.EventListener
-
getAllMatchedUsers
public List<?> getAllMatchedUsers(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceSearch for all users with provided constraints and in a provided order.- Specified by:
getAllMatchedUsersin interfaceXWikiGroupService- Parameters:
matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
withdetails- indicate if aListcontainingStringnames is returned orListcontainingXWikiDocument.nb- the maximum number of results to return. Infinite if 0.start- the index of the first found user to return.order- the fields to order from. It is a table of table with :- fieldname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- asc : a Boolean, if true the order is ascendent
context- theXWikiContext.- Returns:
- the list of users.
- Throws:
XWikiException- error when getting users.
-
getAllMatchedGroups
public List<?> getAllMatchedGroups(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceSearch for all groups with provided constraints and in a provided order.- Specified by:
getAllMatchedGroupsin interfaceXWikiGroupService- Parameters:
matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
withdetails- indicate if aListcontainingStringnames is returned orListcontainingXWikiDocument.nb- the maximum number of result to return. Infinite if 0.start- the index of the first found group to return.order- the field to order from. It is a table of table with :- fieldname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- asc : a Boolean, if true the order is ascendent
context- theXWikiContext.- Returns:
- the list of groups.
- Throws:
XWikiException- error when getting groups.
-
createMatchUserOrGroupWhereClause
protected String createMatchUserOrGroupWhereClause(boolean user, Object[][] matchFields, Object[][] order, List<Object> parameterValues)
Create a "where clause" to use withXWikiStoreInterfacesearchDocuments and searchDocumentsNames methods.- Parameters:
user- if true search for users, otherwise search for groups.matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
order- the field to order from. It is a table of table with :- fieldname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- asc : a Boolean, if true the order is ascendent
parameterValues- the list of values to fill for use with HQL named request.- Returns:
- the formated HQL named request.
-
getAllMatchedUsersOrGroups
protected List<?> getAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order, XWikiContext context) throws XWikiException
Search for all users or group with provided constraints and in a provided order.- Parameters:
user- if true search for users, otherwise search for groups.matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
withdetails- indicate if aListcontainingStringnames is returned orListcontainingXWikiDocument.nb- the maximum number of results to return. Infinite if 0.start- the index of the first found user or group to return.order- the field to order from. It is a table of table with :- fieldname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
context- theXWikiContext.- Returns:
- the list of users or groups.
- Throws:
XWikiException- error when calling forXWikiStoreInterface.searchDocuments(String, int, int, List, XWikiContext)orXWikiStoreInterface.searchDocumentsNames(String, int, int, List, XWikiContext)
-
countAllMatchedUsersOrGroups
protected int countAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context) throws XWikiExceptionReturn number of users or groups with provided constraints.- Parameters:
user- if true search for users, otherwise search for groups.matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
context- theXWikiContext.- Returns:
- the of found users or groups.
- Throws:
XWikiException- error when calling forXWikiStoreInterface.search(String, int, int, List, XWikiContext)
-
countAllMatchedUsers
public int countAllMatchedUsers(Object[][] matchFields, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceReturn number of users with provided constraints.- Specified by:
countAllMatchedUsersin interfaceXWikiGroupService- Parameters:
matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
context- theXWikiContext.- Returns:
- the of found users.
- Throws:
XWikiException- error when getting number of users.
-
countAllMatchedGroups
public int countAllMatchedGroups(Object[][] matchFields, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceReturn number of groups with provided constraints.- Specified by:
countAllMatchedGroupsin interfaceXWikiGroupService- Parameters:
matchFields- the field to math with values. It is a table of table with :- fiedname : the name of the field
- fieldtype : for example StringProperty. If null the field is considered as document field
- pattern matching : based on HQL "like" command
context- theXWikiContext.- Returns:
- the of found groups.
- Throws:
XWikiException- error when getting number of groups.
-
createMatchGroupMembersWhereClause
protected String createMatchGroupMembersWhereClause(String groupFullName, String matchField, Boolean orderAsc, Map<String,Object> parameterValues)
Create a query to filter provided group members. Generate the entire HQL query except the select part.- Parameters:
groupFullName- the fill wiki name of the group.matchField- a string to search in result to filter.orderAsc- if true, the result is ordered ascendent, if false it descendant. If null no order is applied.parameterValues- the values to insert in names query.- Returns:
- the HQL query.
- Since:
- 1.6M1
-
getAllGroupsNamesForMember
public Collection<String> getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceGet all groups containing provided member in the provided member wiki.Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
- Specified by:
getAllGroupsNamesForMemberin interfaceXWikiGroupService- Parameters:
member- the name of the member (user or group).nb- the maximum number of result to return.start- the index of the first found member to return.context- the XWiki context.- Returns:
- the
CollectionofStringcontaining group name. - Throws:
XWikiException- error when browsing groups.
-
getAllGroupsReferencesForMember
public Collection<DocumentReference> getAllGroupsReferencesForMember(DocumentReference memberReference, int limit, int offset, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceGet all groups containing provided member in the current wiki.Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
- Specified by:
getAllGroupsReferencesForMemberin interfaceXWikiGroupService- Parameters:
memberReference- the member. Can be either user or group.limit- the maximum number of result to return.offset- the index of the first found member to return.context- the XWiki context.- Returns:
- the
CollectionofDocumentReferencecontaining representing groups. - Throws:
XWikiException- error when browsing groups.
-
getAllMembersNamesForGroup
public Collection<String> getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceGet all members provided group contains.Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
- Specified by:
getAllMembersNamesForGroupin interfaceXWikiGroupService- Parameters:
group- the name of the group.nb- the maximum number of result to return.start- the index of the first found user to return.context- the XWiki context.- Returns:
- the
CollectionofStringcontaining member name. - Throws:
XWikiException- error when browsing groups.
-
getAllMatchedMembersNamesForGroup
public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start, Boolean orderAsc, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceGet members of provided group.- Specified by:
getAllMatchedMembersNamesForGroupin interfaceXWikiGroupService- Parameters:
group- the group.matchField- a string to search in result to filter.nb- the maximum number of result to return.start- the index of the first found user to return.orderAsc- if true, the result is ordered ascendent, if false it descendant. If null no order is applied.context- the XWiki context.- Returns:
- the
CollectionofStringcontaining member name. - Throws:
XWikiException- error when browsing groups.
-
countAllMatchedMembersNamesForGroup
public int countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext) throws XWikiException
Description copied from interface:XWikiGroupServiceFilters the members of the specified group using the given text and counts the results.- Specified by:
countAllMatchedMembersNamesForGroupin interfaceXWikiGroupService- Parameters:
group- the group whose members are going to be countedfilter- the text used to filter the group membersxcontext- the XWiki context- Returns:
- the number of group members that match the given text filter
- Throws:
XWikiException- if counting the group members fails- See Also:
XWikiGroupService.getAllMatchedMembersNamesForGroup(String, String, int, int, Boolean, XWikiContext)
-
countAllGroupsNamesForMember
public int countAllGroupsNamesForMember(String member, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceReturn the number of groups containing provided member.Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
- Specified by:
countAllGroupsNamesForMemberin interfaceXWikiGroupService- Parameters:
member- the name of the member (user or group).context- the XWiki context.- Returns:
- the number of groups.
- Throws:
XWikiException- error when getting number of users.
-
countAllMembersNamesForGroup
public int countAllMembersNamesForGroup(String group, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupServiceReturn the number of members provided group contains.Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
- Specified by:
countAllMembersNamesForGroupin interfaceXWikiGroupService- Parameters:
group- the name of the group.context- the XWiki context.- Returns:
- the number of members.
- Throws:
XWikiException- error when getting number of groups.
-
-