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, MetaConfigLoaderBuilder

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 Details

  • Method Details

    • 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 the ScimClientConfig. these headers will be overridden by the map from sendRequest(Map) if duplicate keys are present
      preferredHeaders - the http headers that have been added to the sendRequest(Map) method. This map takes precedence for the default headers set in the ScimClientConfig
      request - 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
    • getRequiredResponseHeaders

      protected Map<String,String> getRequiredResponseHeaders()
      this is the default implementation for the expected response headers that should be present within the response. This is based on request since the delete request does not require a content type
    • setExpectedResponseHeaders

      protected RequestBuilder<T> 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 map
      Parameters:
      resource - sets the resource that should be sent to the service provider
    • getHttpUriRequest

      protected abstract org.apache.http.client.methods.HttpUriRequest getHttpUriRequest()
      builds the request for the server
    • getBaseUrl

      protected String getBaseUrl()
      the base url to the scim service
    • getEndpoint

      protected String getEndpoint()
      the resource endpoint path e.g. /Users or /Groups
    • getResource

      public String getResource()
      the resource that should be sent to the service provider
    • getResponseEntityType

      protected Class<T> getResponseEntityType()
      the expected resource type
    • getScimHttpClient

      protected ScimHttpClient getScimHttpClient()
      an apache http client wrapper that offers some convenience methods
    • getRequiredHttpHeaders

      public Map<String,String> getRequiredHttpHeaders()
      the headers that are expected to be returned from the server. If any of the required response headers is missing the response will be marked as not successful