Search in sources :

Example 1 with BpmnCheckResult

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);
}
Also used : CSR(de.trustable.ca3s.core.domain.CSR) ProcessInstanceWithVariables(org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables) CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) ResponseEntity(org.springframework.http.ResponseEntity) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) CAConnectorConfig(de.trustable.ca3s.core.domain.CAConnectorConfig) BpmnCheckResult(de.trustable.ca3s.core.web.rest.data.BpmnCheckResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CAConnectorConfig (de.trustable.ca3s.core.domain.CAConnectorConfig)1 CSR (de.trustable.ca3s.core.domain.CSR)1 CsrAttribute (de.trustable.ca3s.core.domain.CsrAttribute)1 BpmnCheckResult (de.trustable.ca3s.core.web.rest.data.BpmnCheckResult)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 ProcessInstanceWithVariables (org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1