Search in sources :

Example 61 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class PageService method deleteWidgetConfiguration.

@Override
public void deleteWidgetConfiguration(String pageCode, int frameId) {
    try {
        IPage page = this.loadPage(pageCode, STATUS_DRAFT);
        if (null == page) {
            throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
        }
        if (frameId > page.getWidgets().length) {
            throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
        }
        this.pageManager.removeWidget(pageCode, frameId);
    } catch (ApsSystemException e) {
        logger.error("Error in delete widget configuration for page {} and frame {}", pageCode, frameId, e);
        throw new RestServerError("error in delete widget configuration", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) IPage(com.agiletec.aps.system.services.page.IPage) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 62 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class PageService method updatePage.

@Override
public PageDto updatePage(String pageCode, PageRequest pageRequest) {
    IPage oldPage = this.getPageManager().getDraftPage(pageCode);
    if (null == oldPage) {
        throw new RestRourceNotFoundException(null, "page", pageCode);
    }
    this.validateRequest(pageRequest);
    try {
        IPage newPage = this.updatePage(oldPage, pageRequest);
        this.getPageManager().updatePage(newPage);
        return this.getDtoBuilder().convert(newPage);
    } catch (ApsSystemException e) {
        logger.error("Error updating page {}", pageCode, e);
        throw new RestServerError("error in update page", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) IPage(com.agiletec.aps.system.services.page.IPage) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 63 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException 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 64 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class PageModelService method getReferencingObjects.

@SuppressWarnings("unchecked")
public Map<String, List<Object>> getReferencingObjects(PageModel pageModel) throws ApsSystemException {
    Map<String, List<Object>> references = new HashMap<String, List<Object>>();
    try {
        String[] defNames = applicationContext.getBeanNamesForType(PageModelUtilizer.class);
        for (String beanName : defNames) {
            Object service = null;
            try {
                service = applicationContext.getBean(beanName);
            } catch (Throwable t) {
                logger.error("error in hasReferencingObjects", t);
                service = null;
            }
            if (service != null) {
                PageModelUtilizer pageModelUtilizer = (PageModelUtilizer) service;
                List<Object> utilizers = pageModelUtilizer.getPageModelUtilizers(pageModel.getCode());
                if (utilizers != null && !utilizers.isEmpty()) {
                    references.put(pageModelUtilizer.getName() + "Utilizers", utilizers);
                }
            }
        }
    } catch (Throwable t) {
        throw new ApsSystemException("Error on getReferencingObjects methods", t);
    }
    return references;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer)

Example 65 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException 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)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)452 ArrayList (java.util.ArrayList)53 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)48 RestServerError (org.entando.entando.aps.system.exception.RestServerError)39 ApsProperties (com.agiletec.aps.util.ApsProperties)26 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)23 HashMap (java.util.HashMap)23 UserDetails (com.agiletec.aps.system.services.user.UserDetails)21 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)21 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)20 Date (java.util.Date)20 StringReader (java.io.StringReader)18 IPage (com.agiletec.aps.system.services.page.IPage)17 List (java.util.List)17 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)16 File (java.io.File)16 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 Widget (com.agiletec.aps.system.services.page.Widget)15 IOException (java.io.IOException)15 Cache (org.springframework.cache.Cache)15