Class BulkBuilder
java.lang.Object
de.captaingoldfish.scim.sdk.client.builder.RequestBuilder<BulkResponse>
de.captaingoldfish.scim.sdk.client.builder.BulkBuilder
author Pascal Knueppel
created at: 08.03.2020
created at: 08.03.2020
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classan additional build step class that allows to set the values of a bulk operation -
Constructor Summary
ConstructorsConstructorDescriptionBulkBuilder(String baseUrl, ScimHttpClient scimHttpClient, boolean isFullUrl, Supplier<ServiceProvider> serviceProviderSupplier) if the resource should be retrieved by using the fully qualified url -
Method Summary
Modifier and TypeMethodDescriptionaddOperations(List<BulkRequestOperation> requestOperations) adds the given list of operationsbulkRequestOperation(String path) sets the path to the resource endpoint e.g.bulkRequestOperation(String path, String id) sets the path to the resource endpoint e.g.failOnErrors(Integer failOnErrors) sets how many errors are allowed on the server side before the request should be rolled backthe bulk request operations that should be executedprotected org.apache.http.client.methods.HttpUriRequestbuilds the request for the serverprotected org.apache.http.client.methods.HttpUriRequestgetHttpUriRequest(com.fasterxml.jackson.databind.JsonNode requestData) protected StringgetIdFromLocationAttribute(BulkResponseOperation bulkResponseOperation) extracted into its own method for unit tests.getOperationByBulkId(String bulkId) retrieves a request operation from the builder by its bulkId.overrides the default method from the superclass to have easier control of the resource that will be put into the request bodyprotected booleanisExpectedResponseCode(int httpStatus) tells this abstract class if the http status from the server is the expected success statusprotected Function<HttpResponse,Boolean> checks if the response contains a schema-uri that matches the value ofSchemaUris.BULK_RESPONSE_URIsendRequest(boolean runSplittedRequestsParallel) send the request to the serversendRequest(Consumer<ServerResponse<BulkResponse>> responseHandler) send the request to the serversendRequest(Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) send the request to the serversendRequest(Map<String, String> headers, Consumer<ServerResponse<BulkResponse>> responseHandler) send the request to the serversendRequest(Map<String, String> headers, Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) send the request to the serversendRequestWithMultiHeaders(Map<String, String[]> httpHeaders) sends the defined request to the service providersendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, boolean runSplittedRequestsParallel) sendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, Consumer<ServerResponse<BulkResponse>> responseHandler) sendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) setExpectedResponseHeaders(Map<String, String> requiredResponseHeaders) Set this if the SCIM provider is not behaving SCIM compliant by manipulating the expected headers that will be returned from the server null: The headers are checked as normally for the content-type "application/scim+json" empty map: The check of response headers is disabled filled map: The check of the response headers will be done with the entries of this mapvoidsetServiceProviderSupplier(Supplier<ServiceProvider> serviceProviderSupplier) contains the configuration of the service provider that is used to determine the max-operations of a bulk request and to help to split the operations into several requests if necessary.Methods inherited from class de.captaingoldfish.scim.sdk.client.builder.RequestBuilder
addHeaderToRequest, getBaseUrl, getEndpoint, getRequiredHttpHeaders, getRequiredResponseHeaders, getResponseEntityType, getScimHttpClient, sendRequest, sendRequest, setResource, setResource, toResponse
-
Constructor Details
-
BulkBuilder
public BulkBuilder(String baseUrl, ScimHttpClient scimHttpClient, boolean isFullUrl, Supplier<ServiceProvider> serviceProviderSupplier) if the resource should be retrieved by using the fully qualified url- Parameters:
baseUrl- the fully qualified url to the required resourcescimHttpClient- the http client instanceisFullUrl- if the given base url is the fully qualified url or notserviceProviderSupplier- contains the configuration of the service provider that is used to determine the max-operations of a bulk request and to help to split the operations into several requests if necessary.
This object might be null
-
-
Method Details
-
setExpectedResponseHeaders
Set this if the SCIM provider is not behaving SCIM compliant by manipulating the expected headers that will be returned from the server- null: The headers are checked as normally for the content-type "application/scim+json"
- empty map: The check of response headers is disabled
- filled map: The check of the response headers will be done with the entries of this map
- Overrides:
setExpectedResponseHeadersin classRequestBuilder<BulkResponse>
-
getOperationByBulkId
retrieves a request operation from the builder by its bulkId. Modifying the returned operation will also modify the request- Parameters:
bulkId- the bulkId of the operation that should be returned- Returns:
- the request operation with the matching bulkId
-
isExpectedResponseCode
protected boolean isExpectedResponseCode(int httpStatus) tells this abstract class if the http status from the server is the expected success status- Specified by:
isExpectedResponseCodein classRequestBuilder<BulkResponse>- Parameters:
httpStatus- the http status from the server- Returns:
- true if the response status shows success
-
getHttpUriRequest
protected org.apache.http.client.methods.HttpUriRequest getHttpUriRequest()builds the request for the server- Specified by:
getHttpUriRequestin classRequestBuilder<BulkResponse>
-
getHttpUriRequest
protected org.apache.http.client.methods.HttpUriRequest getHttpUriRequest(com.fasterxml.jackson.databind.JsonNode requestData) -
getResource
overrides the default method from the superclass to have easier control of the resource that will be put into the request body- Overrides:
getResourcein classRequestBuilder<BulkResponse>
-
isResponseParseable
checks if the response contains a schema-uri that matches the value ofSchemaUris.BULK_RESPONSE_URI- Overrides:
isResponseParseablein classRequestBuilder<BulkResponse>
-
failOnErrors
sets how many errors are allowed on the server side before the request should be rolled back- Parameters:
failOnErrors- the number of errors that are accepted on the server side
-
bulkRequestOperation
sets the path to the resource endpoint e.g. "/Users" or "/Groups" -
bulkRequestOperation
sets the path to the resource endpoint e.g. "/Users" or "/Groups"- Parameters:
path- "/Users", "/Groups" or any other registered resource pathid- the id of an existing resource in case of patch, update or delete
-
addOperations
adds the given list of operations -
sendRequest
send the request to the server- Parameters:
runSplittedRequestsParallel- if the requests should be run parallel. This is only recommended if no relations between the different bulk-request-operations are set. So if no bulkId-references are set. Otherwise, the relation between these requests might break- Returns:
- the response from the server
-
sendRequest
public ServerResponse<BulkResponse> sendRequest(Consumer<ServerResponse<BulkResponse>> responseHandler) send the request to the server- Parameters:
responseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabled- Returns:
- the response from the server
-
sendRequest
public ServerResponse<BulkResponse> sendRequest(Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) send the request to the server- Parameters:
responseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabledrunSplittedRequestsParallel- if the requests should be run parallel. This is only recommended if no relations between the different bulk-request-operations are set. So if no bulkId-references are set. Otherwise, the relation between these requests might break- Returns:
- the response from the server
-
sendRequest
public ServerResponse<BulkResponse> sendRequest(Map<String, String> headers, Consumer<ServerResponse<BulkResponse>> responseHandler) send the request to the server- Parameters:
headers- the http headers to send additionally to the default headery within the requestresponseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabled- Returns:
- the response from the server
-
sendRequest
public ServerResponse<BulkResponse> sendRequest(Map<String, String> headers, Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) send the request to the server- Parameters:
headers- the http headers to send additionally to the default headery within the requestresponseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabledrunSplittedRequestsParallel- if the requests should be run parallel. This is only recommended if no relations between the different bulk-request-operations are set. So if no bulkId-references are set. Otherwise, the relation between these requests might break- Returns:
- the response from the server
-
sendRequestWithMultiHeaders
sends the defined request to the service provider- Overrides:
sendRequestWithMultiHeadersin classRequestBuilder<BulkResponse>- Parameters:
httpHeaders- allows the user to add additional http headers to the request- Returns:
- the response from the given request. A response must not be returned in any case from the service provider so the returned type is still optional
-
sendRequestWithMultiHeaders
public ServerResponse<BulkResponse> sendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, boolean runSplittedRequestsParallel) - Parameters:
runSplittedRequestsParallel- if the requests should be run parallel. This is only recommended if no relations between the different bulk-request-operations are set. So if no bulkId-references are set. Otherwise, the relation between these requests might break
-
sendRequestWithMultiHeaders
public ServerResponse<BulkResponse> sendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, Consumer<ServerResponse<BulkResponse>> responseHandler) - Parameters:
responseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabled
-
sendRequestWithMultiHeaders
public ServerResponse<BulkResponse> sendRequestWithMultiHeaders(Map<String, String[]> httpHeaders, Consumer<ServerResponse<BulkResponse>> responseHandler, boolean runSplittedRequestsParallel) - Parameters:
responseHandler- a helper method to will allow the client to react to each individual response. This makes only sense if the featureScimClientConfig.isEnableAutomaticBulkRequestSplitting()is enabledrunSplittedRequestsParallel- if the requests should be run parallel. This is only recommended if no relations between the different bulk-request-operations are set. So if no bulkId-references are set. Otherwise, the relation between these requests might break
-
getIdFromLocationAttribute
extracted into its own method for unit tests. -
getBulkRequestOperationList
the bulk request operations that should be executed -
setServiceProviderSupplier
contains the configuration of the service provider that is used to determine the max-operations of a bulk request and to help to split the operations into several requests if necessary.
This object might be null
-