public abstract class

AbstractHandshakeClient

extends Object
java.lang.Object
   ↳ org.mule.modules.handshake.client.impl.AbstractHandshakeClient
Known Direct Subclasses

Class Overview

Base class for all the service client in this project. The class handles:

  • base URL creation
  • creation of the Jersey client
  • set up of basic authentication headers
  • read of files from input streams
  • string serialization of the responses

Summary

Fields
private final String baseUrl
protected final Gson gson
Public Constructors
AbstractHandshakeClient(String baseUrl)
Protected Methods
abstract StringBuilder extendGetBaseUrl(StringBuilder baseUrl)
This method is called by getBaseURL for the user to extend the base URL of its ServiceClient implementation.
<T> HandshakeAPIResponse<T> get(WebResource.Builder resourceBuilder, Type type)
String getBaseURL()
WebResource.Builder getBuilder(String user, String password, String antiThrottleKey, String url, Map<String, String> queryParameters)
Creates a Builder
ClientConfig getJerseyClientConfiguration()
This method is called by getBuilder before the creation of the Client.
MultivaluedMap<String, String> mapToMultivaluedMap(Map<String, String> map)
Transform a map in a MultivaluedMap which is needed by Jersey to send query parameters.
<V> V parseJson(String string, Type type)
Parse JSON to specified type
<T> T post(WebResource.Builder resourceBuilder, Type requestType, Type responseType, Object params)
String readResponseFromClientResponse(ClientResponse clientResponse)
<T> T singleGet(WebResource.Builder resourceBuilder, Type type)
<T> T update(WebResource.Builder resourceBuilder, Type objectType, T edited)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private final String baseUrl

protected final Gson gson

Public Constructors

public AbstractHandshakeClient (String baseUrl)

Parameters
baseUrl

Protected Methods

protected abstract StringBuilder extendGetBaseUrl (StringBuilder baseUrl)

This method is called by getBaseURL for the user to extend the base URL of its ServiceClient implementation.

Parameters
baseUrl A builder with the Base Url
Returns
  • the builder, with the extended content as needed

protected HandshakeAPIResponse<T> get (WebResource.Builder resourceBuilder, Type type)

Parameters
resourceBuilder
type

protected String getBaseURL ()

Returns

protected WebResource.Builder getBuilder (String user, String password, String antiThrottleKey, String url, Map<String, String> queryParameters)

Creates a Builder

Parameters
user For authentication
password For authentication
antiThrottleKey
url The URL to be hit by the client
queryParameters A map containing all the query parameters
Returns
  • the builder.

protected ClientConfig getJerseyClientConfiguration ()

This method is called by getBuilder before the creation of the Client. The ClientConfig is used to create the Client.

protected MultivaluedMap<String, String> mapToMultivaluedMap (Map<String, String> map)

Transform a map in a MultivaluedMap which is needed by Jersey to send query parameters. It also validate that not empty parameters are being send.

Parameters
map The map of query parameters
Returns
  • the same map in an MultivaluedMap object.

protected V parseJson (String string, Type type)

Parse JSON to specified type

Parameters
string JSON-formatted string to parse
type Of the object to obtain
Returns
  • parsed object
Throws
IOException if the string is not JSON-formatted

protected T post (WebResource.Builder resourceBuilder, Type requestType, Type responseType, Object params)

Parameters
resourceBuilder
requestType
responseType
params

protected String readResponseFromClientResponse (ClientResponse clientResponse)

Parameters
clientResponse

protected T singleGet (WebResource.Builder resourceBuilder, Type type)

Parameters
resourceBuilder
type

protected T update (WebResource.Builder resourceBuilder, Type objectType, T edited)

Parameters
resourceBuilder
objectType
edited