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) {
PublicDataTypeAuthorizationInfo authInfo = null;
try {
DataObject dataObject = this.getDataObjectManager().loadDataObject(dataObjectId, true);
if (null == dataObject) {
_logger.debug("public content {} 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;
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class DataObjectHandler method endLastModified.
private void endLastModified() {
StringBuffer textBuffer = this.getTextBuffer();
if (null != textBuffer) {
Date date = DateConverter.parseDate(textBuffer.toString(), SystemConstants.DATA_TYPE_METADATA_DATE_FORMAT);
((DataObject) this.getCurrentEntity()).setLastModified(date);
}
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class BaseDataObjectDispenser method getBaseRenderizationInfo.
public DataObjectRenderizationInfo getBaseRenderizationInfo(PublicDataTypeAuthorizationInfo authInfo, String dataObjectId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx, boolean cacheable) {
DataObjectRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
DataObject dataObjectToRender = this.getDataObjectManager().loadDataObject(dataObjectId, true, cacheable);
renderInfo = this.getBaseRenderizationInfo(dataObjectToRender, modelId, langCode, reqCtx);
}
} catch (Throwable t) {
_logger.error("Error while rendering DataObject {}", dataObjectId, t);
return null;
}
return renderInfo;
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class BaseDataObjectDispenser method getRenderizationInfo.
protected DataObjectRenderizationInfo getRenderizationInfo(PublicDataTypeAuthorizationInfo authInfo, String dataObjectId, long modelId, String langCode, RequestContext reqCtx, boolean cacheable) {
DataObjectRenderizationInfo renderInfo = null;
try {
UserDetails currentUser = (null != reqCtx) ? (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER) : null;
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
renderInfo = this.getBaseRenderizationInfo(authInfo, dataObjectId, modelId, langCode, currentUser, reqCtx, cacheable);
if (null == renderInfo) {
return null;
}
} else {
String renderedDataObject = "Current user '" + currentUser.getUsername() + "' can't view this DataObject";
DataObject dataObjectToRender = this.getDataObjectManager().loadDataObject(dataObjectId, true, cacheable);
renderInfo = new DataObjectRenderizationInfo(dataObjectToRender, renderedDataObject, modelId, langCode, null);
renderInfo.setRenderedDataobject(renderedDataObject);
return renderInfo;
}
} catch (Throwable t) {
_logger.error("Error while rendering dataObject {}", dataObjectId, t);
return null;
}
return renderInfo;
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class DataObjectServiceTest method deleteReferencedDataType.
@Test(expected = ValidationConflictException.class)
public void deleteReferencedDataType() throws Throwable {
when(this.dataObjectManager.getName()).thenReturn(SystemConstants.DATA_OBJECT_MANAGER);
DataObject dataObject = new DataObject();
dataObject.setTypeCode("ABC");
when(this.dataObjectManager.getEntityPrototype("ABC")).thenReturn(dataObject);
List<String> list = new ArrayList<>();
list.add("ABC123");
when(this.dataObjectManager.searchId("ABC", null)).thenReturn(list);
this.dataObjectService.deleteDataType("ABC");
}
Aggregations