Class 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 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
    Next, configure up to three providers, by setting these properties:
    1. hybridUserPropertyProvider.primaryProvider.className = fully.qualified.ClassUserPropertyProvider
    2. hybridUserPropertyProvider.secondaryProvider.className = fully.qualified.ClassUserPropertyProvider
    3. hybridUserPropertyProvider.tertiaryProvider.className = fully.qualified.ClassUserPropertyProvider
    Author:
    Guus der Kinderen, guus.der.kinderen@gmail.com
    • Constructor Detail

      • HybridUserPropertyProvider

        public HybridUserPropertyProvider()
    • 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 interface UserPropertyProvider
        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 interface UserPropertyProvider
        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 of updateProperty(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 interface UserPropertyProvider
        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 of insertProperty(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 interface UserPropertyProvider
        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
      • 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 interface UserPropertyProvider
        Returns:
        true when all backing providers are read-only, otherwise false.