Class MappedUserPropertyProvider
- java.lang.Object
-
- org.jivesoftware.openfire.user.property.MappedUserPropertyProvider
-
- All Implemented Interfaces:
UserPropertyProvider
public class MappedUserPropertyProvider extends Object implements UserPropertyProvider
AUserPropertyProvider
that delegates to a user-specific UserPropertyProvider. This implementation will explicitly verify if a user exists, when operating on its properties, but only if the corresponding mapped provider does so. If that is the case, then the methods of this implementation will throwUserNotFoundException
. This class related to, but is distinct fromHybridUserPropertyProvider
. The Hybrid variant of the provider iterates over providers, operating on the first applicable instance. This Mapped variant, however, maps each user to exactly one provider. To use this provider, use the following system property definition:provider.userproperty.className = org.jivesoftware.openfire.user.MappedUserPropertyProvider
UserPropertyProviderMapper
must be configured using themappedUserPropertyProvider.mapper.className
system property. It is of importance to note that most UserPropertyProviderMapper implementations will require additional configuration.- Author:
- Guus der Kinderen, guus@goodbytes.nl
-
-
Field Summary
Fields Modifier and Type Field Description protected UserPropertyProviderMapper
mapper
Used to determine what provider is to be used to operate on a particular user.static String
PROPERTY_MAPPER_CLASSNAME
Name of the property of which the value is expected to be the classname of the UserPropertyProviderMapper instance to be used by instances of this class.
-
Constructor Summary
Constructors Constructor Description MappedUserPropertyProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteProperty(String username, String propName)
Removes one particular property for a particular user.void
insertProperty(String username, String propName, String propValue)
Adds a property for an user.static UserPropertyProvider
instantiate(String propertyName)
Instantiates a UserPropertyProvider based on a property value (that is expected to be a class name).boolean
isReadOnly()
Returns whether all backing providers are read-only.Map<String,String>
loadProperties(String username)
Retrieves all properties for a particular user.String
loadProperty(String username, String propName)
Retrieves a property value for a user.void
updateProperty(String username, String propName, String propValue)
Changes a property value for an user.
-
-
-
Field Detail
-
PROPERTY_MAPPER_CLASSNAME
public static final String PROPERTY_MAPPER_CLASSNAME
Name of the property of which the value is expected to be the classname of the UserPropertyProviderMapper instance to be used by instances of this class.- See Also:
- Constant Field Values
-
mapper
protected final UserPropertyProviderMapper mapper
Used to determine what provider is to be used to operate on a particular user.
-
-
Method Detail
-
instantiate
public static UserPropertyProvider instantiate(String propertyName)
Instantiates a UserPropertyProvider 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).
-
loadProperties
public Map<String,String> loadProperties(String username) throws UserNotFoundException
Description copied from interface:UserPropertyProvider
Retrieves all properties for a particular user.- Specified by:
loadProperties
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).- Returns:
- A collection, possibly empty, but never null.
- Throws:
UserNotFoundException
- if the user cannot be found
-
loadProperty
public String loadProperty(String username, String propName) throws UserNotFoundException
Description copied from interface:UserPropertyProvider
Retrieves a property value for a user. This method will return null when the desired property was not defined for the user (null values are not supported).- Specified by:
loadProperty
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).propName
- The property name (cannot be null or empty).- Returns:
- The property value (possibly null).
- Throws:
UserNotFoundException
- if the user cannot be found
-
insertProperty
public void insertProperty(String username, String propName, String propValue) throws UserNotFoundException
Description copied from interface:UserPropertyProvider
Adds a property for an user. The behavior of inserting a duplicate property name is not defined by this interface.- Specified by:
insertProperty
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).propName
- The property name (cannot be null or empty).propValue
- The property value (cannot be null).- Throws:
UserNotFoundException
- if the user cannot be found
-
updateProperty
public void updateProperty(String username, String propName, String propValue) throws UserNotFoundException
Description copied from interface:UserPropertyProvider
Changes a property value for an user. The behavior of updating a non-existing property is not defined by this interface.- Specified by:
updateProperty
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).propName
- The property name (cannot be null or empty).propValue
- The property value (cannot be null).- Throws:
UserNotFoundException
- if the user cannot be found
-
deleteProperty
public void deleteProperty(String username, String propName) throws UserNotFoundException
Description copied from interface:UserPropertyProvider
Removes one particular property for a particular user. The behavior of deleting a non-existing property is not defined by this interface.- Specified by:
deleteProperty
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).propName
- The property name (cannot be null or empty).- Throws:
UserNotFoundException
- if the user cannot be found
-
isReadOnly
public boolean isReadOnly()
Returns whether all backing providers are read-only. When read-only, properties can not be created, deleted, or modified. If at least one provider is not read-only, this method returns false.- Specified by:
isReadOnly
in interfaceUserPropertyProvider
- Returns:
- true when all backing providers are read-only, otherwise false.
-
-