use of io.gravitee.rest.api.service.exceptions.QualityRuleNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class QualityRuleServiceImpl method findById.
@Override
public QualityRuleEntity findById(String id) {
try {
LOGGER.debug("Find quality rule by id : {}", id);
Optional<QualityRule> qualityRule = qualityRuleRepository.findById(id);
if (qualityRule.isPresent()) {
return convert(qualityRule.get());
}
throw new QualityRuleNotFoundException(id);
} catch (TechnicalException ex) {
final String error = "An error occurs while trying to find a quality rule using its ID: " + id;
LOGGER.error(error, ex);
throw new TechnicalManagementException(error, ex);
}
}
use of io.gravitee.rest.api.service.exceptions.QualityRuleNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class QualityRuleServiceImpl method update.
@Override
public QualityRuleEntity update(UpdateQualityRuleEntity updateEntity) {
try {
final Optional<QualityRule> optionalQualityRule = qualityRuleRepository.findById(updateEntity.getId());
if (!optionalQualityRule.isPresent()) {
throw new QualityRuleNotFoundException(updateEntity.getId());
}
final QualityRule qualityRule = qualityRuleRepository.update(convert(updateEntity, optionalQualityRule.get()));
auditService.createEnvironmentAuditLog(singletonMap(QUALITY_RULE, qualityRule.getId()), QUALITY_RULE_UPDATED, qualityRule.getUpdatedAt(), optionalQualityRule.get(), qualityRule);
return convert(qualityRule);
} catch (TechnicalException e) {
LOGGER.error("An error occurs while trying to update quality rule {}", updateEntity, e);
throw new TechnicalManagementException("An error occurs while trying to update quality rule " + updateEntity, e);
}
}
Aggregations