From a87e382b3604f0e61f150fef6f682283a711c8d2 Mon Sep 17 00:00:00 2001 From: sol Date: Fri, 24 Mar 2017 16:14:46 +0300 Subject: [PATCH] Bundle items with variable, and additional method to get provider's name Minimized the number of bundle items of dataset publish error message. Method added into each implementation to return its own name and link to the service provider's site --- src/main/java/Bundle.properties | 5 +---- .../iq/dataverse/DOIDataCiteServiceBean.java | 14 +++++++++++++- .../harvard/iq/dataverse/DOIEZIdServiceBean.java | 13 +++++++++++++ .../harvard/iq/dataverse/HandlenetServiceBean.java | 12 +++++++++++- .../edu/harvard/iq/dataverse/IdServiceBean.java | 2 ++ .../engine/command/impl/PublishDatasetCommand.java | 9 ++++----- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/main/java/Bundle.properties b/src/main/java/Bundle.properties index 389d02712e5..cddd708b3da 100755 --- a/src/main/java/Bundle.properties +++ b/src/main/java/Bundle.properties @@ -1020,10 +1020,7 @@ dataset.email.datasetLinkBtn.tip=Link Dataset to Your Dataverse dataset.share.datasetShare=Share Dataset dataset.share.datasetShare.tip=Share this dataset on your favorite social media networks. dataset.share.datasetShare.shareText=View this dataset. -dataset.publish.error.datacite=This dataset may not be published because the DataCite Service is currently inaccessible. Please try again. Does the issue continue to persist? -dataset.publish.error.DataCiteException=This dataset may not be published because the DataCite Service is currently inaccessible. Please try again. Does the issue continue to persist? -dataset.publish.error.HandleException=This dataset may not be published because the Handle.net Service is currently inaccessible. Please try again. Does the issue continue to persist? -dataset.publish.error.EZIDException=This dataset may not be published because the EZID Service is currently inaccessible. Please try again. Does the issue continue to persist? +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. diff --git a/src/main/java/edu/harvard/iq/dataverse/DOIDataCiteServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DOIDataCiteServiceBean.java index a00b614f4b4..c258ee33372 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DOIDataCiteServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DOIDataCiteServiceBean.java @@ -5,7 +5,9 @@ */ package edu.harvard.iq.dataverse; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJB; @@ -238,4 +240,14 @@ private boolean updateIdentifierStatus(Dataset dataset, String statusIn) { return false; } } -} \ No newline at end of file + + @Override + public List getProviderInformation(){ + ArrayList providerInfo = new ArrayList<>(); + String providerName = "DataCite"; + String providerLink = "http://status.datacite.org"; + providerInfo.add(providerName); + providerInfo.add(providerLink); + return providerInfo; + } +} diff --git a/src/main/java/edu/harvard/iq/dataverse/DOIEZIdServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DOIEZIdServiceBean.java index 84193341648..42a51f43f6b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DOIEZIdServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DOIEZIdServiceBean.java @@ -7,8 +7,10 @@ import edu.ucsb.nceas.ezid.EZIDException; import edu.ucsb.nceas.ezid.EZIDService; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.ejb.EJB; @@ -228,4 +230,15 @@ private boolean updateIdentifierStatus(Dataset dataset, String statusIn) { } } + + @Override + public List getProviderInformation(){ + ArrayList providerInfo = new ArrayList<>(); + String providerName = "EZID"; + String providerLink = baseURLString; + providerInfo.add(providerName); + providerInfo.add(providerLink); + return providerInfo; + } } + diff --git a/src/main/java/edu/harvard/iq/dataverse/HandlenetServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/HandlenetServiceBean.java index 5b3cc68fc20..6be5537c04b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/HandlenetServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/HandlenetServiceBean.java @@ -251,7 +251,7 @@ private String getRegistrationUrl(Dataset dataset) { + "/" + dataset.getIdentifier(); return targetUrl; } - + public String getSiteUrl() { logger.log(Level.FINE,"getSiteUrl"); String hostUrl = System.getProperty("dataverse.siteUrl"); @@ -406,6 +406,16 @@ private String getAuthHandle(Dataset datasetIn) { // TODO hack: GNRSServiceBean retrieved this from vdcNetworkService return "0.NA/" + datasetIn.getAuthority(); } + + @Override + public List getProviderInformation(){ + ArrayList providerInfo = new ArrayList<>(); + String providerName = "Handle"; + String providerLink = "https://hdl.handle.net"; + providerInfo.add(providerName); + providerInfo.add(providerLink); + return providerInfo; + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/IdServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/IdServiceBean.java index ea26a62d1ad..3ae507611d6 100644 --- a/src/main/java/edu/harvard/iq/dataverse/IdServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/IdServiceBean.java @@ -15,6 +15,8 @@ public interface IdServiceBean { boolean alreadyExists(Dataset dataset) throws Exception; boolean registerWhenPublished(); + + List getProviderInformation(); String createIdentifier(Dataset dataset) throws Throwable; diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/PublishDatasetCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/PublishDatasetCommand.java index 12bb619d450..331f9e1dee9 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/PublishDatasetCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/PublishDatasetCommand.java @@ -19,6 +19,7 @@ import edu.harvard.iq.dataverse.privateurl.PrivateUrl; import edu.harvard.iq.dataverse.search.IndexResponse; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; +import edu.harvard.iq.dataverse.util.BundleUtil; import static edu.harvard.iq.dataverse.util.json.JsonPrinter.jsonAsDatasetDto; import java.io.FileOutputStream; import java.io.IOException; @@ -97,8 +98,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException { } } } catch (Throwable e) { - String exceptionName=e.getClass().getSimpleName(); - throw new CommandException(ResourceBundle.getBundle("Bundle").getString("dataset.publish.error."+exceptionName), this); + throw new CommandException(BundleUtil.getStringFromBundle("dataset.publish.error", idServiceBean.getProviderInformation()),this); } } else { throw new IllegalCommandException("This dataset may not be published because its id registry service is not supported.", this); @@ -223,8 +223,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException { try{ idServiceBean.publicizeIdentifier(savedDataset); }catch (Throwable e) { - String exceptionName=e.getClass().getSimpleName(); - throw new CommandException(ResourceBundle.getBundle("Bundle").getString("dataset.publish.error."+exceptionName), this); + throw new CommandException(BundleUtil.getStringFromBundle("dataset.publish.error", idServiceBean.getProviderInformation()),this); } PrivateUrl privateUrl = ctxt.engine().submit(new GetPrivateUrlCommand(getRequest(), savedDataset)); if (privateUrl != null) { @@ -248,6 +247,6 @@ public Dataset execute(CommandContext ctxt) throws CommandException { IndexResponse indexResponse = ctxt.solrIndex().indexPermissionsForOneDvObject(savedDataset); return savedDataset; - } + } }