Search in sources :

Example 1 with CsrAttribute

use of de.trustable.ca3s.core.domain.CsrAttribute in project ca3sCore by kuehne-trustable-de.

the class CsrAttributeResourceIT method updateCsrAttribute.

@Test
@Transactional
public void updateCsrAttribute() throws Exception {
    // Initialize the database
    csrAttributeService.save(csrAttribute);
    int databaseSizeBeforeUpdate = csrAttributeRepository.findAll().size();
    // Update the csrAttribute
    CsrAttribute updatedCsrAttribute = csrAttributeRepository.findById(csrAttribute.getId()).get();
    // Disconnect from session so that the updates on updatedCsrAttribute are not directly saved in db
    em.detach(updatedCsrAttribute);
    updatedCsrAttribute.name(UPDATED_NAME).value(UPDATED_VALUE);
    restCsrAttributeMockMvc.perform(put("/api/csr-attributes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedCsrAttribute))).andExpect(status().isOk());
    // Validate the CsrAttribute in the database
    List<CsrAttribute> csrAttributeList = csrAttributeRepository.findAll();
    assertThat(csrAttributeList).hasSize(databaseSizeBeforeUpdate);
    CsrAttribute testCsrAttribute = csrAttributeList.get(csrAttributeList.size() - 1);
    assertThat(testCsrAttribute.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testCsrAttribute.getValue()).isEqualTo(UPDATED_VALUE);
}
Also used : CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CsrAttribute

use of de.trustable.ca3s.core.domain.CsrAttribute in project ca3sCore by kuehne-trustable-de.

the class CsrAttributeResource method createCsrAttribute.

/**
 * {@code POST  /csr-attributes} : Create a new csrAttribute.
 *
 * @param csrAttribute the csrAttribute to create.
 * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new csrAttribute, or with status {@code 400 (Bad Request)} if the csrAttribute has already an ID.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@PostMapping("/csr-attributes")
public ResponseEntity<CsrAttribute> createCsrAttribute(@Valid @RequestBody CsrAttribute csrAttribute) throws URISyntaxException {
    log.debug("REST request to save CsrAttribute : {}", csrAttribute);
    if (csrAttribute.getId() != null) {
        throw new BadRequestAlertException("A new csrAttribute cannot already have an ID", ENTITY_NAME, "idexists");
    }
    CsrAttribute result = csrAttributeService.save(csrAttribute);
    return ResponseEntity.created(new URI("/api/csr-attributes/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(de.trustable.ca3s.core.web.rest.errors.BadRequestAlertException) CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) URI(java.net.URI)

Example 3 with CsrAttribute

use of de.trustable.ca3s.core.domain.CsrAttribute in project ca3sCore by kuehne-trustable-de.

the class CsrAttributeResourceIT method createCsrAttribute.

@Test
@Transactional
public void createCsrAttribute() throws Exception {
    int databaseSizeBeforeCreate = csrAttributeRepository.findAll().size();
    // Create the CsrAttribute
    restCsrAttributeMockMvc.perform(post("/api/csr-attributes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(csrAttribute))).andExpect(status().isCreated());
    // Validate the CsrAttribute in the database
    List<CsrAttribute> csrAttributeList = csrAttributeRepository.findAll();
    assertThat(csrAttributeList).hasSize(databaseSizeBeforeCreate + 1);
    CsrAttribute testCsrAttribute = csrAttributeList.get(csrAttributeList.size() - 1);
    assertThat(testCsrAttribute.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testCsrAttribute.getValue()).isEqualTo(DEFAULT_VALUE);
}
Also used : CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with CsrAttribute

use of de.trustable.ca3s.core.domain.CsrAttribute 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)

Example 5 with CsrAttribute

use of de.trustable.ca3s.core.domain.CsrAttribute in project ca3sCore by kuehne-trustable-de.

the class CSRAdministration method updateARAttributes.

private void updateARAttributes(CSRAdministrationData adminData, CSR csr) {
    for (CsrAttribute csrAttr : csr.getCsrAttributes()) {
        if (csrAttr.getName().startsWith(CsrAttribute.ARA_PREFIX)) {
            for (NamedValue nv : adminData.getArAttributeArr()) {
                if (csrAttr.getName().equals(CsrAttribute.ARA_PREFIX + nv.getName())) {
                    if (!csrAttr.getValue().equals(nv.getValue())) {
                        auditService.saveAuditTrace(auditService.createAuditTraceCsrAttribute(csrAttr.getName(), csrAttr.getValue(), nv.getValue(), csr));
                        csrAttr.setValue(nv.getValue());
                        LOG.debug("CSR attribute {} updated to {}", csrAttr.getName(), csrAttr.getValue());
                    }
                }
            }
        }
    }
    csrAttributeRepository.saveAll(csr.getCsrAttributes());
}
Also used : CsrAttribute(de.trustable.ca3s.core.domain.CsrAttribute) NamedValue(de.trustable.ca3s.core.service.dto.NamedValue)

Aggregations

CsrAttribute (de.trustable.ca3s.core.domain.CsrAttribute)6 BadRequestAlertException (de.trustable.ca3s.core.web.rest.errors.BadRequestAlertException)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Transactional (org.springframework.transaction.annotation.Transactional)2 CAConnectorConfig (de.trustable.ca3s.core.domain.CAConnectorConfig)1 CSR (de.trustable.ca3s.core.domain.CSR)1 NamedValue (de.trustable.ca3s.core.service.dto.NamedValue)1 BpmnCheckResult (de.trustable.ca3s.core.web.rest.data.BpmnCheckResult)1 URI (java.net.URI)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