Search in sources :

Example 11 with DataObject

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;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 12 with DataObject

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);
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) Date(java.util.Date)

Example 13 with DataObject

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;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 14 with DataObject

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;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 15 with DataObject

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");
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)72 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 JAXBDataObject (org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject)7 Test (org.junit.Test)7 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 ArrayList (java.util.ArrayList)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 Category (com.agiletec.aps.system.services.category.Category)4 Date (java.util.Date)4 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)3 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)3 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)3 Group (com.agiletec.aps.system.services.group.Group)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 IDataObjectManager (org.entando.entando.aps.system.services.dataobject.IDataObjectManager)3