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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations