Class RestUtils


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

      • checkHttpErrors

        public static void checkHttpErrors​(Response response)
                                    throws Exception
        Return specialized http error message
        Parameters:
        response - Response object
        Throws:
        Exception - containing specialized http error message
      • getJsonResponseEntity

        public static Object getJsonResponseEntity​(org.apache.http.HttpResponse httpResponse)
                                            throws Exception
        Retrieve response JSON entity content from httpResponse object
        Parameters:
        httpResponse - HttpResponse object
        Returns:
        response Json entity content
        Throws:
        Exception - due to extracting entity or parsing entity problem
      • getTextResponseEntity

        public static Object getTextResponseEntity​(org.apache.http.HttpResponse httpResponse)
                                            throws Exception
        Retrieve response text entity content from httpResponse object
        Parameters:
        httpResponse - HttpResponse object
        Returns:
        response text entity content
        Throws:
        Exception - due to extracting entity or parsing entity problem
      • isHttpError

        public static boolean isHttpError​(int statusCode)
        Checks if statusCode is a valid http code or not
        Parameters:
        statusCode - http code value
        Returns:
        boolean value
      • isUrlNotValid

        public static boolean isUrlNotValid​(String url)
        Checks if url is a valid http or https url.
        Parameters:
        url - value
        Returns:
        boolean value