public String update(Request request, Response response) { String environmentName = request.params("name"); BasicEnvironmentConfig environmentConfig = (BasicEnvironmentConfig) buildEntityFromRequestBody(request); EnvironmentConfig oldEnvironmentConfig = fetchEntityFromConfig(environmentName); HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult(); if (isPutRequestStale(request, oldEnvironmentConfig)) { throw haltBecauseEtagDoesNotMatch("environment", environmentName); } if (!StringUtils.equals(environmentName, environmentConfig.name().toString())) { throw haltBecauseRenameOfEntityIsNotSupported("environment"); } environmentConfigService.updateEnvironment(environmentConfig.name().toString(), environmentConfig, currentUsername(), etagFor(oldEnvironmentConfig), operationResult); setEtagHeader(environmentConfig, response); return handleCreateOrUpdateResponse(request, response, environmentConfig, operationResult); }