Skip to content

Commit

Permalink
Merge pull request #5604 from PaulBoon/5587-support-independent-handl…
Browse files Browse the repository at this point in the history
…e-service

5587 support independent handle service
  • Loading branch information
kcondon authored Mar 7, 2019
2 parents 33afb34 + 926b09c commit d78b08d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
9 changes: 9 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Here are the configuration options for handles:
- :ref:`:Authority <:Authority>`
- :ref:`:IdentifierGenerationStyle <:IdentifierGenerationStyle>` (optional)
- :ref:`:DataFilePIDFormat <:DataFilePIDFormat>` (optional)
- :ref:`:IndependentHandleService <:IndependentHandleService>` (optional)

Note: If you are **minting your own handles** and plan to set up your own handle service, please refer to `Handle.Net documentation <http://handle.net/hnr_documentation.html>`_.

Expand Down Expand Up @@ -1088,6 +1089,14 @@ If you don't want to register file-based PIDs for your installation, set:

Note: File-level PID registration was added in 4.9 and is required until version 4.9.3.

:IndependentHandleService
+++++++++++++++++++++++++++

Specific for Handle PIDs. Set this setting to true if you want to use a Handle service which is setup to work 'independently' (No communication with the Global Handle Registry).
By default this setting is absent and Dataverse assumes it to be false.

``curl -X PUT -d 'true' http://localhost:8080/api/admin/settings/:IndependentHandleService``

:ApplicationTermsOfUse
++++++++++++++++++++++

Expand Down
27 changes: 13 additions & 14 deletions src/main/java/edu/harvard/iq/dataverse/HandlenetServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void reRegisterHandle(DvObject dvObject) {

logger.log(Level.INFO, "Re-registering an existing handle id {0}", handle);

String authHandle = getHandleAuthority(dvObject);
String authHandle = getAuthenticationHandle(dvObject);

HandleResolver resolver = new HandleResolver();

Expand Down Expand Up @@ -148,7 +148,7 @@ public Throwable registerNewHandle(DvObject dvObject) {

logger.log(Level.INFO, "Creating NEW handle {0}", handle);

String authHandle = getHandleAuthority(dvObject);
String authHandle = getAuthenticationHandle(dvObject);

PublicKeyAuthenticationInfo auth = getAuthInfo(handlePrefix);
HandleResolver resolver = new HandleResolver();
Expand Down Expand Up @@ -233,7 +233,7 @@ private PublicKeyAuthenticationInfo getAuthInfo(String handlePrefix) {
key = readKey(adminCredFile);
PrivateKey privkey = null;
privkey = readPrivKey(key, adminCredFile);
String authHandle = getHandleAuthority(handlePrefix);
String authHandle = getAuthenticationHandle(handlePrefix);
PublicKeyAuthenticationInfo auth =
new PublicKeyAuthenticationInfo(Util.encodeString(authHandle), handlenetIndex, privkey);
return auth;
Expand Down Expand Up @@ -308,13 +308,17 @@ private String getDvObjectHandle(DvObject dvObject) {
return handle;
}

private String getHandleAuthority(DvObject dvObject){
return getHandleAuthority(dvObject.getAuthority());
private String getAuthenticationHandle(DvObject dvObject){
return getAuthenticationHandle(dvObject.getAuthority());
}

private String getHandleAuthority(String handlePrefix) {
logger.log(Level.FINE,"getHandleAuthority");
return "0.NA/" + handlePrefix;
private String getAuthenticationHandle(String handlePrefix) {
logger.log(Level.FINE,"getAuthenticationHandle");
if (systemConfig.isIndependentHandleService()) {
return handlePrefix + "/ADMIN";
} else {
return "0.NA/" + handlePrefix;
}
}

@Override
Expand Down Expand Up @@ -355,7 +359,7 @@ public String modifyIdentifierTargetURL(DvObject dvObject) throws Exception {
@Override
public void deleteIdentifier(DvObject dvObject) throws Exception {
String handle = getDvObjectHandle(dvObject);
String authHandle = getAuthHandle(dvObject);
String authHandle = getAuthenticationHandle(dvObject);

String adminCredFile = System.getProperty("dataverse.handlenet.admcredfile");
int handlenetIndex = System.getProperty("dataverse.handlenet.index")!=null? Integer.parseInt(System.getProperty("dataverse.handlenet.index")) : 300;
Expand Down Expand Up @@ -389,11 +393,6 @@ private boolean updateIdentifierStatus(DvObject dvObject, String statusIn) {
reRegisterHandle(dvObject); // No Need to register new - this is only called when a handle exists
return true;
}

private String getAuthHandle(DvObject dvObject) {
// TODO hack: GNRSServiceBean retrieved this from vdcNetworkService
return "0.NA/" + dvObject.getAuthority();
}

@Override
public List<String> getProviderInformation(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,12 @@ Whether Harvesting (OAI) service is enabled
*
*/
FilePIDsEnabled,


/**
* Indicates if the Handle service is setup to work 'independently' (No communication with the Global Handle Registry)
*/
IndependentHandleService,

/**
* Archiving can be configured by providing an Archiver class name (class must extend AstractSubmitToArchiverCommand)
* and a list of settings that should be passed to the Archiver.
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1058,4 +1058,8 @@ public boolean isFilePIDsEnabled() {
return settingsService.isTrueForKey(SettingsServiceBean.Key.FilePIDsEnabled, safeDefaultIfKeyNotFound);
}

public boolean isIndependentHandleService() {
boolean safeDefaultIfKeyNotFound = false;
return settingsService.isTrueForKey(SettingsServiceBean.Key.IndependentHandleService, safeDefaultIfKeyNotFound);
}
}

0 comments on commit d78b08d

Please sign in to comment.