use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class DataObjectUpdaterService method reloadEntityReferences.
public void reloadEntityReferences(String entityId) {
try {
String cacheKey = JacmsSystemConstants.CONTENT_CACHE_PREFIX + entityId;
this.getCacheInfoManager().flushEntry(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
ApsSystemUtils.getLogger().debug("removing_from_cache " + cacheKey);
DataObject content = this.getContentManager().loadDataObject(entityId, true);
if (content != null) {
this.getContentUpdaterDAO().reloadDataObjectCategoryReferences(content);
}
ApsSystemUtils.getLogger().debug("Reload content references for content " + entityId + "- DONE");
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "reloadEntityReferences");
}
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class ApiDataObjectInterface method updateDataObjectText.
public void updateDataObjectText(JAXBDataObjectAttribute jaxbDataObjectAttribute, Properties properties) throws ApiException, Throwable {
try {
String dataId = jaxbDataObjectAttribute.getDataId();
DataObject masterDataObject = this.getDataObjectManager().loadDataObject(jaxbDataObjectAttribute.getDataId(), true);
if (null == masterDataObject) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject with code '" + dataId + "' does not exist", Response.Status.CONFLICT);
}
String attributeName = jaxbDataObjectAttribute.getAttributeName();
AttributeInterface attribute = (AttributeInterface) masterDataObject.getAttribute(attributeName);
if (null == attribute) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject Attribute with code '" + attributeName + "' does not exist into DataObject " + dataId, Response.Status.CONFLICT);
} else if (!(attribute instanceof ITextAttribute)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject Attribute with code '" + attributeName + "' isn't a Text Atttribute", Response.Status.CONFLICT);
}
String langCode = jaxbDataObjectAttribute.getLangCode();
String value = jaxbDataObjectAttribute.getValue();
if (StringUtils.isEmpty(langCode) || StringUtils.isEmpty(value)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "LangCode or value is Empty", Response.Status.CONFLICT);
}
((ITextAttribute) attribute).setText(value, langCode);
this.getDataObjectManager().insertDataObject(masterDataObject);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error updating DataObject attribute", t);
throw new ApsSystemException("Error updating DataObject attribute", t);
}
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class ApiDataObjectInterface method getDataObjectsToHtml.
public String getDataObjectsToHtml(Properties properties) throws Throwable {
StringBuilder render = new StringBuilder();
try {
String modelId = properties.getProperty("modelId");
if (null == modelId || modelId.trim().length() == 0) {
return null;
}
String dataType = properties.getProperty("dataType");
DataObject prototype = (DataObject) this.getDataObjectManager().getEntityPrototype(dataType);
Integer modelIdInteger = this.checkModel(modelId, prototype);
if (null == modelIdInteger) {
return null;
}
List<String> dataObjectsId = this.extractDataObjects(properties);
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
render.append(this.getItemsStartElement());
for (int i = 0; i < dataObjectsId.size(); i++) {
render.append(this.getItemStartElement());
String renderedData = this.getRenderedDataObject(dataObjectsId.get(i), modelIdInteger, langCode);
if (null != renderedData) {
render.append(renderedData);
}
render.append(this.getItemEndElement());
}
render.append(this.getItemsEndElement());
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in getDataObjectsToHtml", t);
throw new ApsSystemException("Error into API method", t);
}
return render.toString();
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class ApiDataObjectInterface method deleteDataObject.
public StringApiResponse deleteDataObject(Properties properties) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String id = properties.getProperty("id");
DataObject masterDataObject = this.getDataObjectManager().loadDataObject(id, false);
if (null == masterDataObject) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject with code '" + id + "' does not exist", Response.Status.CONFLICT);
}
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
if (null == user) {
user = this.getUserManager().getGuestUser();
}
if (!this.getDataObjectAuthorizationHelper().isAuth(user, masterDataObject)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject groups makes the new dataObject not allowed for user " + user.getUsername(), Response.Status.FORBIDDEN);
}
if (masterDataObject.isOnLine()) {
this.getDataObjectManager().removeDataObject(masterDataObject);
}
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error deleting DataObject", t);
throw new ApsSystemException("Error deleting DataObject", t);
}
return response;
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class ApiDataObjectTypeInterface method createJAXBEntityType.
@Override
protected JAXBEntityType createJAXBEntityType(IApsEntity masterEntityType) {
DataObject masterDataObjectType = (DataObject) masterEntityType;
JAXBDataObjectType jaxbDataObjectType = new JAXBDataObjectType(masterDataObjectType);
jaxbDataObjectType.setDefaultModelId(this.extractModelId(masterDataObjectType.getDefaultModel()));
jaxbDataObjectType.setListModelId(this.extractModelId(masterDataObjectType.getListModel()));
return jaxbDataObjectType;
}
Aggregations