use of io.gravitee.management.service.exceptions.ParameterNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class ParameterServiceImpl method update.
@Override
public Parameter update(final String key, final String value) {
try {
final Optional<Parameter> optionalParameter = parameterRepository.findById(key);
if (!optionalParameter.isPresent()) {
throw new ParameterNotFoundException(key);
}
final Parameter parameter = new Parameter();
parameter.setKey(key);
parameter.setValue(value);
final Parameter updatedParameter = parameterRepository.update(parameter);
auditService.createPortalAuditLog(singletonMap(PARAMETER, updatedParameter.getKey()), PARAMETER_UPDATED, new Date(), optionalParameter.get(), updatedParameter);
return updatedParameter;
} catch (final TechnicalException ex) {
final String message = "An error occurs while trying to update parameter for key/value: " + key + '/' + value;
LOGGER.error(message, ex);
throw new TechnicalManagementException(message, ex);
}
}
Aggregations