use of de.trustable.ca3s.core.web.rest.data.BpmnCheckResult in project ca3sCore by kuehne-trustable-de.
the class BPMNUpDownloadController method postBPMNForCSR.
/**
* check results a given process id when processing a given CSR
*
* @param processId the internal process id
* @return the process's response
*/
@RequestMapping(value = "/bpmn/check/csr/{processId}/{csrId}", method = POST)
public ResponseEntity<Map<String, String>> postBPMNForCSR(@PathVariable final String processId, @PathVariable final String csrId) {
LOG.info("Received bpmn check request for process id {} and csr id {}", processId, csrId);
Optional<CSR> csrOpt = csrRepository.findById(Long.parseLong(csrId));
CAConnectorConfig caConfig = caConnectorConfigRepository.getOne(1L);
ProcessInstanceWithVariables processInstanceWithVariables = bpmnUtil.checkCertificateCreationProcess(csrOpt.get(), caConfig, processId);
if (processInstanceWithVariables != null) {
BpmnCheckResult result = new BpmnCheckResult();
Map<String, Object> variables = processInstanceWithVariables.getVariables();
for (String key : variables.keySet()) {
if ("csrAttributes".equals(key)) {
for (CsrAttribute csrAtt : (Set<CsrAttribute>) variables.get(key)) {
LOG.info("bpmn process returns CsrAttribute {} with value {}", csrAtt.getName(), csrAtt.getValue());
result.getCsrAttributes().add(new ImmutablePair<>(csrAtt.getName(), csrAtt.getValue()));
}
} else if ("failureReason".equals(key)) {
result.setFailureReason(variables.get(key).toString());
} else if ("status".equals(key)) {
result.setStatus(variables.get(key).toString());
} else if ("isActive".equals(key)) {
result.setActive(Boolean.parseBoolean(variables.get(key).toString()));
} else {
String value = variables.get(key).toString();
LOG.info("bpmn process returns variable {} with value {}", key, value);
result.getCsrAttributes().add(new ImmutablePair<>(key, value));
}
}
return new ResponseEntity(result, HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Aggregations