Package nl.knaw.dans.bagit.verify
Class ManifestVerifier
java.lang.Object
nl.knaw.dans.bagit.verify.ManifestVerifier
- All Implemented Interfaces:
AutoCloseable
Responsible for all things related to the manifest during verification.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ExecutorService
private static final org.slf4j.Logger
private static final ResourceBundle
private final BagitAlgorithmNameToSupportedAlgorithmMapping
-
Constructor Summary
ConstructorDescriptionCreate a PayloadVerifier using a cached thread pool and theStandardBagitAlgorithmNameToSupportedAlgorithmMapping
mappingManifestVerifier
(ExecutorService executor) Create a PayloadVerifier using a custom thread pool and theStandardBagitAlgorithmNameToSupportedAlgorithmMapping
mappingCreate a PayloadVerifier using a cached thread pool and a custom mappingManifestVerifier
(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, ExecutorService executor) Create a PayloadVerifier using a custom thread pool and a custom mapping -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
CheckAllFilesInPayloadDirAreListedInAllManifests
(Set<Manifest> payLoadManifests, Path payloadDir, boolean ignoreHiddenFiles) private static void
checkAllFilesInPayloadDirAreListedInAtLeastOneAManifest
(Set<Path> filesListedInManifests, Path payloadDir, boolean ignoreHiddenFiles) private void
void
close()
void
verifyManifests
(Bag bag, boolean ignoreHiddenFiles) Verify that all the files in the payload directory are listed in the payload manifest and all files listed in all manifests exist.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
messages
-
nameMapping
-
executor
-
-
Constructor Details
-
ManifestVerifier
public ManifestVerifier()Create a PayloadVerifier using a cached thread pool and theStandardBagitAlgorithmNameToSupportedAlgorithmMapping
mapping -
ManifestVerifier
Create a PayloadVerifier using a cached thread pool and a custom mapping- Parameters:
nameMapping
- the mapping between BagIt algorithm name and the java supported algorithm
-
ManifestVerifier
Create a PayloadVerifier using a custom thread pool and theStandardBagitAlgorithmNameToSupportedAlgorithmMapping
mapping- Parameters:
executor
- the thread pool to use when doing work
-
ManifestVerifier
public ManifestVerifier(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, ExecutorService executor) Create a PayloadVerifier using a custom thread pool and a custom mapping- Parameters:
nameMapping
- the mapping between BagIt algorithm name and the java supported algorithmexecutor
- the thread pool to use when doing work
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
SecurityException
-
verifyManifests
public void verifyManifests(Bag bag, boolean ignoreHiddenFiles) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException, FileNotInPayloadDirectoryException, InterruptedException Verify that all the files in the payload directory are listed in the payload manifest and all files listed in all manifests exist.- Parameters:
bag
- the bag to check to checkignoreHiddenFiles
- to ignore hidden files unless they are specifically listed in a manifest- Throws:
IOException
- if there is a problem reading a fileMaliciousPathException
- the path in the manifest was specifically crafted to cause harmUnsupportedAlgorithmException
- if the algorithm used for the manifest is unsupportedInvalidBagitFileFormatException
- if any of the manifests don't conform to the bagit specificationFileNotInPayloadDirectoryException
- if a file is listed in a manifest but doesn't exist in the payload directoryInterruptedException
- if a thread is interrupted while doing work
-
getAllFilesListedInManifests
private Set<Path> getAllFilesListedInManifests(Bag bag) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException -
checkAllFilesListedInManifestExist
private void checkAllFilesListedInManifestExist(Set<Path> files) throws FileNotInPayloadDirectoryException, InterruptedException -
checkAllFilesInPayloadDirAreListedInAtLeastOneAManifest
private static void checkAllFilesInPayloadDirAreListedInAtLeastOneAManifest(Set<Path> filesListedInManifests, Path payloadDir, boolean ignoreHiddenFiles) throws IOException - Throws:
IOException
-
CheckAllFilesInPayloadDirAreListedInAllManifests
private static void CheckAllFilesInPayloadDirAreListedInAllManifests(Set<Manifest> payLoadManifests, Path payloadDir, boolean ignoreHiddenFiles) throws IOException - Throws:
IOException
-