From 57ef136e8ecfe193bdaf43b54e0bc36fb630c3ab Mon Sep 17 00:00:00 2001 From: sol Date: Wed, 3 May 2017 19:44:30 +0300 Subject: [PATCH] Adjustment on Deaccession and Destroy commands Deaccession command refered to the correct bundle item deleteIdentfier method called by Destroy command --- src/main/java/Bundle.properties | 2 +- .../command/impl/DeaccessionDatasetVersionCommand.java | 8 ++++++-- .../engine/command/impl/DestroyDatasetCommand.java | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/Bundle.properties b/src/main/java/Bundle.properties index 79fbc0e2c58..87f52c18323 100755 --- a/src/main/java/Bundle.properties +++ b/src/main/java/Bundle.properties @@ -1126,7 +1126,7 @@ dataset.share.datasetShare.tip=Share this dataset on your favorite social media dataset.share.datasetShare.shareText=View this dataset. dataset.publish.error=This dataset may not be published because the {0} Service is currently inaccessible. Please try again. Does the issue continue to persist? dataset.publish.error.doi=This dataset may not be published because the DOI update failed. -dataset.delete.error.datacite=Could not deaccession the dataset because the DOI update failed. +dataset.delete.error=Could not deaccession the dataset because the {0} update failed. dataset.versionUI.draft=Draft dataset.versionUI.inReview=In Review diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeaccessionDatasetVersionCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeaccessionDatasetVersionCommand.java index e43f1379dd7..8168bd6b324 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeaccessionDatasetVersionCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeaccessionDatasetVersionCommand.java @@ -20,6 +20,8 @@ import edu.harvard.iq.dataverse.export.ExportException; import edu.harvard.iq.dataverse.export.ExportService; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; +import edu.harvard.iq.dataverse.util.BundleUtil; +import java.util.ArrayList; import java.util.ResourceBundle; import java.util.logging.Logger; import java.util.logging.Level; @@ -53,6 +55,8 @@ public DatasetVersion execute(CommandContext ctxt) throws CommandException { if (deleteDOIIdentifier) { String nonNullDefaultIfKeyNotFound = ""; String protocol = ctxt.settings().getValueForKey(SettingsServiceBean.Key.Protocol, nonNullDefaultIfKeyNotFound); + ArrayList currentProtocol = new ArrayList<>(); + currentProtocol.add(protocol); IdServiceBean idServiceBean = IdServiceBean.getBean(ctxt); logger.fine("protocol=" + protocol); @@ -60,9 +64,9 @@ public DatasetVersion execute(CommandContext ctxt) throws CommandException { idServiceBean.deleteIdentifier(ds); } catch (Exception e) { if (e.toString().contains("Internal Server Error")) { - throw new CommandException(ResourceBundle.getBundle("Bundle").getString("dataset.publish.error.datacite"), this); + throw new CommandException(BundleUtil.getStringFromBundle("dataset.publish.error", idServiceBean.getProviderInformation()),this); } - throw new CommandException(ResourceBundle.getBundle("Bundle").getString("dataset.delete.error.datacite"), this); + throw new CommandException(BundleUtil.getStringFromBundle("dataset.delete.error", currentProtocol),this); } } DatasetVersion managed = ctxt.em().merge(theVersion); diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DestroyDatasetCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DestroyDatasetCommand.java index b0aecaf10e4..bc1ce5c542c 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DestroyDatasetCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DestroyDatasetCommand.java @@ -3,6 +3,7 @@ import edu.harvard.iq.dataverse.DataFile; import edu.harvard.iq.dataverse.Dataset; import edu.harvard.iq.dataverse.Dataverse; +import edu.harvard.iq.dataverse.IdServiceBean; import edu.harvard.iq.dataverse.authorization.DataverseRole; import edu.harvard.iq.dataverse.search.IndexServiceBean; import edu.harvard.iq.dataverse.RoleAssignment; @@ -85,7 +86,13 @@ protected void executeImpl(CommandContext ctxt) throws CommandException { // TODO make ignorant of configured bean ctxt.doiDataCite().deleteRecordFromCache(doomed); } - + + IdServiceBean idServiceBean = IdServiceBean.getBean(ctxt); + try{ + idServiceBean.deleteIdentifier(doomed); + } catch (Exception e) { + logger.log(Level.WARNING, "Identifier deletion was not successfull:",e.getMessage()); + } Dataverse toReIndex = managedDoomed.getOwner(); // dataset