Class MappedUserPropertyProvider
java.lang.Object
org.jivesoftware.openfire.user.property.MappedUserPropertyProvider
- All Implemented Interfaces:
UserPropertyProvider
A
UserPropertyProvider 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 throw
UserNotFoundException.
This class related to, but is distinct from HybridUserPropertyProvider. 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 the mappedUserPropertyProvider.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
FieldsModifier and TypeFieldDescriptionprotected final UserPropertyProviderMapperUsed to determine what provider is to be used to operate on a particular user.static final StringName 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 -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteProperty(String username, String propName) Removes one particular property for a particular user.voidinsertProperty(String username, String propName, String propValue) Adds a property for an user.static UserPropertyProviderinstantiate(String propertyName) Instantiates a UserPropertyProvider based on a property value (that is expected to be a class name).booleanReturns whether all backing providers are read-only.loadProperties(String username) Retrieves all properties for a particular user.loadProperty(String username, String propName) Retrieves a property value for a user.voidupdateProperty(String username, String propName, String propValue) Changes a property value for an user.
-
Field Details
-
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:
-
mapper
Used to determine what provider is to be used to operate on a particular user.
-
-
Constructor Details
-
MappedUserPropertyProvider
public MappedUserPropertyProvider()
-
-
Method Details
-
instantiate
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
Description copied from interface:UserPropertyProviderRetrieves all properties for a particular user.- Specified by:
loadPropertiesin 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
Description copied from interface:UserPropertyProviderRetrieves 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:
loadPropertyin 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:UserPropertyProviderAdds a property for an user. The behavior of inserting a duplicate property name is not defined by this interface.- Specified by:
insertPropertyin 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:UserPropertyProviderChanges a property value for an user. The behavior of updating a non-existing property is not defined by this interface.- Specified by:
updatePropertyin 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
Description copied from interface:UserPropertyProviderRemoves one particular property for a particular user. The behavior of deleting a non-existing property is not defined by this interface.- Specified by:
deletePropertyin 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:
isReadOnlyin interfaceUserPropertyProvider- Returns:
- true when all backing providers are read-only, otherwise false.
-