Package org.apache.guacamole.net.auth
Class DecoratingActivityRecordSet<RecordType extends ActivityRecord>
- java.lang.Object
-
- org.apache.guacamole.net.auth.DelegatingActivityRecordSet<RecordType>
-
- org.apache.guacamole.net.auth.DecoratingActivityRecordSet<RecordType>
-
- Type Parameters:
RecordType
- The type of records stored within this ActivityRecordSet.
- All Implemented Interfaces:
ActivityRecordSet<RecordType>
public abstract class DecoratingActivityRecordSet<RecordType extends ActivityRecord> extends DelegatingActivityRecordSet<RecordType>
ActivityRecordSet implementation which simplifies decorating the records within an underlying ActivityRecordSet. The decorate() function must be implemented to define how each record is decorated. As ActivityRecordSets are read-only, there is no need to define an undecorate() function as required byDecoratingDirectory
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.guacamole.net.auth.ActivityRecordSet
ActivityRecordSet.SortableProperty
-
-
Constructor Summary
Constructors Constructor Description DecoratingActivityRecordSet(ActivityRecordSet<RecordType> recordSet)
Creates a new DecoratingActivityRecordSet which decorates the records within the given set.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Collection<RecordType>
asCollection()
Returns all records within this set as a standard Collection.ActivityRecordSet<RecordType>
contains(String value)
Returns the subset of records which contain the given value.protected ActivityRecordSet<RecordType>
decorate(ActivityRecordSet<RecordType> recordSet)
Given an ActivityRecordSet which originates from a different AuthenticationProvider, returns an identical type of record set optionally wrapped with additional information, functionality, etc.protected abstract RecordType
decorate(RecordType record)
Given a record retrieved from a ActivityRecordSet which originates from a different AuthenticationProvider, returns an identical type of record optionally wrapped with additional information, functionality, etc.RecordType
get(String string)
Returns the record having the given unique identifier, if records within this set have unique identifiers.ActivityRecordSet<RecordType>
limit(int limit)
Returns the subset of records containing only the firstlimit
records.ActivityRecordSet<RecordType>
sort(ActivityRecordSet.SortableProperty property, boolean desc)
Returns a ActivityRecordSet containing identically the records within this set, sorted according to the specified criteria.-
Methods inherited from class org.apache.guacamole.net.auth.DelegatingActivityRecordSet
getDelegateActivityRecordSet
-
-
-
-
Constructor Detail
-
DecoratingActivityRecordSet
public DecoratingActivityRecordSet(ActivityRecordSet<RecordType> recordSet)
Creates a new DecoratingActivityRecordSet which decorates the records within the given set.- Parameters:
recordSet
- The ActivityRecordSet whose records are being decorated.
-
-
Method Detail
-
decorate
protected abstract RecordType decorate(RecordType record) throws org.apache.guacamole.GuacamoleException
Given a record retrieved from a ActivityRecordSet which originates from a different AuthenticationProvider, returns an identical type of record optionally wrapped with additional information, functionality, etc. If this record set chooses to decorate the record provided, it is up to the implementation of that decorated record to properly pass through operations as appropriate. All records retrieved from this DecoratingActivityRecordSet will first be passed through this function.- Parameters:
record
- A record from a ActivityRecordSet which originates from a different AuthenticationProvider.- Returns:
- A record which may have been decorated by this DecoratingActivityRecordSet. If the record was not decorated, the original, unmodified record may be returned instead.
- Throws:
org.apache.guacamole.GuacamoleException
- If the provided record cannot be decorated due to an error.
-
decorate
protected ActivityRecordSet<RecordType> decorate(ActivityRecordSet<RecordType> recordSet) throws org.apache.guacamole.GuacamoleException
Given an ActivityRecordSet which originates from a different AuthenticationProvider, returns an identical type of record set optionally wrapped with additional information, functionality, etc. If this record set chooses to decorate the record set provided, it is up to the implementation of that decorated record set to properly pass through operations as appropriate. All record sets retrieved from this DecoratingActivityRecordSet will first be passed through this function, such as those returned bylimit(int)
and similar functions.By default, this function will wrap any provided ActivityRecordSet in a simple, anonymous instance of DecoratingActivityRecordSet that delegates to the decorate() implementations of this DecoratingActivityRecordSet. This default behavior may need to be overridden if the DecoratingActivityRecordSet implementation maintains any internal state.
- Parameters:
recordSet
- An ActivityRecordSet which originates from a different AuthenticationProvider.- Returns:
- A record set which may have been decorated by this DecoratingActivityRecordSet. If the record set was not decorated, the original, unmodified record set may be returned instead, however beware that this may result in records within the set no longer being decorated.
- Throws:
org.apache.guacamole.GuacamoleException
- If the provided record set cannot be decorated due to an error.
-
get
public RecordType get(String string) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ActivityRecordSet
Returns the record having the given unique identifier, if records within this set have unique identifiers. If records within this set do not have defined unique identifiers, this function has no effect.- Specified by:
get
in interfaceActivityRecordSet<RecordType extends ActivityRecord>
- Overrides:
get
in classDelegatingActivityRecordSet<RecordType extends ActivityRecord>
- Parameters:
string
- The unique identifier of the record to retrieve.- Returns:
- The record having the given unique identifier, or null if there is no such record.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while retrieving the record.
-
sort
public ActivityRecordSet<RecordType> sort(ActivityRecordSet.SortableProperty property, boolean desc) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ActivityRecordSet
Returns a ActivityRecordSet containing identically the records within this set, sorted according to the specified criteria. The sort operation performed is guaranteed to be stable with respect to any past call to sort(). This function may also affect the contents of the current ActivityRecordSet. The contents of the current ActivityRecordSet should NOT be relied upon after this function is called.- Specified by:
sort
in interfaceActivityRecordSet<RecordType extends ActivityRecord>
- Overrides:
sort
in classDelegatingActivityRecordSet<RecordType extends ActivityRecord>
- Parameters:
property
- The property by which the records within the resulting set should be sorted.desc
- Whether the records should be sorted according to the specified property in descending order. If false, records will be sorted according to the specified property in ascending order.- Returns:
- The ActivityRecordSet, sorted according to the specified criteria.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while sorting the current subset, or if the given property is not supported by the implementation.
-
limit
public ActivityRecordSet<RecordType> limit(int limit) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ActivityRecordSet
Returns the subset of records containing only the firstlimit
records. If the subset has fewer thanlimit
records, then this function has no effect. This function may also affect the contents of the current ActivityRecordSet. The contents of the current ActivityRecordSet should NOT be relied upon after this function is called.- Specified by:
limit
in interfaceActivityRecordSet<RecordType extends ActivityRecord>
- Overrides:
limit
in classDelegatingActivityRecordSet<RecordType extends ActivityRecord>
- Parameters:
limit
- The maximum number of records that the new subset should contain.- Returns:
- The subset of records that containing only the first
limit
records. - Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while limiting the current subset.
-
contains
public ActivityRecordSet<RecordType> contains(String value) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ActivityRecordSet
Returns the subset of records which contain the given value. The properties and semantics involved with determining whether a particular record "contains" the given value is implementation dependent. This function may affect the contents of the current ActivityRecordSet. The contents of the current ActivityRecordSet should NOT be relied upon after this function is called.- Specified by:
contains
in interfaceActivityRecordSet<RecordType extends ActivityRecord>
- Overrides:
contains
in classDelegatingActivityRecordSet<RecordType extends ActivityRecord>
- Parameters:
value
- The value which all records within the resulting subset should contain.- Returns:
- The subset of records which contain the specified value.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while restricting the current subset.
-
asCollection
public Collection<RecordType> asCollection() throws org.apache.guacamole.GuacamoleException
Description copied from interface:ActivityRecordSet
Returns all records within this set as a standard Collection.- Specified by:
asCollection
in interfaceActivityRecordSet<RecordType extends ActivityRecord>
- Overrides:
asCollection
in classDelegatingActivityRecordSet<RecordType extends ActivityRecord>
- Returns:
- A collection containing all records within this set.
- Throws:
org.apache.guacamole.GuacamoleException
- If an error occurs while retrieving the records within this set.
-
-