Package org.dspace.checker
Class CheckerCommand
- java.lang.Object
-
- org.dspace.checker.CheckerCommand
-
public final class CheckerCommand extends Object
Main class for the checksum checker tool, which calculates checksums for each bitstream whose ID is in the most_recent_checksum table, and compares it against the last calculated checksum for that bitstream.
- Author:
- Jim Downing, Grace Carpenter, Nathan Sarr TODO the accessor methods are currently unused - are they useful? TODO check for any existing resource problems
-
-
Constructor Summary
Constructors Constructor Description CheckerCommand(Context context)Default constructor uses DSpace plugin manager to construct dependencies.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MostRecentChecksumcheckBitstream(Bitstream bitstream)Check a specified bitstream.protected ChecksumResultcompareChecksums(String checksumA, String checksumB)Compares two checksums.protected ChecksumResultgetChecksumResultByCode(ChecksumResultCode checksumResultCode)ChecksumResultsCollectorgetCollector()Get the collector that holds/logs the results for this process run.BitstreamDispatchergetDispatcher()Get dispatcher being used by this run of the checker.DategetProcessStartDate()Get time at which checker process began.booleanisReportVerbose()Determine if any errors are reportedvoidprocess()Uses the options set up on this checker to determine a mode of execution, and then accepts bitstream ids from the dispatcher and checks their bitstreams against the db records.protected voidprocessBitstream(MostRecentChecksum info)Process general case bitstream.protected voidprocessDeletedBitstream(MostRecentChecksum info)Process bitstream that was marked 'deleted' in bitstream table.protected voidprocessNullInfoBitstream(MostRecentChecksum info)Process bitstream whose ID was not found in most_recent_checksum or bitstream table.voidsetCollector(ChecksumResultsCollector collector)Set the collector that holds/logs the results for this process run.voidsetDispatcher(BitstreamDispatcher dispatcher)Set the dispatcher to be used by this run of the checker.voidsetProcessStartDate(Date startDate)Set time at which checker process began.voidsetReportVerbose(boolean reportVerbose)Set report errors only
-
-
-
Constructor Detail
-
CheckerCommand
public CheckerCommand(Context context)
Default constructor uses DSpace plugin manager to construct dependencies.- Parameters:
context- Context
-
-
Method Detail
-
process
public void process() throws SQLExceptionUses the options set up on this checker to determine a mode of execution, and then accepts bitstream ids from the dispatcher and checks their bitstreams against the db records.
N.B. a valid BitstreamDispatcher must be provided using setBitstreamDispatcher before calling this method
- Throws:
SQLException- if database error
-
checkBitstream
protected MostRecentChecksum checkBitstream(Bitstream bitstream) throws SQLException
Check a specified bitstream.- Parameters:
bitstream- the bitstream- Returns:
- the information about the bitstream and its checksum data
- Throws:
SQLException- if database error
-
compareChecksums
protected ChecksumResult compareChecksums(String checksumA, String checksumB) throws SQLException
Compares two checksums.- Parameters:
checksumA- the first checksumchecksumB- the second checksum- Returns:
- a result code (constants defined in Util)
- Throws:
SQLException- if database error
-
processDeletedBitstream
protected void processDeletedBitstream(MostRecentChecksum info) throws SQLException
Process bitstream that was marked 'deleted' in bitstream table. A deleted bitstream should only be checked once afterwards it should be marked 'to_be_processed=false'. Note that to_be_processed must be manually updated in db to allow for future processing.- Parameters:
info- a deleted bitstream.- Throws:
SQLException- if database error
-
processNullInfoBitstream
protected void processNullInfoBitstream(MostRecentChecksum info) throws SQLException
Process bitstream whose ID was not found in most_recent_checksum or bitstream table. No updates can be done. The missing bitstream is output to the log file.- Parameters:
info- A not found BitStreamInfo TODO is this method required?- Throws:
SQLException- if database error
-
processBitstream
protected void processBitstream(MostRecentChecksum info) throws SQLException
Process general case bitstream.
Note: bitstream will have timestamp indicating it was "checked", even if actual checksumming never took place.
TODO Why does bitstream have a timestamp indicating it's checked if checksumming doesn't occur?- Parameters:
info- BitstreamInfo to handle- Throws:
SQLException- if database error
-
getChecksumResultByCode
protected ChecksumResult getChecksumResultByCode(ChecksumResultCode checksumResultCode) throws SQLException
- Throws:
SQLException
-
getDispatcher
public BitstreamDispatcher getDispatcher()
Get dispatcher being used by this run of the checker.- Returns:
- the dispatcher being used by this run.
-
setDispatcher
public void setDispatcher(BitstreamDispatcher dispatcher)
Set the dispatcher to be used by this run of the checker.- Parameters:
dispatcher- Dispatcher to use.
-
getCollector
public ChecksumResultsCollector getCollector()
Get the collector that holds/logs the results for this process run.- Returns:
- The ChecksumResultsCollector being used.
-
setCollector
public void setCollector(ChecksumResultsCollector collector)
Set the collector that holds/logs the results for this process run.- Parameters:
collector- the collector to be used for this run
-
getProcessStartDate
public Date getProcessStartDate()
Get time at which checker process began.- Returns:
- start time
-
setProcessStartDate
public void setProcessStartDate(Date startDate)
Set time at which checker process began.- Parameters:
startDate- start time
-
isReportVerbose
public boolean isReportVerbose()
Determine if any errors are reported- Returns:
- true if only errors reported
-
setReportVerbose
public void setReportVerbose(boolean reportVerbose)
Set report errors only- Parameters:
reportVerbose- true to report only errors in the logs.
-
-