Package org.jivesoftware.openfire.user
Class UserMultiProvider
- java.lang.Object
-
- org.jivesoftware.openfire.user.UserMultiProvider
-
- All Implemented Interfaces:
UserProvider
- Direct Known Subclasses:
HybridUserProvider
,MappedUserProvider
public abstract class UserMultiProvider extends Object implements UserProvider
AUserProvider
that delegates to one or more 'backing' UserProvider.- Author:
- GUus der Kinderen, guus@goodbytes.nl
-
-
Constructor Summary
Constructors Constructor Description UserMultiProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<User>
findUsers(Set<String> fields, String query)
Searches for users based on a set of fields and a query string.Collection<User>
findUsers(Set<String> fields, String query, int startIndex, int numResults)
Searches for users based on a set of fields and a query string.Set<String>
getSearchFields()
Returns the combination of search fields supported by the backing providers.int
getUserCount()
Returns the number of users in the system.Collection<String>
getUsernames()
Returns an unmodifiable Collection of usernames of all users in the system.Collection<User>
getUsers()
Returns an unmodifiable Collections of all users in the system.Collection<User>
getUsers(int startIndex, int numResults)
Returns an unmodifiable Collections of users in the system within the specified range.static UserProvider
instantiate(String propertyName)
Instantiates a UserProvider based on a property value (that is expected to be a class name).boolean
isEmailRequired()
Returns whether all backing providers require an email address to be set on User objects.boolean
isNameRequired()
Returns whether all backing providers require a name to be set on User objects.boolean
isReadOnly()
Returns whether all backing providers are read-only.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jivesoftware.openfire.user.UserProvider
createUser, deleteUser, loadUser, setCreationDate, setEmail, setModificationDate, setName
-
-
-
-
Method Detail
-
instantiate
public static UserProvider instantiate(String propertyName)
Instantiates a UserProvider based on a property value (that is expected to be a class name). When the property is not set, this method returns null. When the property is set, but an exception occurs while instantiating the class, this method logs the error and returns null. UserProvider classes are required to have a public, no-argument constructor.- Parameters:
propertyName
- A property name (cannot ben ull).- Returns:
- A user provider (can be null).
-
getUserCount
public int getUserCount()
Description copied from interface:UserProvider
Returns the number of users in the system.- Specified by:
getUserCount
in interfaceUserProvider
- Returns:
- the total number of users.
-
getUsers
public Collection<User> getUsers()
Description copied from interface:UserProvider
Returns an unmodifiable Collections of all users in the system. TheUserCollection
class can be used to assist in the implementation of this method. It takes a String [] of usernames and presents it as a Collection of User objects (obtained with calls toUserManager.getUser(String)
.- Specified by:
getUsers
in interfaceUserProvider
- Returns:
- an unmodifiable Collection of all users.
-
getUsernames
public Collection<String> getUsernames()
Description copied from interface:UserProvider
Returns an unmodifiable Collection of usernames of all users in the system.- Specified by:
getUsernames
in interfaceUserProvider
- Returns:
- an unmodifiable Collection of all usernames in the system.
-
getUsers
public Collection<User> getUsers(int startIndex, int numResults)
Description copied from interface:UserProvider
Returns an unmodifiable Collections of users in the system within the specified range. TheUserCollection
class can be used to assist in the implementation of this method. It takes a String [] of usernames and presents it as a Collection of User objects (obtained with calls toUserManager.getUser(String)
.It is possible that the number of results returned will be less than that specified by
numResults
ifnumResults
is greater than the number of records left to display.- Specified by:
getUsers
in interfaceUserProvider
- Parameters:
startIndex
- the beginning index to start the results at.numResults
- the total number of results to return.- Returns:
- an unmodifiable Collection of users within the specified range.
-
findUsers
public Collection<User> findUsers(Set<String> fields, String query) throws UnsupportedOperationException
Searches for users based on a set of fields and a query string. The fields must be taken from the values returned bygetSearchFields()
. The query can include wildcards. For example, a search on the field "Name" with a query of "Ma*" might return user's with the name "Matt", "Martha" and "Madeline". This method throws an UnsupportedOperationException when none of the backing providers support search. When fields are provided that are not supported by a particular provider, those fields are ignored by that provider (but can still be used by other providers).- Specified by:
findUsers
in interfaceUserProvider
- Parameters:
fields
- the fields to search on.query
- the query string.- Returns:
- a Collection of users that match the search.
- Throws:
UnsupportedOperationException
- When none of the providers support search.
-
findUsers
public Collection<User> findUsers(Set<String> fields, String query, int startIndex, int numResults) throws UnsupportedOperationException
Searches for users based on a set of fields and a query string. The fields must be taken from the values returned bygetSearchFields()
. The query can include wildcards. For example, a search on the field "Name" with a query of "Ma*" might return user's with the name "Matt", "Martha" and "Madeline". This method throws an UnsupportedOperationException when none of the backing providers support search. When fields are provided that are not supported by a particular provider, those fields are ignored by that provider (but can still be used by other providers). The startIndex and numResults parameters are used to page through search results. For example, if the startIndex is 0 and numResults is 10, the first 10 search results will be returned. Note that numResults is a request for the number of results to return and that the actual number of results returned may be fewer.- Specified by:
findUsers
in interfaceUserProvider
- Parameters:
fields
- the fields to search on.query
- the query string.startIndex
- the starting index in the search result to return.numResults
- the number of users to return in the search result.- Returns:
- a Collection of users that match the search.
- Throws:
UnsupportedOperationException
- When none of the providers support search.
-
getSearchFields
public Set<String> getSearchFields() throws UnsupportedOperationException
Returns the combination of search fields supported by the backing providers. Note that the returned fields might not be supported by every backing provider.- Specified by:
getSearchFields
in interfaceUserProvider
- Returns:
- the valid search fields.
- Throws:
UnsupportedOperationException
- If no search fields are returned, or when at least one of the providers throws UnsupportedOperationException when its #getSearchField() is invoked.
-
isReadOnly
public boolean isReadOnly()
Returns whether all backing providers are read-only. When read-only, users can not be created, deleted, or modified. If at least one provider is not read-only, this method returns false.- Specified by:
isReadOnly
in interfaceUserProvider
- Returns:
- true when all backing providers are read-only, otherwise false.
-
isNameRequired
public boolean isNameRequired()
Returns whether all backing providers require a name to be set on User objects. If at least one proivder does not, this method returns false.- Specified by:
isNameRequired
in interfaceUserProvider
- Returns:
- true when all backing providers require a name to be set on User objects, otherwise false.
-
isEmailRequired
public boolean isEmailRequired()
Returns whether all backing providers require an email address to be set on User objects. If at least one proivder does not, this method returns false.- Specified by:
isEmailRequired
in interfaceUserProvider
- Returns:
- true when all backing providers require an email address to be set on User objects, otherwise false.
-
-