Class ARCLookup
- java.lang.Object
-
- dk.netarkivet.common.distribute.arcrepository.ARCLookup
-
public class ARCLookup extends 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
Constructors Constructor Description ARCLookup(ViewerArcRepositoryClient arcRepositoryClient)
Create a new ARCLookup object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultStream
lookup(URI uri)
Look up a given URI and return the contents as an InputStream.void
setIndex(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)
The setter for the option to search for URIs with ftp instead of http as the scheme.
-
-
-
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)
The setter for the option to search for URIs with ftp instead of http as the scheme. Note that The scheme information is absent from the original URI request, when the request arrives here- 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(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(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.
-
-