Class DecoratingDirectory<ObjectType extends Identifiable>

  • Type Parameters:
    ObjectType - The type of objects stored within this Directory.
    All Implemented Interfaces:
    Directory<ObjectType>

    public abstract class DecoratingDirectory<ObjectType extends Identifiable>
    extends DelegatingDirectory<ObjectType>
    Directory implementation which simplifies decorating the objects within an underlying Directory. The decorate() and undecorate() functions must be implemented to define how each object is decorated, and how that decoration may be removed.
    • Constructor Detail

      • DecoratingDirectory

        public DecoratingDirectory​(Directory<ObjectType> directory)
        Creates a new DecoratingDirectory which decorates the objects within the given directory.
        Parameters:
        directory - The Directory whose objects are being decorated.
    • Method Detail

      • decorate

        protected abstract ObjectType decorate​(ObjectType object)
                                        throws org.apache.guacamole.GuacamoleException
        Given an object retrieved from a Directory which originates from a different AuthenticationProvider, returns an identical type of object optionally wrapped with additional information, functionality, etc. If this directory chooses to decorate the object provided, it is up to the implementation of that decorated object to properly pass through operations as appropriate, as well as provide for an eventual undecorate() operation. All objects retrieved from this DecoratingDirectory will first be passed through this function.
        Parameters:
        object - An object from a Directory which originates from a different AuthenticationProvider.
        Returns:
        An object which may have been decorated by this DecoratingDirectory. If the object was not decorated, the original, unmodified object may be returned instead.
        Throws:
        org.apache.guacamole.GuacamoleException - If the provided object cannot be decorated due to an error.
      • undecorate

        protected abstract ObjectType undecorate​(ObjectType object)
                                          throws org.apache.guacamole.GuacamoleException
        Given an object originally returned from a call to this DecoratingDirectory's decorate() function, reverses the decoration operation, returning the original object. This function is effectively the exact inverse of the decorate() function. The return value of undecorate(decorate(X)) must be identically X. All objects given to this DecoratingDirectory via add() or update() will first be passed through this function.
        Parameters:
        object - An object which was originally returned by a call to this DecoratingDirectory's decorate() function.
        Returns:
        The original object which was provided to this DecoratingDirectory's decorate() function.
        Throws:
        org.apache.guacamole.GuacamoleException - If the provided object cannot be undecorated due to an error.
      • get

        public ObjectType get​(String identifier)
                       throws org.apache.guacamole.GuacamoleException
        Description copied from interface: Directory
        Returns the object having the given identifier. Note that changes to the object returned will not necessarily affect the object stored within the Directory. To update an object stored within an Directory such that future calls to get() will return the updated object, you must call update() on the object after modification.
        Specified by:
        get in interface Directory<ObjectType extends Identifiable>
        Overrides:
        get in class DelegatingDirectory<ObjectType extends Identifiable>
        Parameters:
        identifier - The identifier to use when locating the object to return.
        Returns:
        The object having the given identifier, or null if no such object exists.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while retrieving the object, or if permission for retrieving the object is denied.
      • getAll

        public Collection<ObjectType> getAll​(Collection<String> identifiers)
                                      throws org.apache.guacamole.GuacamoleException
        Description copied from interface: Directory
        Returns the objects having the given identifiers. Note that changes to any object returned will not necessarily affect the object stored within the Directory. To update an object stored within a Directory such that future calls to get() will return the updated object, you must call update() on the object after modification.
        Specified by:
        getAll in interface Directory<ObjectType extends Identifiable>
        Overrides:
        getAll in class DelegatingDirectory<ObjectType extends Identifiable>
        Parameters:
        identifiers - The identifiers to use when locating the objects to return.
        Returns:
        The objects having the given identifiers. If any identifiers do not correspond to accessible objects, those identifiers will be ignored. If no objects correspond to any of the given identifiers, the returned collection will be empty.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while retrieving the objects, or if permission to retrieve the requested objects is denied.
      • add

        public void add​(ObjectType object)
                 throws org.apache.guacamole.GuacamoleException
        Description copied from interface: Directory
        Adds the given object to the overall set. If a new identifier is created for the added object, that identifier will be automatically assigned via setIdentifier().
        Specified by:
        add in interface Directory<ObjectType extends Identifiable>
        Overrides:
        add in class DelegatingDirectory<ObjectType extends Identifiable>
        Parameters:
        object - The object to add.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while adding the object, or if adding the object is not allowed.
      • update

        public void update​(ObjectType object)
                    throws org.apache.guacamole.GuacamoleException
        Description copied from interface: Directory
        Updates the stored object with the data contained in the given object.
        Specified by:
        update in interface Directory<ObjectType extends Identifiable>
        Overrides:
        update in class DelegatingDirectory<ObjectType extends Identifiable>
        Parameters:
        object - The object which will supply the data for the update.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while updating the object, or if updating the object is not allowed.