Skip to content

Commit

Permalink
check for super user context before archiving
Browse files Browse the repository at this point in the history
  • Loading branch information
ffritze committed Mar 11, 2024
1 parent 360d0ad commit 9ae0538
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4276,6 +4276,36 @@ public void processPublishButton() {
}
}
}

public void processArchiveButton() {
if (session.getUser().isSuperuser()) {
if (dataset.isReleased()) {
PrimeFaces.current().executeScript("PF('archiveDataset').show()");
}

if (!dataset.isReleased()) {
if (dataset.getOwner().isReleased()) {
PrimeFaces.current().executeScript("PF('archiveDataset').show()");
return;
}
if (!dataset.getOwner().isReleased()) {
if (canPublishDataverse()) {
if (dataset.getOwner().getOwner() == null
|| (dataset.getOwner().getOwner() != null && dataset.getOwner().getOwner().isReleased())) {
PrimeFaces.current().executeScript("PF('archiveDataset').show()");
return;
}
if ((dataset.getOwner().getOwner() != null && !dataset.getOwner().getOwner().isReleased())) {
PrimeFaces.current().executeScript("PF('maynotPublishParent').show()");
}

} else {
PrimeFaces.current().executeScript("PF('mayNotRelease').show()");
}
}
}
}
}

public boolean releaseDraftPopup(){
return dataset.isReleased();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ metrics.citations.dialog.header=Dataset Citations
metrics.citations.dialog.help=Citations for this dataset are retrieved from Crossref via DataCite using Make Data Count standards. For more information about dataset metrics, please refer to the <a href="{0}/{1}/user/dataset-management.html#dataset-metrics-and-make-data-count" title="Dataset Metrics and Make Data Count - Dataverse User Guide" target="_blank">User Guide</a>.
metrics.citations.dialog.empty=Sorry, no citations were found.
dataset.publish.btn=Publish
dataset.archive.btn=Archive
dataset.publish.header=Publish Dataset
dataset.rejectBtn=Return to Author
dataset.submitBtn=Submit for Review
Expand Down
8 changes: 8 additions & 0 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@
#{bundle['dataset.publish.btn']}
</p:commandLink>
</li>
<li jsf:rendered="#{showPublishLink}" class="#{DataverseSession.getUser().isSuperuser() and (!DatasetPage.hasValidTermsOfAccess or ( DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview)) ? 'disabled' : ''}">
<!-- Archive LINK -->
<p:commandLink styleClass="#{!DatasetPage.hasValidTermsOfAccess or (DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview) ? 'disabled' : ''}"
disabled="#{!DatasetPage.hasValidTermsOfAccess or (DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview)}"
action="#{DatasetPage.processArchiveButton()}">
#{bundle['dataset.archive.btn']}
</p:commandLink>
</li>
<li jsf:rendered="#{showSubmitForReviewLink}" class="#{DatasetPage.dataset.latestVersion.inReview or DatasetPage.dataset.locked ? 'disabled' : ''}">
<!-- Submit for Review LINK -->
<p:commandLink class="#{DatasetPage.dataset.latestVersion.inReview or DatasetPage.dataset.locked ? 'disabled' : ''}"
Expand Down

0 comments on commit 9ae0538

Please sign in to comment.