use of com.emc.sa.service.vipr.customservices.tasks.CustomServicesTaskResult in project coprhd-controller by CoprHD.
the class CustomServicesService method wfExecutor.
/**
* Method to parse Workflow Definition JSON
*
* @throws Exception
*/
public void wfExecutor(final URI uri, final Map<String, CustomServicesWorkflowDocument.InputGroup> stepInput) throws Exception {
logger.info("CS: Parsing Workflow Definition");
final ImmutableMap<String, Step> stepsHash = getStepHash(uri);
Step step = stepsHash.get(StepType.START.toString());
String next = step.getNext().getDefaultStep();
long timeout = System.currentTimeMillis();
while (next != null && !next.equals(StepType.END.toString())) {
step = stepsHash.get(next);
ExecutionUtils.currentContext().logInfo("customServicesService.stepStatus", step.getId(), step.getFriendlyName(), step.getType());
updateInputPerStep(step);
final CustomServicesTaskResult res;
try {
final MakeCustomServicesExecutor task = executor.get(step.getType());
task.setParam(getClient().getRestClient());
res = ViPRExecutionUtils.execute(task.makeCustomServicesExecutor(inputPerStep.get(step.getId()), step));
boolean isSuccess = isSuccess(step, res);
if (isSuccess) {
try {
updateOutputPerStep(step, res);
} catch (final Exception e) {
logger.warn("Failed to parse output" + e + "step Id: {}", step.getId());
}
}
next = getNext(isSuccess, res, step);
} catch (final Exception e) {
logger.warn("failed to execute step step Id:{}", step.getId() + "Try to get failure path. Exception Received:", e);
next = getNext(false, null, step);
}
if (next == null) {
ExecutionUtils.currentContext().logError("customServicesService.logStatus", "Step Id: " + step.getId() + "\t Step Name: " + step.getFriendlyName() + "Failed. Failing the Workflow");
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow Execution failed");
}
if ((System.currentTimeMillis() - timeout) > CustomServicesConstants.WORKFLOW_TIMEOUT) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Operation Timed out");
}
}
}
Aggregations