use of com.emc.storageos.model.customservices.CustomServicesWorkflowDocument in project coprhd-controller by CoprHD.
the class CustomServicesService method getStepHash.
private ImmutableMap<String, Step> getStepHash(final URI uri) throws Exception {
final String raw;
raw = ExecutionUtils.currentContext().getOrder().getWorkflowDocument();
if (null == raw) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Invalid custom service. Workflow document cannot be null");
}
final CustomServicesWorkflowDocument obj = WorkflowHelper.toWorkflowDocument(raw);
final List<CustomServicesWorkflow> wfs = customServicesWorkflowManager.getByNameOrId(obj.getName());
if (wfs == null || wfs.isEmpty() || wfs.size() > 1) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow list is null or empty or more than one workflow per Workflow name:" + obj.getName());
}
if (wfs.get(0) == null || StringUtils.isEmpty(wfs.get(0).getState())) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow state is null or empty for workflow:" + obj.getName());
}
if (wfs.get(0).getState().equals(CustomServicesWorkflow.CustomServicesWorkflowStatus.NONE.toString()) || wfs.get(0).getState().equals(CustomServicesWorkflow.CustomServicesWorkflowStatus.INVALID.toString())) {
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow state is not valid. Cannot run workflow" + obj.getName() + "State:" + wfs.get(0).getState());
}
final List<Step> steps = obj.getSteps();
final ImmutableMap.Builder<String, Step> builder = ImmutableMap.builder();
for (final Step step : steps) {
builder.put(step.getId(), step);
}
final ImmutableMap<String, Step> stepsHash = builder.build();
ExecutionUtils.currentContext().logInfo("customServicesService.status", obj.getName());
return stepsHash;
}
Aggregations