org.openrdf.repository.http
Class HTTPRepository

java.lang.Object
  extended by org.openrdf.repository.http.HTTPRepository
All Implemented Interfaces:
Repository

public class HTTPRepository
extends Object
implements Repository

A repository that serves as a proxy for a remote repository on a Sesame server. Methods in this class may throw the specific RepositoryException subclasses UnautorizedException and NotAllowedException, the semantics of which are defined by the HTTP protocol.

Author:
Arjohn Kampman, jeen, Herko ter Horst
See Also:
UnauthorizedException, org.openrdf.http.protocol.NotAllowedException

Constructor Summary
HTTPRepository(String repositoryURL)
           
HTTPRepository(String serverURL, String repositoryID)
           
 
Method Summary
 RepositoryConnection getConnection()
          Opens a connection to this repository that can be used for querying and updating the contents of the repository.
 File getDataDir()
          Get the directory where data and logging for this repository is stored.
 RDFFormat getPreferredRDFFormat()
          Indicates the current preferred RDFFormat.
 TupleQueryResultFormat getPreferredTupleQueryResultFormat()
          Indicates the current preferred TupleQueryResultFormat.
 ValueFactory getValueFactory()
          Gets a ValueFactory for this Repository.
 void initialize()
          Initializes this repository.
 boolean isWritable()
          Checks whether this repository is writable, i.e.
 void setDataDir(File dataDir)
          Set the directory where data and logging for this repository is stored.
 void setPreferredRDFFormat(RDFFormat format)
          Sets the preferred serialization format for RDF to the supplied RDFFormat, overriding the HTTPClient's default preference.
 void setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
          Sets the preferred serialization format for tuple query results to the supplied TupleQueryResultFormat, overriding the HTTPClient's default preference.
 void setUsernameAndPassword(String username, String password)
          Set the username and password to use for authenticating with the remote repository.
 void shutDown()
          Shuts the repository down, releasing any resources that it keeps hold of.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPRepository

public HTTPRepository(String serverURL,
                      String repositoryID)

HTTPRepository

public HTTPRepository(String repositoryURL)
Method Detail

setDataDir

public void setDataDir(File dataDir)
Description copied from interface: Repository
Set the directory where data and logging for this repository is stored.

Specified by:
setDataDir in interface Repository
Parameters:
dataDir - the directory where data for this repository is stored

getDataDir

public File getDataDir()
Description copied from interface: Repository
Get the directory where data and logging for this repository is stored.

Specified by:
getDataDir in interface Repository
Returns:
the directory where data for this repository is stored.

initialize

public void initialize()
                throws RepositoryException
Description copied from interface: Repository
Initializes this repository. A repository needs to be initialized before it can be used.

Specified by:
initialize in interface Repository
Throws:
RepositoryException - If the initialization failed.

shutDown

public void shutDown()
              throws RepositoryException
Description copied from interface: Repository
Shuts the repository down, releasing any resources that it keeps hold of. Once shut down, the repository can no longer be used until it is re-initialized.

Specified by:
shutDown in interface Repository
Throws:
RepositoryException

getValueFactory

public ValueFactory getValueFactory()
Description copied from interface: Repository
Gets a ValueFactory for this Repository.

Specified by:
getValueFactory in interface Repository
Returns:
A repository-specific ValueFactory.

getConnection

public RepositoryConnection getConnection()
                                   throws RepositoryException
Description copied from interface: Repository
Opens a connection to this repository that can be used for querying and updating the contents of the repository. Created connections need to be closed to make sure that any resources they keep hold of are released. The best way to do this is to use a try-finally-block as follows:
 Connection con = repository.getConnection();
 try {
        // perform operations on the connection
 }
 finally {
        con.close();
 }
 

Specified by:
getConnection in interface Repository
Returns:
A connection that allows operations on this repository.
Throws:
RepositoryException - If something went wrong during the creation of the Connection.

isWritable

public boolean isWritable()
                   throws RepositoryException
Description copied from interface: Repository
Checks whether this repository is writable, i.e. if the data contained in this repository can be changed. The writability of the repository is determined by the writability of the Sail that this repository operates on.

Specified by:
isWritable in interface Repository
Throws:
RepositoryException

setPreferredTupleQueryResultFormat

public void setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
Sets the preferred serialization format for tuple query results to the supplied TupleQueryResultFormat, overriding the HTTPClient's default preference. Setting this parameter is not necessary in most cases as the HTTPClient by default indicates a preference for the most compact and efficient format available.

Parameters:
format - the preferred TupleQueryResultFormat. If set to 'null' no explicit preference will be stated.

getPreferredTupleQueryResultFormat

public TupleQueryResultFormat getPreferredTupleQueryResultFormat()
Indicates the current preferred TupleQueryResultFormat.

Returns:
The preferred format, of 'null' if no explicit preference is defined.

setPreferredRDFFormat

public void setPreferredRDFFormat(RDFFormat format)
Sets the preferred serialization format for RDF to the supplied RDFFormat, overriding the HTTPClient's default preference. Setting this parameter is not necessary in most cases as the HTTPClient by default indicates a preference for the most compact and efficient format available.

Use with caution: if set to a format that does not support context serialization any context info contained in the query result will be lost.

Parameters:
format - the preferred RDFFormat. If set to 'null' no explicit preference will be stated.

getPreferredRDFFormat

public RDFFormat getPreferredRDFFormat()
Indicates the current preferred RDFFormat.

Returns:
The preferred format, of 'null' if no explicit preference is defined.

setUsernameAndPassword

public void setUsernameAndPassword(String username,
                                   String password)
Set the username and password to use for authenticating with the remote repository.

Parameters:
username - the username. Setting this to null will disable authentication.
password - the password. Setting this to null will disable authentication.


Copyright © 2001-2008 Aduna. All Rights Reserved.