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
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final ResourceBundle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static DirectoryStream<Path>getAllManifestFiles(Path rootDir) (package private) static voidreadAllManifests(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 ManifestreadManifest(BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping, Path manifestFile, Path bagRootDir, Charset charset) Reads a manifest file and converts it to aManifestobject.
-
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 andMessageDigestnamesrootDir- 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 aManifestobject.- Parameters:
nameMapping- a map between BagIt algorithm names andMessageDigestnamesmanifestFile- 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
-