Search in sources :

Example 1 with SerializationException

use of de.cinovo.cloudconductor.api.lib.exceptions.SerializationException in project cloudconductor-agent-redhat by cinovo.

the class AbstractApiHandler method request.

protected final HTTPRequest request(String path, Object obj, JavaType type) throws SerializationException {
    try {
        ObjectWriter bodyWriter = AbstractApiHandler.mapper.writer();
        if ((type != null) && ((obj instanceof Set) || (obj instanceof List))) {
            bodyWriter = bodyWriter.forType(type);
        }
        String body = bodyWriter.writeValueAsString(obj);
        return this.request(path).body(body).header("Content-Type", MediaType.APPLICATION_JSON);
    } catch (IOException e) {
        throw new SerializationException();
    }
}
Also used : Set(java.util.Set) SerializationException(de.cinovo.cloudconductor.api.lib.exceptions.SerializationException) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) List(java.util.List) IOException(java.io.IOException)

Aggregations

ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 SerializationException (de.cinovo.cloudconductor.api.lib.exceptions.SerializationException)1 IOException (java.io.IOException)1 List (java.util.List)1 Set (java.util.Set)1