Skip to content

Commit

Permalink
Notes about ways to resolve issues inc. pos. fix for lock not deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Feb 22, 2021
1 parent 3812e4a commit 97eeab8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,13 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
final Dataset ds = ctxt.em().merge(theDataset);
//Remove any pre-pub workflow lock (not needed as WorkflowServiceBean.workflowComplete() should already have removed it after setting the finalizePublication lock?)
ctxt.datasets().removeDatasetLocks(ds, DatasetLock.Reason.Workflow);

//Should this be in onSuccess()?
ctxt.workflows().getDefaultWorkflow(TriggerType.PostPublishDataset).ifPresent(wf -> {
try {
ctxt.workflows().start(wf, buildContext(ds, TriggerType.PostPublishDataset, datasetExternallyReleased));
} catch (CommandException ex) {
ctxt.datasets().removeDatasetLocks(ds, DatasetLock.Reason.Workflow);
logger.log(Level.SEVERE, "Error invoking post-publish workflow: " + ex.getMessage(), ex);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public PublishDatasetResult execute(CommandContext ctxt) throws CommandException

Dataset theDataset = getDataset();


//ToDo - any reason to set the version in publish versus finalize? Failure in a prepub workflow or finalize will leave draft versions with an assigned version number as is.
//Changing the dataset in this transaction also potentially makes a race condition with a prepub workflow, possibly resulting in an OptimisticLockException there.

// Set the version numbers:

if (theDataset.getPublicationDate() == null) {
Expand All @@ -86,6 +90,7 @@ public PublishDatasetResult execute(CommandContext ctxt) throws CommandException
theDataset.getLatestVersion().setMinorVersionNumber(new Long(0));
}

//ToDo - should this be in onSuccess()? May relate to todo above
Optional<Workflow> prePubWf = ctxt.workflows().getDefaultWorkflow(TriggerType.PrePublishDataset);
if ( prePubWf.isPresent() ) {
// We start a workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public WorkflowServiceBean() {
* @param ctxt the context in which the workflow is executed.
* @throws CommandException If the dataset could not be locked.
*/
//ToDo - should this be @Async? or just the forward() method?
@Asynchronous
public void start(Workflow wf, WorkflowContext ctxt) throws CommandException {

Expand Down

0 comments on commit 97eeab8

Please sign in to comment.