Class RestApiUtil


  • public class RestApiUtil
    extends java.lang.Object
    Utility methods for calling external APIs in a standardized way.
    Since:
    0.8.0
    • Constructor Detail

      • RestApiUtil

        public RestApiUtil()
    • Method Detail

      • callApi

        public static ServiceResponse callApi​(java.lang.String url,
                                              java.lang.String path,
                                              java.lang.String username,
                                              java.lang.String password)
                                       throws java.net.URISyntaxException,
                                              java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callApi

        public static ServiceResponse callApi​(java.lang.String url,
                                              java.lang.String path,
                                              java.lang.String username,
                                              java.lang.String password,
                                              RestApiUtil.RestOptions opts)
                                       throws java.net.URISyntaxException,
                                              java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callApi

        public static ServiceResponse callApi​(java.lang.String url,
                                              java.lang.String path,
                                              java.lang.String username,
                                              java.lang.String password,
                                              RestApiUtil.RestOptions opts,
                                              java.lang.String method)
                                       throws java.net.URISyntaxException,
                                              java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callJsonApi

        public static ServiceResponse callJsonApi​(java.lang.String url,
                                                  java.lang.String path)
                                           throws java.net.URISyntaxException,
                                                  java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callJsonApi

        public static ServiceResponse callJsonApi​(java.lang.String url,
                                                  java.lang.String path,
                                                  RestApiUtil.RestOptions opts)
                                           throws java.net.URISyntaxException,
                                                  java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callJsonApi

        public static ServiceResponse callJsonApi​(java.lang.String url,
                                                  java.lang.String path,
                                                  RestApiUtil.RestOptions opts,
                                                  java.lang.String method)
                                           throws java.net.URISyntaxException,
                                                  java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callJsonApi

        public static ServiceResponse callJsonApi​(java.lang.String url,
                                                  java.lang.String path,
                                                  java.lang.String username,
                                                  java.lang.String password,
                                                  RestApiUtil.RestOptions opts)
                                           throws java.net.URISyntaxException,
                                                  java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callJsonApi

        public static ServiceResponse callJsonApi​(java.lang.String url,
                                                  java.lang.String path,
                                                  java.lang.String username,
                                                  java.lang.String password,
                                                  RestApiUtil.RestOptions opts,
                                                  java.lang.String method)
                                           throws java.net.URISyntaxException,
                                                  java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callXmlApi

        public static ServiceResponse callXmlApi​(java.lang.String url,
                                                 java.lang.String path,
                                                 RestApiUtil.RestOptions opts)
                                          throws java.net.URISyntaxException,
                                                 java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • callXmlApi

        public static ServiceResponse callXmlApi​(java.lang.String url,
                                                 java.lang.String path,
                                                 java.lang.String username,
                                                 java.lang.String password,
                                                 RestApiUtil.RestOptions opts,
                                                 java.lang.String method)
                                          throws java.net.URISyntaxException,
                                                 java.lang.Exception
        Throws:
        java.net.URISyntaxException
        java.lang.Exception
      • addRequiredHeader

        public static java.util.Map<java.lang.String,​java.lang.String> addRequiredHeader​(java.util.Map<java.lang.String,​java.lang.String> headers,
                                                                                               java.lang.String name,
                                                                                               java.lang.String value)
      • shutdownClient

        public static void shutdownClient​(org.apache.http.client.HttpClient httpClient)
        Wrapper method for shutting down an HttpClient connection Manager This is typically used when using a Keep-Alive connection manager
        Parameters:
        httpClient - the HttpClient we wish to permanently shutdown.
      • shutdownClient

        public static void shutdownClient​(org.apache.http.conn.HttpClientConnectionManager connectionManager)