public final class BagVerifier
extends java.lang.Object
implements java.lang.AutoCloseable
| Constructor and Description |
|---|
BagVerifier()
Create a BagVerifier with a cached thread pool and a
StandardBagitAlgorithmNameToSupportedAlgorithmMapping |
BagVerifier(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping)
Create a BagVerifier with a cached thread pool and a custom mapping
|
BagVerifier(java.util.concurrent.ExecutorService executor)
Create a BagVerifier with a custom thread pool and a
StandardBagitAlgorithmNameToSupportedAlgorithmMapping |
BagVerifier(java.util.concurrent.ExecutorService executor,
BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping)
Create a BagVerifier with a custom thread pool and a custom mapping
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canQuickVerify(Bag bag)
Determine if we can quickly verify by comparing the number of files and the total number of bytes expected
|
void |
close() |
java.util.concurrent.ExecutorService |
getExecutor() |
ManifestVerifier |
getManifestVerifier() |
void |
isComplete(Bag bag,
boolean ignoreHiddenFiles)
See https://tools.ietf.org/html/draft-kunze-bagit-13#section-3
A bag is complete if every element is present every file in the payload manifest(s) are present every file in the tag manifest(s) are present. |
void |
isValid(Bag bag,
boolean ignoreHiddenFiles)
See https://tools.ietf.org/html/draft-kunze-bagit-13#section-3
A bag is valid if the bag is complete and every checksum has been verified against the contents of its corresponding file. |
static void |
quicklyVerify(Bag bag)
Quickly verify by comparing the number of files and the total number of bytes expected
|
public BagVerifier()
StandardBagitAlgorithmNameToSupportedAlgorithmMappingpublic BagVerifier(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping)
nameMapping - the mapping between BagIt algorithm name and the java supported algorithmpublic BagVerifier(java.util.concurrent.ExecutorService executor)
StandardBagitAlgorithmNameToSupportedAlgorithmMappingexecutor - the thread pool to use when doing workpublic BagVerifier(java.util.concurrent.ExecutorService executor,
BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping)
nameMapping - the mapping between BagIt algorithm name and the java supported algorithmexecutor - the thread pool to use when doing workpublic void close()
throws java.lang.SecurityException
close in interface java.lang.AutoCloseablejava.lang.SecurityExceptionpublic static boolean canQuickVerify(Bag bag)
bag - the Bag object you wish to checkpublic static void quicklyVerify(Bag bag) throws java.io.IOException, InvalidPayloadOxumException
bag - the bag to verify by payload-oxumjava.io.IOException - if there is an error reading a fileInvalidPayloadOxumException - if either the total bytes or the number of files
calculated for the payload directory of the bag is different than the supplied valuesPayloadOxumDoesNotExistException - if the bag does not contain a payload-oxum.
To check, run canQuickVerify(gov.loc.repository.bagit.domain.Bag)public void isValid(Bag bag, boolean ignoreHiddenFiles) throws java.io.IOException, FileNotInManifestException, MissingPayloadManifestException, MissingBagitFileException, MissingPayloadDirectoryException, FileNotInPayloadDirectoryException, java.lang.InterruptedException, MaliciousPathException, CorruptChecksumException, VerificationException, UnsupportedAlgorithmException, InvalidBagitFileFormatException
bag - the Bag object to checkignoreHiddenFiles - ignore hidden files unless explicitly listed in manifest(s)CorruptChecksumException - when the computed hash doesn't match given hashjava.io.IOException - if there was an error with the fileFileNotInManifestException - if a file is found in the payload directory but not in manifest(s)MissingPayloadManifestException - if there is not at least one payload manifestMissingBagitFileException - if there is no bagit.txt fileMissingPayloadDirectoryException - if there is no /data directoryFileNotInPayloadDirectoryException - if a manifest lists a file but it is not in the payload directoryjava.lang.InterruptedException - if the threads are interrupted when checking if all files are listed in manifest(s)MaliciousPathException - if there is path that is referenced in the manifest that is outside the bag root directoryVerificationException - some other exception happened during processing so capture it here.UnsupportedAlgorithmException - if the manifest uses a algorithm that isn't supportedInvalidBagitFileFormatException - if the manifest is not formatted properlypublic void isComplete(Bag bag, boolean ignoreHiddenFiles) throws java.io.IOException, MissingPayloadManifestException, MissingBagitFileException, MissingPayloadDirectoryException, FileNotInPayloadDirectoryException, java.lang.InterruptedException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException
bag - the Bag object to checkignoreHiddenFiles - ignore hidden files unless explicitly listed in manifest(s)java.io.IOException - if there was an error with the fileMissingPayloadManifestException - if there is not at least one payload manifestMissingBagitFileException - if there is no bagit.txt fileMissingPayloadDirectoryException - if there is no /data directoryFileNotInPayloadDirectoryException - if a manifest lists a file but it is not in the payload directoryjava.lang.InterruptedException - if the threads are interrupted when checking if all files are listed in manifest(s)MaliciousPathException - if there is path that is referenced in the manifest that is outside the bag root directoryUnsupportedAlgorithmException - if the manifest uses a algorithm that isn't supportedInvalidBagitFileFormatException - if the manifest is not formatted properlypublic java.util.concurrent.ExecutorService getExecutor()
public ManifestVerifier getManifestVerifier()