public class ServiceUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
MULTICAST_GROUP_ADDRESS |
static int |
MULTICAST_PORT |
| Constructor and Description |
|---|
ServiceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildURL(String host,
int port,
boolean useSSL,
String uri)
Gets the fully qualified URL string to the service.
|
static IMarshaller |
determineCommonMimeType(List<String> remoteSupportedMimeTypes)
Determine which mime-type and corresponding marshaller is mutually supported.
|
static org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
boolean useSSL)
Executes the specified request.
|
static org.apache.http.HttpResponse |
executeRequest(RegistryDescriptor registryDescriptor,
WebCall webCall,
Serializable entity) |
static org.apache.http.HttpResponse |
executeRequest(ServiceDescriptor serviceDescriptor,
WebCall webCall,
Serializable entity) |
static org.apache.http.HttpResponse |
executeRequest(String host,
int port,
boolean useSSL,
WebCall webCall,
List<String> remoteSupportedMimeTypes,
Serializable entity) |
static String |
getAcceptedMimeTypes()
Creates a comma-separated string of all mime-types supported by the
MarshallerFactory. |
static IMarshaller |
getMarshallerToCommunicateWithRestServer(String host,
int port,
String restServerUri)
Gets a
IMarshaller by querying the REST server's supported mime-types and trying to find a match by the clients supported mime-types. |
static String |
getMimeTypeForResponse(org.apache.http.Header acceptHeader)
Gets the mime-type from the request header 'accept' to determine the content-type of the response content.
|
static String |
getMimeTypeFromResponse(org.apache.http.HttpResponse response)
Gets the mime-type from the response header 'content-type' to determine how to deserialize the response entity.
|
static String |
getServiceURL(ServiceDescriptor serviceDescriptor)
Gets the fully qualified URL string to the service.
|
static List<String> |
getSupportedMediaTypesOfRestServer(String host,
int port,
String mediaTypesQueryUri)
Queries the supported mime-types from the REST server.
|
static void |
validateResponse(org.apache.http.HttpRequest httpRequest,
org.apache.http.HttpResponse httpResponse)
Validates the response if the status OK was returned, otherwise it will throw a
ServiceException. |
public static final String MULTICAST_GROUP_ADDRESS
public static final int MULTICAST_PORT
public static String getAcceptedMimeTypes()
MarshallerFactory.public static String getMimeTypeForResponse(org.apache.http.Header acceptHeader)
headers - the request headerspublic static String getMimeTypeFromResponse(org.apache.http.HttpResponse response)
response - the responsepublic static List<String> getSupportedMediaTypesOfRestServer(String host, int port, String mediaTypesQueryUri) throws ServiceException
ServiceExceptionpublic static IMarshaller getMarshallerToCommunicateWithRestServer(String host, int port, String restServerUri) throws ServiceException
IMarshaller by querying the REST server's supported mime-types and trying to find a match by the clients supported mime-types.host - the host of the REST serverport - the port of the REST serverrestServerUri - the URI which returns the mime-types in text/plainIMarshallerServiceExceptionpublic static void validateResponse(org.apache.http.HttpRequest httpRequest,
org.apache.http.HttpResponse httpResponse)
throws ServiceException
ServiceException.httpResponse - the responseServiceExceptionpublic static String getServiceURL(ServiceDescriptor serviceDescriptor)
serviceDescriptor - the ServiceDescriptorpublic static String buildURL(String host, int port, boolean useSSL, String uri)
host - the hostport - the portuseSSL - the flag whether to use SSLuri - the uri to the resourcepublic static org.apache.http.HttpResponse executeRequest(RegistryDescriptor registryDescriptor, WebCall webCall, Serializable entity) throws ServiceException
ServiceExceptionpublic static org.apache.http.HttpResponse executeRequest(ServiceDescriptor serviceDescriptor, WebCall webCall, Serializable entity) throws ServiceException
ServiceExceptionpublic static org.apache.http.HttpResponse executeRequest(String host, int port, boolean useSSL, WebCall webCall, List<String> remoteSupportedMimeTypes, Serializable entity) throws ServiceException
ServiceExceptionpublic static org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpUriRequest request,
boolean useSSL)
throws ServiceException
request - the requestuseSSL - whether to use SSL for the connectionServiceExceptionpublic static IMarshaller determineCommonMimeType(List<String> remoteSupportedMimeTypes) throws ServiceException
remoteSupportedMimeTypes - the mime-types supported by the remote serverIMarshaller or nullServiceExceptionCopyright © 2016. All rights reserved.