Class RequestBuilder<T extends ScimObjectNode>
- java.lang.Object
-
- de.captaingoldfish.scim.sdk.client.builder.RequestBuilder<T>
-
- Direct Known Subclasses:
BulkBuilder,CreateBuilder,ETagRequestBuilder,ListBuilder.GetRequestBuilder,ListBuilder.PostRequestBuilder
public abstract class RequestBuilder<T extends ScimObjectNode> extends Object
author Pascal Knueppel
created at: 07.12.2019 - 23:15
an abstract request builder implementation
-
-
Constructor Summary
Constructors Constructor Description RequestBuilder(String baseUrl, String endpoint, Class<T> responseEntityType, ScimHttpClient scimHttpClient)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddHeaderToRequest(Map<String,String[]> defaultHeaders, Map<String,String[]> preferredHeaders, org.apache.http.client.methods.HttpUriRequest request)adds the http headers to the current requestprotected abstract org.apache.http.client.methods.HttpUriRequestgetHttpUriRequest()builds the request for the serverprotected abstract booleanisExpectedResponseCode(int httpStatus)tells this abstract class if the http status from the server is the expected success statusprotected Function<HttpResponse,Boolean>isResponseParseable()an optional method that might be used by a builder to verify if the response can be parsed into the expected resource typeServerResponse<T>sendRequest()sends the defined request to the service providerServerResponse<T>sendRequest(Map<String,String> headers)sends the defined request to the service providerServerResponse<T>sendRequestWithMultiHeaders(Map<String,String[]> httpHeaders)sends the defined request to the service providerprotected RequestBuilder<T>setResource(com.fasterxml.jackson.databind.JsonNode resource)protected RequestBuilder<T>setResource(String resource)protected ServerResponse<T>toResponse(HttpResponse response)moved into its own method to override the returned class in the list-builder that has a sub-generic type
-
-
-
Constructor Detail
-
RequestBuilder
public RequestBuilder(String baseUrl, String endpoint, Class<T> responseEntityType, ScimHttpClient scimHttpClient)
-
-
Method Detail
-
setResource
protected RequestBuilder<T> setResource(String resource)
- Parameters:
resource- sets the resource that should be sent to the service provider
-
setResource
protected RequestBuilder<T> setResource(com.fasterxml.jackson.databind.JsonNode resource)
- Parameters:
resource- sets the resource that should be sent to the service provider
-
isExpectedResponseCode
protected abstract boolean isExpectedResponseCode(int httpStatus)
tells this abstract class if the http status from the server is the expected success status- Parameters:
httpStatus- the http status from the server- Returns:
- true if the response status shows success
-
isResponseParseable
protected Function<HttpResponse,Boolean> isResponseParseable()
an optional method that might be used by a builder to verify if the response can be parsed into the expected resource type
-
sendRequest
public ServerResponse<T> sendRequest()
sends the defined request to the service provider- 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<T> sendRequestWithMultiHeaders(Map<String,String[]> httpHeaders)
sends the defined request to the service provider- 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
-
addHeaderToRequest
protected void addHeaderToRequest(Map<String,String[]> defaultHeaders, Map<String,String[]> preferredHeaders, org.apache.http.client.methods.HttpUriRequest request)
adds the http headers to the current request- Parameters:
defaultHeaders- the default http headers from theScimClientConfig. these headers will be overridden by the map fromsendRequest(Map)if duplicate keys are presentpreferredHeaders- the http headers that have been added to thesendRequest(Map)method. This map takes precedence for the default headers set in theScimClientConfigrequest- the request object to which these http headers will be added
-
sendRequest
public ServerResponse<T> sendRequest(Map<String,String> headers)
sends the defined request to the service provider- 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
-
toResponse
protected ServerResponse<T> toResponse(HttpResponse response)
moved into its own method to override the returned class in the list-builder that has a sub-generic type
-
getHttpUriRequest
protected abstract org.apache.http.client.methods.HttpUriRequest getHttpUriRequest()
builds the request for the server
-
-