org.openrdf.http.client
Class HTTPClient

java.lang.Object
  extended by org.openrdf.http.client.HTTPClient

public class HTTPClient
extends Object

Low-level HTTP client for Sesame's HTTP protocol. Methods correspond directly to the functionality offered by the protocol.

Author:
Herko ter Horst, Arjohn Kampman

Constructor Summary
HTTPClient()
           
 
Method Summary
protected  void checkRepositoryURL()
           
protected  void checkServerURL()
           
 void clearNamespaces()
           
protected  boolean getBoolean(org.apache.commons.httpclient.HttpMethod method)
           
 TupleQueryResult getContextIDs()
           
 void getContextIDs(TupleQueryResultHandler handler)
           
protected  ErrorInfo getErrorInfo(org.apache.commons.httpclient.HttpMethod method)
           
protected  org.apache.commons.httpclient.HttpClient getHttpClient()
           
 String getNamespace(String prefix)
           
 TupleQueryResult getNamespaces()
           
 void getNamespaces(TupleQueryResultHandler handler)
           
 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.HttpMethod getQueryMethod(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings)
           
protected  List<org.apache.commons.httpclient.NameValuePair> getQueryMethodParameters(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings)
           
protected  void getRDF(org.apache.commons.httpclient.HttpMethod method, RDFHandler handler, boolean requireContext)
           
 TupleQueryResult getRepositoryList()
           
 void getRepositoryList(TupleQueryResultHandler handler)
           
 String getRepositoryURL()
           
protected  String getResponseMIMEType(org.apache.commons.httpclient.HttpMethod method)
          Gets the MIME type specified in the response headers of the supplied method, if any.
 String getServerProtocol()
           
 String getServerURL()
           
 void getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts)
           
protected  void getTupleQueryResult(org.apache.commons.httpclient.HttpMethod method, TupleQueryResultHandler handler)
           
 ValueFactory getValueFactory()
           
protected  void releaseConnection(org.apache.commons.httpclient.HttpMethod method)
           
 void removeNamespacePrefix(String prefix)
           
 boolean sendBooleanQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, 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)
           
 void sendTransaction(Iterable<? extends TransactionOperation> txn)
           
 TupleQueryResult sendTupleQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings)
           
 void sendTupleQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, TupleQueryResultHandler handler, Binding... bindings)
           
protected  void setDoAuthentication(org.apache.commons.httpclient.HttpMethod method)
           
 void setNamespacePrefix(String prefix, String name)
           
 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 setRepositoryID(String repositoryID)
           
 void setRepositoryURL(String repositoryURL)
           
 void setServerURL(String serverURL)
           
 void setUsernameAndPassword(String username, String password)
          Set the username and password for authenication with the remote server.
 void setValueFactory(ValueFactory valueFactory)
           
 long size(Resource... contexts)
           
 void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, Resource... contexts)
           
 void upload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, Resource... contexts)
           
protected  void upload(org.apache.commons.httpclient.methods.RequestEntity reqEntity, String baseURI, boolean overwrite, Resource... contexts)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPClient

public HTTPClient()
Method Detail

getHttpClient

protected final org.apache.commons.httpclient.HttpClient getHttpClient()

setValueFactory

public void setValueFactory(ValueFactory valueFactory)

getValueFactory

public ValueFactory getValueFactory()

setServerURL

public void setServerURL(String serverURL)

getServerURL

public String getServerURL()

checkServerURL

protected void checkServerURL()

setRepositoryURL

public void setRepositoryURL(String repositoryURL)

getRepositoryURL

public String getRepositoryURL()

checkRepositoryURL

protected void checkRepositoryURL()

setRepositoryID

public void setRepositoryID(String repositoryID)

setPreferredTupleQueryResultFormat

public void setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
Sets the preferred format for encoding tuple query results. The binary format is preferred by default.

Parameters:
format - The preferred TupleQueryResultFormat, or null to indicate no specific format is preferred.

getPreferredTupleQueryResultFormat

public TupleQueryResultFormat getPreferredTupleQueryResultFormat()
Gets the preferred TupleQueryResultFormat for encoding tuple query results.

Returns:
The preferred format, of null if no specific format is preferred.

setPreferredRDFFormat

public void setPreferredRDFFormat(RDFFormat format)
Sets the preferred format for encoding RDF documents. The Turtle format is preferred by default.

Parameters:
format - The preferred RDFFormat, or null to indicate no specific format is preferred.

getPreferredRDFFormat

public RDFFormat getPreferredRDFFormat()
Gets the preferred RDFFormat for encoding RDF documents.

Returns:
The preferred format, of null if no specific format is preferred.

setPreferredBooleanQueryResultFormat

public void setPreferredBooleanQueryResultFormat(BooleanQueryResultFormat format)
Sets the preferred format for encoding boolean query results. The binary format is preferred by default.

Parameters:
format - The preferred BooleanQueryResultFormat, or null to indicate no specific format is preferred.

getPreferredBooleanQueryResultFormat

public BooleanQueryResultFormat getPreferredBooleanQueryResultFormat()
Gets the preferred BooleanQueryResultFormat for encoding boolean query results.

Returns:
The preferred format, of null if no specific format is preferred.

setUsernameAndPassword

public void setUsernameAndPassword(String username,
                                   String password)
Set the username and password for authenication with the remote server.

Parameters:
username - the username
password - the password

getServerProtocol

public String getServerProtocol()
                         throws IOException,
                                RepositoryException,
                                UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

getRepositoryList

public TupleQueryResult getRepositoryList()
                                   throws IOException,
                                          RepositoryException,
                                          UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

getRepositoryList

public void getRepositoryList(TupleQueryResultHandler handler)
                       throws IOException,
                              TupleQueryResultHandlerException,
                              RepositoryException,
                              UnauthorizedException
Throws:
IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException

sendTupleQuery

public TupleQueryResult sendTupleQuery(QueryLanguage ql,
                                       String query,
                                       Dataset dataset,
                                       boolean includeInferred,
                                       Binding... bindings)
                                throws IOException,
                                       RepositoryException,
                                       MalformedQueryException,
                                       UnauthorizedException
Throws:
IOException
RepositoryException
MalformedQueryException
UnauthorizedException

sendTupleQuery

public void sendTupleQuery(QueryLanguage ql,
                           String query,
                           Dataset dataset,
                           boolean includeInferred,
                           TupleQueryResultHandler handler,
                           Binding... bindings)
                    throws IOException,
                           TupleQueryResultHandlerException,
                           RepositoryException,
                           MalformedQueryException,
                           UnauthorizedException
Throws:
IOException
TupleQueryResultHandlerException
RepositoryException
MalformedQueryException
UnauthorizedException

sendGraphQuery

public GraphQueryResult sendGraphQuery(QueryLanguage ql,
                                       String query,
                                       Dataset dataset,
                                       boolean includeInferred,
                                       Binding... bindings)
                                throws IOException,
                                       RepositoryException,
                                       MalformedQueryException,
                                       UnauthorizedException
Throws:
IOException
RepositoryException
MalformedQueryException
UnauthorizedException

sendGraphQuery

public void sendGraphQuery(QueryLanguage ql,
                           String query,
                           Dataset dataset,
                           boolean includeInferred,
                           RDFHandler handler,
                           Binding... bindings)
                    throws IOException,
                           RDFHandlerException,
                           RepositoryException,
                           MalformedQueryException,
                           UnauthorizedException
Throws:
IOException
RDFHandlerException
RepositoryException
MalformedQueryException
UnauthorizedException

sendBooleanQuery

public boolean sendBooleanQuery(QueryLanguage ql,
                                String query,
                                Dataset dataset,
                                boolean includeInferred,
                                Binding... bindings)
                         throws IOException,
                                RepositoryException,
                                MalformedQueryException,
                                UnauthorizedException
Throws:
IOException
RepositoryException
MalformedQueryException
UnauthorizedException

getQueryMethod

protected org.apache.commons.httpclient.HttpMethod getQueryMethod(QueryLanguage ql,
                                                                  String query,
                                                                  Dataset dataset,
                                                                  boolean includeInferred,
                                                                  Binding... bindings)

getQueryMethodParameters

protected List<org.apache.commons.httpclient.NameValuePair> getQueryMethodParameters(QueryLanguage ql,
                                                                                     String query,
                                                                                     Dataset dataset,
                                                                                     boolean includeInferred,
                                                                                     Binding... bindings)

getStatements

public void getStatements(Resource subj,
                          URI pred,
                          Value obj,
                          boolean includeInferred,
                          RDFHandler handler,
                          Resource... contexts)
                   throws IOException,
                          RDFHandlerException,
                          RepositoryException,
                          UnauthorizedException
Throws:
IOException
RDFHandlerException
RepositoryException
UnauthorizedException

sendTransaction

public void sendTransaction(Iterable<? extends TransactionOperation> txn)
                     throws IOException,
                            RepositoryException,
                            UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

upload

public void upload(Reader contents,
                   String baseURI,
                   RDFFormat dataFormat,
                   boolean overwrite,
                   Resource... contexts)
            throws IOException,
                   RDFParseException,
                   RepositoryException,
                   UnauthorizedException
Throws:
IOException
RDFParseException
RepositoryException
UnauthorizedException

upload

public void upload(InputStream contents,
                   String baseURI,
                   RDFFormat dataFormat,
                   boolean overwrite,
                   Resource... contexts)
            throws IOException,
                   RDFParseException,
                   RepositoryException,
                   UnauthorizedException
Throws:
IOException
RDFParseException
RepositoryException
UnauthorizedException

upload

protected void upload(org.apache.commons.httpclient.methods.RequestEntity reqEntity,
                      String baseURI,
                      boolean overwrite,
                      Resource... contexts)
               throws IOException,
                      RDFParseException,
                      RepositoryException,
                      UnauthorizedException
Throws:
IOException
RDFParseException
RepositoryException
UnauthorizedException

getContextIDs

public TupleQueryResult getContextIDs()
                               throws IOException,
                                      RepositoryException,
                                      UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

getContextIDs

public void getContextIDs(TupleQueryResultHandler handler)
                   throws IOException,
                          TupleQueryResultHandlerException,
                          RepositoryException,
                          UnauthorizedException
Throws:
IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException

getNamespaces

public TupleQueryResult getNamespaces()
                               throws IOException,
                                      RepositoryException,
                                      UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

getNamespaces

public void getNamespaces(TupleQueryResultHandler handler)
                   throws IOException,
                          TupleQueryResultHandlerException,
                          RepositoryException,
                          UnauthorizedException
Throws:
IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException

getNamespace

public String getNamespace(String prefix)
                    throws IOException,
                           RepositoryException,
                           UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

setNamespacePrefix

public void setNamespacePrefix(String prefix,
                               String name)
                        throws IOException,
                               RepositoryException,
                               UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

removeNamespacePrefix

public void removeNamespacePrefix(String prefix)
                           throws IOException,
                                  RepositoryException,
                                  UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

clearNamespaces

public void clearNamespaces()
                     throws IOException,
                            RepositoryException,
                            UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

size

public long size(Resource... contexts)
          throws IOException,
                 RepositoryException,
                 UnauthorizedException
Throws:
IOException
RepositoryException
UnauthorizedException

getTupleQueryResult

protected void getTupleQueryResult(org.apache.commons.httpclient.HttpMethod method,
                                   TupleQueryResultHandler handler)
                            throws IOException,
                                   TupleQueryResultHandlerException,
                                   RepositoryException,
                                   MalformedQueryException,
                                   UnauthorizedException
Throws:
IOException
TupleQueryResultHandlerException
RepositoryException
MalformedQueryException
UnauthorizedException

getRDF

protected void getRDF(org.apache.commons.httpclient.HttpMethod method,
                      RDFHandler handler,
                      boolean requireContext)
               throws IOException,
                      RDFHandlerException,
                      RepositoryException,
                      MalformedQueryException,
                      UnauthorizedException
Throws:
IOException
RDFHandlerException
RepositoryException
MalformedQueryException
UnauthorizedException

getBoolean

protected boolean getBoolean(org.apache.commons.httpclient.HttpMethod method)
                      throws IOException,
                             RepositoryException,
                             MalformedQueryException,
                             UnauthorizedException
Throws:
IOException
RepositoryException
MalformedQueryException
UnauthorizedException

getResponseMIMEType

protected String getResponseMIMEType(org.apache.commons.httpclient.HttpMethod method)
                              throws IOException
Gets the MIME type specified in the response headers of the supplied method, if any. For example, if the response headers contain Content-Type: application/xml;charset=UTF-8, this method will return application/xml as the MIME type.

Parameters:
method - The method to get the reponse MIME type from.
Returns:
The response MIME type, or null if not available.
Throws:
IOException

getErrorInfo

protected ErrorInfo getErrorInfo(org.apache.commons.httpclient.HttpMethod method)
                          throws RepositoryException
Throws:
RepositoryException

setDoAuthentication

protected final void setDoAuthentication(org.apache.commons.httpclient.HttpMethod method)

releaseConnection

protected final void releaseConnection(org.apache.commons.httpclient.HttpMethod method)


Copyright © 2001-2007 Aduna. All Rights Reserved.