Package nl.knaw.dans.bagit.conformance
Class ManifestChecker
java.lang.Object
nl.knaw.dans.bagit.conformance.ManifestChecker
Part of the BagIt conformance suite.
This checker checks for various problems related to the manifests in a bag.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
private static final String
private static final org.slf4j.Logger
private static final ResourceBundle
private static final String
private static final String
private static final String
private static final String
private static final Version
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) static void
checkAlgorthm
(String algorithm, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) private static void
checkForBagWithinBag
(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, boolean isPayloadManifest) private static void
checkForDifferentCase
(String path, Set<String> paths, Path manifestFile, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) private static String
checkForManifestCreatedWithMD5SumTools
(String path, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) private static void
checkForOSSpecificFiles
(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, Path manifestFile) private static void
checkForRelativePaths
(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, Path manifestFile) private static boolean
checkManifest
(Path file, List<Path> payloadManifests, List<Path> tagManifests, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) private static void
checkManifestPayload
(Path manifestFile, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, boolean isPayloadManifest) static void
checkManifests
(Version version, Path bagitDir, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) Check for all the manifest specific potential problems(package private) static void
checkManifestSets
(Version version, List<Path> tagManifests, List<Path> payloadManifests, Set<BagitWarning> warnings, Charset encoding) (package private) static void
checkManifestsListSameSetOfFiles
(Set<BagitWarning> warnings, List<Path> manifestPaths, Charset charset) private static void
checkNormalization
(String path, Path rootDir, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) (package private) static String
(package private) static String
normalizePathToNFD
(Path path) (package private) static String
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
messages
-
THUMBS_DB_FILE
- See Also:
-
DS_STORE_FILE
- See Also:
-
SPOTLIGHT_FILE
- See Also:
-
TRASHES_FILE
- See Also:
-
FS_EVENTS_FILE
- See Also:
-
OS_FILES_REGEX
- See Also:
-
VERSION_1_0
-
-
Constructor Details
-
ManifestChecker
private ManifestChecker()
-
-
Method Details
-
checkManifests
public static void checkManifests(Version version, Path bagitDir, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) throws IOException, InvalidBagitFileFormatException, MaliciousPathException, UnsupportedAlgorithmException Check for all the manifest specific potential problems- Parameters:
version
- the version of the bag we are checkingbagitDir
- the directory where the manifests are storedencoding
- the encoding of the manifestswarnings
- the set of warnings that will be appended to while checkingwarningsToIgnore
- the set of warnings to ignore- Throws:
IOException
- if there is a problem reading a file (because it doesn't exist)InvalidBagitFileFormatException
- if one (or more) of the files does not match the formatting as specified in the specificationMaliciousPathException
- if someone crafted the bag to specifically try and write outside the bag directoryUnsupportedAlgorithmException
- if a manifest uses an algorithm that the computer doesn't know how to use
-
checkManifest
private static boolean checkManifest(Path file, List<Path> payloadManifests, List<Path> tagManifests, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) throws IOException, InvalidBagitFileFormatException -
checkManifestPayload
private static void checkManifestPayload(Path manifestFile, Charset encoding, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, boolean isPayloadManifest) throws IOException, InvalidBagitFileFormatException -
parsePath
- Throws:
InvalidBagitFileFormatException
-
checkForManifestCreatedWithMD5SumTools
private static String checkForManifestCreatedWithMD5SumTools(String path, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) -
checkForDifferentCase
private static void checkForDifferentCase(String path, Set<String> paths, Path manifestFile, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) -
checkNormalization
private static void checkNormalization(String path, Path rootDir, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) throws IOException - Throws:
IOException
-
normalizePathToNFD
-
checkForBagWithinBag
private static void checkForBagWithinBag(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, boolean isPayloadManifest) -
checkForRelativePaths
private static void checkForRelativePaths(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, Path manifestFile) -
checkForOSSpecificFiles
private static void checkForOSSpecificFiles(String line, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore, Path manifestFile) -
checkAlgorthm
static void checkAlgorthm(String algorithm, Set<BagitWarning> warnings, Collection<BagitWarning> warningsToIgnore) -
checkManifestSets
static void checkManifestSets(Version version, List<Path> tagManifests, List<Path> payloadManifests, Set<BagitWarning> warnings, Charset encoding) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException -
checkManifestsListSameSetOfFiles
static void checkManifestsListSameSetOfFiles(Set<BagitWarning> warnings, List<Path> manifestPaths, Charset charset) throws IOException, MaliciousPathException, UnsupportedAlgorithmException, InvalidBagitFileFormatException -
getOsFilesRegex
-