|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.netarkivet.archive.checksum.ChecksumArchive
dk.netarkivet.archive.checksum.FileChecksumArchive
public final class FileChecksumArchive
A checksum archive in the form of a file (as alternative to a database).
Each entry in the file is on its own line, thus the number of lines is the
number of entries.
The entries on a line is in the format of a ChecksumJob:
'filename' + ## + 'checksum'
The lines are not sorted.
TODO synchronize the memory archive with the file archive.
Method Summary | |
---|---|
protected java.lang.String |
calculateChecksum(java.io.File f)
Method for calculating the checksum of a file. |
protected java.lang.String |
calculateChecksum(java.io.InputStream is)
Method for calculating the checksum of a inputstream. |
void |
cleanup()
The method for cleaning up when done. |
void |
correct(java.lang.String filename,
java.io.File correctFile)
Method for correcting a bad entry from the archive. |
java.io.File |
getAllFilenames()
Method for retrieving the names of all the files within the archive as a temporary file. |
java.io.File |
getArchiveAsFile()
Method for retrieving the archive as a temporary file containing the checksum entries. |
java.lang.String |
getChecksum(java.lang.String filename)
Method for retrieving the checksum of a record, based on the filename. |
java.lang.String |
getFileName()
Method for retrieving the name of the checksum file. |
static FileChecksumArchive |
getInstance()
Method for obtaining the current singleton instance of this class. |
java.lang.String |
getWrongEntryFilename()
Method for retrieving the name of the wrongEntryFile. |
boolean |
hasEnoughSpace()
Method for testing where there is enough space left on local drive. |
boolean |
hasEntry(java.lang.String filename)
Method for checking whether an entry exists within the archive. |
void |
upload(RemoteFile arcfile,
java.lang.String filename)
The method for uploading an arcFile to the archive. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static FileChecksumArchive getInstance()
public java.lang.String getFileName()
public java.lang.String getWrongEntryFilename()
public boolean hasEnoughSpace()
hasEnoughSpace
in class ChecksumArchive
public void upload(RemoteFile arcfile, java.lang.String filename) throws ArgumentNotValid
upload
in class ChecksumArchive
arcfile
- The remote file containing the arcFile to upload.filename
- The name of the arcFile.
ArgumentNotValid
- If the RemoteFile is null or if the filename
is not valid.public java.lang.String getChecksum(java.lang.String filename) throws ArgumentNotValid
getChecksum
in class ChecksumArchive
filename
- The name of the file to have recorded in the archive.
ArgumentNotValid
- If the filename is not valid (null or empty).public boolean hasEntry(java.lang.String filename)
hasEntry
in class ChecksumArchive
filename
- The name of the file whose entry in the archive should
be determined.
protected java.lang.String calculateChecksum(java.io.File f) throws IOFailure
calculateChecksum
in class ChecksumArchive
f
- The file to calculate the checksum of.
IOFailure
- If a IOException is caught during the calculation of
the MD5-checksum.protected java.lang.String calculateChecksum(java.io.InputStream is) throws IOFailure
calculateChecksum
in class ChecksumArchive
is
- The inputstream to calculate the checksum of.
IOFailure
- If a error occurs during the generation of the
MD5 checksum.public void correct(java.lang.String filename, java.io.File correctFile) throws IOFailure, ArgumentNotValid, IllegalState
correct
in class ChecksumArchive
filename
- The name of the file whose record should be removed.correctFile
- The file that should replace the current entry
ArgumentNotValid
- If one of the arguments are not valid.
IOFailure
- If the entry cannot be corrected. Either the bad entry
cannot be stored, or the new checksum file cannot be created.
IllegalState
- If no such entry exists to be corrected, or if the
entry has a different checksum than the incorrectChecksum.public java.io.File getArchiveAsFile() throws IOFailure
getArchiveAsFile
in class ChecksumArchive
IOFailure
- If problems occurs during the creation of the file.public java.io.File getAllFilenames() throws IOFailure
getAllFilenames
in class ChecksumArchive
IOFailure
- If problems occurs during the creation of the file.public void cleanup()
cleanup
in class ChecksumArchive
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |