Search in sources :

Example 1 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectDAO method buildAddEntityStatement.

@Override
protected void buildAddEntityStatement(IApsEntity entity, PreparedStatement stat) throws Throwable {
    DataObject dataobject = (DataObject) entity;
    stat.setString(1, dataobject.getId());
    stat.setString(2, dataobject.getTypeCode());
    stat.setString(3, dataobject.getDescription());
    stat.setString(4, dataobject.getStatus());
    stat.setString(5, dataobject.getXML());
    String currentDate = DateConverter.getFormattedDate(new Date(), JacmsSystemConstants.CONTENT_METADATA_DATE_FORMAT);
    stat.setString(6, currentDate);
    stat.setString(7, currentDate);
    stat.setString(8, dataobject.getXML());
    stat.setString(9, dataobject.getMainGroup());
    stat.setString(10, dataobject.getVersion());
    stat.setString(11, dataobject.getFirstEditor());
    stat.setString(12, dataobject.getLastEditor());
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) Date(java.util.Date)

Example 2 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectDAO method buildUpdateEntityStatement.

protected void buildUpdateEntityStatement(IApsEntity entity, boolean updateDate, PreparedStatement stat) throws Throwable {
    DataObject dataobject = (DataObject) entity;
    int index = 1;
    stat.setString(index++, dataobject.getTypeCode());
    stat.setString(index++, dataobject.getDescription());
    stat.setString(index++, dataobject.getStatus());
    stat.setString(index++, dataobject.getXML());
    if (updateDate) {
        stat.setString(index++, DateConverter.getFormattedDate(new Date(), JacmsSystemConstants.CONTENT_METADATA_DATE_FORMAT));
    }
    stat.setString(index++, dataobject.getMainGroup());
    stat.setString(index++, dataobject.getVersion());
    stat.setString(index++, dataobject.getLastEditor());
    stat.setString(index++, dataobject.getId());
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) Date(java.util.Date)

Example 3 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class DataObjectManager method loadDataObject.

@Override
public DataObject loadDataObject(String id, boolean onLine, boolean cacheable) throws ApsSystemException {
    DataObject dataobject = null;
    try {
        DataObjectRecordVO dataobjectVo = this.loadDataObjectVO(id);
        dataobject = this.createDataObject(dataobjectVo, onLine);
    } catch (ApsSystemException e) {
        logger.error("Error while loading dataobject : id {}", id, e);
        throw new ApsSystemException("Error while loading dataobject : id " + id, e);
    }
    return dataobject;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) DataObjectRecordVO(org.entando.entando.aps.system.services.dataobject.model.DataObjectRecordVO) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 4 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class ApiDataObjectInterface method addDataObject.

public StringApiResponse addDataObject(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 dataObject = (DataObject) jaxbDataObject.buildEntity(prototype, this.getCategoryManager());
        if (null != dataObject.getId()) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "You cannot specify DataObject Id", Response.Status.CONFLICT);
        }
        UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
        dataObject.setFirstEditor((null != user) ? user.getUsername() : SystemConstants.GUEST_USER_NAME);
        response = this.validateAndSaveDataObject(dataObject, properties);
    } catch (ApiException ae) {
        response.addErrors(ae.getErrors());
        response.setResult(IResponseBuilder.FAILURE, null);
    } catch (Throwable t) {
        _logger.error("Error adding DataObject", t);
        throw new ApsSystemException("Error adding 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) UserDetails(com.agiletec.aps.system.services.user.UserDetails) 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 5 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class ApiDataObjectInterface method getDataObject.

public JAXBDataObject getDataObject(Properties properties) throws ApiException, Throwable {
    JAXBDataObject jaxbDataObject = null;
    String id = properties.getProperty("id");
    try {
        String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
        DataObject mainDataObject = this.getPublicDataObject(id);
        jaxbDataObject = this.getJAXBDataObjectInstance(mainDataObject, langCode);
        UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
        if (null == user) {
            user = this.getUserManager().getGuestUser();
        }
        if (!this.getDataObjectAuthorizationHelper().isAuth(user, mainDataObject)) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Required DataObject '" + id + "' does not allowed", Response.Status.FORBIDDEN);
        }
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("error in getDataObject", t);
        throw new ApsSystemException("Error into API method", t);
    }
    return jaxbDataObject;
}
Also used : JAXBDataObject(org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) UserDetails(com.agiletec.aps.system.services.user.UserDetails) JAXBDataObject(org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

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