de.fuberlin.wiwiss.marbles.loading
Class CacheController

java.lang.Object
  extended by de.fuberlin.wiwiss.marbles.loading.CacheController

public class CacheController
extends java.lang.Object

Implements caching of data retrieved from HTTP URLs using a Sesame repository Uses HTTP in RDF namespace, but currently does not follow the ontology as this would require deeper nesting with b-nodes, which is an overcomplication for the current use cases

Author:
Christian Becker
See Also:
http://www.w3.org/TR/HTTP-in-RDF/

Constructor Summary
CacheController(org.openrdf.repository.sail.SailRepository dataRepository, org.openrdf.repository.sail.SailRepository metaDataRepository)
          Constructs a new CacheController
 
Method Summary
 void addURLData(java.lang.String url, org.openrdf.model.Graph data, org.apache.commons.httpclient.HttpMethod method)
          Adds retrieved URL data to the cache
 org.apache.commons.httpclient.Header getCachedHeaderData(org.openrdf.repository.RepositoryConnection metaDataConn, org.openrdf.model.Resource mainResource, java.lang.String headerField)
          Retrieves a cached response header field from the metadata cache
 org.apache.commons.httpclient.Header getCachedHeaderData(org.openrdf.repository.RepositoryConnection metaDataConn, java.lang.String url, java.lang.String headerField)
          Retrieves a cached response header field from the metadata cache
 java.lang.String getCachedHeaderDataValue(org.openrdf.repository.RepositoryConnection metaDataConn, org.openrdf.model.Resource mainResource, java.lang.String headerField)
          Retrieves the value of a cached response header field from the metadata cache
 java.lang.String getCachedHeaderDataValue(org.openrdf.repository.RepositoryConnection metaDataConn, java.lang.String url, java.lang.String headerField)
          Retrieves the value of a cached response header field from the metadata cache
 java.lang.String getCachedRedirect(java.lang.String uri)
          Provides redirection targets from the cache
 org.openrdf.repository.Repository getDataRepository()
           
 org.openrdf.repository.Repository getMetaDataRepository()
           
 boolean hasURLData(java.lang.String url)
          Determines whether the cache holds a valid copy of an URL's data
 void removeData(java.lang.String url)
          Removes data for a given URL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheController

public CacheController(org.openrdf.repository.sail.SailRepository dataRepository,
                       org.openrdf.repository.sail.SailRepository metaDataRepository)
Constructs a new CacheController

Parameters:
dataRepository -
metaDataRepository -
Method Detail

removeData

public void removeData(java.lang.String url)
Removes data for a given URL

Parameters:
url - The URL whose data is to be removed

addURLData

public void addURLData(java.lang.String url,
                       org.openrdf.model.Graph data,
                       org.apache.commons.httpclient.HttpMethod method)
Adds retrieved URL data to the cache

Parameters:
url - The URL that was retrieved
data - The retrieved data
method - Used to obtain metadata

hasURLData

public boolean hasURLData(java.lang.String url)
Determines whether the cache holds a valid copy of an URL's data

Parameters:
url - The URL of interest
Returns:
true, if a valid copy is present

getCachedRedirect

public java.lang.String getCachedRedirect(java.lang.String uri)
Provides redirection targets from the cache

Parameters:
uri - The URI of interest
Returns:
The redirection target, or null if there is none

getCachedHeaderData

public org.apache.commons.httpclient.Header getCachedHeaderData(org.openrdf.repository.RepositoryConnection metaDataConn,
                                                                org.openrdf.model.Resource mainResource,
                                                                java.lang.String headerField)
                                                         throws org.openrdf.repository.RepositoryException
Retrieves a cached response header field from the metadata cache

Parameters:
metaDataConn - A connection to the metadata repository
mainResource - The resource of interest
headerField - The header field of interest
Returns:
Header data
Throws:
org.openrdf.repository.RepositoryException

getCachedHeaderData

public org.apache.commons.httpclient.Header getCachedHeaderData(org.openrdf.repository.RepositoryConnection metaDataConn,
                                                                java.lang.String url,
                                                                java.lang.String headerField)
                                                         throws org.openrdf.repository.RepositoryException
Retrieves a cached response header field from the metadata cache

Parameters:
metaDataConn - A connection to the metadata repository
url - The resource of interest
headerField - The header field of interest
Returns:
Header data
Throws:
org.openrdf.repository.RepositoryException

getCachedHeaderDataValue

public java.lang.String getCachedHeaderDataValue(org.openrdf.repository.RepositoryConnection metaDataConn,
                                                 org.openrdf.model.Resource mainResource,
                                                 java.lang.String headerField)
                                          throws org.openrdf.repository.RepositoryException
Retrieves the value of a cached response header field from the metadata cache

Parameters:
metaDataConn - A connection to the metadata repository
mainResource - The resource of interest
headerField - The header field of interest
Returns:
Header data
Throws:
org.openrdf.repository.RepositoryException

getCachedHeaderDataValue

public java.lang.String getCachedHeaderDataValue(org.openrdf.repository.RepositoryConnection metaDataConn,
                                                 java.lang.String url,
                                                 java.lang.String headerField)
                                          throws org.openrdf.repository.RepositoryException
Retrieves the value of a cached response header field from the metadata cache

Parameters:
metaDataConn - A connection to the metadata repository
url - The resource of interest
headerField - The header field of interest
Returns:
Header data
Throws:
org.openrdf.repository.RepositoryException

getDataRepository

public org.openrdf.repository.Repository getDataRepository()
Returns:
The repository that holds retrieved data using URLs as graphs (contexts)

getMetaDataRepository

public org.openrdf.repository.Repository getMetaDataRepository()
Returns:
The repository that holds metadata about the contents of the dataRepository