diff --git a/src/main/java/gov/loc/repository/bagit/conformance/profile/BagitProfileDeserializer.java b/src/main/java/gov/loc/repository/bagit/conformance/profile/BagitProfileDeserializer.java index 6934be65b..3d48bec68 100644 --- a/src/main/java/gov/loc/repository/bagit/conformance/profile/BagitProfileDeserializer.java +++ b/src/main/java/gov/loc/repository/bagit/conformance/profile/BagitProfileDeserializer.java @@ -65,11 +65,24 @@ public BagitProfile deserialize(final JsonParser p, final DeserializationContext } private static void parseBagitProfileInfo(final JsonNode node, final BagitProfile profile) { - final JsonNode bagitProfileInfoNode = node.get("BagIt-Profile-Info"); logger.debug(messages.getString("parsing_bagit_profile_info_section")); + + final JsonNode bagitProfileInfoNode = node.get("BagIt-Profile-Info"); + parseMandatoryTagsOfBagitProfileInfo(bagitProfileInfoNode, profile); + parseOptionalTagsOfBagitProfileInfo(bagitProfileInfoNode, profile); + } - // Read required tags - // due to specification defined at https://github.com/bagit-profiles/bagit-profiles + /** + * Parse required tags due to specification defined at + * {@link https://github.com/bagit-profiles/bagit-profiles} + * Note: If one of the tags is missing, a NullPointerException is thrown. + * + * @param bagitProfileInfoNode Root node of the bagit profile info section. + * @param profile Representation of bagit profile. + */ + private static void parseMandatoryTagsOfBagitProfileInfo(final JsonNode bagitProfileInfoNode, final BagitProfile profile) { + logger.debug(messages.getString("parsing_mandatory_tags_of_bagit_profile_info_section")); + final String profileIdentifier = bagitProfileInfoNode.get("BagIt-Profile-Identifier").asText(); logger.debug(messages.getString("identifier"), profileIdentifier); profile.setBagitProfileIdentifier(profileIdentifier); @@ -85,8 +98,18 @@ private static void parseBagitProfileInfo(final JsonNode node, final BagitProfil final String version = bagitProfileInfoNode.get("Version").asText(); logger.debug(messages.getString("version"), version); profile.setVersion(version); + } + + /** + * Parse optional tags due to specification defined at + * {@link https://github.com/bagit-profiles/bagit-profiles} + * + * @param bagitProfileInfoNode Root node of the bagit profile info section. + * @param profile Representation of bagit profile . + */ + private static void parseOptionalTagsOfBagitProfileInfo(final JsonNode bagitProfileInfoNode, final BagitProfile profile) { + logger.debug(messages.getString("parsing_optional_tags_of_bagit_profile_info_section")); - // Read optional tags final JsonNode contactNameNode = bagitProfileInfoNode.get("Contact-Name"); if (contactNameNode != null) { final String contactName = contactNameNode.asText(); diff --git a/src/main/resources/MessageBundle.properties b/src/main/resources/MessageBundle.properties index a77720d16..e8e1a3701 100644 --- a/src/main/resources/MessageBundle.properties +++ b/src/main/resources/MessageBundle.properties @@ -4,6 +4,8 @@ fetch_allowed=Are fetch files allowed? [{}] serialization_allowed=Serialization is: [{}] parsing_bagit_profile_info_section=Parsing the BagIt-Profile-Info section +parsing_mandatory_tags_of_bagit_profile_info_section=Parsing mandatory tags of the BagIt-Profile-Info section +parsing_optional_tags_of_bagit_profile_info_section=Parsing optional tags of the BagIt-Profile-Info section identifier=Identifier is [{}] source_organization=Source-Organization is [{}] contact_name=Contact-Name is [{}] diff --git a/src/main/resources/MessageBundle_ar.properties b/src/main/resources/MessageBundle_ar.properties index 4bb857652..81353903e 100644 --- a/src/main/resources/MessageBundle_ar.properties +++ b/src/main/resources/MessageBundle_ar.properties @@ -5,6 +5,8 @@ fetch_allowed=Are fetch files allowed? [{}] serialization_allowed=Serialization is\: [{}] parsing_bagit_profile_info_section=Parsing the BagIt-Profile-Info section +parsing_mandatory_tags_of_bagit_profile_info_section=Parsing mandatory tags of the BagIt-Profile-Info section +parsing_optional_tags_of_bagit_profile_info_section=Parsing optional tags of the BagIt-Profile-Info section identifier=Identifier is [{}] source_organization=Source-Organization is [{}] contact_name=Contact-Name is [{}] diff --git a/src/main/resources/MessageBundle_de_DE.properties b/src/main/resources/MessageBundle_de_DE.properties index a0a29095b..7386be7f6 100644 --- a/src/main/resources/MessageBundle_de_DE.properties +++ b/src/main/resources/MessageBundle_de_DE.properties @@ -4,6 +4,8 @@ fetch_allowed=Sind Fetch Dateien erlaubt? [{}] serialization_allowed=Serialisierung ist: [{}] parsing_bagit_profile_info_section=Lese Abschnitt BagIt-Profile-Info +parsing_mandatory_tags_of_bagit_profile_info_section=Parse die ben\u00f6tigten Tags im Abschnitt BagIt-Profile-Info +parsing_optional_tags_of_bagit_profile_info_section=Parse die optionalen Tags im Abschnitt BagIt-Profile-Info identifier=Identifier hat den Wert [{}] source_organization=Source-Organization hat den Wert [{}] contact_name=Contact-Name hat den Wert [{}] diff --git a/src/main/resources/MessageBundle_es_ES.properties b/src/main/resources/MessageBundle_es_ES.properties index 16f23fd86..38af9cee7 100644 --- a/src/main/resources/MessageBundle_es_ES.properties +++ b/src/main/resources/MessageBundle_es_ES.properties @@ -5,6 +5,8 @@ fetch_allowed=\u00bfSe permiten archivos de recuperaci\u00f3n? [{}] serialization_allowed=Serializaci\u00f3n es\: [{}] parsing_bagit_profile_info_section=An\u00e1lisis de la secci\u00f3n de informaci\u00f3n de perfil BagIt +parsing_mandatory_tags_of_bagit_profile_info_section=An\u00e1lisis de las etiquetas obligatorias de la secci\u00f3n de informaci\u00f3n de perfil BagIt +parsing_optional_tags_of_bagit_profile_info_section=An\u00e1lisis de las etiquetas opcionales de la secci\u00f3n de informaci\u00f3n de perfil BagIt identifier=Identificador es [{}] source_organization=Organizaci\u00f3n de la fuente es [{}] contact_name=Nombre del contacto es [{}] diff --git a/src/main/resources/MessageBundle_zh.properties b/src/main/resources/MessageBundle_zh.properties index 4bb857652..81353903e 100644 --- a/src/main/resources/MessageBundle_zh.properties +++ b/src/main/resources/MessageBundle_zh.properties @@ -5,6 +5,8 @@ fetch_allowed=Are fetch files allowed? [{}] serialization_allowed=Serialization is\: [{}] parsing_bagit_profile_info_section=Parsing the BagIt-Profile-Info section +parsing_mandatory_tags_of_bagit_profile_info_section=Parsing mandatory tags of the BagIt-Profile-Info section +parsing_optional_tags_of_bagit_profile_info_section=Parsing optional tags of the BagIt-Profile-Info section identifier=Identifier is [{}] source_organization=Source-Organization is [{}] contact_name=Contact-Name is [{}]