Skip to content

Commit

Permalink
Merge pull request #4830 from QualitativeDataRepository/4828-DOI_regi…
Browse files Browse the repository at this point in the history
…stration_with_EZID_does_not_make_DOIs_public

4828 - handle pre-registering providers when creating file pids
  • Loading branch information
kcondon authored Aug 3, 2018
2 parents 68b535c + 4d45d2d commit db89320
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
String nonNullDefaultIfKeyNotFound = "";
String protocol = ctxt.settings().getValueForKey(SettingsServiceBean.Key.Protocol, nonNullDefaultIfKeyNotFound);
String authority = ctxt.settings().getValueForKey(SettingsServiceBean.Key.Authority, nonNullDefaultIfKeyNotFound);
GlobalIdServiceBean idServiceBean = GlobalIdServiceBean.getBean(target.getProtocol(), ctxt);
// Get the idServiceBean that is configured to mint new IDs
GlobalIdServiceBean idServiceBean = GlobalIdServiceBean.getBean(protocol, ctxt);
try {
//Test to see if identifier already present
//if so, leave.
Expand All @@ -56,15 +57,20 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
}
String doiRetString = idServiceBean.createIdentifier(target);
if (doiRetString != null && doiRetString.contains(target.getIdentifier())) {
if (!idServiceBean.registerWhenPublished()) {
// Should register ID before publicize() is called
// For example, DOIEZIdServiceBean tries to recreate the id if the identifier isn't registered before
// publicizeIdentifier is called
target.setIdentifierRegistered(true);
target.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
}
if (target.isReleased()) {
idServiceBean.publicizeIdentifier(target);
}

if (!idServiceBean.registerWhenPublished() || target.isReleased()) {
if (idServiceBean.registerWhenPublished() && target.isReleased()) {
target.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
target.setIdentifierRegistered(true);
}

ctxt.em().merge(target);
ctxt.em().flush();
if (target.isInstanceofDataset()) {
Expand All @@ -81,10 +87,17 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
}
doiRetString = idServiceBean.createIdentifier(df);
if (doiRetString != null && doiRetString.contains(df.getIdentifier())) {
if (!idServiceBean.registerWhenPublished()) {
// Should register ID before publicize() is called
// For example, DOIEZIdServiceBean tries to recreate the id if the identifier isn't registered before
// publicizeIdentifier is called
df.setIdentifierRegistered(true);
df.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
}
if (df.isReleased()) {
idServiceBean.publicizeIdentifier(df);
}
if (!idServiceBean.registerWhenPublished() || df.isReleased()) {
if (idServiceBean.registerWhenPublished() && df.isReleased()) {
df.setGlobalIdCreateTime(new Timestamp(new Date().getTime()));
df.setIdentifierRegistered(true);
}
Expand Down

0 comments on commit db89320

Please sign in to comment.