Package utility
Class UtilRest
- java.lang.Object
-
- utility.UtilRest
-
public class UtilRest extends Object
Utility Class for Rest related static helper methods.- Version:
- 1.0
- Author:
- Frank Giordano
-
-
Constructor Summary
Constructors Constructor Description UtilRest()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkHttpErrors(Response response)
Return specialized http error message if anystatic Optional<Object>
getJsonResponseEntity(org.apache.http.HttpResponse httpResponse)
Retrieve response JSON entity content from httpResponse objectstatic Optional<Object>
getTextResponseEntity(org.apache.http.HttpResponse httpResponse)
Retrieve response text entity content from httpResponse objectstatic boolean
isHttpError(int statusCode)
Checks if statusCode is a valid http code or not
-
-
-
Method Detail
-
getJsonResponseEntity
public static Optional<Object> getJsonResponseEntity(org.apache.http.HttpResponse httpResponse) throws Exception
Retrieve response JSON entity content from httpResponse object- Parameters:
httpResponse
- HttpResponse object- Returns:
- The response Json entity content
- Throws:
Exception
- due to extracting entity or parsing entity problem
-
getTextResponseEntity
public static Optional<Object> getTextResponseEntity(org.apache.http.HttpResponse httpResponse) throws Exception
Retrieve response text entity content from httpResponse object- Parameters:
httpResponse
- HttpResponse object- Returns:
- The response text entity content
- Throws:
Exception
- due to extracting entity or parsing entity problem
-
checkHttpErrors
public static void checkHttpErrors(Response response) throws Exception
Return specialized http error message if any- Parameters:
response
- Response object- Throws:
Exception
- containing specialized http error message
-
isHttpError
public static boolean isHttpError(int statusCode)
Checks if statusCode is a valid http code or not- Parameters:
statusCode
- The http code value- Returns:
- A boolean value
-
-