Class 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.
    • 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 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 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 found
        response - 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 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.