use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiResourceInterface method addResource.
public StringApiResponse addResource(JAXBResource jaxbResource, Properties properties) throws ApiException, Throwable {
StringApiResponse response = new StringApiResponse();
BaseResourceDataBean bean = null;
try {
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
this.check(jaxbResource, user, response, true);
if (null != response.getErrors() && !response.getErrors().isEmpty()) {
return response;
}
bean = jaxbResource.createBataBean(this.getCategoryManager());
String id = bean.getResourceId();
if (null != id && id.trim().length() > 0) {
Pattern pattern = Pattern.compile("^[a-zA-Z]+$");
Matcher matcher = pattern.matcher(id);
if (!matcher.matches()) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "The resourceId can contain only alphabetic characters", Response.Status.CONFLICT);
}
}
this.getResourceManager().addResource(bean);
response.setResult(IResponseBuilder.SUCCESS);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in addResource", t);
throw new ApsSystemException("Error into API method", t);
} finally {
if (null != bean && null != bean.getFile()) {
bean.getFile().delete();
}
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiResourceInterface method updateResource.
public StringApiResponse updateResource(JAXBResource jaxbResource, Properties properties) throws Throwable {
StringApiResponse response = new StringApiResponse();
BaseResourceDataBean bean = null;
try {
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
this.check(jaxbResource, user, response, false);
if (null != response.getErrors() && !response.getErrors().isEmpty()) {
return response;
}
bean = jaxbResource.createBataBean(this.getCategoryManager());
this.getResourceManager().updateResource(bean);
response.setResult(IResponseBuilder.SUCCESS);
} catch (Throwable t) {
_logger.error("error in updateResource", t);
throw new ApsSystemException("Error into API method", t);
} finally {
if (null != bean && null != bean.getFile()) {
bean.getFile().delete();
}
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class CmsPageManagerWrapper method getContentUtilizers.
@Override
public List getContentUtilizers(String contentId) throws ApsSystemException {
List<IPage> pages = new ArrayList<IPage>();
try {
IPage root = this.getPageManager().getOnlineRoot();
this.searchContentUtilizers(root, pages, contentId);
} catch (Throwable t) {
_logger.error("Error loading referenced pages", t);
throw new ApsSystemException("Error loading referenced pages with content " + contentId, t);
}
return pages;
}
use of com.agiletec.aps.system.exception.ApsSystemException 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 com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class RowContentListTag method getContents.
protected List<Properties> getContents(RequestContext reqCtx) throws ApsSystemException {
List<Properties> contents = null;
try {
Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
if (null == currentWidget || null == currentWidget.getConfig()) {
return new ArrayList<Properties>();
}
String widgetConfig = currentWidget.getConfig().getProperty("contents");
contents = RowContentListHelper.fromParameterToContents(widgetConfig);
if (StringUtils.isBlank(widgetConfig)) {
return contents;
}
} catch (Throwable t) {
_logger.error("Error extracting contents", t);
throw new ApsSystemException("Error extracting contents", t);
}
return contents;
}
Aggregations