Class HybridUserPropertyProvider
java.lang.Object
org.jivesoftware.openfire.user.property.HybridUserPropertyProvider
- All Implemented Interfaces:
UserPropertyProvider
Delegate UserPropertyProvider operations among up to three configurable provider implementation classes.
This implementation will not explicitly verify if a user exists, when operating on its properties. The methods of
this implementation will not throw
UserNotFoundException.
This class related to, but is distinct from MappedUserPropertyProvider. 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.
To use this provider, use the following system property definition:
provider.userproperty.className = org.jivesoftware.openfire.user.HybridUserPropertyProvider
hybridUserPropertyProvider.primaryProvider.className = fully.qualified.ClassUserPropertyProviderhybridUserPropertyProvider.secondaryProvider.className = fully.qualified.ClassUserPropertyProviderhybridUserPropertyProvider.tertiaryProvider.className = fully.qualified.ClassUserPropertyProvider
- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteProperty(String username, String propName) Removes a property from all non-read-only providers.voidinsertProperty(String username, String propName, String propValue) Adds a new property, updating a previous property value if one already exists.booleanReturns whether all backing providers are read-only.loadProperties(String username) Returns the properties from the first provider that returns a non-empty collection.loadProperty(String username, String propName) Returns a property from the first provider that returns a non-null value.voidupdateProperty(String username, String propName, String propValue) Updates a property (or adds a new property when the property does not exist).
-
Constructor Details
-
HybridUserPropertyProvider
public HybridUserPropertyProvider()
-
-
Method Details
-
loadProperties
Returns the properties from the first provider that returns a non-empty collection. When none of the providers provide properties an empty collection is returned.- Specified by:
loadPropertiesin interfaceUserPropertyProvider- Parameters:
username- The identifier of the user (cannot be null or empty).- Returns:
- A collection, possibly empty, never null.
-
loadProperty
Returns a property from the first provider that returns a non-null value. This method will return null when the desired property was not defined in any provider.- 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).
-
insertProperty
public void insertProperty(String username, String propName, String propValue) throws UnsupportedOperationException Adds a new property, updating a previous property value if one already exists. Note that the implementation of this method is equal to that ofupdateProperty(String, String, String). First, tries to find a provider that has the property for the provided user. If that provider is read-only, an UnsupportedOperationException is thrown. If the provider is not read-only, the existing property value will be updated. When the property is not defined in any provider, it will be added in the first non-read-only provider. When all providers are read-only, an UnsupportedOperationException is thrown.- 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:
UnsupportedOperationException- if the property cannot be added
-
updateProperty
public void updateProperty(String username, String propName, String propValue) throws UnsupportedOperationException Updates a property (or adds a new property when the property does not exist). Note that the implementation of this method is equal to that ofinsertProperty(String, String, String). First, tries to find a provider that has the property for the provided user. If that provider is read-only, an UnsupportedOperationException is thrown. If the provider is not read-only, the existing property value will be updated. When the property is not defined in any provider, it will be added in the first non-read-only provider. When all providers are read-only, an UnsupportedOperationException is thrown.- 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:
UnsupportedOperationException- if the property cannot be updated
-
deleteProperty
Removes a property from all non-read-only providers.- 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:
UnsupportedOperationException- if the property cannot be deleted
-
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.
-