Class MappedUserPropertyProvider

  • All Implemented Interfaces:
    UserPropertyProvider

    public class MappedUserPropertyProvider
    extends Object
    implements 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
    To be usable, a 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 Detail

      • PROPERTY_MAPPER_CLASSNAME

        public static final String 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:
        Constant Field Values
      • mapper

        protected final UserPropertyProviderMapper mapper
        Used to determine what provider is to be used to operate on a particular user.
    • Constructor Detail

      • MappedUserPropertyProvider

        public MappedUserPropertyProvider()
    • Method Detail

      • instantiate

        public static UserPropertyProvider instantiate​(String propertyName)
        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).
      • loadProperty

        public String loadProperty​(String username,
                                   String propName)
                            throws UserNotFoundException
        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 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).
        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 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:
        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 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:
        UserNotFoundException - if the user cannot be found
      • deleteProperty

        public void deleteProperty​(String username,
                                   String propName)
                            throws UserNotFoundException
        Description copied from interface: UserPropertyProvider
        Removes one particular property for a particular user. The behavior of deleting a non-existing property is not defined by this interface.
        Specified by:
        deleteProperty in interface UserPropertyProvider
        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:
        isReadOnly in interface UserPropertyProvider
        Returns:
        true when all backing providers are read-only, otherwise false.