dk.netarkivet.viewerproxy
Class ARCArchiveAccess

java.lang.Object
  extended by dk.netarkivet.viewerproxy.ARCArchiveAccess
All Implemented Interfaces:
URIResolver

public class ARCArchiveAccess
extends java.lang.Object
implements URIResolver

The ARCArchiveAccess class implements reading of ARC indexes and files. It builds on the Java ARC utils and Lucene indexes, and handles using these in an HTTP context.


Field Summary
 
Fields inherited from interface dk.netarkivet.viewerproxy.URIResolver
NOT_FOUND
 
Constructor Summary
ARCArchiveAccess(ViewerArcRepositoryClient arcRepositoryClient)
          Initialise new ARCArchiveAccess with no index file.
 
Method Summary
protected  void createNotFoundResponse(java.net.URI uri, Response response)
          Generate an appropriate response when a URI is not found.
protected  java.lang.String filterHeader(java.lang.String headername, java.lang.String headercontents)
          Apply filters to HTTP headers.
 int lookup(Request request, Response response)
          Look up a given URI and add its contents to the Response given.
 void setIndex(java.io.File index)
          This method resets the Lucene index this object works on, and replaces it with the given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ARCArchiveAccess

public ARCArchiveAccess(ViewerArcRepositoryClient arcRepositoryClient)
Initialise new ARCArchiveAccess with no index file.

Parameters:
arcRepositoryClient - The arcRepositoryClient to use when retrieving
Throws:
ArgumentNotValid - if arcRepositoryClient is null.
Method Detail

setIndex

public void setIndex(java.io.File index)
This method resets the Lucene index this object works on, and replaces it with the given index.

Parameters:
index - The new index file, a directory containing Lucene files.
Throws:
ArgumentNotValid - If argument is null
IOFailure - if the file cannot be read

lookup

public int lookup(Request request,
                  Response response)
Look up a given URI and add its contents to the Response given.

Specified by:
lookup in interface URIResolver
Parameters:
request - The request to look up record for
response - The response to optionally update.
Returns:
The response code for this page if found, or URIResolver.NOT_FOUND otherwise.
Throws:
IOFailure - on trouble looking up the request (timeout, i/o, etc.)
See Also:
URIResolver.lookup(Request, Response)

createNotFoundResponse

protected void createNotFoundResponse(java.net.URI uri,
                                      Response response)
Generate an appropriate response when a URI is not found. If this fails, it is logged, but otherwise ignored.

Parameters:
uri - The URI attempted read that could not be found
response - The Response object to write the error response into.

filterHeader

protected java.lang.String filterHeader(java.lang.String headername,
                                        java.lang.String headercontents)
Apply filters to HTTP headers. Can be overridden in subclasses. Currently only removes Transfer-encoding headers.

Parameters:
headername - The name of the header field, e.g. Content-Type Remember that this is not case sensitive
headercontents - The contents of the header field, e.g. text/html
Returns:
A (possibly modified) header contents string, or null if the header should be skipped.