Class ResourceHandler<T extends ResourceNode>
java.lang.Object
de.captaingoldfish.scim.sdk.server.endpoints.ResourceHandler<T>
- Direct Known Subclasses:
ResourceTypeHandler,SchemaHandler,ServiceProviderHandler
author Pascal Knueppel
created at: 07.10.2019 - 23:17
this abstract class is the base for the developer to implement
created at: 07.10.2019 - 23:17
this abstract class is the base for the developer to implement
-
Constructor Summary
ConstructorsConstructorDescriptiondefault constructor that resolves the generic type for this class -
Method Summary
Modifier and TypeMethodDescriptionabstract TcreateResource(T resource, Context context) permanently create a resourceabstract voiddeleteResource(String id, Context context) permanently deletes the resource with the given idgives access to the changePassword value of the current service provider configurationfinal intabstract TgetResource(String id, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) extract a resource by its idthe resource type that is the basic definition of this handler implementationthis method is used to resolve a resource type by the $ref-uri attribute or by the type-attribute of a resource-reference attributeprotected Optional<AbstractResourceValidator>getResponseValidator(List<SchemaAttribute> attributesList, List<SchemaAttribute> excludedAttributesList, com.fasterxml.jackson.databind.JsonNode requestDocument, BiFunction<String, String, String> referenceUrlSupplier) can be used to override the response-verifier if custom validation is wantedallows to access the definition of the main schemaallows to access the attribute definitions of a schema extensionthe current service provider configuration of the resource-typegetType()the generic type of this classfinal booleanabstract PartialListResponse<T>listResources(long startIndex, int count, FilterNode filter, SchemaAttribute sortBy, SortOrder sortOrder, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) queries several resources based on the following valuesprotected voidpostConstruct(ResourceType resourceType) an arbitrary method that might be useful for implementations that need to do some initialization after the registration of the resource is completeprotected voidsetResourceType(ResourceType resourceType) the resource type that is the basic definition of this handler implementationprotected voidallows to access the definition of the main schemaprotected voidsetSchemaExtensions(List<Schema> schemaExtensions) allows to access the attribute definitions of a schema extensionprotected voidsetServiceProvider(ServiceProvider serviceProvider) the current service provider configuration of the resource-typeabstract TupdateResource(T resourceToUpdate, Context context) should update an existing resource with the given one.
-
Constructor Details
-
ResourceHandler
public ResourceHandler()default constructor that resolves the generic type for this class
-
-
Method Details
-
createResource
permanently create a resource- Parameters:
resource- the resource to storecontext- the current request context that holds additional useful information. This object is never null- Returns:
- the stored resource with additional meta information as id, created, lastModified timestamps etc.
-
getResource
public abstract T getResource(String id, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) extract a resource by its id- Parameters:
id- the id of the resource to returnauthorization- should return the roles of an user and may contain arbitrary data needed in the handler implementationattributes- the attributes that should be returned to the client. If the client sends this parameter the evaluation of these parameters might help to improve database performance by omitting unnecessary table joinsexcludedAttributes- the attributes that should NOT be returned to the client. If the client send this parameter the evaluation of these parameters might help to improve database performance by omitting unnecessary table joinscontext- the current request context that holds additional useful information. This object is never null- Returns:
- the found resource
-
listResources
public abstract PartialListResponse<T> listResources(long startIndex, int count, FilterNode filter, SchemaAttribute sortBy, SortOrder sortOrder, List<SchemaAttribute> attributes, List<SchemaAttribute> excludedAttributes, Context context) queries several resources based on the following values- Parameters:
startIndex- the start index that has a minimum value of 1. So the given startIndex here will never be lower than 1count- the number of entries that should be returned to the client. The minimum value of this value is 0.filter- the parsed filter expression if the client has given a filtersortBy- the attribute value that should be used for sortingsortOrder- the sort orderattributes- the attributes that should be returned to the client. If the client sends this parameter the evaluation of these parameters might help to improve database performance by omitting unnecessary table joinsexcludedAttributes- the attributes that should NOT be returned to the client. If the client send this parameter the evaluation of these parameters might help to improve database performance by omitting unnecessary table joinscontext- the current request context that holds additional useful information. This object is never null- Returns:
- a list of several resources and a total results value. You may choose to leave the totalResults value blank but this might lead to erroneous results on the client side
-
updateResource
should update an existing resource with the given one. Simply use the id of the given resource and override the existing one with the given one. Be careful there have been no checks in advance for you if the resource to update does exist. This has to be done manually.
NOTE:
this method is also called by patch. But in the case of patch the check if the resource does exist will have been executed and the given resource is the already updated resource.- Parameters:
resourceToUpdate- the resource that should override an existing onecontext- the current request context that holds additional useful information. This object is never null- Returns:
- the updated resource with the values changed and a new lastModified value
-
deleteResource
permanently deletes the resource with the given id- Parameters:
id- the id of the resource to deletecontext- the current request context that holds additional useful information. This object is never null
-
isChangePasswordSupported
public final boolean isChangePasswordSupported()- Returns:
- true if the value in the in the corresponding value in the
ServiceProviderconfiguration is true, false else
-
getMaxResults
public final int getMaxResults()- Returns:
- the maximum results value from the current
ServiceProviderconfiguration
-
getRequestValidator
- Returns:
- allows to define a custom request validator that is executed after schema validation and before the
call to the actual
ResourceHandlerimplementation.
-
getResourceTypeByRef
this method is used to resolve a resource type by the $ref-uri attribute or by the type-attribute of a resource-reference attribute- Parameters:
ref- the $ref or type value of a resource-reference attribute e.g.: "User" or "http://localhost:8080/scim/v2/Users" or "http://localhost:8080/scim/v2/Users/${id}"- Returns:
- the resource type definition of the referenced type.
-
postConstruct
an arbitrary method that might be useful for implementations that need to do some initialization after the registration of the resource is complete -
getResponseValidator
protected Optional<AbstractResourceValidator> getResponseValidator(List<SchemaAttribute> attributesList, List<SchemaAttribute> excludedAttributesList, com.fasterxml.jackson.databind.JsonNode requestDocument, BiFunction<String, String, String> referenceUrlSupplier) can be used to override the response-verifier if custom validation is wanted- Parameters:
attributesList- the attributes from the requestexcludedAttributesList- the excluded attributes from the requestrequestDocument- the request documentreferenceUrlSupplier- the url-supplier to build specific urls for resources- Returns:
- an optional response-validator
-
getType
the generic type of this class -
getServiceProvider
the current service provider configuration of the resource-type -
setServiceProvider
the current service provider configuration of the resource-type -
getResourceType
the resource type that is the basic definition of this handler implementation -
setResourceType
the resource type that is the basic definition of this handler implementation -
getSchema
allows to access the definition of the main schema -
setSchema
allows to access the definition of the main schema -
getSchemaExtensions
allows to access the attribute definitions of a schema extension -
setSchemaExtensions
allows to access the attribute definitions of a schema extension -
getChangePasswordSupported
gives access to the changePassword value of the current service provider configuration
-