use of gov.loc.repository.bagit.exceptions.conformance.RequiredManifestNotPresentException in project bagit-java by LibraryOfCongress.
the class BagProfileChecker method requiredManifestsExist.
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static void requiredManifestsExist(final Set<Manifest> manifests, final List<String> requiredManifestTypes, final boolean isPayloadManifest) throws RequiredManifestNotPresentException {
final Set<String> manifestTypesPresent = new HashSet<>();
logger.debug(messages.getString("check_required_manifests_present"));
for (final Manifest manifest : manifests) {
manifestTypesPresent.add(manifest.getAlgorithm().getBagitName());
}
for (final String requiredManifestType : requiredManifestTypes) {
if (!manifestTypesPresent.contains(requiredManifestType)) {
final StringBuilder sb = new StringBuilder();
if (isPayloadManifest) {
sb.append("tag");
sb.append(MessageFormatter.format(messages.getString("required_tag_manifest_type_not_present"), requiredManifestType).getMessage());
} else {
sb.append(MessageFormatter.format(messages.getString("required_manifest_type_not_present"), requiredManifestType).getMessage());
}
throw new RequiredManifestNotPresentException(sb.toString());
}
}
}
Aggregations