Class HybridUserPropertyProvider
- java.lang.Object
-
- org.jivesoftware.openfire.user.property.HybridUserPropertyProvider
-
- All Implemented Interfaces:
UserPropertyProvider
public class HybridUserPropertyProvider extends Object implements 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 throwUserNotFoundException
. This class related to, but is distinct fromMappedUserPropertyProvider
. 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.ClassUserPropertyProvider
hybridUserPropertyProvider.secondaryProvider.className = fully.qualified.ClassUserPropertyProvider
hybridUserPropertyProvider.tertiaryProvider.className = fully.qualified.ClassUserPropertyProvider
- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Constructor Summary
Constructors Constructor Description HybridUserPropertyProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteProperty(String username, String propName)
Removes a property from all non-read-only providers.void
insertProperty(String username, String propName, String propValue)
Adds a new property, updating a previous property value if one already exists.boolean
isReadOnly()
Returns whether all backing providers are read-only.Map<String,String>
loadProperties(String username)
Returns the properties from the first provider that returns a non-empty collection.String
loadProperty(String username, String propName)
Returns a property from the first provider that returns a non-null value.void
updateProperty(String username, String propName, String propValue)
Updates a property (or adds a new property when the property does not exist).
-
-
-
Method Detail
-
loadProperties
public Map<String,String> loadProperties(String username)
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:
loadProperties
in interfaceUserPropertyProvider
- Parameters:
username
- The identifier of the user (cannot be null or empty).- Returns:
- A collection, possibly empty, never null.
-
loadProperty
public String loadProperty(String username, String propName)
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:
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).
-
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:
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:
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:
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:
UnsupportedOperationException
- if the property cannot be updated
-
deleteProperty
public void deleteProperty(String username, String propName) throws UnsupportedOperationException
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
-
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.
-
-