Package nl.knaw.dans.bagit.conformance
Class BagProfileChecker
java.lang.Object
nl.knaw.dans.bagit.conformance.BagProfileChecker
Responsible for checking a bag against a profile
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private static final ResourceBundle
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
bagConformsToProfile
(InputStream jsonProfile, Bag bag) Check a bag against a bagit-profile as described by https://github.com/ruebot/bagit-profiles
Note: This implementation does not check the Serialization part of the profile!private static void
checkFetch
(Path rootDir, boolean allowFetchFile, List<FetchItem> itemsToFetch) private static void
checkForAcceptableValues
(Metadata bagMetadata, Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement) private static void
checkForNoneRepeatableMetadata
(Metadata bagMetadata, Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement, boolean metadataContainsKey) private static void
checkIfMetadataEntryIsRequired
(Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement, boolean metadataContainsKey) private static void
checkMetadata
(Metadata bagMetadata, Map<String, BagInfoRequirement> bagInfoEntryRequirements) private static BagitProfile
parseBagitProfile
(InputStream jsonProfile) private static void
requiredManifestsExist
(Set<Manifest> manifests, List<String> requiredManifestTypes, boolean isPayloadManifest) private static void
requiredTagFilesExist
(Path rootDir, List<String> requiredTagFilePaths)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
messages
-
-
Constructor Details
-
BagProfileChecker
private BagProfileChecker()
-
-
Method Details
-
bagConformsToProfile
public static void bagConformsToProfile(InputStream jsonProfile, Bag bag) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException, FetchFileNotAllowedException, RequiredMetadataFieldNotPresentException, MetatdataValueIsNotAcceptableException, RequiredManifestNotPresentException, BagitVersionIsNotAcceptableException, RequiredTagFileNotPresentException, MetatdataValueIsNotRepeatableException Check a bag against a bagit-profile as described by https://github.com/ruebot/bagit-profiles
Note: This implementation does not check the Serialization part of the profile!- Parameters:
jsonProfile
- the input stream to the json string describing the profilebag
- the bag to check against the profile- Throws:
IOException
- if there is a problem reading the profilecom.fasterxml.jackson.databind.JsonMappingException
- if there is a problem mapping the profile to theBagitProfile
com.fasterxml.jackson.core.JsonParseException
- if there is a problem parsing the json while mapping to java objectFetchFileNotAllowedException
- if there is a fetch file when the profile prohibits itMetatdataValueIsNotAcceptableException
- if a metadata value is not in the list of acceptable valuesMetatdataValueIsNotRepeatableException
- if a metadata value shows up more than once when not repeatableRequiredMetadataFieldNotPresentException
- if a metadata field is not present but it should beRequiredManifestNotPresentException
- if a payload or tag manifest type is not present but should beBagitVersionIsNotAcceptableException
- if the version of the bag is not in the list of acceptable versionsRequiredTagFileNotPresentException
- if a tag file is not present but should be
-
parseBagitProfile
private static BagitProfile parseBagitProfile(InputStream jsonProfile) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException - Throws:
com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.databind.JsonMappingException
IOException
-
checkFetch
private static void checkFetch(Path rootDir, boolean allowFetchFile, List<FetchItem> itemsToFetch) throws FetchFileNotAllowedException - Throws:
FetchFileNotAllowedException
-
checkMetadata
private static void checkMetadata(Metadata bagMetadata, Map<String, BagInfoRequirement> bagInfoEntryRequirements) throws RequiredMetadataFieldNotPresentException, MetatdataValueIsNotAcceptableException, MetatdataValueIsNotRepeatableException -
checkIfMetadataEntryIsRequired
private static void checkIfMetadataEntryIsRequired(Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement, boolean metadataContainsKey) throws RequiredMetadataFieldNotPresentException -
checkForAcceptableValues
private static void checkForAcceptableValues(Metadata bagMetadata, Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement) throws MetatdataValueIsNotAcceptableException -
checkForNoneRepeatableMetadata
private static void checkForNoneRepeatableMetadata(Metadata bagMetadata, Map.Entry<String, BagInfoRequirement> bagInfoEntryRequirement, boolean metadataContainsKey) throws MetatdataValueIsNotRepeatableException -
requiredManifestsExist
private static void requiredManifestsExist(Set<Manifest> manifests, List<String> requiredManifestTypes, boolean isPayloadManifest) throws RequiredManifestNotPresentException -
requiredTagFilesExist
private static void requiredTagFilesExist(Path rootDir, List<String> requiredTagFilePaths) throws RequiredTagFileNotPresentException
-