use of org.entando.entando.aps.system.services.dataobject.model.DataObject 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 org.entando.entando.aps.system.services.dataobject.model.DataObject 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 org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class ApiDataObjectTypeInterface method checkEntityTypeToUpdate.
@Override
protected void checkEntityTypeToUpdate(JAXBEntityType jaxbEntityType, IApsEntity entityTypeToUpdate, StringApiResponse response) throws ApiException, Throwable {
JAXBDataObjectType jaxbDataObjectType = (JAXBDataObjectType) jaxbEntityType;
DataObject dataType = (DataObject) entityTypeToUpdate;
boolean defaultModelCheck = this.checkDataObjectModel(jaxbDataObjectType.getDefaultModelId(), dataType, response);
if (defaultModelCheck) {
dataType.setDefaultModel(String.valueOf(jaxbDataObjectType.getDefaultModelId()));
}
boolean listModelCheck = this.checkDataObjectModel(jaxbDataObjectType.getListModelId(), dataType, response);
if (listModelCheck) {
dataType.setListModel(String.valueOf(jaxbDataObjectType.getListModelId()));
}
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class BaseDataListHelper method getFilters.
@Override
public EntitySearchFilter[] getFilters(String dataType, String filtersShowletParam, String langCode) {
DataObject prototype = this.getDataObjectManager().createDataObject(dataType);
if (null == filtersShowletParam || filtersShowletParam.trim().length() == 0 || null == prototype) {
return null;
}
BaseFilterUtils dom = new BaseFilterUtils();
return dom.getFilters(prototype, filtersShowletParam, langCode);
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class DataAuthorizationHelper method getAuthorizationInfo.
@Override
public // @CacheableInfo(groups = "T(com.agiletec.plugins.jacms.aps.system.services.cache.CmsCacheWrapperManager).getContentCacheGroupsCsv(#contentId)")
PublicDataTypeAuthorizationInfo getAuthorizationInfo(String dataObjectId, boolean cacheable) {
PublicDataTypeAuthorizationInfo authInfo = null;
try {
DataObject dataObject = this.getDataObjectManager().loadDataObject(dataObjectId, true, cacheable);
if (null == dataObject) {
_logger.debug("public dataObject {} doesn't exist", dataObjectId);
return null;
}
authInfo = new PublicDataTypeAuthorizationInfo(dataObject, this.getLangManager().getLangs());
} catch (Throwable t) {
_logger.error("error in getAuthorizationInfo for dataObject {}", dataObjectId, t);
}
return authInfo;
}
Aggregations