Class HttpDataService
- java.lang.Object
-
- net.sf.jasperreports.dataadapters.http.HttpDataService
-
- All Implemented Interfaces:
DataFileService
public class HttpDataService extends Object implements DataFileService
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SET
static String
EXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHOD
static String
HTTP_DATA_SERVICE_NAME
static String
PARAMETER_PASSWORD
Deprecated.Replaced byPROPERTY_PASSWORD
.static String
PARAMETER_PREFIX_POST_PARAMETER
Deprecated.Replaced byPROPERTY_POST_PARAMETER
.static String
PARAMETER_PREFIX_URL_PARAMETER
Deprecated.Replaced byPROPERTY_URL_PARAMETER
.static String
PARAMETER_URL
Deprecated.Replaced byPROPERTY_URL
.static String
PARAMETER_USERNAME
Deprecated.Replaced byPROPERTY_USERNAME
.static String
PROPERTY_BODY
Property that specifies the POST/PUT request body to be sent when HTTP data adapter is used.static String
PROPERTY_HEADER
Property that specifies the name of the request header to be sent when HTTP data adapter is used.static String
PROPERTY_METHOD
Property that specifies the HTTP request method to be used by the HTTP data adapters.static String
PROPERTY_PASSWORD
Property that specifies the password to be used by the HTTP data adapters with basic authentication.static String
PROPERTY_POST_PARAMETER
Property that specifies the name of the request POST parameter to be sent when HTTP data adapter is used.static String
PROPERTY_URL
Property that specifies the base URL to be used by the HTTP data adapters.static 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.static String
PROPERTY_USERNAME
Property 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 List<org.apache.http.NameValuePair>
collectHeaders(Map<String,Object> reportParameters)
protected List<org.apache.http.NameValuePair>
collectParameters(List<HttpLocationParameter> dataAdapterParameters, Map<String,Object> parameterValues, String propertyName, String parameterPrefix)
protected List<org.apache.http.NameValuePair>
collectPostParameters(Map<String,Object> reportParameters)
protected List<org.apache.http.NameValuePair>
collectUrlParameters(Map<String,Object> reportParameters)
protected org.apache.http.client.methods.HttpGet
createGetRequest(URI requestURI)
protected org.apache.http.impl.client.CloseableHttpClient
createHttpClient(Map<String,Object> parameters)
protected org.apache.http.client.methods.HttpPost
createPostRequest(URI requestURI, String body)
protected org.apache.http.client.methods.HttpPost
createPostRequest(URI requestURI, List<org.apache.http.NameValuePair> postParameters)
protected org.apache.http.client.methods.HttpPut
createPutRequest(URI requestURI, String body)
protected org.apache.http.client.methods.HttpPut
createPutRequest(URI requestURI, List<org.apache.http.NameValuePair> postParameters)
protected org.apache.http.client.methods.HttpRequestBase
createRequest(Map<String,Object> parameters)
protected org.apache.http.HttpEntity
createRequestEntity(String body)
protected org.apache.http.HttpEntity
createRequestEntity(List<org.apache.http.NameValuePair> postParameters)
protected String
getBody(Map<String,Object> parameters)
DataFileConnection
getDataFileConnection(Map<String,Object> parameters)
protected RequestMethod
getMethod(Map<String,Object> parameters)
protected String
getPassword(Map<String,Object> parameters)
protected String
getPropertyOrParameterValue(String propName, String paramName, Map<String,Object> parameterValues)
protected URI
getRequestURI(Map<String,Object> parameters)
protected String
getURL(Map<String,Object> parameters)
protected String
getUsername(Map<String,Object> parameters)
protected void
setAuthentication(Map<String,Object> parameters, org.apache.http.impl.client.HttpClientBuilder clientBuilder)
protected String
toHttpParameterValue(Object value)
-
-
-
Field Detail
-
HTTP_DATA_SERVICE_NAME
public static final String HTTP_DATA_SERVICE_NAME
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SET
public static final String EXCEPTION_MESSAGE_KEY_NO_HTTP_URL_SET
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHOD
public static final String EXCEPTION_MESSAGE_KEY_UNKNOWN_REQUEST_METHOD
- See Also:
- Constant Field Values
-
PARAMETER_URL
public static final String PARAMETER_URL
Deprecated.Replaced byPROPERTY_URL
.- See Also:
- Constant Field Values
-
PARAMETER_USERNAME
public static final String PARAMETER_USERNAME
Deprecated.Replaced byPROPERTY_USERNAME
.- See Also:
- Constant Field Values
-
PARAMETER_PASSWORD
public static final String PARAMETER_PASSWORD
Deprecated.Replaced byPROPERTY_PASSWORD
.- See Also:
- Constant Field Values
-
PARAMETER_PREFIX_URL_PARAMETER
public static final String PARAMETER_PREFIX_URL_PARAMETER
Deprecated.Replaced byPROPERTY_URL_PARAMETER
.- See Also:
- Constant Field Values
-
PARAMETER_PREFIX_POST_PARAMETER
public static final String PARAMETER_PREFIX_POST_PARAMETER
Deprecated.Replaced byPROPERTY_POST_PARAMETER
.- See Also:
- Constant Field Values
-
PROPERTY_METHOD
public static final 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 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 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 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 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 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 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 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(Map<String,Object> parameters) throws JRException
- Specified by:
getDataFileConnection
in interfaceDataFileService
- Throws:
JRException
-
createHttpClient
protected org.apache.http.impl.client.CloseableHttpClient createHttpClient(Map<String,Object> parameters)
-
setAuthentication
protected void setAuthentication(Map<String,Object> parameters, org.apache.http.impl.client.HttpClientBuilder clientBuilder)
-
createRequest
protected org.apache.http.client.methods.HttpRequestBase createRequest(Map<String,Object> parameters)
-
createGetRequest
protected org.apache.http.client.methods.HttpGet createGetRequest(URI requestURI)
-
createPostRequest
protected org.apache.http.client.methods.HttpPost createPostRequest(URI requestURI, String body)
-
createPostRequest
protected org.apache.http.client.methods.HttpPost createPostRequest(URI requestURI, List<org.apache.http.NameValuePair> postParameters)
-
createPutRequest
protected org.apache.http.client.methods.HttpPut createPutRequest(URI requestURI, String body)
-
createPutRequest
protected org.apache.http.client.methods.HttpPut createPutRequest(URI requestURI, List<org.apache.http.NameValuePair> postParameters)
-
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(String body)
-
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(List<org.apache.http.NameValuePair> postParameters)
-
collectUrlParameters
protected List<org.apache.http.NameValuePair> collectUrlParameters(Map<String,Object> reportParameters)
-
collectPostParameters
protected List<org.apache.http.NameValuePair> collectPostParameters(Map<String,Object> reportParameters)
-
collectHeaders
protected List<org.apache.http.NameValuePair> collectHeaders(Map<String,Object> reportParameters)
-
collectParameters
protected List<org.apache.http.NameValuePair> collectParameters(List<HttpLocationParameter> dataAdapterParameters, Map<String,Object> parameterValues, String propertyName, String parameterPrefix)
-
getMethod
protected RequestMethod getMethod(Map<String,Object> parameters)
-
getPropertyOrParameterValue
protected String getPropertyOrParameterValue(String propName, String paramName, Map<String,Object> parameterValues)
-
-