|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.oai.harvester.Harvester
Harvests metadata from an OAI data provider, saving the results to file or returning
the raw XML as an array of Strings. The static methods harvest(String
baseURL,String metadataPrefix,String set,Date from,Date until,String
outdir,HarvestMessageHandler msgHandler,boolean writeHeaders)
and harvest(String baseURL,String metadataPrefix,String set,Date from,Date until,String
outdir,boolean writeHeaders)
are provided for convenience. If not using the static
methods, note that a new Harvester instance must be used for each harvest performed.
For information on OAI, see:
OAI v2.0 spec:
http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm
OAI tools:
http://www.openarchives.org/tools/tools.html
Repository Explorer:
http://oai.dlib.vt.edu/cgi-bin/Explorer/oai2.0/testoai
HarvestMessageHandler
Constructor Summary | |
---|---|
Harvester()
Creates a Harvester that uses no HarvestMessageHandler. |
|
Harvester(HarvestMessageHandler msgHandler)
Creates a Harvester that uses the given HarvestMessageHandler. |
Method Summary | |
---|---|
String[][] |
doHarvest(String baseURL,
String metadataPrefix,
String set,
Date from,
Date until,
String outdir,
boolean writeHeaders)
Performs the harvest. |
void |
error(SAXParseException exc)
Part of ErrorHandler interface. |
void |
fatalError(SAXParseException exc)
Part of ErrorHandler interface. |
long |
getEndTime()
Gets the endTime when the havest completed either because of an error or at the end of a successful harvest. |
String |
getHarvestedRecordsDir()
Gets the harvestedRecordsDir attribute of the Harvester object |
long |
getHarvestUid()
Returns a unique ID for this harvest. |
int |
getNumRecordsHarvested()
Gets the current number of records that have been harvested by this harvester. |
int |
getNumResumptionTokensIssued()
Gets the number of resumption tokens that have currently been issued by the data provider. |
long |
getStartTime()
Gets the startTime when the harvest began, or 0 if it has not begun yet. |
static String[][] |
harvest(String baseURL,
String metadataPrefix,
String set,
Date from,
Date until,
String outdir,
boolean writeHeaders)
Harvest the given provider, saving the resulting metadata to file or returning the results as an array of Strings. |
static String[][] |
harvest(String baseURL,
String metadataPrefix,
String set,
Date from,
Date until,
String outdir,
HarvestMessageHandler msgHandler,
boolean writeHeaders)
Harvest the given provider, saving the resulting metadata to file or returning the results as an array of Strings. |
boolean |
isRunning()
Determines whether this Harvester is currently running or not. |
void |
kill()
Gracefully kills the harvest after the current record is finished being harvested. |
static void |
main(String[] args)
Command line test interface for the harvester. |
void |
setNumRecordsForNotification(int numRecords)
Sets the number of records harvested before statusMessage notifications to the HarvestMessageHandler are made. |
void |
warning(SAXParseException exc)
Part of ErrorHandler interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Harvester()
public Harvester(HarvestMessageHandler msgHandler)
msgHandler
- The HarvestMessageHandler that will receive messages as the
harvest progresses, or null if none.Method Detail |
public static void main(String[] args)
Parameters:
args
- The command line argumentspublic static String[][] harvest(String baseURL, String metadataPrefix, String set, Date from, Date until, String outdir, HarvestMessageHandler msgHandler, boolean writeHeaders) throws Hexception, OAIErrorException
SimpleHarvestMessageHandler
to have
harvest messaged sent to standard out.
baseURL
- The baseURL of the data provider.metadataPrefix
- metadataPrefix. e.g., "oai_dc"set
- set. e.g., "testset" or null for none.from
- from date. May be null.until
- until date. May be null.outdir
- path of output dir. If null or "", we return the
String[][] array; if specified we return null.msgHandler
- A handler for status messages that occur during
harvesting, or null to ingnore messages.writeHeaders
- True to have headers written, false not to.
Hexception
- If serious error.
OAIErrorException
- If OAI error.public static String[][] harvest(String baseURL, String metadataPrefix, String set, Date from, Date until, String outdir, boolean writeHeaders) throws Hexception, OAIErrorException
baseURL
- The baseURL of the data provider.metadataPrefix
- metadataPrefix. e.g., "oai_dc"set
- set. e.g., "testset" or null for none.from
- from date. May be null.until
- until date. May be null.outdir
- path of output dir. If null or "", we return the
String[][] array; if specified we return null.writeHeaders
- True to have headers written, false not to.
Hexception
- If serious error.
OAIErrorException
- If OAI error.public void kill()
public void setNumRecordsForNotification(int numRecords)
numRecords
- The new numRecordsForNotification valuepublic long getStartTime()
public String getHarvestedRecordsDir()
public long getHarvestUid()
public long getEndTime()
public int getNumRecordsHarvested()
public int getNumResumptionTokensIssued()
public boolean isRunning()
public String[][] doHarvest(String baseURL, String metadataPrefix, String set, Date from, Date until, String outdir, boolean writeHeaders) throws Hexception, OAIErrorException
metadataPrefix
- metadataPrefix. e.g., "oai_dc"set
- set. e.g., "testset" or null for none.from
- from date. May be null.until
- until date. May be null.outdir
- path of output dir. If null or "", we return the
String[][] array; if specified we return null.writeHeaders
- True to have oai headers written to file, false not to.
baseURL
- The baseURL of the data provider.
Hexception
- If serious error.
OAIErrorException
- If OAI error was returned by the data provider.public void fatalError(SAXParseException exc)
fatalError
in interface ErrorHandler
exc
- DESCRIPTIONpublic void error(SAXParseException exc)
error
in interface ErrorHandler
exc
- DESCRIPTIONpublic void warning(SAXParseException exc)
warning
in interface ErrorHandler
exc
- DESCRIPTION
|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |