public class HTTPClient extends Object
BackgroundTupleResult
and BackgroundGraphResult
. For boolean
queries the result is parsed in the current thread. All methods in this class
guarantee that HTTP connections are closed properly and returned to the
connection pool. Functionality specific to the Sesame HTTP protocol can be
found in SesameHTTPClient
(which is used by Remote Repositories).SesameHTTPClient
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.httpclient.HttpClient |
httpClient |
Constructor and Description |
---|
HTTPClient() |
Modifier and Type | Method and Description |
---|---|
protected void |
execute(Runnable command) |
Map<String,String> |
getAdditionalHttpHeaders() |
protected BackgroundTupleResult |
getBackgroundTupleQueryResult(org.apache.commons.httpclient.HttpMethod method)
Parse the response in a background thread.
|
protected boolean |
getBoolean(org.apache.commons.httpclient.HttpMethodBase method)
Parse the response in this thread using a suitable
BooleanQueryResultParser . |
long |
getConnectionTimeout()
Gets the http connection read timeout in milliseconds.
|
protected ErrorInfo |
getErrorInfo(org.apache.commons.httpclient.HttpMethod method) |
protected org.apache.commons.httpclient.HttpClient |
getHttpClient() |
ParserConfig |
getParserConfig() |
BooleanQueryResultFormat |
getPreferredBooleanQueryResultFormat()
Gets the preferred
BooleanQueryResultFormat for encoding boolean
query results. |
RDFFormat |
getPreferredRDFFormat()
Gets the preferred
RDFFormat for encoding RDF documents. |
TupleQueryResultFormat |
getPreferredTupleQueryResultFormat()
Gets the preferred
TupleQueryResultFormat for encoding tuple query
results. |
protected org.apache.commons.httpclient.HttpMethodBase |
getQueryMethod(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
Binding... bindings) |
protected List<org.apache.commons.httpclient.NameValuePair> |
getQueryMethodParameters(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
Binding... bindings) |
String |
getQueryURL() |
protected void |
getRDF(org.apache.commons.httpclient.HttpMethod method,
RDFHandler handler,
boolean requireContext)
Parse the response in this thread using the provided
RDFHandler . |
protected BackgroundGraphResult |
getRDFBackground(org.apache.commons.httpclient.HttpMethodBase method,
boolean requireContext)
Parse the response in a background thread.
|
protected String |
getResponseMIMEType(org.apache.commons.httpclient.HttpMethod method)
Gets the MIME type specified in the response headers of the supplied
method, if any.
|
protected void |
getTupleQueryResult(org.apache.commons.httpclient.HttpMethod method,
TupleQueryResultHandler handler)
Parse the response in this thread using the provided
TupleQueryResultHandler . |
protected org.apache.commons.httpclient.HttpMethod |
getUpdateMethod(QueryLanguage ql,
String update,
String baseURI,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
protected List<org.apache.commons.httpclient.NameValuePair> |
getUpdateMethodParameters(QueryLanguage ql,
String update,
String baseURI,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
String |
getUpdateURL() |
ValueFactory |
getValueFactory() |
void |
initialize()
(re)initializes the connection manager and HttpClient (if not already
done), for example after a shutdown has been invoked earlier.
|
protected boolean |
is2xx(int statusCode)
Checks whether the specified status code is in the 2xx-range, indicating a
successfull request.
|
protected void |
releaseConnection(org.apache.commons.httpclient.HttpMethod method) |
boolean |
sendBooleanQuery(QueryLanguage ql,
String query,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
boolean |
sendBooleanQuery(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
Binding... bindings) |
GraphQueryResult |
sendGraphQuery(QueryLanguage ql,
String query,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
void |
sendGraphQuery(QueryLanguage ql,
String query,
Dataset dataset,
boolean includeInferred,
RDFHandler handler,
Binding... bindings) |
GraphQueryResult |
sendGraphQuery(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
Binding... bindings) |
void |
sendGraphQuery(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
RDFHandler handler,
Binding... bindings) |
TupleQueryResult |
sendTupleQuery(QueryLanguage ql,
String query,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
TupleQueryResult |
sendTupleQuery(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
Binding... bindings) |
void |
sendTupleQuery(QueryLanguage ql,
String query,
String baseURI,
Dataset dataset,
boolean includeInferred,
int maxQueryTime,
TupleQueryResultHandler handler,
Binding... bindings) |
void |
sendUpdate(QueryLanguage ql,
String update,
String baseURI,
Dataset dataset,
boolean includeInferred,
Binding... bindings) |
void |
setAdditionalHttpHeaders(Map<String,String> additionalHttpHeaders) |
void |
setConnectionTimeout(long timeout)
Sets the http connection read timeout.
|
protected void |
setDoAuthentication(org.apache.commons.httpclient.HttpMethod method) |
void |
setParserConfig(ParserConfig parserConfig)
Sets the parser configuration used to process HTTP response data.
|
void |
setPreferredBooleanQueryResultFormat(BooleanQueryResultFormat format)
Sets the preferred format for encoding boolean query results.
|
void |
setPreferredRDFFormat(RDFFormat format)
Sets the preferred format for encoding RDF documents.
|
void |
setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
Sets the preferred format for encoding tuple query results.
|
void |
setQueryURL(String queryURL) |
void |
setUpdateURL(String updateURL) |
void |
setUsernameAndPassword(String username,
String password)
Set the username and password for authentication with the remote server.
|
protected void |
setUsernameAndPasswordForUrl(String username,
String password,
String url) |
void |
setValueFactory(ValueFactory valueFactory) |
void |
shutDown() |
public void shutDown()
public void initialize()
protected final org.apache.commons.httpclient.HttpClient getHttpClient()
public void setValueFactory(ValueFactory valueFactory)
public ValueFactory getValueFactory()
public void setQueryURL(String queryURL)
public void setUpdateURL(String updateURL)
public void setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
binary
format is preferred by
default.format
- The preferred TupleQueryResultFormat
, or null to
indicate no specific format is preferred.public TupleQueryResultFormat getPreferredTupleQueryResultFormat()
TupleQueryResultFormat
for encoding tuple query
results.public void setPreferredRDFFormat(RDFFormat format)
Turtle
format is preferred by default.format
- The preferred RDFFormat
, or null to indicate no
specific format is preferred.public RDFFormat getPreferredRDFFormat()
RDFFormat
for encoding RDF documents.public void setPreferredBooleanQueryResultFormat(BooleanQueryResultFormat format)
binary
format is preferred by
default.format
- The preferred BooleanQueryResultFormat
, or null to
indicate no specific format is preferred.public BooleanQueryResultFormat getPreferredBooleanQueryResultFormat()
BooleanQueryResultFormat
for encoding boolean
query results.public void setUsernameAndPassword(String username, String password)
username
- the usernamepassword
- the passwordprotected void setUsernameAndPasswordForUrl(String username, String password, String url)
public void setAdditionalHttpHeaders(Map<String,String> additionalHttpHeaders)
additionalHttpHeaders
- The additionalHttpHeaders to set as key value pairs.public Map<String,String> getAdditionalHttpHeaders()
protected void execute(Runnable command)
public String getQueryURL()
public String getUpdateURL()
public TupleQueryResult sendTupleQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public TupleQueryResult sendTupleQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public void sendTupleQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, TupleQueryResultHandler handler, Binding... bindings) throws IOException, TupleQueryResultHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public void sendUpdate(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public GraphQueryResult sendGraphQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public GraphQueryResult sendGraphQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public void sendGraphQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, RDFHandler handler, Binding... bindings) throws IOException, RDFHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public void sendGraphQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, RDFHandler handler, Binding... bindings) throws IOException, RDFHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public boolean sendBooleanQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
public boolean sendBooleanQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
protected org.apache.commons.httpclient.HttpMethodBase getQueryMethod(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
protected org.apache.commons.httpclient.HttpMethod getUpdateMethod(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings)
protected List<org.apache.commons.httpclient.NameValuePair> getQueryMethodParameters(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
protected List<org.apache.commons.httpclient.NameValuePair> getUpdateMethodParameters(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings)
protected BackgroundTupleResult getBackgroundTupleQueryResult(org.apache.commons.httpclient.HttpMethod method) throws RepositoryException, QueryInterruptedException, org.apache.commons.httpclient.HttpException, MalformedQueryException, IOException
BackgroundTupleResult
or (in the error-case) in this
method.RepositoryException
QueryInterruptedException
org.apache.commons.httpclient.HttpException
MalformedQueryException
IOException
protected void getTupleQueryResult(org.apache.commons.httpclient.HttpMethod method, TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
TupleQueryResultHandler
. All HTTP connections are closed and
released in this methodprotected BackgroundGraphResult getRDFBackground(org.apache.commons.httpclient.HttpMethodBase method, boolean requireContext) throws IOException, RDFHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
BackgroundGraphResult
or (in the error-case) in this
method.protected void getRDF(org.apache.commons.httpclient.HttpMethod method, RDFHandler handler, boolean requireContext) throws IOException, RDFHandlerException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
RDFHandler
.
All HTTP connections are closed and released in this methodprotected boolean getBoolean(org.apache.commons.httpclient.HttpMethodBase method) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException
BooleanQueryResultParser
. All HTTP connections are closed and
released in this methodprotected boolean is2xx(int statusCode)
protected String getResponseMIMEType(org.apache.commons.httpclient.HttpMethod method) throws IOException
method
- The method to get the reponse MIME type from.IOException
protected ErrorInfo getErrorInfo(org.apache.commons.httpclient.HttpMethod method) throws RepositoryException
RepositoryException
protected final void setDoAuthentication(org.apache.commons.httpclient.HttpMethod method)
protected final void releaseConnection(org.apache.commons.httpclient.HttpMethod method)
public void setParserConfig(ParserConfig parserConfig)
parserConfig
- The parserConfig to set.public ParserConfig getParserConfig()
public long getConnectionTimeout()
public void setConnectionTimeout(long timeout)
timeout
- timeout in milliseconds. Zero sets to infinity.Copyright © 2001-2016 Aduna. All Rights Reserved.