Class SimpleDirectory<ObjectType extends Identifiable>
java.lang.Object
org.apache.guacamole.net.auth.simple.SimpleDirectory<ObjectType>
- Type Parameters:
ObjectType
- The type of objects stored within this SimpleDirectory.
- All Implemented Interfaces:
Directory<ObjectType>
- Direct Known Subclasses:
SimpleConnectionDirectory
,SimpleConnectionGroupDirectory
,SimpleUserDirectory
public class SimpleDirectory<ObjectType extends Identifiable>
extends Object
implements Directory<ObjectType>
An extremely simple read-only implementation of a Directory which provides
access to a pre-defined Map of arbitrary objects. Any changes to the Map
will affect the available contents of this SimpleDirectory.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.guacamole.net.auth.Directory
Directory.Type
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty SimpleDirectory which does not provide access to any objects.SimpleDirectory
(Collection<ObjectType> objects) Creates a new SimpleDirectory which provides access to the objects contained within the Collection.SimpleDirectory
(Map<String, ObjectType> objects) Creates a new SimpleDirectory which provides access to the objects contained within the given Map.SimpleDirectory
(ObjectType object) Creates a new SimpleDirectory which provides access to the given object.SimpleDirectory
(ObjectType... objects) Creates a new SimpleDirectory which provides access to the given objects. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ObjectType connection) Adds the given object to the overall set.Returns the object having the given identifier.getAll
(Collection<String> identifiers) Returns the objects having the given identifiers.Returns a Set containing all identifiers for all objects within this Directory.protected Map
<String, ObjectType> Returns the Map which currently backs this SimpleDirectory.void
Removes the object with the given identifier from the overall set.protected void
setObjects
(Map<String, ObjectType> objects) Sets the Map which backs this SimpleDirectory.void
update
(ObjectType connection) Updates the stored object with the data contained in the given object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.guacamole.net.auth.Directory
tryAtomically
-
Constructor Details
-
SimpleDirectory
public SimpleDirectory()Creates a new empty SimpleDirectory which does not provide access to any objects. -
SimpleDirectory
Creates a new SimpleDirectory which provides access to the objects contained within the given Map. The given Map will be used to back all operations on the SimpleDirectory.- Parameters:
objects
- The Map of objects to provide access to.
-
SimpleDirectory
Creates a new SimpleDirectory which provides access to the given object.- Parameters:
object
- The object to provide access to.
-
SimpleDirectory
Creates a new SimpleDirectory which provides access to the given objects. Note that a new Map will be created to store the given objects. If the objects are already available in Map form, it is more efficient to use theSimpleDirectory(java.util.Map)
constructor.- Parameters:
objects
- The objects that should be present in this directory.
-
SimpleDirectory
Creates a new SimpleDirectory which provides access to the objects contained within the Collection. Note that a new Map will be created to store the given objects. If the objects are already available in Map form, it is more efficient to use theSimpleDirectory(java.util.Map)
constructor.- Parameters:
objects
- A Collection of all objects that should be present in this directory.
-
-
Method Details
-
setObjects
Sets the Map which backs this SimpleDirectory. Future function calls which retrieve objects from this SimpleDirectory will use the provided Map.- Parameters:
objects
- The Map of objects to provide access to.
-
getObjects
Returns the Map which currently backs this SimpleDirectory. Changes to this Map will affect future function calls that retrieve objects from this SimpleDirectory.- Returns:
- The Map of objects which currently backs this SimpleDirectory.
-
get
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 interfaceDirectory<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 interfaceDirectory<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.
-
getIdentifiers
Description copied from interface:Directory
Returns a Set containing all identifiers for all objects within this Directory.- Specified by:
getIdentifiers
in interfaceDirectory<ObjectType extends Identifiable>
- Returns:
- A Set of all identifiers.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while retrieving the identifiers.
-
add
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 interfaceDirectory<ObjectType extends Identifiable>
- Parameters:
connection
- 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
Description copied from interface:Directory
Updates the stored object with the data contained in the given object.- Specified by:
update
in interfaceDirectory<ObjectType extends Identifiable>
- Parameters:
connection
- 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.
-
remove
Description copied from interface:Directory
Removes the object with the given identifier from the overall set.- Specified by:
remove
in interfaceDirectory<ObjectType extends Identifiable>
- Parameters:
identifier
- The identifier of the object to remove.- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while removing the object, or if removing the object is not allowed.
-