Search in sources :

Example 51 with ResourceNotFoundException

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));
}
Also used : ConsumerRecordVO(org.entando.entando.aps.system.services.oauth2.model.ConsumerRecordVO) ApiConsumer(org.entando.entando.aps.system.services.oauth2.model.ApiConsumer) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Example 52 with ResourceNotFoundException

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);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 53 with ResourceNotFoundException

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);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)53 RestServerError (org.entando.entando.aps.system.exception.RestServerError)27 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)20 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)15 IPage (com.agiletec.aps.system.services.page.IPage)9 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)9 Category (com.agiletec.aps.system.services.category.Category)7 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)7 ResponseEntity (org.springframework.http.ResponseEntity)7 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)5 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 Group (com.agiletec.aps.system.services.group.Group)3 Widget (com.agiletec.aps.system.services.page.Widget)3 Role (com.agiletec.aps.system.services.role.Role)3