Skip to content

Commit

Permalink
Merge branch 'develop' into 3438-email-verification
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Jan 21, 2021
2 parents 7ad36ce + 9d6801d commit 8f9c03b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
5 changes: 3 additions & 2 deletions doc/sphinx-guides/source/developers/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Workflow steps are created using *step providers*. Dataverse ships with an inter

Steps can be internal (say, writing some data to the log) or external. External steps involve Dataverse sending a request to an external system, and waiting for the system to reply. The wait period is arbitrary, and so allows the external system unbounded operation time. This is useful, e.g., for steps that require human intervension, such as manual approval of a dataset publication.

The external system reports the step result back to dataverse, by sending a HTTP ``POST`` command to ``api/workflows/{invocation-id}``. The body of the request is passed to the paused step for further processing.
The external system reports the step result back to dataverse, by sending a HTTP ``POST`` command to ``api/workflows/{invocation-id}`` with Content-Type: text/plain. The body of the request is passed to the paused step for further processing.

If a step in a workflow fails, Dataverse make an effort to roll back all the steps that preceded it. Some actions, such as writing to the log, cannot be rolled back. If such an action has a public external effect (e.g. send an EMail to a mailing list) it is advisable to put it in the post-release workflow.

Expand Down Expand Up @@ -60,7 +60,7 @@ A step that writes data about the current workflow invocation to the instance lo
pause
+++++

A step that pauses the workflow. The workflow is paused until a POST request is sent to ``/api/workflows/{invocation-id}``.
A step that pauses the workflow. The workflow is paused until a POST request is sent to ``/api/workflows/{invocation-id}``. Sending 'fail' in the POST body (Content-type:text/plain) will trigger a failure and workflow rollback. All other responses are considered as successes.

.. code:: json
Expand All @@ -74,6 +74,7 @@ http/sr
+++++++

A step that sends a HTTP request to an external system, and then waits for a response. The response has to match a regular expression specified in the step parameters. The url, content type, and message body can use data from the workflow context, using a simple markup language. This step has specific parameters for rollback.
The workflow is restarted when the external system replies with a POST request to ``/api/workflows/{invocation-id}``. Responses starting with "OK" (Content-type:text/plain) are considered successes. Other responses will be considered failures and trigger workflow rollback.

.. code:: json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ public boolean onSuccess(CommandContext ctxt, Object r) {
}

if (dataset != null) {
logger.fine("From onSuccess, calling FinalizeDatasetPublicationCommand for dataset " + dataset.getGlobalId().asString());
ctxt.datasets().callFinalizePublishCommandAsynchronously(dataset.getId(), ctxt, request, datasetExternallyReleased);
Optional<Workflow> prePubWf = ctxt.workflows().getDefaultWorkflow(TriggerType.PrePublishDataset);
//A pre-publication workflow will call FinalizeDatasetPublicationCommand itself when it completes
if (! prePubWf.isPresent() ) {
logger.fine("From onSuccess, calling FinalizeDatasetPublicationCommand for dataset " + dataset.getGlobalId().asString());
ctxt.datasets().callFinalizePublishCommandAsynchronously(dataset.getId(), ctxt, request, datasetExternallyReleased);
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ public WorkflowContext( DataverseRequest aRequest, Dataset aDataset, TriggerType
aDataset.getLatestVersion().getMinorVersionNumber(),
aTriggerType, null, null, datasetExternallyReleased);
}

public WorkflowContext(DataverseRequest request, Dataset dataset, long nextVersionNumber,
long nextMinorVersionNumber, TriggerType type, Map<String, Object> settings, ApiToken apiToken, boolean datasetExternallyReleased) {
long nextMinorVersionNumber, TriggerType type, Map<String, Object> settings, ApiToken apiToken, boolean datasetExternallyReleased) {
this(request, dataset, nextVersionNumber,nextMinorVersionNumber, type, settings, apiToken, datasetExternallyReleased, null);
}

public WorkflowContext(DataverseRequest request, Dataset dataset, long nextVersionNumber,
long nextMinorVersionNumber, TriggerType type, Map<String, Object> settings, ApiToken apiToken, boolean datasetExternallyReleased, String invocationId) {
this.request = request;
this.dataset = dataset;
this.nextVersionNumber = nextVersionNumber;
Expand All @@ -51,6 +55,9 @@ public WorkflowContext(DataverseRequest request, Dataset dataset, long nextVersi
this.settings = settings;
this.apiToken = apiToken;
this.datasetExternallyReleased = datasetExternallyReleased;
if(invocationId!=null) {
setInvocationId(invocationId);
}
}

public Dataset getDataset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ private WorkflowContext refresh( WorkflowContext ctxt, Map<String, Object> setti
* resumed workflows. (The overall method is needed to allow the context to be updated in the start() method with the
* settings and APItoken retrieved by the WorkflowServiceBean) - JM - 9/18.
*/
return new WorkflowContext( ctxt.getRequest(),
em.merge(ctxt.getDataset()), ctxt.getNextVersionNumber(),
ctxt.getNextMinorVersionNumber(), ctxt.getType(), settings, apiToken, ctxt.getDatasetExternallyReleased());
WorkflowContext newCtxt =new WorkflowContext( ctxt.getRequest(),
em.merge(ctxt.getDataset()), ctxt.getNextVersionNumber(),
ctxt.getNextMinorVersionNumber(), ctxt.getType(), settings, apiToken, ctxt.getDatasetExternallyReleased(), ctxt.getInvocationId());
return newCtxt;
}

}

0 comments on commit 8f9c03b

Please sign in to comment.