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 ofXWikiGroupService
users and groups manager.- Version:
- $Id: 61853acf8e11d95f8cb5b36393dc084d62c91963 $
-
-
Field Summary
Fields Modifier and Type Field Description static EntityReference
GROUPCLASS_REFERENCE
-
Constructor Summary
Constructors Constructor Description XWikiGroupServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addUserToGroup(String username, String database, String group, XWikiContext context)
Deprecated.int
countAllGroupsNamesForMember(String member, XWikiContext context)
Return the number of groups containing provided member.int
countAllMatchedGroups(Object[][] matchFields, XWikiContext context)
Return number of groups with provided constraints.int
countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext)
Filters the members of the specified group using the given text and counts the results.int
countAllMatchedUsers(Object[][] matchFields, XWikiContext context)
Return number of users with provided constraints.protected int
countAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context)
Return number of users or groups with provided constraints.int
countAllMembersNamesForGroup(String group, XWikiContext context)
Return the number of members provided group contains.protected String
createMatchGroupMembersWhereClause(String groupFullName, String matchField, Boolean orderAsc, Map<String,Object> parameterValues)
Create a query to filter provided group members.protected String
createMatchUserOrGroupWhereClause(boolean user, Object[][] matchFields, Object[][] order, List<Object> parameterValues)
Create a "where clause" to use withXWikiStoreInterface
searchDocuments and searchDocumentsNames methods.void
flushCache()
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()
String
getName()
void
init(XWiki xwiki, XWikiContext context)
void
initCache(int iCapacity, XWikiContext context)
void
initCache(XWikiContext context)
protected boolean
isAllGroupImplicit(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.void
onEvent(Event event, Object source, Object data)
void
removeUserOrGroupFromAllGroups(String memberWiki, String memberSpace, String memberName, XWikiContext context)
Remove user or group name from all groups.void
replaceMemberInAllGroups(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:
init
in interfaceXWikiGroupService
- Throws:
XWikiException
-
initCache
public void initCache(XWikiContext context) throws XWikiException
- Specified by:
initCache
in interfaceXWikiGroupService
- Throws:
XWikiException
-
initCache
public void initCache(int iCapacity, XWikiContext context) throws XWikiException
- Specified by:
initCache
in interfaceXWikiGroupService
- Throws:
XWikiException
-
flushCache
public void flushCache()
- Specified by:
flushCache
in interfaceXWikiGroupService
-
isAllGroupImplicit
protected boolean isAllGroupImplicit(XWikiContext context)
Check whether the configuration specifies that every user is implicitly in XWikiAllGroup. Configured by thexwiki.authentication.group.allgroupimplicit
parameter inxwiki.cfg
.- Parameters:
context
- the current XWiki context- Returns:
true
if the group is implicit and all users should be by default in it,false
if 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:
listGroupsForUser
in interfaceXWikiGroupService
- Throws:
XWikiException
-
addUserToGroup
@Deprecated public void addUserToGroup(String username, String database, String group, XWikiContext context) throws XWikiException
Deprecated.- Specified by:
addUserToGroup
in interfaceXWikiGroupService
- Throws:
XWikiException
-
replaceMemberInAllGroups
public void replaceMemberInAllGroups(DocumentReference memberSourceReference, DocumentReference memberTargetReference, XWikiContext context) throws XWikiException
Description copied from interface:XWikiGroupService
Replace a given member reference by another one in all groups of the wiki.- Specified by:
replaceMemberInAllGroups
in 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:XWikiGroupService
Remove user or group name from all groups.- Specified by:
removeUserOrGroupFromAllGroups
in 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:
listMemberForGroup
in interfaceXWikiGroupService
- Throws:
XWikiException
-
listAllGroups
@Deprecated public List<String> listAllGroups(XWikiContext context) throws XWikiException
Deprecated.- Specified by:
listAllGroups
in interfaceXWikiGroupService
- Throws:
XWikiException
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.xwiki.observation.EventListener
-
getEvents
public List<Event> getEvents()
- Specified by:
getEvents
in interfaceorg.xwiki.observation.EventListener
-
onEvent
public void onEvent(Event event, Object source, Object data)
- Specified by:
onEvent
in 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:XWikiGroupService
Search for all users with provided constraints and in a provided order.- Specified by:
getAllMatchedUsers
in 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 aList
containingString
names is returned orList
containingXWikiDocument
.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:XWikiGroupService
Search for all groups with provided constraints and in a provided order.- Specified by:
getAllMatchedGroups
in 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 aList
containingString
names is returned orList
containingXWikiDocument
.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 withXWikiStoreInterface
searchDocuments 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 aList
containingString
names is returned orList
containingXWikiDocument
.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 XWikiException
Return 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:XWikiGroupService
Return number of users with provided constraints.- Specified by:
countAllMatchedUsers
in 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:XWikiGroupService
Return number of groups with provided constraints.- Specified by:
countAllMatchedGroups
in 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:XWikiGroupService
Get 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:
getAllGroupsNamesForMember
in 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
Collection
ofString
containing 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:XWikiGroupService
Get 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:
getAllGroupsReferencesForMember
in 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
Collection
ofDocumentReference
containing 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:XWikiGroupService
Get 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:
getAllMembersNamesForGroup
in 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
Collection
ofString
containing 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:XWikiGroupService
Get members of provided group.- Specified by:
getAllMatchedMembersNamesForGroup
in 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
Collection
ofString
containing member name. - Throws:
XWikiException
- error when browsing groups.
-
countAllMatchedMembersNamesForGroup
public int countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext) throws XWikiException
Description copied from interface:XWikiGroupService
Filters the members of the specified group using the given text and counts the results.- Specified by:
countAllMatchedMembersNamesForGroup
in 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:XWikiGroupService
Return 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:
countAllGroupsNamesForMember
in 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:XWikiGroupService
Return 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:
countAllMembersNamesForGroup
in 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.
-
-