Class RequestUtils
java.lang.Object
de.captaingoldfish.scim.sdk.server.utils.RequestUtils
author Pascal Knueppel
created at: 12.10.2019 - 20:08
this class will add some helper methods that can be used to validate or modify request based attributes based on the SCIM specification RFC7643 and RFC7644
created at: 12.10.2019 - 20:08
this class will add some helper methods that can be used to validate or modify request based attributes based on the SCIM specification RFC7643 and RFC7644
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<SchemaAttribute>getAttributes(ResourceType resourceType, String attributes) this method will parse either the attributes parameter or the excludedAttributes parameter into a list ofSchemaAttributes.static intgetEffectiveCount(ServiceProvider serviceProvider, Integer count) Will get the effective count value as described in RFC7644:
Non-negative integer.static intgetEffectiveFailOnErrors(BulkRequest bulkRequest) will check the failOnErrors attribute in a bulk request and return a sanitized value.
RFC7644 chapter 3.7.3 defines the minimum value of failOnErrors as 1static longgetEffectiveStartIndex(Long startIndex) The 1-based index of the first query result.getQueryParameters(String query) gets the query parameter from the given URLstatic SchemaAttributegetSchemaAttributeByAttributeName(ResourceType resourceType, String attributeName) gets theSchemaAttributefrom the givenResourceTypestatic SchemaAttributegetSchemaAttributeForFilter(ResourceType resourceType, FilterAttributeName attributeName) gets theSchemaAttributefrom the givenResourceTypeparseCount(String countQueryParameter) tries to parse the incoming count value as integer numberstatic FilterNodeparseFilter(ResourceType resourceType, String filter) parses the filter of a list requeststatic AttributePathRootparsePatchPath(ResourceType resourceType, String path) parses a value path context for patch path expressionsparseStartIndex(String startIndexQueryParameter) tries to parse the incoming startIndex value as long number
-
Method Details
-
getAttributes
this method will parse either the attributes parameter or the excludedAttributes parameter into a list ofSchemaAttributes. The expected form of the attributes list is: form (e.g., userName, name, emails)- Parameters:
attributes- the comma separated string of scim attribute names- Returns:
- the list of attributes
-
parseFilter
parses the filter of a list request- Parameters:
resourceType- the resource type that describes the endpoint on which the filter is used so that the filter expression can be correctly resolvedfilter- the filter expression that must apply to the given resource type- Returns:
- The parsed filter expression as resolvable tree structure that might be used to resolve them to jpa predicates for example
-
parsePatchPath
parses a value path context for patch path expressions- Parameters:
resourceType- the resource type that describes the endpoint on which the path expression is usedpath- the path expression that must apply to the given resource type- Returns:
- The parsed path expression as resolvable tree structure to find matching attributes within a single resource
-
parseStartIndex
tries to parse the incoming startIndex value as long number- Parameters:
countQueryParameter- the query parameter that should be a number- Returns:
- the parsed startIndex value or an empty if the parameter is missing
-
parseCount
tries to parse the incoming count value as integer number- Parameters:
countQueryParameter- the query parameter that should be a number- Returns:
- the parsed count value or an empty if the parameter is missing
-
getEffectiveStartIndex
The 1-based index of the first query result. A value less than 1 SHALL be interpreted as 1.- Parameters:
startIndex- the index to start with to list the resources- Returns:
- number "1" or greater
-
getEffectiveCount
Will get the effective count value as described in RFC7644:
Non-negative integer. Specifies the desired maximum number of query results per page, e.g., 10. A negative value SHALL be interpreted as "0". A value of "0" indicates that no resource results are to be returned except for "totalResults".
DEFAULT: None
When specified, the service provider MUST NOT return more results than specified, although it MAY return fewer results. If unspecified, the maximum number of results is set by the service provider. -
getSchemaAttributeByAttributeName
public static SchemaAttribute getSchemaAttributeByAttributeName(ResourceType resourceType, String attributeName) gets theSchemaAttributefrom the givenResourceType- Parameters:
resourceType- the resource type from which the attribute definition should be extractedattributeName- this instance holds the attribute name to extract theSchemaAttributefrom theResourceType- Returns:
- the found
SchemaAttributedefinition - Throws:
BadRequestException- if noSchemaAttributewas found for the given name attribute
-
getSchemaAttributeForFilter
public static SchemaAttribute getSchemaAttributeForFilter(ResourceType resourceType, FilterAttributeName attributeName) gets theSchemaAttributefrom the givenResourceType- Parameters:
resourceType- the resource type from which the attribute definition should be extractedattributeName- this instance holds the attribute name to extract theSchemaAttributefrom theResourceType- Returns:
- the found
SchemaAttributedefinition - Throws:
InvalidFilterException- if noSchemaAttributewas found for the given name attribute
-
getQueryParameters
gets the query parameter from the given URL- Parameters:
query- the query string- Returns:
- the query parameters as a map
-
getEffectiveFailOnErrors
will check the failOnErrors attribute in a bulk request and return a sanitized value.
RFC7644 chapter 3.7.3 defines the minimum value of failOnErrors as 1The "failOnErrors" attribute is set to '1', indicating that the service provider will stop processing and return results after one error
- Parameters:
bulkRequest- the bulk request- Returns:
- a failOnErrors value that has been validated and sanitized
-