Skip to content
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

as per the proposed spec, allow for payload-oxum to be in bagit.txt #80

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

johnscancella
Copy link
Contributor

values.encoding = encoding;
}
if("Payload-Byte-Count".equals(pair.getKey())){ //assume version is 1.0+
logger.debug("Payload-Byte-Count is [{}]", pair.getKey());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be getValue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and possibly the whole thing should be something like "{} is {}", pair.getKey(), pair.getValue()?

values.payloadByteCount = Long.valueOf(pair.getValue());
}
if("Payload-File-Count".equals(pair.getKey())){ //assume version is 1.0+
logger.debug("Payload-File-Count is [{}]", pair.getKey());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment for payload byte count


if(bag.getPayloadByteCount() != null && bag.getPayloadFileCount() != null){
logger.debug("Found payload byte and file count, using that instead of payload-oxum");
//TODO check if it matches payload-oxum, and if not issue warning?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on a warning - I was just looking to see what would happen if both are present or if they are and do not match. I would use the bagit.txt fields in preference but issue a validation error or possibly just a linter warning if Payload-Oxum doesn't match the more controlled fields.

@@ -41,5 +64,13 @@ public static void writeBagitFile(final Version version, final Charset encoding,
final String secondLine = "Tag-File-Character-Encoding : " + encoding + System.lineSeparator();
logger.debug("Writing line [{}] to [{}]", secondLine, bagitPath);
Files.write(bagitPath, secondLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE, StandardOpenOption.APPEND);

if(version.compareTo(ONE_DOT_ZERO) >= 0 && payloadByteCount != null && payloadFileCount != null){ //if it is 1.0 or greater
final String thirdLine = "Payload-Byte-Count : " + payloadByteCount + System.lineSeparator();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether now is the right time to fix the naming convention here - firstLine, et al. are making me itch a bit.

Also, looking at the Files.write code, this is repeatedly opening the same file with a bunch of redundant options and the getBytes calls are being repeated on every line as well. Could all of this be collapsed into a single array with 2-4 lines for a single Files.write call using the form which accepts text and the target output encoding?

@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage decreased (-0.05%) to 96.753% when pulling c837810 on migrate_payload_oxum into 87a33bc on master.

@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage decreased (-0.8%) to 96.008% when pulling 983bb66 on migrate_payload_oxum into 87a33bc on master.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage decreased (-0.8%) to 96.008% when pulling f3c1c81 on migrate_payload_oxum into 87a33bc on master.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage decreased (-0.7%) to 96.078% when pulling e451843 on migrate_payload_oxum into 87a33bc on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants