Package nl.knaw.dans.bagit.reader
Class ManifestReader
java.lang.Object
nl.knaw.dans.bagit.reader.ManifestReader
This class is responsible for reading and parsing manifest files on the filesystem
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private static final ResourceBundle
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static DirectoryStream<Path>
getAllManifestFiles
(Path rootDir) (package private) static void
readAllManifests
(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, Path rootDir, Bag bag) Finds and reads all manifest files in the rootDir and adds them to the given bag.readChecksumFileMap
(Path manifestFile, Path bagRootDir, Charset charset) static Manifest
readManifest
(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, Path manifestFile, Path bagRootDir, Charset charset) Reads a manifest file and converts it to aManifest
object.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
messages
-
-
Constructor Details
-
ManifestReader
private ManifestReader()
-
-
Method Details
-
readAllManifests
static void readAllManifests(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, Path rootDir, Bag bag) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException Finds and reads all manifest files in the rootDir and adds them to the given bag.- Parameters:
nameMapping
- a map between BagIt algorithm names andMessageDigest
namesrootDir
- the directory that contain the manifest(s)bag
- to update with the manifests- Throws:
IOException
- if there is a problem reading a fileMaliciousPathException
- 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 properly
-
getAllManifestFiles
- Throws:
IOException
-
readManifest
public static Manifest readManifest(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, Path manifestFile, Path bagRootDir, Charset charset) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException Reads a manifest file and converts it to aManifest
object.- Parameters:
nameMapping
- a map between BagIt algorithm names andMessageDigest
namesmanifestFile
- a specific manifest filebagRootDir
- the root directory of the bagcharset
- the encoding to use when reading the manifest file- Returns:
- the converted manifest object from the file
- Throws:
IOException
- if there is a problem reading a fileMaliciousPathException
- 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 properly
-
readChecksumFileMap
static Map<Path,String> readChecksumFileMap(Path manifestFile, Path bagRootDir, Charset charset) throws IOException, MaliciousPathException, InvalidBagitFileFormatException
-