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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations