Search in sources :

Example 1 with RestServerError

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

the class WidgetDtoBuilder method toDto.

@Override
protected WidgetDto toDto(WidgetType src) {
    WidgetDto dest = new WidgetDto();
    dest.setCode(src.getCode());
    dest.setGroup(src.getMainGroup());
    dest.setTitles((Hashtable) src.getTitles());
    Integer count = 0;
    try {
        List<IPage> onLinePages = this.getPageManager().getOnlineWidgetUtilizers(src.getCode());
        count += onLinePages.size();
        List<IPage> draftPages = this.getPageManager().getDraftWidgetUtilizers(src.getCode());
        count += draftPages.size();
    } catch (Exception e) {
        logger.error("Error extracting utilizers for widget {}", src.getCode());
        throw new RestServerError("Error extracting utilizers for widget " + src.getCode(), e);
    }
    dest.setUsed(count);
    dest.setPluginCode(src.getPluginCode());
    List<WidgetTypeParameter> params = src.getTypeParameters();
    dest.setHasConfig(null != params && params.size() > 0);
    return dest;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) RestServerError(org.entando.entando.aps.system.exception.RestServerError) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 2 with RestServerError

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

the class ContentListViewerWidgetValidator method validate.

@Override
public BeanPropertyBindingResult validate(WidgetConfigurationRequest widget, IPage page) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(widget, widget.getClass().getSimpleName());
    try {
        logger.debug("validating widget {} for page {}", widget.getCode(), page.getCode());
        WidgetValidatorCmsHelper.validateTitle(widget, getLangManager(), bindingResult);
        WidgetValidatorCmsHelper.validateLink(widget, getLangManager(), getPageManager(), bindingResult);
        this.validateContentType(widget, bindingResult);
        this.validateFilters(widget, bindingResult);
        this.validateContentModel(widget, bindingResult);
    } catch (Throwable e) {
        logger.error("error in validate wiget {} in page {}", widget.getCode(), page.getCode());
        throw new RestServerError("error in widget config validation", e);
    }
    return bindingResult;
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 3 with RestServerError

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

the class ContentViewerWidgetValidator method validate.

@Override
public BeanPropertyBindingResult validate(WidgetConfigurationRequest widget, IPage page) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(widget, widget.getClass().getSimpleName());
    try {
        logger.debug("validating widget {} for page {}", widget.getCode(), page.getCode());
        String contentId = WidgetValidatorCmsHelper.extractConfigParam(widget, WIDGET_CONFIG_KEY_CONTENT_ID);
        WidgetValidatorCmsHelper.validateSingleContentOnPage(widget.getCode(), page, contentId, this.getContentManager(), bindingResult);
        this.validateContentModel(widget, bindingResult);
    } catch (ApsSystemException e) {
        logger.error("error in validate wiget {} in page {}", widget.getCode(), page.getCode());
        throw new RestServerError("error in widget config validation", e);
    }
    return bindingResult;
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 4 with RestServerError

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

the class RowContentListViewerWidgetValidator method validate.

@Override
public BeanPropertyBindingResult validate(WidgetConfigurationRequest widget, IPage page) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(widget, widget.getClass().getSimpleName());
    try {
        logger.debug("validating widget {} for page {}", widget.getCode(), page.getCode());
        WidgetValidatorCmsHelper.validateTitle(widget, getLangManager(), bindingResult);
        WidgetValidatorCmsHelper.validateLink(widget, getLangManager(), getPageManager(), bindingResult);
        this.validateContents(widget, page, bindingResult);
    } catch (Throwable e) {
        logger.error("error in validate wiget {} in page {}", widget.getCode(), page.getCode());
        throw new RestServerError("error in widget config validation", e);
    }
    return bindingResult;
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

Example 5 with RestServerError

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

the class GuiFragmentValidator method validate.

@Override
public void validate(Object target, Errors errors) {
    GuiFragmentRequestBody request = (GuiFragmentRequestBody) target;
    String code = request.getCode();
    try {
        if (null != this.guiFragmentManager.getGuiFragment(code)) {
            errors.rejectValue("code", ERRCODE_FRAGMENT_ALREADY_EXISTS, new String[] { code }, "guifragment.exists");
        } else if (code.length() > 50) {
            errors.rejectValue("code", ERRCODE_FRAGMENT_INVALID_CODE, new String[] {}, "guifragment.code.invalid");
        } else if (!code.matches("^[a-zA-Z0-9_]*$")) {
            errors.rejectValue("code", ERRCODE_FRAGMENT_INVALID_CODE, new String[] {}, "guifragment.code.invalid");
        }
        this.validateGuiCode(request, errors);
    } catch (Exception e) {
        logger.error("Error extracting fragment {}", code, e);
        throw new RestServerError("error extracting fragment", e);
    }
}
Also used : GuiFragmentRequestBody(org.entando.entando.web.guifragment.model.GuiFragmentRequestBody) RestServerError(org.entando.entando.aps.system.exception.RestServerError)

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