Class HttpAccess


  • public class HttpAccess
    extends Object
    Http net Object Accessor.
    • Constructor Detail

      • HttpAccess

        public HttpAccess()
        Instantiates a new http access.
      • HttpAccess

        public HttpAccess​(ResponseStatusValidator validator)
        Instantiates a new http access.
        Parameters:
        validator - the validator
      • HttpAccess

        public HttpAccess​(HttpAccessService accessService,
                          ResponseStatusValidator validator)
        Instantiates a new http access.
        Parameters:
        accessService - the access service
        validator - the validator
      • HttpAccess

        public HttpAccess​(HttpAccessService accessService)
        Instantiates a new http access.
        Parameters:
        accessService - the access service
    • Method Detail

      • doGet

        public String doGet​(String strUrl)
                     throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        Returns:
        The response content of the Get request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doGet

        public String doGet​(String strUrl,
                            fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                            List<String> listElements)
                     throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        Returns:
        The response content of the Get request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doGet

        public String doGet​(String strUrl,
                            fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                            List<String> listElements,
                            Map<String,​String> headers)
                     throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headers - the headers
        Returns:
        The response content of the Get request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doGet

        public String doGet​(String strUrl,
                            fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                            List<String> listElements,
                            Map<String,​String> headersRequest,
                            Map<String,​String> headersResponse)
                     throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Get request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPost

        public String doPost​(String strUrl,
                             Map<String,​String> params)
                      throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPost

        public String doPost​(String strUrl,
                             Map<String,​String> params,
                             fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                             List<String> listElements)
                      throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPost

        public String doPost​(String strUrl,
                             Map<String,​String> params,
                             fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                             List<String> listElements,
                             Map<String,​String> headersRequest)
                      throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPost

        public String doPost​(String strUrl,
                             Map<String,​String> params,
                             fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                             List<String> listElements,
                             Map<String,​String> headersRequest,
                             Map<String,​String> headersResponse)
                      throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doRequestEnclosingMethod

        public String doRequestEnclosingMethod​(String strUrl,
                                               String strMethod,
                                               String strContent,
                                               String contentType,
                                               String charset,
                                               fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                               List<String> listElements,
                                               Map<String,​String> headersRequest,
                                               Map<String,​String> headersResponse)
                                        throws HttpAccessException
        Do request enclosing method.
        Parameters:
        strUrl - the str url
        strMethod - the str method
        strContent - the str content
        contentType - the content type
        charset - the charset
        authenticator - the authenticator
        listElements - the list elements
        headersRequest - the headers request
        headersResponse - the headers response
        Returns:
        the string
        Throws:
        HttpAccessException - the http access exception
      • doPostJSON

        public String doPostJSON​(String strUrl,
                                 String strJSON,
                                 fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                 List<String> listElements,
                                 Map<String,​String> headersRequest,
                                 Map<String,​String> headersResponse)
                          throws HttpAccessException
        Do post json.
        Parameters:
        strUrl - the str url
        strJSON - the str json
        authenticator - the authenticator
        listElements - the list elements
        headersRequest - the headers request
        headersResponse - the headers response
        Returns:
        the string
        Throws:
        HttpAccessException - the http access exception
      • doPutJSON

        public String doPutJSON​(String strUrl,
                                String strJSON,
                                fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                List<String> listElements,
                                Map<String,​String> headersRequest,
                                Map<String,​String> headersResponse)
                         throws HttpAccessException
        Do put json.
        Parameters:
        strUrl - the str url
        strJSON - the str json
        authenticator - the authenticator
        listElements - the list elements
        headersRequest - the headers request
        headersResponse - the headers response
        Returns:
        the string
        Throws:
        HttpAccessException - the http access exception
      • doPostMultiValues

        public String doPostMultiValues​(String strUrl,
                                        Map<String,​List<String>> params)
                                 throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiValues

        public String doPostMultiValues​(String strUrl,
                                        Map<String,​List<String>> params,
                                        fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                        List<String> listElements)
                                 throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiValues

        public String doPostMultiValues​(String strUrl,
                                        Map<String,​List<String>> params,
                                        fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                        List<String> listElements,
                                        Map<String,​String> headersRequest)
                                 throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiValues

        public String doPostMultiValues​(String strUrl,
                                        Map<String,​List<String>> params,
                                        fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                        List<String> listElements,
                                        Map<String,​String> headersRequest,
                                        Map<String,​String> headersResponse)
                                 throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiPart

        public String doPostMultiPart​(String strUrl,
                                      Map<String,​List<String>> params,
                                      Map<String,​org.apache.commons.fileupload.FileItem> fileItems)
                               throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        fileItems - The list of file items
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiPart

        public String doPostMultiPart​(String strUrl,
                                      Map<String,​List<String>> params,
                                      Map<String,​org.apache.commons.fileupload.FileItem> fileItems,
                                      fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                      List<String> listElements)
                               throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        fileItems - The list of file items
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiPart

        public String doPostMultiPart​(String strUrl,
                                      Map<String,​List<String>> params,
                                      Map<String,​org.apache.commons.fileupload.FileItem> fileItems,
                                      fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                      List<String> listElements,
                                      Map<String,​String> headersRequest)
                               throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        fileItems - The list of file items
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPostMultiPart

        public String doPostMultiPart​(String strUrl,
                                      Map<String,​List<String>> params,
                                      Map<String,​org.apache.commons.fileupload.FileItem> fileItems,
                                      fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                      List<String> listElements,
                                      Map<String,​String> headersRequest,
                                      Map<String,​String> headersResponse)
                               throws HttpAccessException
        Send a POST HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        params - the list of parameters to post
        fileItems - The list of file items
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doPut

        public String doPut​(String strUrl,
                            fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                            List<String> listElements,
                            Map<String,​String> params,
                            Map<String,​String> headersRequest,
                            Map<String,​String> headersResponse)
                     throws HttpAccessException
        Send a PUT HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        params - the params
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doDelete

        public String doDelete​(String strUrl,
                               fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                               List<String> listElements,
                               Map<String,​String> headersRequest,
                               Map<String,​String> headersResponse)
                        throws HttpAccessException
        Send a DELETE HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • doDeleteJSON

        public String doDeleteJSON​(String strUrl,
                                   String strJSON,
                                   fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator,
                                   List<String> listElements,
                                   Map<String,​String> headersRequest,
                                   Map<String,​String> headersResponse)
                            throws HttpAccessException
        Send a DELETE HTTP request to an url and return the response content.
        Parameters:
        strUrl - the url to access
        strJson - the json to send in body
        authenticator - The RequestAuthenticator
        listElements - to include in the signature
        headersRequest - Map of headers request parameters
        headersResponse - Map to contain response headers
        Returns:
        The response content of the Post request to the given Url
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • downloadFile

        public void downloadFile​(String strUrl,
                                 String strFilePath)
                          throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        strFilePath - the file path
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • downloadFile

        public void downloadFile​(String strUrl,
                                 OutputStream outputStream)
                          throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content in the ouput stream.
        Parameters:
        strUrl - The Url to access
        outputStream - write in the outpustrean the contents of the file
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • getFileName

        public String getFileName​(String strUrl)
                           throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        Returns:
        the file name
        Throws:
        HttpAccessException - if there is a problem to access to the given Url
      • downloadFile

        public org.apache.commons.fileupload.FileItem downloadFile​(String strUrl)
                                                            throws HttpAccessException
        Send a GET HTTP request to an Url and return the response content.
        Parameters:
        strUrl - The Url to access
        Returns:
        a FileItem
        Throws:
        HttpAccessException - if there is a problem to access to the given Url