public String update(Request req, Response res) { PipelineTemplateConfig existingTemplateConfig = fetchEntityFromConfig(req.params("template_name")); PipelineTemplateConfig templateConfigFromRequest = buildEntityFromRequestBody(req); if (isRenameAttempt(existingTemplateConfig, templateConfigFromRequest)) { throw haltBecauseRenameOfEntityIsNotSupported("templates"); } if (isPutRequestStale(req, existingTemplateConfig)) { throw haltBecauseEtagDoesNotMatch("template", existingTemplateConfig.name()); } HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); templateConfigService.updateTemplateConfig(SessionUtils.currentUsername(), templateConfigFromRequest, result, etagFor(existingTemplateConfig)); return handleCreateOrUpdateResponse(req, res, templateConfigFromRequest, result); }