Package org.jivesoftware.openfire.user
Class HybridUserProvider
- java.lang.Object
-
- org.jivesoftware.openfire.user.UserMultiProvider
-
- org.jivesoftware.openfire.user.HybridUserProvider
-
- All Implemented Interfaces:
UserProvider
public class HybridUserProvider extends UserMultiProvider
Delegate UserProvider operations among up to three configurable provider implementation classes. This class related to, but is distinct fromMappedUserProvider
. The Hybrid variant of the provider iterates over providers, operating on the first applicable instance. The Mapped variant, however, maps each user to exactly one provider.- Author:
- Marc Seeger, Chris Neasbitt, Tom Evans, Guus der Kinderen
-
-
Constructor Summary
Constructors Constructor Description HybridUserProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description User
createUser(String username, String password, String name, String email)
Creates a new user in the first non-read-only provider.void
deleteUser(String username)
Removes a user from all non-read-only providers.UserProvider
getUserProvider(String username)
Returns the first provider that contains the user, or the first provider that is not read-only when the user does not exist in any provider.protected List<UserProvider>
getUserProviders()
User
loadUser(String username)
Loads a user from the first provider that contains the user.void
setCreationDate(String username, Date creationDate)
Changes the creation date of a user in the first provider that contains the user.void
setEmail(String username, String email)
Changes the email address of a user in the first provider that contains the user.void
setModificationDate(String username, Date modificationDate)
Changes the modification date of a user in the first provider that contains the user.void
setName(String username, String name)
Changes the full name of a user in the first provider that contains the user.-
Methods inherited from class org.jivesoftware.openfire.user.UserMultiProvider
findUsers, findUsers, getSearchFields, getUserCount, getUsernames, getUsers, getUsers, instantiate, isEmailRequired, isNameRequired, isReadOnly
-
-
-
-
Method Detail
-
getUserProviders
protected List<UserProvider> getUserProviders()
-
createUser
public User createUser(String username, String password, String name, String email) throws UserAlreadyExistsException
Creates a new user in the first non-read-only provider.- Parameters:
username
- the username.password
- the plain-text password.name
- the user's name, which can benull
, unless isNameRequired is set to true.email
- the user's email address, which can benull
, unless isEmailRequired is set to true.- Returns:
- The user that was created.
- Throws:
UserAlreadyExistsException
- if the user already exists
-
deleteUser
public void deleteUser(String username)
Removes a user from all non-read-only providers.- Parameters:
username
- the username to delete.
-
getUserProvider
public UserProvider getUserProvider(String username)
Returns the first provider that contains the user, or the first provider that is not read-only when the user does not exist in any provider.- Parameters:
username
- the username (cannot be null or empty).- Returns:
- The user provider (never null)
-
loadUser
public User loadUser(String username) throws UserNotFoundException
Loads a user from the first provider that contains the user.- Parameters:
username
- the username (cannot be null or empty).- Returns:
- The user (never null).
- Throws:
UserNotFoundException
- When none of the providers contains the user.
-
setCreationDate
public void setCreationDate(String username, Date creationDate) throws UserNotFoundException
Changes the creation date of a user in the first provider that contains the user.- Parameters:
username
- the username.creationDate
- the date the user was created.- Throws:
UserNotFoundException
- when the user was not found in any provider.UnsupportedOperationException
- when the provider is read-only.
-
setModificationDate
public void setModificationDate(String username, Date modificationDate) throws UserNotFoundException
Changes the modification date of a user in the first provider that contains the user.- Parameters:
username
- the username.modificationDate
- the date the user was (last) modified.- Throws:
UserNotFoundException
- when the user was not found in any provider.UnsupportedOperationException
- when the provider is read-only.
-
setName
public void setName(String username, String name) throws UserNotFoundException
Changes the full name of a user in the first provider that contains the user.- Parameters:
username
- the username.name
- the new full name a user.- Throws:
UserNotFoundException
- when the user was not found in any provider.UnsupportedOperationException
- when the provider is read-only.
-
setEmail
public void setEmail(String username, String email) throws UserNotFoundException
Changes the email address of a user in the first provider that contains the user.- Parameters:
username
- the username.email
- the new email address of a user.- Throws:
UserNotFoundException
- when the user was not found in any provider.UnsupportedOperationException
- when the provider is read-only.
-
-