Search in sources :

Example 6 with RestServerError

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

the class LabelService method addLabelGroup.

@Override
public LabelDto addLabelGroup(LabelDto labelRequest) {
    try {
        BeanPropertyBindingResult validationResult = this.validateAddLabelGroup(labelRequest);
        if (validationResult.hasErrors()) {
            throw new ValidationGenericException(validationResult);
        }
        String code = labelRequest.getKey();
        ApsProperties languages = new ApsProperties();
        languages.putAll(labelRequest.getTitles());
        this.getI18nManager().addLabelGroup(code, languages);
        return labelRequest;
    } catch (ApsSystemException t) {
        logger.error("error in add label group with code {}", labelRequest.getKey(), t);
        throw new RestServerError("error in add label group", t);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 7 with RestServerError

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

the class LabelService method updateLabelGroup.

@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
    try {
        String code = labelRequest.getKey();
        ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
        if (null == labelGroup) {
            logger.warn("no label found with key {}", code);
            throw new RestRourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
        }
        BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
        if (validationResult.hasErrors()) {
            throw new ValidationGenericException(validationResult);
        }
        ApsProperties languages = new ApsProperties();
        languages.putAll(labelRequest.getTitles());
        this.getI18nManager().updateLabelGroup(code, languages);
        return labelRequest;
    } catch (ApsSystemException t) {
        logger.error("error in update label group with code {}", labelRequest.getKey(), t);
        throw new RestServerError("error in update label group", t);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 8 with RestServerError

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

the class PageService method movePage.

@Override
public PageDto movePage(String pageCode, PagePositionRequest pageRequest) {
    IPage parent = this.getPageManager().getDraftPage(pageRequest.getParentCode()), page = this.getPageManager().getDraftPage(pageCode);
    boolean moved = true;
    int iterations = Math.abs(page.getPosition() - pageRequest.getPosition());
    boolean moveUp = page.getPosition() > pageRequest.getPosition();
    try {
        if (page.getParentCode().equals(parent.getCode())) {
            while (iterations-- > 0 && (moved = this.getPageManager().movePage(pageCode, moveUp))) ;
        } else {
            moved = this.getPageManager().movePage(page, parent);
        }
        page = this.getPageManager().getDraftPage(pageCode);
    } catch (ApsSystemException e) {
        logger.error("Error moving page {}", pageCode, e);
        throw new RestServerError("error in moving page", e);
    }
    return this.getDtoBuilder().convert(page);
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 9 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError 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 10 with RestServerError

use of org.entando.entando.aps.system.exception.RestServerError 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)

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