Class InMemoryUserService
java.lang.Object
org.apache.directory.scim.example.jersey.service.InMemoryUserService
- All Implemented Interfaces:
Repository<ScimUser>
@Named
@ApplicationScoped
public class InMemoryUserService
extends Object
implements Repository<ScimUser>
Creates a singleton (effectively) Repository with a memory-based
persistence layer.
- Author:
- Chris Harm <crh5255@psu.edu>
-
Constructor Summary
ModifierConstructorDescriptionprotected
InMemoryUserService
(SchemaRegistry schemaRegistry, PatchHandler patchHandler) -
Method Summary
Modifier and TypeMethodDescriptionAllows the SCIM server's REST implementation to create a resource via a POST to a valid end-point.void
Deletes the ScimResource with the provided identifier (if it exists).find
(Filter filter, PageRequest pageRequest, SortRequest sortRequest) Finds and retrieves all ScimResource objects known to the persistence layer that match the criteria specified by the passed Filter.Retrieves the ScimResource associated with the provided identifier.List<Class<? extends ScimExtension>>
Returns a list of the SCIM Extensions that this repository considers to be associated with the ScimResource of type T.Returns the type of ScimResource this repository manages.void
init()
patch
(String id, String version, List<PatchOperation> patchOperations, Set<AttributeReference> includedAttributeReferences, Set<AttributeReference> excludedAttributeReferences) Allows the SCIM server's REST implementation to update and existing resource via a PATCH to a valid end-point.update
(String id, String version, ScimUser resource, Set<AttributeReference> includedAttributeReferences, Set<AttributeReference> excludedAttributeReferences) Allows the SCIM server's REST implementation to update and existing resource via a PUT to a valid end-point.
-
Constructor Details
-
InMemoryUserService
-
InMemoryUserService
protected InMemoryUserService()
-
-
Method Details
-
init
@PostConstruct public void init() -
getResourceClass
Description copied from interface:Repository
Returns the type of ScimResource this repository manages.- Specified by:
getResourceClass
in interfaceRepository<ScimUser>
- Returns:
- The type of resource this repository manages.
-
create
Description copied from interface:Repository
Allows the SCIM server's REST implementation to create a resource via a POST to a valid end-point.- Specified by:
create
in interfaceRepository<ScimUser>
- Parameters:
resource
- The ScimResource to create and persist.- Returns:
- The newly created ScimResource.
- Throws:
UnableToCreateResourceException
- See Also:
-
update
public ScimUser update(String id, String version, ScimUser resource, Set<AttributeReference> includedAttributeReferences, Set<AttributeReference> excludedAttributeReferences) throws ResourceException Description copied from interface:Repository
Allows the SCIM server's REST implementation to update and existing resource via a PUT to a valid end-point.
SCIM Implementation NOTE: SCIM supports versioning of resources via HTTP ETags, if the (optional)version
parameter is present, (and supported by the server), it can be used as a mechanism for caching and to ensure clients do not inadvertently overwrite other changes.- Specified by:
update
in interfaceRepository<ScimUser>
- Parameters:
id
- the identifier of the ScimResource to update and persist.version
- an optional version (usually used as an ETag) that can be used to optimize update requests, may be compared against, the currentScimResource.meta.version
.resource
- an updated resource to persistincludedAttributeReferences
- optional set of attributes to include from ScimResource, may be used to optimize queries.excludedAttributeReferences
- optional set of attributes to exclude from ScimResource, may be used to optimize queries.- Returns:
- The newly updated ScimResource.
- Throws:
ResourceException
- When the ScimResource cannot be updated.
-
patch
public ScimUser patch(String id, String version, List<PatchOperation> patchOperations, Set<AttributeReference> includedAttributeReferences, Set<AttributeReference> excludedAttributeReferences) throws ResourceException Description copied from interface:Repository
Allows the SCIM server's REST implementation to update and existing resource via a PATCH to a valid end-point.
SCIM Implementation NOTE: SCIM supports versioning of resources via HTTP ETags, if the (optional)version
parameter is present, (and supported by the server), it can be used as a mechanism for caching and to ensure clients do not inadvertently overwrite other changes.- Specified by:
patch
in interfaceRepository<ScimUser>
- Parameters:
id
- the identifier of the ScimResource to update and persist.version
- an optional version (usually used as an ETag) that can be used to optimize update requests, may be compared against, the currentScimResource.meta.version
.patchOperations
- a list of patch operations to apply to an existing resource.includedAttributeReferences
- optional set of attributes to include from ScimResource, may be used to optimize queries.excludedAttributeReferences
- optional set of attributes to exclude from ScimResource, may be used to optimize queries.- Returns:
- The newly updated ScimResource.
- Throws:
ResourceException
- When the ScimResource cannot be updated.
-
get
Description copied from interface:Repository
Retrieves the ScimResource associated with the provided identifier.- Specified by:
get
in interfaceRepository<ScimUser>
- Parameters:
id
- The identifier of the target ScimResource.- Returns:
- The requested ScimResource.
- See Also:
-
delete
Description copied from interface:Repository
Deletes the ScimResource with the provided identifier (if it exists). This interface makes no distinction between hard and soft deletes but rather leaves that to the designer of the persistence layer.- Specified by:
delete
in interfaceRepository<ScimUser>
- Parameters:
id
- The ScimResource's identifier.- See Also:
-
find
public FilterResponse<ScimUser> find(Filter filter, PageRequest pageRequest, SortRequest sortRequest) Description copied from interface:Repository
Finds and retrieves all ScimResource objects known to the persistence layer that match the criteria specified by the passed Filter. The results may be truncated by the scope specified by the passed PageRequest and the order of the returned resources may be controlled by the passed SortRequest.- Specified by:
find
in interfaceRepository<ScimUser>
- Parameters:
filter
- The filter that determines the ScimResources that will be part of the ResultListpageRequest
- For paged requests, this object specifies the start index and number of ScimResources that should be returned.sortRequest
- Specifies which fields the returned ScimResources should be sorted by and whether the sort order is ascending or descending.- Returns:
- A list of the ScimResources that pass the filter criteria, truncated to match the requested "page" and sorted according to the provided requirements.
- See Also:
-
getExtensionList
Description copied from interface:Repository
Returns a list of the SCIM Extensions that this repository considers to be associated with the ScimResource of type T.- Specified by:
getExtensionList
in interfaceRepository<ScimUser>
- Returns:
- A list of ScimExtension classes.
- See Also:
-