Package dk.netarkivet.viewerproxy
Class ARCArchiveAccess
- java.lang.Object
-
- dk.netarkivet.viewerproxy.ARCArchiveAccess
-
- All Implemented Interfaces:
URIResolver
public class ARCArchiveAccess extends 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
Constructors Constructor Description ARCArchiveAccess(ViewerArcRepositoryClient arcRepositoryClient)
Initialise new ARCArchiveAccess with no index file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createNotFoundResponse(URI uri, Response response)
Generate an appropriate response when a URI is not found.protected String
filterHeader(String headername, 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(File index)
This method resets the Lucene index this object works on, and replaces it with the given index.
-
-
-
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(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 nullIOFailure
- 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 interfaceURIResolver
- Parameters:
request
- The request to look up record forresponse
- The response to return to the browser- 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(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 foundresponse
- The Response object to write the error response into.
-
filterHeader
protected String filterHeader(String headername, 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 sensitiveheadercontents
- 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.
-
-