-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapt parsing Bagit Profile due to specification. #128
base: master
Are you sure you want to change the base?
Conversation
…/bagit-profiles/bagit-profiles) Inclusion of "Contact-Name," "Contact-Phone" and "Contact-Email," as defined in the BagIt spec, is not required but is encouraged. -> Add "Contact-Phone" -> "Contact-Name" and "Contact-Email" are now optional Add test for minimal profile Adapt other tests. Bag-Info: The parameters "required" is 'false' and "repeatable" is 'true' by default. Changed implementation accordingly. ("repeatable": Not used yet inside the library!?)
|
||
|
||
// Read required tags first | ||
// due to specification defined at https://github.com/bagit-profiles/bagit-profiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure what this comment means. Why do you need to read required tags first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First the required tags are read and then the optional tags because they have to be handled differently. It's just to keep the code clearer.
If one of the required ones do not already exist, the optional ones are no longer read at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless there is an error being thrown that I don't know about, how are you stopping if a required tag is missing? To put it another way, what would break if you moved those if not null
statements to being read first?
Perhaps a better way to make it cleaner would be to make another method that contained all the reads for optional tags. Something like
final JsonNode contactNameNode = bagitProfileInfoNode.get("Contact-Name");
if (contactNameNode != null) {
final String contactName = contactNameNode.asText();
logger.debug(messages.getString("contact_name"), contactName);
profile.setContactName(contactName);
}
final JsonNode contactEmailNode = bagitProfileInfoNode.get("Contact-Email");
if (contactEmailNode != null) {
final String contactEmail = contactEmailNode.asText();
logger.debug(messages.getString("contact_email"), contactEmail);
profile.setContactEmail(contactEmail);
}
final JsonNode contactPhoneNode = bagitProfileInfoNode.get("Contact-Phone");
if (contactPhoneNode != null) {
final String contactPhone = contactPhoneNode.asText();
logger.debug(messages.getString("contact_phone"), contactPhone);
profile.setContactPhone(contactPhone);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If one of the required tags is not present, a NullPointerException is thrown.
final String profileIdentifier = bagitProfileInfoNode.get("BagIt-Profile-Identifier").asText();
See documentation of class BagLinter:
This class is only to be used on VALID bags, using it on un-validated bags may result in
exceptions being thrown (like {@link java.io.IOException} )
Therefore, no error handling is done anywhere in the code.
src/main/java/gov/loc/repository/bagit/conformance/profile/BagInfoRequirement.java
Show resolved
Hide resolved
Awesome work! I had a couple questions but overall really great work |
@jscancella: Have you seen my changes yet? It would be great if you'd take a look at them. |
Looks good to me. Now you just need someone at LC to merge it |
@acdha It'd be great if you could merge the code. |
@VolkerHartmann I'm not a member of this particular repository |
Who is currently maintaining bagit-java at @LibraryOfCongress? #125 and #128 seem ready for merging but the discussion sort of fizzled out. Is there some way to help out with testing/deployment etc.? |
@kba I suspect after I left the answer is no one. |
Adapt parsing Bagit Profile due to specification. (https://github.com/bagit-profiles/bagit-profiles)
Inclusion of "Contact-Name," "Contact-Phone" and "Contact-Email," as defined in the BagIt spec, is not required but is encouraged.
-> Add "Contact-Phone"
-> "Contact-Name" and "Contact-Email" are now optional
Add test for minimal profile
Adapt other tests.
Bag-Info:
The parameters "required" is 'false' and "repeatable" is 'true' by default.
Changed implementation accordingly.
("repeatable": Not used yet inside the library!?)
Please ensure you have completed the following before submitting:
Note: you can complete both boxes by running and fixing warnings/errors with
gradle clean check