Package utility

Class UtilRest


  • public class UtilRest
    extends Object
    Utility Class for Rest related static helper methods.
    Version:
    1.0
    Author:
    Frank Giordano
    • Constructor Detail

      • UtilRest

        public UtilRest()
    • 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