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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations