Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make use of the datasetExternallyReleased property in the publish com… #5005

Merged
merged 5 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public WorkflowComment addWorkflowComment(WorkflowComment workflowComment) {
}

@Asynchronous
public void callFinalizePublishCommandAsynchronously(Long datasetId, CommandContext ctxt, DataverseRequest request) throws CommandException {
public void callFinalizePublishCommandAsynchronously(Long datasetId, CommandContext ctxt, DataverseRequest request, boolean isPidPrePublished) throws CommandException {

// Since we are calling the next command asynchronously anyway - sleep here
// for a few seconds, just in case, to make sure the database update of
Expand All @@ -727,7 +727,7 @@ public void callFinalizePublishCommandAsynchronously(Long datasetId, CommandCont
Dataset theDataset = find(datasetId);
String nonNullDefaultIfKeyNotFound = "";
String doiProvider = ctxt.settings().getValueForKey(SettingsServiceBean.Key.DoiProvider, nonNullDefaultIfKeyNotFound);
commandEngine.submit(new FinalizeDatasetPublicationCommand(theDataset, doiProvider, request));
commandEngine.submit(new FinalizeDatasetPublicationCommand(theDataset, doiProvider, request, isPidPrePublished));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ public class FinalizeDatasetPublicationCommand extends AbstractPublishDatasetCom
private static final Logger logger = Logger.getLogger(FinalizeDatasetPublicationCommand.class.getName());

String doiProvider;

/**
* mirror field from {@link PublishDatasetCommand} of same name
*/
final boolean datasetExternallyReleased;

public FinalizeDatasetPublicationCommand(Dataset aDataset, String aDoiProvider, DataverseRequest aRequest) {
this( aDataset, aDoiProvider, aRequest, false );
}
public FinalizeDatasetPublicationCommand(Dataset aDataset, String aDoiProvider, DataverseRequest aRequest, boolean isPidPrePublished) {
super(aDataset, aRequest);
doiProvider = aDoiProvider;
datasetExternallyReleased = isPidPrePublished;
}

@Override
Expand Down Expand Up @@ -96,18 +105,22 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
ctxt.em().merge(ddu);

updateParentDataversesSubjectsField(theDataset, ctxt);
publicizeExternalIdentifier(theDataset, ctxt);
if (!datasetExternallyReleased){
publicizeExternalIdentifier(theDataset, ctxt);
}

PrivateUrl privateUrl = ctxt.engine().submit(new GetPrivateUrlCommand(getRequest(), theDataset));
if (privateUrl != null) {
ctxt.engine().submit(new DeletePrivateUrlCommand(getRequest(), theDataset));
}

if ( theDataset.getLatestVersion().getVersionState() != RELEASED ) {
// some imported datasets may already be released.
publicizeExternalIdentifier(theDataset, ctxt);
theDataset.getLatestVersion().setVersionState(RELEASED);
}
if ( theDataset.getLatestVersion().getVersionState() != RELEASED ) {
// some imported datasets may already be released.
if (!datasetExternallyReleased){
publicizeExternalIdentifier(theDataset, ctxt);
}
theDataset.getLatestVersion().setVersionState(RELEASED);
}

exportMetadata(ctxt.settings());
boolean doNormalSolrDocCleanUp = true;
Expand Down Expand Up @@ -192,7 +205,7 @@ private void publicizeExternalIdentifier(Dataset dataset, CommandContext ctxt) t
// one currently configured for the Dataverse. This is to specifically
// address the issue with the datasets with handle ids registered,
// that are currently configured to use DOI.
if (currentGlobalIdProtocol.equals(protocol) || dataFilePIDFormat.equals("INDEPENDENT")) {
if (currentGlobalIdProtocol.equals(protocol) || dataFilePIDFormat.equals("INDEPENDENT")) {//TODO(pm) - check authority too
//A false return value indicates a failure in calling the service
for (DataFile df : dataset.getFiles()) {
logger.log(Level.FINE, "registering global id for file {0}", df.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public PublishDatasetResult execute(CommandContext ctxt) throws CommandException
ctxt.workflows().start(prePubWf.get(), buildContext(doiProvider, TriggerType.PrePublishDataset) );
return new PublishDatasetResult(theDataset, false);

} else {
} else{
// We will skip trying to register the global identifiers for datafiles
// if "dependent" file-level identifiers are requested, AND the naming
// protocol of the dataset global id is different from the
Expand All @@ -99,8 +99,13 @@ public PublishDatasetResult execute(CommandContext ctxt) throws CommandException
// than the configured limit number of files, then call Finalize
// asychronously (default is 10)
String currentGlobalIdProtocol = ctxt.settings().getValueForKey(SettingsServiceBean.Key.Protocol, "");
String currentGlobalAuthority= ctxt.settings().getValueForKey(SettingsServiceBean.Key.Authority, "");
String dataFilePIDFormat = ctxt.settings().getValueForKey(SettingsServiceBean.Key.DataFilePIDFormat, "DEPENDENT");
boolean registerGlobalIdsForFiles = currentGlobalIdProtocol.equals(theDataset.getProtocol()) || dataFilePIDFormat.equals("INDEPENDENT");
boolean registerGlobalIdsForFiles = currentGlobalIdProtocol.equals(theDataset.getProtocol()) || dataFilePIDFormat.equals("INDEPENDENT"); // note that despite its name, the FinalizeDatasetPublicationComment in the else branch will still try to register, so this logic is duplicated there
if ( registerGlobalIdsForFiles )
{
registerGlobalIdsForFiles = currentGlobalAuthority.equals( theDataset.getAuthority() );
}

if (theDataset.getFiles().size() > ctxt.systemConfig().getPIDAsynchRegFileCount() && registerGlobalIdsForFiles) {
String info = "Adding File PIDs asynchronously";
Expand All @@ -110,12 +115,12 @@ public PublishDatasetResult execute(CommandContext ctxt) throws CommandException
lock.setDataset(theDataset);
lock.setInfo(info);
ctxt.datasets().addDatasetLock(theDataset, lock);
ctxt.datasets().callFinalizePublishCommandAsynchronously(theDataset.getId(), ctxt, request);
ctxt.datasets().callFinalizePublishCommandAsynchronously(theDataset.getId(), ctxt, request, datasetExternallyReleased);
return new PublishDatasetResult(theDataset, false);

} else {
// Synchronous publishing (no workflow involved)
theDataset = ctxt.engine().submit(new FinalizeDatasetPublicationCommand(ctxt.em().merge(theDataset), doiProvider, getRequest()));
theDataset = ctxt.engine().submit(new FinalizeDatasetPublicationCommand(ctxt.em().merge(theDataset), doiProvider, getRequest(),datasetExternallyReleased));
return new PublishDatasetResult(theDataset, true);
}
}
Expand Down