Package fr.paris.lutece.util.httpaccess
Class HttpAccess
- java.lang.Object
-
- fr.paris.lutece.util.httpaccess.HttpAccess
-
public class HttpAccess extends Object
Http net Object Accessor.
-
-
Constructor Summary
Constructors Constructor Description HttpAccess()Instantiates a new http access.HttpAccess(HttpAccessService accessService)Instantiates a new http access.HttpAccess(HttpAccessService accessService, ResponseStatusValidator validator)Instantiates a new http access.HttpAccess(ResponseStatusValidator validator)Instantiates a new http access.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdoDelete(String strUrl, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Send a DELETE HTTP request to an url and return the response content.StringdoDeleteJSON(String strUrl, String strJSON, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Send a DELETE HTTP request to an url and return the response content.StringdoGet(String strUrl)Send a GET HTTP request to an Url and return the response content.StringdoGet(String strUrl, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements)Send a GET HTTP request to an Url and return the response content.StringdoGet(String strUrl, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headers)Send a GET HTTP request to an Url and return the response content.StringdoGet(String strUrl, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Send a GET HTTP request to an Url and return the response content.StringdoPost(String strUrl, Map<String,String> params)Send a POST HTTP request to an url and return the response content.StringdoPost(String strUrl, Map<String,String> params, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements)Send a POST HTTP request to an url and return the response content.StringdoPost(String strUrl, Map<String,String> params, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest)Send a POST HTTP request to an url and return the response content.StringdoPost(String strUrl, Map<String,String> params, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Send a POST HTTP request to an url and return the response content.StringdoPostJSON(String strUrl, String strJSON, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Do post json.StringdoPostJSON(String strUrl, String strJSON, Map<String,String> headersRequest, Map<String,String> headersResponse)Do post json.StringdoPostMultiPart(String strUrl, Map<String,List<String>> params, Map<String,org.apache.commons.fileupload.FileItem> fileItems)Send a POST HTTP request to an url and return the response content.StringdoPostMultiPart(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)Send a POST HTTP request to an url and return the response content.StringdoPostMultiPart(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)Send a POST HTTP request to an url and return the response content.StringdoPostMultiPart(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)Send a POST HTTP request to an url and return the response content.StringdoPostMultiValues(String strUrl, Map<String,List<String>> params)Send a POST HTTP request to an url and return the response content.StringdoPostMultiValues(String strUrl, Map<String,List<String>> params, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements)Send a POST HTTP request to an url and return the response content.StringdoPostMultiValues(String strUrl, Map<String,List<String>> params, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest)Send a POST HTTP request to an url and return the response content.StringdoPostMultiValues(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)Send a POST HTTP request to an url and return the response content.StringdoPut(String strUrl, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> params, Map<String,String> headersRequest, Map<String,String> headersResponse)Send a PUT HTTP request to an url and return the response content.StringdoPutJSON(String strUrl, String strJSON, fr.paris.lutece.util.signrequest.RequestAuthenticator authenticator, List<String> listElements, Map<String,String> headersRequest, Map<String,String> headersResponse)Do put json.StringdoPutJSON(String strUrl, String strJSON, Map<String,String> headersRequest, Map<String,String> headersResponse)Do put json.StringdoRequestEnclosingMethod(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)Do request enclosing method.org.apache.commons.fileupload.FileItemdownloadFile(String strUrl)Send a GET HTTP request to an Url and return the response content.voiddownloadFile(String strUrl, OutputStream outputStream)Send a GET HTTP request to an Url and return the response content in the ouput stream.voiddownloadFile(String strUrl, String strFilePath)Send a GET HTTP request to an Url and return the response content.StringgetFileName(String strUrl)Send a GET HTTP request to an Url and return the response content.
-
-
-
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 servicevalidator- 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 accessauthenticator- TheRequestAuthenticatorlistElements- 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 accessauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheaders- 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 accessauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 accessparams- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 urlstrMethod- the str methodstrContent- the str contentcontentType- the content typecharset- the charsetauthenticator- the authenticatorlistElements- the list elementsheadersRequest- the headers requestheadersResponse- 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 urlstrJSON- the str jsonauthenticator- the authenticatorlistElements- the list elementsheadersRequest- the headers requestheadersResponse- the headers response- Returns:
- the string
- Throws:
HttpAccessException- the http access exception
-
doPostJSON
public String doPostJSON(String strUrl, String strJSON, Map<String,String> headersRequest, Map<String,String> headersResponse) throws HttpAccessException
Do post json.- Parameters:
strUrl- the str urlstrJSON- the str jsonheadersRequest- the headers requestheadersResponse- 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 urlstrJSON- the str jsonauthenticator- the authenticatorlistElements- the list elementsheadersRequest- the headers requestheadersResponse- the headers response- Returns:
- the string
- Throws:
HttpAccessException- the http access exception
-
doPutJSON
public String doPutJSON(String strUrl, String strJSON, Map<String,String> headersRequest, Map<String,String> headersResponse) throws HttpAccessException
Do put json.- Parameters:
strUrl- the str urlstrJSON- the str jsonheadersRequest- the headers requestheadersResponse- 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 accessparams- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- 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 accessparams- the list of parameters to postauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 accessparams- the list of parameters to postfileItems- 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 accessparams- the list of parameters to postfileItems- The list of file itemsauthenticator- TheRequestAuthenticatorlistElements- 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 accessparams- the list of parameters to postfileItems- The list of file itemsauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- 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 accessparams- the list of parameters to postfileItems- The list of file itemsauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 accessauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureparams- the paramsheadersRequest- Map of headers request parametersheadersResponse- 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 accessauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 accessstrJson- the json to send in bodyauthenticator- TheRequestAuthenticatorlistElements- to include in the signatureheadersRequest- Map of headers request parametersheadersResponse- 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 accessstrFilePath- 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 accessoutputStream- 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
-
-