Package net.sf.jasperreports.data.http
Class HttpDataService
- java.lang.Object
-
- net.sf.jasperreports.data.http.HttpDataService
-
- All Implemented Interfaces:
DataFileService
public class HttpDataService extends java.lang.Object implements DataFileService
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SETstatic java.lang.StringEXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHODstatic java.lang.StringHTTP_DATA_SERVICE_NAMEstatic java.lang.StringPARAMETER_PASSWORDDeprecated.Replaced byPROPERTY_PASSWORD.static java.lang.StringPARAMETER_PREFIX_POST_PARAMETERDeprecated.Replaced byPROPERTY_POST_PARAMETER.static java.lang.StringPARAMETER_PREFIX_URL_PARAMETERDeprecated.Replaced byPROPERTY_URL_PARAMETER.static java.lang.StringPARAMETER_URLDeprecated.Replaced byPROPERTY_URL.static java.lang.StringPARAMETER_USERNAMEDeprecated.Replaced byPROPERTY_USERNAME.static java.lang.StringPROPERTY_BODYProperty that specifies the POST/PUT request body to be sent when HTTP data adapter is used.static java.lang.StringPROPERTY_HEADERProperty that specifies the name of the request header to be sent when HTTP data adapter is used.static java.lang.StringPROPERTY_METHODProperty that specifies the HTTP request method to be used by the HTTP data adapters.static java.lang.StringPROPERTY_PASSWORDProperty that specifies the password to be used by the HTTP data adapters with basic authentication.static java.lang.StringPROPERTY_POST_PARAMETERProperty that specifies the name of the request POST parameter to be sent when HTTP data adapter is used.static java.lang.StringPROPERTY_URLProperty that specifies the base URL to be used by the HTTP data adapters.static java.lang.StringPROPERTY_URL_PARAMETERProperty that specifies the name of the request parameter to be added to the URL when HTTP data adapter is used.static java.lang.StringPROPERTY_USERNAMEProperty that specifies the user name to be used by the HTTP data adapters with basic authentication.
-
Constructor Summary
Constructors Constructor Description HttpDataService(ParameterContributorContext context, HttpDataLocation dataLocation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<org.apache.http.NameValuePair>collectHeaders(java.util.Map<java.lang.String,java.lang.Object> reportParameters)protected java.util.List<org.apache.http.NameValuePair>collectParameters(java.util.List<HttpLocationParameter> dataAdapterParameters, java.util.Map<java.lang.String,java.lang.Object> parameterValues, java.lang.String propertyName, java.lang.String parameterPrefix)protected java.util.List<org.apache.http.NameValuePair>collectPostParameters(java.util.Map<java.lang.String,java.lang.Object> reportParameters)protected java.util.List<org.apache.http.NameValuePair>collectUrlParameters(java.util.Map<java.lang.String,java.lang.Object> reportParameters)protected org.apache.http.client.methods.HttpGetcreateGetRequest(java.net.URI requestURI)protected org.apache.http.impl.client.CloseableHttpClientcreateHttpClient(java.util.Map<java.lang.String,java.lang.Object> parameters)protected org.apache.http.client.methods.HttpPostcreatePostRequest(java.net.URI requestURI, java.lang.String body)protected org.apache.http.client.methods.HttpPostcreatePostRequest(java.net.URI requestURI, java.util.List<org.apache.http.NameValuePair> postParameters)protected org.apache.http.client.methods.HttpPutcreatePutRequest(java.net.URI requestURI, java.lang.String body)protected org.apache.http.client.methods.HttpPutcreatePutRequest(java.net.URI requestURI, java.util.List<org.apache.http.NameValuePair> postParameters)protected org.apache.http.client.methods.HttpRequestBasecreateRequest(java.util.Map<java.lang.String,java.lang.Object> parameters)protected org.apache.http.HttpEntitycreateRequestEntity(java.lang.String body)protected org.apache.http.HttpEntitycreateRequestEntity(java.util.List<org.apache.http.NameValuePair> postParameters)protected java.lang.StringgetBody(java.util.Map<java.lang.String,java.lang.Object> parameters)DataFileConnectiongetDataFileConnection(java.util.Map<java.lang.String,java.lang.Object> parameters)protected RequestMethodgetMethod(java.util.Map<java.lang.String,java.lang.Object> parameters)protected java.lang.StringgetPassword(java.util.Map<java.lang.String,java.lang.Object> parameters)protected java.lang.StringgetPropertyOrParameterValue(java.lang.String propName, java.lang.String paramName, java.util.Map<java.lang.String,java.lang.Object> parameterValues)protected java.net.URIgetRequestURI(java.util.Map<java.lang.String,java.lang.Object> parameters)protected java.lang.StringgetURL(java.util.Map<java.lang.String,java.lang.Object> parameters)protected java.lang.StringgetUsername(java.util.Map<java.lang.String,java.lang.Object> parameters)protected voidsetAuthentication(java.util.Map<java.lang.String,java.lang.Object> parameters, org.apache.http.impl.client.HttpClientBuilder clientBuilder)protected java.lang.StringtoHttpParameterValue(java.lang.Object value)
-
-
-
Field Detail
-
HTTP_DATA_SERVICE_NAME
public static final java.lang.String HTTP_DATA_SERVICE_NAME
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SET
public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SET
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHOD
public static final java.lang.String EXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHOD
- See Also:
- Constant Field Values
-
PARAMETER_URL
public static final java.lang.String PARAMETER_URL
Deprecated.Replaced byPROPERTY_URL.- See Also:
- Constant Field Values
-
PARAMETER_USERNAME
public static final java.lang.String PARAMETER_USERNAME
Deprecated.Replaced byPROPERTY_USERNAME.- See Also:
- Constant Field Values
-
PARAMETER_PASSWORD
public static final java.lang.String PARAMETER_PASSWORD
Deprecated.Replaced byPROPERTY_PASSWORD.- See Also:
- Constant Field Values
-
PARAMETER_PREFIX_URL_PARAMETER
public static final java.lang.String PARAMETER_PREFIX_URL_PARAMETER
Deprecated.Replaced byPROPERTY_URL_PARAMETER.- See Also:
- Constant Field Values
-
PARAMETER_PREFIX_POST_PARAMETER
public static final java.lang.String PARAMETER_PREFIX_POST_PARAMETER
Deprecated.Replaced byPROPERTY_POST_PARAMETER.- See Also:
- Constant Field Values
-
PROPERTY_METHOD
public static final java.lang.String PROPERTY_METHOD
Property that specifies the HTTP request method to be used by the HTTP data adapters. When used at parameter level, it does not need to provide a value, but is just used to mark the parameter that will provide the HTTP method.- See Also:
- Constant Field Values
-
PROPERTY_URL
public static final java.lang.String PROPERTY_URL
Property that specifies the base URL to be used by the HTTP data adapters. When used at parameter level, it does not need to provide a value, but is just used to mark the parameter that will provide the URL value.- See Also:
- Constant Field Values
-
PROPERTY_USERNAME
public static final java.lang.String PROPERTY_USERNAME
Property that specifies the user name to be used by the HTTP data adapters with basic authentication. When used at parameter level, it does not need to provide a value, but is just used to mark the parameter that will provide the user name value.- See Also:
- Constant Field Values
-
PROPERTY_PASSWORD
public static final java.lang.String PROPERTY_PASSWORD
Property that specifies the password to be used by the HTTP data adapters with basic authentication. When used at parameter level, it does not need to provide a value, but is just used to mark the parameter that will provide the user password value.- See Also:
- Constant Field Values
-
PROPERTY_URL_PARAMETER
public static final java.lang.String PROPERTY_URL_PARAMETER
Property that specifies the name of the request parameter to be added to the URL when HTTP data adapter is used. If the property is present, but has no value, the name of the request parameter is the same as the report parameter name.- See Also:
- Constant Field Values
-
PROPERTY_BODY
public static final java.lang.String PROPERTY_BODY
Property that specifies the POST/PUT request body to be sent when HTTP data adapter is used. When used at parameter level, it does not need to provide a value, but is just used to mark the parameter that will provide the POST/PUT request body value.- See Also:
- Constant Field Values
-
PROPERTY_POST_PARAMETER
public static final java.lang.String PROPERTY_POST_PARAMETER
Property that specifies the name of the request POST parameter to be sent when HTTP data adapter is used. If the property is present, but has no value, the name of the request parameter is the same as the report parameter name.- See Also:
- Constant Field Values
-
PROPERTY_HEADER
public static final java.lang.String PROPERTY_HEADER
Property that specifies the name of the request header to be sent when HTTP data adapter is used. If the property is present, but has no value, the name of the request header is the same as the report parameter name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpDataService
public HttpDataService(ParameterContributorContext context, HttpDataLocation dataLocation)
-
-
Method Detail
-
getDataFileConnection
public DataFileConnection getDataFileConnection(java.util.Map<java.lang.String,java.lang.Object> parameters) throws JRException
- Specified by:
getDataFileConnectionin interfaceDataFileService- Throws:
JRException
-
createHttpClient
protected org.apache.http.impl.client.CloseableHttpClient createHttpClient(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
setAuthentication
protected void setAuthentication(java.util.Map<java.lang.String,java.lang.Object> parameters, org.apache.http.impl.client.HttpClientBuilder clientBuilder)
-
getUsername
protected java.lang.String getUsername(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
getPassword
protected java.lang.String getPassword(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
createRequest
protected org.apache.http.client.methods.HttpRequestBase createRequest(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
createGetRequest
protected org.apache.http.client.methods.HttpGet createGetRequest(java.net.URI requestURI)
-
createPostRequest
protected org.apache.http.client.methods.HttpPost createPostRequest(java.net.URI requestURI, java.lang.String body)
-
createPostRequest
protected org.apache.http.client.methods.HttpPost createPostRequest(java.net.URI requestURI, java.util.List<org.apache.http.NameValuePair> postParameters)
-
createPutRequest
protected org.apache.http.client.methods.HttpPut createPutRequest(java.net.URI requestURI, java.lang.String body)
-
createPutRequest
protected org.apache.http.client.methods.HttpPut createPutRequest(java.net.URI requestURI, java.util.List<org.apache.http.NameValuePair> postParameters)
-
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(java.lang.String body)
-
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(java.util.List<org.apache.http.NameValuePair> postParameters)
-
collectUrlParameters
protected java.util.List<org.apache.http.NameValuePair> collectUrlParameters(java.util.Map<java.lang.String,java.lang.Object> reportParameters)
-
collectPostParameters
protected java.util.List<org.apache.http.NameValuePair> collectPostParameters(java.util.Map<java.lang.String,java.lang.Object> reportParameters)
-
collectHeaders
protected java.util.List<org.apache.http.NameValuePair> collectHeaders(java.util.Map<java.lang.String,java.lang.Object> reportParameters)
-
collectParameters
protected java.util.List<org.apache.http.NameValuePair> collectParameters(java.util.List<HttpLocationParameter> dataAdapterParameters, java.util.Map<java.lang.String,java.lang.Object> parameterValues, java.lang.String propertyName, java.lang.String parameterPrefix)
-
getRequestURI
protected java.net.URI getRequestURI(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
getURL
protected java.lang.String getURL(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
getMethod
protected RequestMethod getMethod(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
getBody
protected java.lang.String getBody(java.util.Map<java.lang.String,java.lang.Object> parameters)
-
getPropertyOrParameterValue
protected java.lang.String getPropertyOrParameterValue(java.lang.String propName, java.lang.String paramName, java.util.Map<java.lang.String,java.lang.Object> parameterValues)
-
toHttpParameterValue
protected java.lang.String toHttpParameterValue(java.lang.Object value)
-
-