use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiDataObjectInterface method validate.
private List<ApiError> validate(DataObject dataObject) throws ApsSystemException {
List<ApiError> errors = new ArrayList<ApiError>();
try {
if (null == dataObject.getMainGroup()) {
errors.add(new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, "Main group null", Response.Status.CONFLICT));
}
List<FieldError> fieldErrors = dataObject.validate(this.getGroupManager());
if (null != fieldErrors) {
for (int i = 0; i < fieldErrors.size(); i++) {
FieldError fieldError = fieldErrors.get(i);
if (fieldError instanceof AttributeFieldError) {
AttributeFieldError attributeError = (AttributeFieldError) fieldError;
errors.add(new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, attributeError.getFullMessage(), Response.Status.CONFLICT));
} else {
errors.add(new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, fieldError.getMessage(), Response.Status.CONFLICT));
}
}
}
} catch (Throwable t) {
_logger.error("Error validating DataObject", t);
throw new ApsSystemException("Error validating DataObject", t);
}
return errors;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiDataObjectInterface method updateDataObject.
public StringApiResponse updateDataObject(JAXBDataObject jaxbDataObject, Properties properties) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbDataObject.getTypeCode();
DataObject prototype = (DataObject) this.getDataObjectManager().getEntityPrototype(typeCode);
if (null == prototype) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject type with code '" + typeCode + "' does not exist", Response.Status.CONFLICT);
}
DataObject content = (DataObject) jaxbDataObject.buildEntity(prototype, this.getCategoryManager());
DataObject masterData = this.getDataObjectManager().loadDataObject(content.getId(), false);
if (null == masterData) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject with code '" + content.getId() + "' does not exist", Response.Status.CONFLICT);
} else if (!masterData.getMainGroup().equals(content.getMainGroup())) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Invalid main group " + content.getMainGroup() + " not equals then master " + masterData.getMainGroup(), Response.Status.CONFLICT);
}
response = this.validateAndSaveDataObject(content, properties);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error updating DataObject", t);
throw new ApsSystemException("Error updating DataObject", t);
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiDataObjectInterface method getDataObjectToHtml.
public String getDataObjectToHtml(Properties properties) throws ApiException, Throwable {
String render = null;
String id = properties.getProperty("id");
String modelId = properties.getProperty("modelId");
try {
if (null == modelId || modelId.trim().length() == 0) {
return null;
}
DataObject mainDataObject = this.getPublicDataObject(id);
Integer modelIdInteger = this.checkModel(modelId, mainDataObject);
if (null != modelIdInteger) {
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
render = this.getRenderedDataObject(id, modelIdInteger, langCode);
}
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in getDataObjectToHtml", t);
throw new ApsSystemException("Error into API method", t);
}
return render;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class BaseDataListHelper method getDataTypesId.
@Override
public // @CacheableInfo(groups = "T(com.agiletec.plugins.jacms.aps.system.JacmsSystemConstants).CONTENTS_ID_CACHE_GROUP_PREFIX.concat(#bean.contentType)", expiresInMinute = 30)
List<String> getDataTypesId(IDataTypeListBean bean, UserDetails user) throws Throwable {
List<String> contentsId = null;
try {
if (null == bean.getDataType()) {
throw new ApsSystemException("DataObject type not defined");
}
// this.getAllowedGroups(user);
Collection<String> userGroupCodes = getAllowedGroupCodes(user);
contentsId = this.getDataObjectManager().loadDataObjectsId(bean.getDataType(), bean.getCategories(), bean.getFilters(), userGroupCodes);
} catch (Throwable t) {
_logger.error("Error extracting DataObjects id", t);
throw new ApsSystemException("Error extracting DataObjects id", t);
}
return contentsId;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class DataObjectListHelper method getConfiguredUserFilters.
@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
List<UserFilterOptionBean> userEntityFilters = null;
try {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || null == config.getProperty(WIDGET_PARAM_CONTENT_TYPE)) {
return null;
}
String dataObjectTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
IApsEntity prototype = this.getDataObjectManager().getEntityPrototype(dataObjectTypeCode);
if (null == prototype) {
_logger.error("Null dataObject type by code '{}'", dataObjectTypeCode);
return null;
}
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String userFilters = config.getProperty(WIDGET_PARAM_USER_FILTERS);
if (null != userFilters && userFilters.length() > 0) {
userEntityFilters = FilterUtils.getUserFilters(userFilters, currentFrame, currentLang, prototype, this.getUserFilterDateFormat(), reqCtx.getRequest());
}
} catch (Throwable t) {
_logger.error("Error extracting user filters", t);
throw new ApsSystemException("Error extracting user filters", t);
}
return userEntityFilters;
}
Aggregations