Search in sources :

Example 6 with DataObject

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;
}
Also used : JAXBDataObject(org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 7 with DataObject

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;
}
Also used : JAXBDataObject(org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 8 with DataObject

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

Example 9 with DataObject

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

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

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