dk.netarkivet.common.distribute.arcrepository
Class ARCLookup

java.lang.Object
  extended by dk.netarkivet.common.distribute.arcrepository.ARCLookup

public class ARCLookup
extends java.lang.Object

This class allows lookup of URLs in the ArcRepository, using full Lucene indexes to find offsets. The input takes the form of a directory containing a Lucene index.


Constructor Summary
ARCLookup(ViewerArcRepositoryClient arcRepositoryClient)
          Create a new ARCLookup object.
 
Method Summary
 ResultStream lookup(java.net.URI uri)
          Look up a given URI and return the contents as an InputStream.
 void setIndex(java.io.File indexDir)
          This method sets the current Lucene index this object works on, replacing and closing the current index if one is already set.
 void setTryToLookupUriAsFtp(boolean searchForFtpUri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ARCLookup

public ARCLookup(ViewerArcRepositoryClient arcRepositoryClient)
Create a new ARCLookup object.

Parameters:
arcRepositoryClient - The interface to the ArcRepository
Throws:
ArgumentNotValid - if arcRepositoryClient is null.
Method Detail

setTryToLookupUriAsFtp

public void setTryToLookupUriAsFtp(boolean searchForFtpUri)
Parameters:
searchForFtpUri - if true, we replace the http schema with ftp and try again, if unsuccessful with http as the schema

setIndex

public void setIndex(java.io.File indexDir)
This method sets the current Lucene index this object works on, replacing and closing the current index if one is already set.

Parameters:
indexDir - The new index, a directory containing Lucene files.
Throws:
ArgumentNotValid - If argument is null

lookup

public ResultStream lookup(java.net.URI uri)
Look up a given URI and return the contents as an InputStream. The uri is first checked using url-decoding (e.g. "," in the argument is converted to "%2C"). If this returns no match, the method then searches for a non-url-decoded match. If neither returns a match the method returns null. If the tryToLookupUriAsFtp field is set to true, we will try exchanging the schema with ftp, whenever we can't lookup the uri with the original schema.

Parameters:
uri - The URI to find in the archive. If the URI does not match any entries in the archive, null is returned.
Returns:
An InputStream Containing all the data in the entry, or null if the entry was not found
Throws:
IOFailure - If the ARC file was found in the Lucene index but not in the bit archive, or if some other failure happened while finding the file.