public class HttpEntityHelper extends Object
HttpEntity
instances.Constructor and Description |
---|
HttpEntityHelper() |
Modifier and Type | Method and Description |
---|---|
static org.apache.http.HttpEntity |
createErrorEntity(RestHandlerException e)
Creates an
HttpEntity representing the error wrapped in the provided RestHandlerException . |
static org.apache.http.HttpEntity |
createHttpEntity(Object object)
Creates an
HttpEntity from the provided object . |
static com.google.gson.JsonElement |
getJsonElementFromHttpEntity(org.apache.http.HttpEntity entity)
Returns a
JsonElement extracted from the content of the provided entity . |
static String |
getStringFromHttpEntity(org.apache.http.HttpEntity entity)
Returns the
String representation of the content of the provided entity . |
public static String getStringFromHttpEntity(@Nonnull org.apache.http.HttpEntity entity)
String
representation of the content of the provided entity
.entity
- the HttpEntity
to return a String
fromString
extracted from the content of the provided entity
NullPointerException
- if the provided entity
is null
XatkitException
- if an error occurred when processing the provided entity
public static com.google.gson.JsonElement getJsonElementFromHttpEntity(@Nonnull org.apache.http.HttpEntity entity)
JsonElement
extracted from the content of the provided entity
.entity
- the HttpEntity
to return a JsonElement
fromJsonElement
extracted from the content of the provided entity
NullPointerException
- if the provided entity
is null
com.google.gson.JsonSyntaxException
- if the provided entity
does not contain a valid JSON elementXatkitException
- if an error occurred when processing the provided entity
public static org.apache.http.HttpEntity createHttpEntity(@Nonnull Object object)
HttpEntity
from the provided object
.object
- the Object
to translate to an HttpEntity
HttpEntity
NullPointerException
- if the provided object
is null
XatkitException
- if the provided object
's type is not supportedpublic static org.apache.http.HttpEntity createErrorEntity(@Nonnull RestHandlerException e)
HttpEntity
representing the error wrapped in the provided RestHandlerException
.
The created HttpEntity
contains a Json element with the following content:
{
"error" : <e.getMessage()>
}
e
- the RestHandlerException
to transform into an error HttpEntity
HttpEntity
NullPointerException
- if the provided RestHandlerException
is null
Copyright © 2020 SOM Research Lab. All rights reserved.