use of com.netflix.spinnaker.front50.exceptions.InvalidRequestException in project front50 by spinnaker.
the class DeliveryController method deleteConfig.
@PreAuthorize("hasPermission(#application, 'APPLICATION', 'WRITE')")
@ApiOperation(value = "", notes = "Delete a delivery config")
@RequestMapping(method = RequestMethod.DELETE, value = "/applications/{application}/deliveries/{id}")
void deleteConfig(@PathVariable String application, @PathVariable String id) {
Delivery config = deliveryRepository.findById(id);
if (!config.getApplication().equals(application)) {
throw new InvalidRequestException("No config with id " + id + " found in application " + application);
}
deliveryRepository.delete(id);
}
use of com.netflix.spinnaker.front50.exceptions.InvalidRequestException in project front50 by spinnaker.
the class PipelineController method update.
@PreAuthorize("hasPermission(#pipeline.application, 'APPLICATION', 'WRITE')")
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Pipeline update(@PathVariable final String id, @RequestParam(value = "staleCheck", required = false, defaultValue = "false") Boolean staleCheck, @RequestBody Pipeline pipeline) {
Pipeline existingPipeline = pipelineDAO.findById(id);
if (!pipeline.getId().equals(existingPipeline.getId())) {
throw new InvalidRequestException(format("The provided id %s doesn't match the pipeline id %s", pipeline.getId(), existingPipeline.getId()));
}
validatePipeline(pipeline, staleCheck);
pipeline.setName(pipeline.getName().trim());
pipeline.setLastModified(System.currentTimeMillis());
pipeline = ensureCronTriggersHaveIdentifier(pipeline);
pipelineDAO.update(id, pipeline);
return pipeline;
}
use of com.netflix.spinnaker.front50.exceptions.InvalidRequestException in project front50 by spinnaker.
the class PipelineTemplateController method update.
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
PipelineTemplate update(@PathVariable String id, @RequestBody PipelineTemplate pipelineTemplate) {
PipelineTemplate existingPipelineTemplate = getPipelineTemplateDAO().findById(id);
if (!pipelineTemplate.getId().equals(existingPipelineTemplate.getId())) {
throw new InvalidRequestException("The provided id " + id + " doesn't match the pipeline template id " + pipelineTemplate.getId());
}
pipelineTemplate.setLastModified(System.currentTimeMillis());
getPipelineTemplateDAO().update(id, pipelineTemplate);
return pipelineTemplate;
}
use of com.netflix.spinnaker.front50.exceptions.InvalidRequestException in project front50 by spinnaker.
the class V2PipelineTemplateController method computeSHA256Digest.
@VisibleForTesting
public String computeSHA256Digest(PipelineTemplate pipelineTemplate) {
Map<String, Object> sortedMap = (Map<String, Object>) sortObjectRecursive(pipelineTemplate);
try {
String jsonPayload = objectMapper.writeValueAsString(sortedMap).replaceAll("\\s+", "");
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hashBytes = digest.digest(jsonPayload.getBytes(StandardCharsets.UTF_8));
return Hex.encodeHexString(hashBytes);
} catch (NoSuchAlgorithmException | JsonProcessingException e) {
throw new InvalidRequestException(String.format("Computing digest for pipeline template %s failed. Nested exception is %s", pipelineTemplate.undecoratedId(), e));
}
}
use of com.netflix.spinnaker.front50.exceptions.InvalidRequestException in project front50 by spinnaker.
the class ProjectsController method put.
@ApiOperation(value = "", notes = "Update an existing project")
@RequestMapping(method = RequestMethod.PUT, value = "/{projectId}")
public Project put(@PathVariable final String projectId, @RequestBody final Project project) {
Project existingProject = projectDAO.findById(projectId);
project.setId(existingProject.getId());
project.setCreateTs(existingProject.getCreateTs());
project.setUpdateTs(System.currentTimeMillis());
try {
if (!projectDAO.findByName(project.getName()).getId().equals(projectId)) {
// renamed projects must still be uniquely named
throw new InvalidRequestException(format("A Project named '%s' already exists", project.getName()));
}
} catch (NotFoundException ignored) {
}
projectDAO.update(projectId, project);
return project;
}
Aggregations