Package org.dspace.checker
Class CheckerCommand
java.lang.Object
org.dspace.checker.CheckerCommand
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
ConstructorsConstructorDescriptionCheckerCommand(Context context) Default constructor uses DSpace plugin manager to construct dependencies. -
Method Summary
Modifier and TypeMethodDescriptionprotected MostRecentChecksumcheckBitstream(Bitstream bitstream) Check a specified bitstream.protected ChecksumResultcompareChecksums(String checksumA, String checksumB) Compares two checksums.protected ChecksumResultgetChecksumResultByCode(ChecksumResultCode checksumResultCode) Get the collector that holds/logs the results for this process run.Get dispatcher being used by this run of the checker.Get time at which checker process began.booleanDetermine 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 voidProcess general case bitstream.protected voidProcess bitstream that was marked 'deleted' in bitstream table.protected voidProcess 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(Instant startDate) Set time at which checker process began.voidsetReportVerbose(boolean reportVerbose) Set report errors only
-
Constructor Details
-
CheckerCommand
Default constructor uses DSpace plugin manager to construct dependencies.- Parameters:
context- Context
-
-
Method Details
-
process
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.
N.B. a valid BitstreamDispatcher must be provided using setBitstreamDispatcher before calling this method
- Throws:
SQLException- if database error
-
checkBitstream
Check a specified bitstream.- Parameters:
bitstream- the bitstream- Returns:
- the information about the bitstream and its checksum data
- Throws:
SQLException- if database error
-
compareChecksums
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
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
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
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
Get dispatcher being used by this run of the checker.- Returns:
- the dispatcher being used by this run.
-
setDispatcher
Set the dispatcher to be used by this run of the checker.- Parameters:
dispatcher- Dispatcher to use.
-
getCollector
Get the collector that holds/logs the results for this process run.- Returns:
- The ChecksumResultsCollector being used.
-
setCollector
Set the collector that holds/logs the results for this process run.- Parameters:
collector- the collector to be used for this run
-
getProcessStartDate
Get time at which checker process began.- Returns:
- start time
-
setProcessStartDate
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.
-