Search in sources :

Example 46 with RestServerError

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

the class GuiFragmentService method getGuiFragments.

@Override
public PagedMetadata<GuiFragmentDtoSmall> getGuiFragments(RestListRequest restListReq) {
    PagedMetadata<GuiFragmentDtoSmall> pagedMetadata = null;
    try {
        SearcherDaoPaginatedResult<GuiFragment> fragments = this.getGuiFragmentManager().getGuiFragments(restListReq.buildFieldSearchFilters());
        List<GuiFragmentDtoSmall> dtoList = this.getDtoSmallBuilder().convert(fragments.getList());
        pagedMetadata = new PagedMetadata<>(restListReq, fragments);
        pagedMetadata.setBody(dtoList);
    } catch (Throwable t) {
        logger.error("error in search fragments", t);
        throw new RestServerError("error in search fragments", t);
    }
    return pagedMetadata;
}
Also used : GuiFragmentDtoSmall(org.entando.entando.aps.system.services.guifragment.model.GuiFragmentDtoSmall) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 47 with RestServerError

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

the class GuiFragmentService method updateGuiFragment.

@Override
public GuiFragmentDto updateGuiFragment(GuiFragmentRequestBody guiFragmentRequest) {
    String code = guiFragmentRequest.getCode();
    try {
        GuiFragment fragment = this.getGuiFragmentManager().getGuiFragment(code);
        if (null == fragment) {
            throw new RestRourceNotFoundException(GuiFragmentValidator.ERRCODE_FRAGMENT_DOES_NOT_EXISTS, "fragment", code);
        }
        fragment.setGui(guiFragmentRequest.getGuiCode());
        this.getGuiFragmentManager().updateGuiFragment(fragment);
        return this.getDtoBuilder().convert(fragment);
    } catch (RestRourceNotFoundException e) {
        throw e;
    } catch (ApsSystemException e) {
        logger.error("Error updating fragment {}", code, e);
        throw new RestServerError("error in update fragment", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 48 with RestServerError

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

the class GuiFragmentService method addGuiFragment.

@Override
public GuiFragmentDto addGuiFragment(GuiFragmentRequestBody guiFragmentRequest) {
    try {
        GuiFragment fragment = this.createGuiFragment(guiFragmentRequest);
        this.getGuiFragmentManager().addGuiFragment(fragment);
        return this.getDtoBuilder().convert(fragment);
    } catch (ApsSystemException e) {
        logger.error("Error adding fragment", e);
        throw new RestServerError("error add fragment", e);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 49 with RestServerError

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

the class GuiFragmentService method removeGuiFragment.

@Override
public void removeGuiFragment(String guiFragmentCode) {
    try {
        GuiFragment fragment = this.getGuiFragmentManager().getGuiFragment(guiFragmentCode);
        if (null == fragment) {
            return;
        }
        GuiFragmentDto dto = this.getDtoBuilder().convert(fragment);
        BeanPropertyBindingResult validationResult = this.checkFragmentForDelete(fragment, dto);
        if (validationResult.hasErrors()) {
            throw new ValidationGenericException(validationResult);
        }
        this.getGuiFragmentManager().deleteGuiFragment(guiFragmentCode);
    } catch (ApsSystemException e) {
        logger.error("Error in delete guiFragmentCode {}", guiFragmentCode, e);
        throw new RestServerError("error in delete guiFragmentCode", e);
    }
}
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) GuiFragmentDto(org.entando.entando.aps.system.services.guifragment.model.GuiFragmentDto)

Example 50 with RestServerError

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

the class LabelService method removeLabelGroup.

@Override
public void removeLabelGroup(String code) {
    try {
        ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
        if (null == labelGroup) {
            logger.warn("no label found with key {}", code);
            return;
        }
        this.getI18nManager().deleteLabelGroup(code);
    } catch (ApsSystemException t) {
        logger.error("error in delete label group with code {}", code, t);
        throw new RestServerError("error in delete label group", t);
    }
}
Also used : RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

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