Skip to content

Commit

Permalink
Split the parsing of the BagIt-Profile-Info section into mandatory an…
Browse files Browse the repository at this point in the history
…d optional tags.
  • Loading branch information
Volker Hartmann committed Nov 15, 2018
1 parent f2e4ab1 commit e6ce9a7
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/MessageBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/MessageBundle_ar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/MessageBundle_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/MessageBundle_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/MessageBundle_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 [{}]
Expand Down

0 comments on commit e6ce9a7

Please # to comment.