From c2f52cb2532011d998e367c335ebd2b78a2e6136 Mon Sep 17 00:00:00 2001 From: Mark Patton Date: Thu, 2 Nov 2023 15:14:22 -0400 Subject: [PATCH] Update the file name for the NIHMS package to indicate the latest bulk submission spec. Also cleanup the file name generation. --- .../deposit/provider/nihms/NihmsAssembler.java | 17 +++-------------- .../provider/nihms/NihmsAssemblerIT.java | 6 +++--- .../nihms/NihmsMetadataSerializerTest.java | 6 ++++-- .../provider/nihms/NihmsThreadedAssemblyIT.java | 4 ++-- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssembler.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssembler.java index 602de4e9..d999c0e1 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssembler.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssembler.java @@ -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; @@ -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. @@ -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(); diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerIT.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerIT.java index 87a2cd8f..6b96194e 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerIT.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerIT.java @@ -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; @@ -78,7 +78,7 @@ public void setUp() throws Exception { protected Map 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); } @@ -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()); } diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializerTest.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializerTest.java index 9c9e4a26..772d1860 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializerTest.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializerTest.java @@ -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; @@ -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(); @@ -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); diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsThreadedAssemblyIT.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsThreadedAssemblyIT.java index 4475065c..9ee2bbb5 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsThreadedAssemblyIT.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsThreadedAssemblyIT.java @@ -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; @@ -41,7 +41,7 @@ protected AbstractAssembler assemblerUnderTest() { protected Map 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));