From dcc059b27507b6ab46637dae7a801686f9c33da0 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 16 Dec 2025 10:35:40 -0500 Subject: [PATCH 1/2] archival submit fix - per version cache --- .../edu/harvard/iq/dataverse/DatasetPage.java | 28 +++++++++++++------ src/main/webapp/dataset-versions.xhtml | 4 +-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 20617160a1c..8eba6cbeab9 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -387,7 +387,7 @@ public void setSelectedHostDataverse(Dataverse selectedHostDataverse) { private boolean showIngestSuccess; private Boolean archivable = null; - private Boolean versionArchivable = null; + private HashMap versionArchivable = new HashMap<>(); private Boolean someVersionArchived = null; public boolean isShowIngestSuccess() { @@ -6147,10 +6147,11 @@ public boolean isArchivable() { return archivable; } - public boolean isVersionArchivable() { - if (versionArchivable == null) { + public boolean isVersionArchivable(Long id) { + Boolean thisVersionArchivable = versionArchivable.get(id); + if (thisVersionArchivable == null) { // If this dataset isn't in an archivable collection return false - versionArchivable = false; + thisVersionArchivable = false; if (isArchivable()) { boolean checkForArchivalCopy = false; // Otherwise, we need to know if the archiver is single-version-only @@ -6167,11 +6168,19 @@ public boolean isVersionArchivable() { if (checkForArchivalCopy) { // If we have to check (single version archiving), we can't allow archiving if // one version is already archived (or attempted - any non-null status) - versionArchivable = !isSomeVersionArchived(); + thisVersionArchivable = !isSomeVersionArchived(); } else { - // If we allow multiple versions or didn't find one that has had archiving run - // on it, we can archive, so return true - versionArchivable = true; + // If we didn't find one that has had archiving run + // on it, or archiving per version is supported and either + // the status is null or the archiver can delete prior runs and status isn't success, + // we can archive, so return true + // Find the specific version by id + DatasetVersion targetVersion = dataset.getVersions().stream() + .filter(v -> v.getId().equals(id)) + .findFirst() + .orElse(null); + String status = targetVersion.getArchivalCopyLocationStatus(); + thisVersionArchivable = (status == null) || ((!status.equals(DatasetVersion.ARCHIVAL_STATUS_SUCCESS) && (!status.equals(DatasetVersion.ARCHIVAL_STATUS_PENDING)) && supportsDelete)); } } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { @@ -6180,8 +6189,9 @@ public boolean isVersionArchivable() { } } } + versionArchivable.put(id, thisVersionArchivable); } - return versionArchivable; + return thisVersionArchivable; } public boolean isSomeVersionArchived() { diff --git a/src/main/webapp/dataset-versions.xhtml b/src/main/webapp/dataset-versions.xhtml index 9e5f0a9b24d..ee726bb5eee 100644 --- a/src/main/webapp/dataset-versions.xhtml +++ b/src/main/webapp/dataset-versions.xhtml @@ -171,11 +171,11 @@ - - + From ad0476ad7927016bbed38caa0c57695bee5b70e0 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jan 2026 17:54:41 -0500 Subject: [PATCH 2/2] missing code to get supportsDelete --- src/main/java/edu/harvard/iq/dataverse/DatasetPage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 8eba6cbeab9..042bcc5a0e7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -6147,22 +6147,27 @@ public boolean isArchivable() { return archivable; } + /** Method to decide if a 'Submit' button should be enabled for archiving a dataset version. */ public boolean isVersionArchivable(Long id) { Boolean thisVersionArchivable = versionArchivable.get(id); if (thisVersionArchivable == null) { // If this dataset isn't in an archivable collection return false thisVersionArchivable = false; if (isArchivable()) { - boolean checkForArchivalCopy = false; + // Otherwise, we need to know if the archiver is single-version-only // If it is, we have to check for an existing archived version to answer the // question String className = settingsWrapper.getValueForKey(SettingsServiceBean.Key.ArchiverClassName, null); if (className != null) { try { + boolean checkForArchivalCopy = false; Class clazz = Class.forName(className); Method m = clazz.getMethod("isSingleVersion", SettingsWrapper.class); + Method m2 = clazz.getMethod("supportsDelete"); + Object[] params = { settingsWrapper }; + boolean supportsDelete = (Boolean) m2.invoke(null); checkForArchivalCopy = (Boolean) m.invoke(null, params); if (checkForArchivalCopy) {