Search in sources :

Example 1 with TriggerType

use of edu.harvard.iq.dataverse.workflow.WorkflowContext.TriggerType in project dataverse by IQSS.

the class WorkflowsAdmin method setDefault.

@Path("default/{triggerType}")
@PUT
public Response setDefault(@PathParam("triggerType") String triggerType, String identifier) {
    try {
        long idtf = Long.parseLong(identifier.trim());
        TriggerType tt = TriggerType.valueOf(triggerType);
        Optional<Workflow> wf = workflows.getWorkflow(idtf);
        if (wf.isPresent()) {
            workflows.setDefaultWorkflowId(tt, idtf);
            return ok("Default workflow id for trigger " + tt.name() + " set to " + idtf);
        } else {
            return notFound("Can't find workflow with id " + idtf);
        }
    } catch (NumberFormatException nfe) {
        return badRequest("workflow identifier has to be numeric.");
    } catch (IllegalArgumentException iae) {
        return badRequest("Unknown trigger type '" + triggerType + "'. Available triggers: " + Arrays.toString(TriggerType.values()));
    }
}
Also used : TriggerType(edu.harvard.iq.dataverse.workflow.WorkflowContext.TriggerType) Workflow(edu.harvard.iq.dataverse.workflow.Workflow) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Aggregations

Workflow (edu.harvard.iq.dataverse.workflow.Workflow)1 TriggerType (edu.harvard.iq.dataverse.workflow.WorkflowContext.TriggerType)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1