Skip to content

Commit

Permalink
Completed implementation of HandlenetServiceBean
Browse files Browse the repository at this point in the history
- pulled up methods to AbstractIdServiceBean
- implemented methods of HandleNetServiceBean that still threw a NotImplementedException and were called somewhere

This is a squashed commit of https://github.com/DANS-KNAW-jp/dataverse/pull/1
alias https://github.com/DANS-KNAW-jp/dataverse/tree/DDN-184-handle-implementation
  • Loading branch information
jo-pol committed Sep 15, 2016
1 parent cafe13b commit 354e624
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 296 deletions.
12 changes: 6 additions & 6 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ Non-superusers who are not "Admin" on the root dataverse will not be able to to
Persistent Identifiers and Publishing Datasets
++++++++++++++++++++++++++++++++++++++++++++++

Persistent identifiers are a required and integral part of the Dataverse platform. They provide a URL that is guaranteed to resolve to the datasets they represent. Dataverse currently supports creating identifiers using DOI and additionally displaying identifiers created using HDL. By default and for testing convenience, the installer configures a temporary DOI test namespace through EZID. This is sufficient to create and publish datasets but they are not citable nor guaranteed to be preserved. To properly configure persistent identifiers for a production installation, an account and associated namespace must be acquired for a fee from one of two DOI providers: EZID (http://ezid.cdlib.org) or DataCite (https://www.datacite.org). Once account credentials and DOI namespace have been acquired, please complete the following identifier configuration parameters:
Persistent identifiers are a required and integral part of the Dataverse platform. They provide a URL that is guaranteed to resolve to the datasets they represent. Dataverse currently supports creating identifiers using DOI and HDL. By default and for testing convenience, the installer configures a temporary DOI test namespace through EZID. This is sufficient to create and publish datasets but they are not citable nor guaranteed to be preserved. To properly configure persistent identifiers for a production installation, an account and associated namespace must be acquired for a fee from a DOI or HDL provider: EZID (http://ezid.cdlib.org), DataCite (https://www.datacite.org) (https://www.handle.net). Once account credentials and namespace have been acquired, please complete the following identifier configuration parameters:

JVM Options: :ref:`doi.baseurlstring`, :ref:`doi.username`, :ref:`doi.password`
JVM Options: :ref:`doi.baseurlstring`, :ref:`doi.username`, :ref:`doi.password`, :ref:`dataverse.handlenet.admcredfile`, :ref:`dataverse.handlenet.admprivphrase`

Database Settings: :ref:`:DoiProvider`, :ref:`:Protocol`, :ref:`:Authority`, :ref:`:DoiSeparator`

Expand Down Expand Up @@ -211,11 +211,11 @@ Used in conjuction with ``doi.baseurlstring``.
dataverse.handlenet.admcredfile
+++++++++++++++++++++++++++++++

For Handle support (not fully developed).
For Handle support, typically the full path to handle/svr_1/admpriv.bin

dataverse.handlenet.admprivphrase
+++++++++++++++++++++++++++++++++
For Handle support (not fully developed).
For Handle support.

Database Settings
-----------------
Expand Down Expand Up @@ -275,14 +275,14 @@ As of this writing "EZID" and "DataCite" are the only valid options.
:Protocol
+++++++++
.. _:Protocol:
As of this writing "doi" is the only valid option for the protocol for a persistent ID.
As of this writing "doi" and "hdl" are the only valid option for the protocol for a persistent ID.

``curl -X PUT -d doi http://localhost:8080/api/admin/settings/:Protocol``

:Authority
++++++++++
.. _:Authority:
Use the DOI authority assigned to you by your DoiProvider.
Use the DOI authority assigned to you by your DoiProvider or HandleProvider, note to provide the handle authority without its "20." prefix.

``curl -X PUT -d 10.xxxx http://localhost:8080/api/admin/settings/:Authority``

Expand Down
86 changes: 86 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/AbstractIdServiceBean.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,95 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import edu.harvard.iq.dataverse.util.SystemConfig;

import javax.ejb.EJB;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public abstract class AbstractIdServiceBean implements IdServiceBean {

private static final Logger logger = Logger.getLogger(AbstractIdServiceBean.class.getCanonicalName());

@EJB
DataverseServiceBean dataverseService;
@EJB
SettingsServiceBean settingsService;
@EJB
SystemConfig systemConfig;

@Override
public String getIdentifierForLookup(String protocol, String authority, String separator, String identifier) {
logger.log(Level.FINE,"getIdentifierForLookup");
return protocol + ":" + authority + separator + identifier;
}

@Override
public HashMap<String, String> getMetadataFromStudyForCreateIndicator(Dataset datasetIn) {
logger.log(Level.FINE,"getMetadataFromStudyForCreateIndicator");
HashMap<String, String> metadata = new HashMap<>();

String authorString = datasetIn.getLatestVersion().getAuthorsStr();

if (authorString.isEmpty()) {
authorString = ":unav";
}

String producerString = dataverseService.findRootDataverse().getName() + " Dataverse";

if (producerString.isEmpty()) {
producerString = ":unav";
}
metadata.put("datacite.creator", authorString);
metadata.put("datacite.title", datasetIn.getLatestVersion().getTitle());
metadata.put("datacite.publisher", producerString);
metadata.put("datacite.publicationyear", generateYear());
metadata.put("_target", getTargetUrl(datasetIn));
return metadata;
}

protected HashMap<String, String> getUpdateMetadataFromDataset(Dataset datasetIn) {
logger.log(Level.FINE,"getUpdateMetadataFromDataset");
HashMap<String, String> metadata = new HashMap<>();

String authorString = datasetIn.getLatestVersion().getAuthorsStr();

if (authorString.isEmpty()) {
authorString = ":unav";
}

String producerString = dataverseService.findRootDataverse().getName() + " Dataverse";

if(producerString.isEmpty()) {
producerString = ":unav";
}
metadata.put("datacite.creator", authorString);
metadata.put("datacite.title", datasetIn.getLatestVersion().getTitle());
metadata.put("datacite.publisher", producerString);

return metadata;
}

@Override
public HashMap<String, String> getMetadataFromDatasetForTargetURL(Dataset datasetIn) {
logger.log(Level.FINE,"getMetadataFromDatasetForTargetURL");
HashMap<String, String> metadata = new HashMap<>();
metadata.put("_target", getTargetUrl(datasetIn));
return metadata;
}

protected String getTargetUrl(Dataset datasetIn) {
logger.log(Level.FINE,"getTargetUrl");
return systemConfig.getDataverseSiteUrl() + Dataset.TARGET_URL + datasetIn.getGlobalId();
}

@Override
public String getIdentifierFromDataset(Dataset dataset) {
logger.log(Level.FINE,"getIdentifierFromDataset");
return dataset.getGlobalId();
}

@Override
public String generateYear()
{
Expand Down
Loading

0 comments on commit 354e624

Please sign in to comment.