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 entityNullPointerException - if the provided entity is nullXatkitException - if an error occurred when processing the provided entitypublic 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 entityNullPointerException - if the provided entity is nullcom.google.gson.JsonSyntaxException - if the provided entity does not contain a valid JSON elementXatkitException - if an error occurred when processing the provided entitypublic static org.apache.http.HttpEntity createHttpEntity(@Nonnull Object object)
HttpEntity from the provided object.object - the Object to translate to an HttpEntityHttpEntityNullPointerException - if the provided object is nullXatkitException - 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 HttpEntityHttpEntityNullPointerException - if the provided RestHandlerException is nullCopyright © 2020 SOM Research Lab. All rights reserved.