Search in sources :

Example 11 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class PageModelService method removePageModel.

@Override
public void removePageModel(String code) {
    try {
        PageModel pageModel = this.getPageModelManager().getPageModel(code);
        if (null == pageModel) {
            return;
        }
        BeanPropertyBindingResult validationResult = this.validateDelete(pageModel);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getPageModelManager().deletePageModel(code);
    } catch (ApsSystemException e) {
        logger.error("Error in delete pagemodel {}", code, e);
        throw new RestServerError("error in delete pagemodel", e);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 12 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class PageModelService method getPageModels.

@Override
public PagedMetadata<PageModelDto> getPageModels(RestListRequest restListReq) {
    try {
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
        filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(PageModelDto.getEntityFieldName(i.getKey())));
        SearcherDaoPaginatedResult<PageModel> pageModels = this.getPageModelManager().searchPageModels(filters);
        List<PageModelDto> dtoList = null;
        if (null != pageModels) {
            dtoList = this.getDtoBuilder().convert(pageModels.getList());
        }
        PagedMetadata<PageModelDto> pagedMetadata = new PagedMetadata<>(restListReq, pageModels);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error in search pageModels", t);
        throw new RestServerError("error in search pageModels", t);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageModelValidator(org.entando.entando.web.pagemodel.validator.PageModelValidator) RestServerError(org.entando.entando.aps.system.exception.RestServerError) Frame(com.agiletec.aps.system.services.pagemodel.Frame) Service(org.springframework.stereotype.Service) Map(java.util.Map) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) BeansException(org.springframework.beans.BeansException) Collectors(java.util.stream.Collectors) PageModelFrameReq(org.entando.entando.web.pagemodel.model.PageModelFrameReq) PageModelRequest(org.entando.entando.web.pagemodel.model.PageModelRequest) ApplicationContext(org.springframework.context.ApplicationContext) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto)

Example 13 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class PageSettingsService method updatePageSettings.

@Override
public PageSettingsDto updatePageSettings(PageSettingsRequest request) {
    try {
        Map<String, String> params = this.createParamsMap(request);
        Map<String, String> systemParams = this.getSystemParams();
        params.keySet().forEach((param) -> {
            systemParams.put(param, params.get(param));
        });
        String xmlParams = this.getConfigManager().getConfigItem(SystemConstants.CONFIG_ITEM_PARAMS);
        String newXmlParams = SystemParamsUtils.getNewXmlParams(xmlParams, systemParams);
        this.getConfigManager().updateConfigItem(SystemConstants.CONFIG_ITEM_PARAMS, newXmlParams);
        return this.getDtoBuilder().convert(systemParams);
    } catch (Throwable e) {
        logger.error("Error updating page settings", e);
        throw new RestServerError("Error updating page settings", e);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 14 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class RoleService method addRole.

@Override
public RoleDto addRole(RoleRequest roleRequest) {
    try {
        Role role = this.createRole(roleRequest);
        BeanPropertyBindingResult validationResult = this.validateRoleForAdd(role);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getRoleManager().addRole(role);
        RoleDto dto = this.getDtoBuilder().toDto(role, this.getRoleManager().getPermissionsCodes());
        return dto;
    } catch (ApsSystemException e) {
        logger.error("Error adding a role", e);
        throw new RestServerError("error in add role", e);
    }
}
Also used : Role(com.agiletec.aps.system.services.role.Role) RoleDto(org.entando.entando.aps.system.services.role.model.RoleDto) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 15 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.

the class RoleService method removeRole.

@Override
public void removeRole(String roleCode) {
    try {
        Role role = this.getRoleManager().getRole(roleCode);
        if (null == role) {
            logger.info("role {} does not exists", roleCode);
            return;
        }
        BeanPropertyBindingResult validationResult = this.validateRoleForDelete(role);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getRoleManager().removeRole(role);
    } catch (ApsSystemException e) {
        logger.error("Error in delete role {}", roleCode, e);
        throw new RestServerError("error in delete role", e);
    }
}
Also used : Role(com.agiletec.aps.system.services.role.Role) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Aggregations

RestServerError (org.entando.entando.aps.system.exception.RestServerError)65 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)45 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)28 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)25 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)13 ArrayList (java.util.ArrayList)12 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)12 IPage (com.agiletec.aps.system.services.page.IPage)10 List (java.util.List)10 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)9 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)8 LoggerFactory (org.slf4j.LoggerFactory)8 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)7 RestListRequest (org.entando.entando.web.common.model.RestListRequest)7 Logger (org.slf4j.Logger)7 ApsProperties (com.agiletec.aps.util.ApsProperties)6 Group (com.agiletec.aps.system.services.group.Group)5 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 Category (com.agiletec.aps.system.services.category.Category)4