Search in sources :

Example 1 with ParameterNotFoundException

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);
    }
}
Also used : TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Parameter(io.gravitee.repository.management.model.Parameter) ParameterNotFoundException(io.gravitee.management.service.exceptions.ParameterNotFoundException) Date(java.util.Date) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

ParameterNotFoundException (io.gravitee.management.service.exceptions.ParameterNotFoundException)1 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 Parameter (io.gravitee.repository.management.model.Parameter)1 Date (java.util.Date)1