Class UserPropertyMultiProvider
java.lang.Object
org.jivesoftware.openfire.user.property.UserPropertyMultiProvider
- All Implemented Interfaces:
UserPropertyProvider
- Direct Known Subclasses:
HybridUserPropertyProvider
,MappedUserPropertyProvider
A
UserPropertyProvider
that delegates to one or more 'backing' UserProvider.- Author:
- Guus der Kinderen, guus@goodbytes.nl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteProperty
(String username, String propName) Removes a property from all non-read-only providers.void
insertProperty
(String username, String propName, String propValue) Adds a property for an user.static UserPropertyProvider
instantiate
(String propertyName) Deprecated, for removal: This API element is subject to removal in a future version.static UserPropertyProvider
instantiate
(SystemProperty<Class> implementationProperty) Instantiates a UserPropertyProvider based on Class-based system property.static UserPropertyProvider
instantiate
(SystemProperty<Class> implementationProperty, SystemProperty<String> configProperty) Instantiates a UserPropertyProvider based on Class-based system property.boolean
Returns 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.void
updateProperty
(String username, String propName, String propValue) Changes a property value for an user.
-
Constructor Details
-
UserPropertyMultiProvider
public UserPropertyMultiProvider()
-
-
Method Details
-
instantiate
@Deprecated(forRemoval=true, since="5.0.0") public static UserPropertyProvider instantiate(String propertyName) Deprecated, for removal: This API element is subject to removal in a future version.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. UserPropertyProvider classes are required to have a public, no-argument constructor.- Parameters:
propertyName
- A property name (cannot be null).- Returns:
- A user provider (can be null).
-
instantiate
public static UserPropertyProvider instantiate(@Nonnull SystemProperty<Class> implementationProperty) Instantiates a UserPropertyProvider based on Class-based system property. 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. UserPropertyProvider classes are required to have a public, no-argument constructor.- Parameters:
implementationProperty
- A property that defines the class of the instance to be returned.- Returns:
- A user provider (can be null).
-
instantiate
public static UserPropertyProvider instantiate(@Nonnull SystemProperty<Class> implementationProperty, @Nullable SystemProperty<String> configProperty) Instantiates a UserPropertyProvider based on Class-based system property. 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. UserPropertyProvider classes are required to have a public, no-argument constructor, but can have an optional additional constructor that takes a single String argument. If such constructor is defined, then it is invoked with the value of the second argument of this method. This is typically used to (but needs not) identify a property (by name) that holds additional configuration for the to be instantiated UserPropertyProvider. This implementation will pass on any non-empty value to the constructor. When a configuration argument is provided, but no constructor exists in the implementation that accepts a single String value, this method will log a warning and attempt to return an instance based on the no-arg constructor of the class.- Parameters:
implementationProperty
- A property that defines the class of the instance to be returned.configProperty
- A property that holds an opaque configuration string value passed to the constructor.- Returns:
- A user provider (can be null).
-
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.
-
loadProperties
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
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
Removes a property from all non-read-only providers.- 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:
UnsupportedOperationException
- if the property cannot be deleted
-
instantiate(SystemProperty)
orinstantiate(SystemProperty, SystemProperty)
instead.