Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public void setSelectedHostDataverse(Dataverse selectedHostDataverse) {
private boolean showIngestSuccess;

private Boolean archivable = null;
private Boolean versionArchivable = null;
private HashMap<Long,Boolean> versionArchivable = new HashMap<>();
private Boolean someVersionArchived = null;

public boolean isShowIngestSuccess() {
Expand Down Expand Up @@ -6147,31 +6147,45 @@ public boolean isArchivable() {
return archivable;
}

public boolean isVersionArchivable() {
if (versionArchivable == null) {
/** 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
versionArchivable = 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");
Copy link
Contributor

Choose a reason for hiding this comment

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

@qqmyers When I try to run this I'm getting a No Such Method Exception on supportsDelete. I've set up my local to use LocalSubmitToArchiveCommand. It's unclear why we're checking for this method or what needs to be done in the setup to get it. Bottom Line is that versionArchivable is always returning false so I'm not seeing the submit button.

Copy link
Member Author

@qqmyers qqmyers Feb 19, 2026

Choose a reason for hiding this comment

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

Sorry, it's an error in me trying to pull things apart for review - supportsDelete is part of #12103. I could drop it here, but I might suggest trying to run #12167 instead which has all the merged changes. (The idea at this point is to review all the PRs like this and not merge them, instead QAing and then merging #12167. So I could add a commit here to remove the supportsDelete part as long as that's never getting merged in the end, but any testing of functionality you do on this one would need to be repeated on the combined one.) Let me know if you want this one cleaned up.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. thanks. I'll go back and take them in order.


Object[] params = { settingsWrapper };
boolean supportsDelete = (Boolean) m2.invoke(null);
checkForArchivalCopy = (Boolean) m.invoke(null, params);

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) {
Expand All @@ -6180,8 +6194,9 @@ public boolean isVersionArchivable() {
}
}
}
versionArchivable.put(id, thisVersionArchivable);
}
return versionArchivable;
return thisVersionArchivable;
}

public boolean isSomeVersionArchived() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/dataset-versions.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@
</ui:fragment>
<h:outputText value="#{bundle['file.dataFilesTab.versions.headers.archived.pending']}" rendered="#{'pending' eq versionTab.archivalCopyLocationStatus}" title="#{DatasetPage.isSuperUser() ? versionTab.archivalCopyLocationMessage : ''}"/>
<h:outputText value="#{bundle['file.dataFilesTab.versions.headers.archived.failure']}" rendered="#{'failure' eq versionTab.archivalCopyLocationStatus}" title="#{DatasetPage.isSuperUser() ? versionTab.archivalCopyLocationMessage : ''}"/>
<p:commandLink rendered="#{DatasetPage.isSuperUser() and DatasetPage.versionArchivable and empty(versionTab.archivalCopyLocation)}" update="#{p:resolveClientId('datasetForm:tabView:versionsTable', view)},:messagePanel"
<p:commandLink rendered="#{DatasetPage.isSuperUser() and DatasetPage.isVersionArchivable(versionTab.id) and empty(versionTab.archivalCopyLocation)}" update="#{p:resolveClientId('datasetForm:tabView:versionsTable', view)},:messagePanel"
action="#{DatasetPage.archiveVersion(versionTab.id)}">
<h:outputText value="#{bundle['file.dataFilesTab.versions.headers.archived.submit']}"/>
</p:commandLink>
<h:outputText value="#{bundle['file.dataFilesTab.versions.headers.archived.notarchived']}" rendered="#{ empty(versionTab.archivalCopyLocation) and ((not DatasetPage.isSuperUser() and DatasetPage.someVersionArchived) or (DatasetPage.isSuperUser() and not DatasetPage.versionArchivable))}"/>
<h:outputText value="#{bundle['file.dataFilesTab.versions.headers.archived.notarchived']}" rendered="#{ empty(versionTab.archivalCopyLocation) and ((not DatasetPage.isSuperUser() and DatasetPage.someVersionArchived) or (DatasetPage.isSuperUser() and not DatasetPage.isVersionArchivable(versionTab.id)))}"/>

</ui:fragment>
</p:column><!-- end: archivalCopy column -->
Expand Down