use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class ApiConsumerServiceImpl method update.
@Override
public ApiConsumer update(ApiConsumer consumer) throws ApsSystemException {
ConsumerRecordVO record = consumerManager.getConsumerRecord(consumer.getKey());
if (record == null) {
throw new ResourceNotFoundException(ApiConsumer.class.getName(), consumer.getKey());
}
ConsumerRecordVO updatedRecord = consumer.toConsumerRecordVO();
updatedRecord.setIssuedDate(record.getIssuedDate());
return new ApiConsumer(consumerManager.updateConsumer(updatedRecord));
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class LanguageService method disableLang.
protected LanguageDto disableLang(String code) {
try {
Lang sysLang = this.getLangManager().getAssignableLangs().stream().filter(i -> i.getCode().equals(code)).findFirst().orElse(null);
if (null == sysLang) {
logger.warn("no lang found with code {}", code);
throw new ResourceNotFoundException(LanguageValidator.ERRCODE_LANGUAGE_DOES_NOT_EXISTS, "language", code);
}
// idempotent
Lang lang = this.getLangManager().getLang(code);
if (null != this.getLangManager().getLang(code)) {
BeanPropertyBindingResult validations = this.validateDisable(lang);
if (validations.hasErrors()) {
throw new ValidationConflictException(validations);
}
}
this.getLangManager().removeLang(code);
return this.getLanguageDtoBuilder().convert(sysLang);
} catch (ApsSystemException ex) {
throw new RestServerError("error disabling language " + code, ex);
}
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class LanguageService method enableLang.
protected LanguageDto enableLang(String code) {
try {
Lang lang = this.getLangManager().getAssignableLangs().stream().filter(i -> i.getCode().equals(code)).findFirst().orElse(null);
if (null == lang) {
logger.warn("no lang found with code {}", code);
throw new ResourceNotFoundException(LanguageValidator.ERRCODE_LANGUAGE_DOES_NOT_EXISTS, "language", code);
}
// idempotent
if (null == this.getLangManager().getLang(code)) {
logger.warn("the lang {} is already active", code);
this.getLangManager().addLang(lang.getCode());
}
return this.getLanguageDtoBuilder().convert(lang);
} catch (ApsSystemException ex) {
throw new RestServerError("error enabling lang " + code, ex);
}
}
Aggregations