Skip to content

Commit

Permalink
Update the file name for the NIHMS package to indicate the latest bul…
Browse files Browse the repository at this point in the history
…k submission spec. Also cleanup the file name generation.
  • Loading branch information
markpatton authored and rpoet-jh committed Nov 6, 2023
1 parent c7dd7fb commit c2f52cb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

import static org.eclipse.pass.deposit.assembler.AssemblerSupport.buildMetadata;

import java.net.URI;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.eclipse.pass.deposit.assembler.AbstractAssembler;
import org.eclipse.pass.deposit.assembler.ArchivingPackageStream;
Expand All @@ -45,7 +43,7 @@ public class NihmsAssembler extends AbstractAssembler {
* Package specification URI identifying the NIHMS native packaging spec, as specified by their 07/2017
* bulk publishing pdf.
*/
public static final String SPEC_NIHMS_NATIVE_2017_07 = "nihms-native-2017-07";
public static final String SPEC_NIHMS_NATIVE_2022_05 = "nihms-native-2022-05";

/**
* Mime type of zip files.
Expand Down Expand Up @@ -81,20 +79,11 @@ protected PackageStream createPackageStream(DepositSubmission submission,
}

static void namePackage(DepositSubmission submission, MetadataBuilder mb) {
String submissionUuid = null;

try {
URI submissionUri = URI.create(submission.getId());
submissionUuid = submissionUri.getPath().substring(submissionUri.getPath().lastIndexOf("/") + 1);
} catch (Exception e) {
submissionUuid = UUID.randomUUID().toString();
}

String packageFileName = String.format(PACKAGE_FILE_NAME,
SPEC_NIHMS_NATIVE_2017_07,
SPEC_NIHMS_NATIVE_2022_05,
ZonedDateTime.now()
.format(DateTimeFormatter.ofPattern("uuuu-MM-dd_HH-MM-ss")),
submissionUuid);
submission.getId());

StringBuilder ext = new StringBuilder(packageFileName);
PackageStream.Metadata md = mb.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.eclipse.pass.deposit.provider.nihms;

import static org.eclipse.pass.deposit.provider.nihms.NihmsAssembler.APPLICATION_GZIP;
import static org.eclipse.pass.deposit.provider.nihms.NihmsAssembler.SPEC_NIHMS_NATIVE_2017_07;
import static org.eclipse.pass.deposit.provider.nihms.NihmsAssembler.SPEC_NIHMS_NATIVE_2022_05;
import static org.eclipse.pass.deposit.util.DepositTestUtil.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void setUp() throws Exception {
protected Map<String, Object> getOptions() {
return new HashMap<>() {
{
put(Spec.KEY, SPEC_NIHMS_NATIVE_2017_07);
put(Spec.KEY, SPEC_NIHMS_NATIVE_2022_05);
put(Archive.KEY, Archive.OPTS.TAR);
put(Compression.KEY, Compression.OPTS.GZIP);
}
Expand All @@ -101,7 +101,7 @@ protected void verifyStreamMetadata(PackageStream.Metadata metadata) {
assertEquals(Compression.OPTS.GZIP, metadata.compression());
assertEquals(Archive.OPTS.TAR, metadata.archive());
assertTrue(metadata.archived());
assertEquals(SPEC_NIHMS_NATIVE_2017_07, metadata.spec());
assertEquals(SPEC_NIHMS_NATIVE_2022_05, metadata.spec());
assertEquals(APPLICATION_GZIP, metadata.mimeType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -102,6 +103,7 @@ public void setup() throws Exception {

// populate article metadata
article.setDoi(URI.create("10.1234/smh0000001"));
article.setEmbargoLiftDate(ZonedDateTime.now().plusYears(100));

//populate persons
DepositMetadata.Person person1 = new DepositMetadata.Person();
Expand All @@ -114,8 +116,8 @@ public void setup() throws Exception {

// Enter the first person twice, as both an author and a PI
DepositMetadata.Person person1a = new DepositMetadata.Person(person1);
person1.setType(DepositMetadata.PERSON_TYPE.pi);
personList.add(person1);
person1a.setType(DepositMetadata.PERSON_TYPE.pi);
personList.add(person1a);

DepositMetadata.Person person2 = new DepositMetadata.Person();
person2.setType(DepositMetadata.PERSON_TYPE.submitter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.eclipse.pass.deposit.provider.nihms;

import static java.util.Collections.singletonList;
import static org.eclipse.pass.deposit.provider.nihms.NihmsAssembler.SPEC_NIHMS_NATIVE_2017_07;
import static org.eclipse.pass.deposit.provider.nihms.NihmsAssembler.SPEC_NIHMS_NATIVE_2022_05;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -41,7 +41,7 @@ protected AbstractAssembler assemblerUnderTest() {
protected Map<String, Object> packageOptions() {
return new HashMap<>() {
{
put(PackageOptions.Spec.KEY, SPEC_NIHMS_NATIVE_2017_07);
put(PackageOptions.Spec.KEY, SPEC_NIHMS_NATIVE_2022_05);
put(PackageOptions.Archive.KEY, PackageOptions.Archive.OPTS.TAR);
put(PackageOptions.Compression.KEY, PackageOptions.Compression.OPTS.GZIP);
put(PackageOptions.Checksum.KEY, singletonList(PackageOptions.Checksum.OPTS.SHA256));
Expand Down

0 comments on commit c2f52cb

Please sign in to comment.