use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.
the class DataObjectModelAction method trash.
public String trash() {
try {
String check = this.checkDelete();
if (null != check) {
return check;
}
long modelId = this.getModelId().longValue();
DataObjectModel model = this.getDataObjectModelManager().getDataObjectModel(modelId);
if (null != model) {
this.setDescription(model.getDescription());
this.setDataType(model.getDataType());
} else {
return "noModel";
}
} catch (Throwable t) {
_logger.error("error in trash", t);
// ApsSystemUtils.logThrowable(t, this, "trash");
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.
the class DataObjectModelAction method getBeanFromForm.
private DataObjectModel getBeanFromForm() {
DataObjectModel dataObjectModel = new DataObjectModel();
dataObjectModel.setId(this.getModelId());
dataObjectModel.setShape(this.getDataObjectShape());
dataObjectModel.setDataType(this.getDataType());
dataObjectModel.setDescription(this.getDescription());
if (null != this.getStylesheet() && this.getStylesheet().trim().length() > 0) {
dataObjectModel.setStylesheet(this.getStylesheet());
}
if (getStrutsAction() == ApsAdminSystemConstants.EDIT) {
dataObjectModel.setId(new Long(this.getModelId()).longValue());
}
return dataObjectModel;
}
use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.
the class DataObjectModelAction method delete.
public String delete() {
try {
String check = this.checkDelete();
if (null != check) {
return check;
}
long modelId = this.getModelId().longValue();
DataObjectModel model = this.getDataObjectModelManager().getDataObjectModel(modelId);
this.getDataObjectModelManager().removeDataObjectModel(model);
} catch (Throwable t) {
_logger.error("error in delete", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.
the class DataObjectModelValidator method validateBody.
public int validateBody(DataObjectModelRequest request, boolean isPut, Errors errors) {
Long dataModelId = Long.parseLong(request.getModelId());
String typeCode = request.getType();
try {
IApsEntity prototype = this.dataObjectManager.getEntityPrototype(typeCode);
if (null == prototype) {
errors.rejectValue("type", (isPut) ? ERRCODE_PUT_DATAOBJECTTYPE_DOES_NOT_EXIST : ERRCODE_POST_DATAOBJECTTYPE_DOES_NOT_EXIST, new String[] { typeCode }, "dataObjectModel.type.doesNotExist");
return 404;
}
if (StringUtils.isEmpty(request.getModel())) {
errors.rejectValue("model", ERRCODE_DATAOBJECT_MODEL_INVALID, new String[] {}, "dataObjectModel.model.notBlank");
return 400;
}
if (isPut) {
DataObjectModel dataModel = this.dataObjectModelManager.getDataObjectModel(dataModelId);
if (null == dataModel) {
errors.rejectValue("modelId", ERRCODE_DATAOBJECTMODEL_DOES_NOT_EXIST, new String[] { String.valueOf(dataModelId) }, "dataObjectModel.doesNotExist");
return 404;
} else if (!dataModel.getDataType().equals(typeCode)) {
errors.rejectValue("type", ERRCODE_PUT_EXTRACTED_MISMATCH, new String[] { typeCode, dataModel.getDataType() }, "dataObjectModel.type.doesNotMachWithModel");
return 400;
}
}
} catch (Exception e) {
throw new RuntimeException("Error extracting model", e);
}
return 0;
}
use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.
the class ApiDataObjectModelInterface method getModel.
public DataObjectModel getModel(Properties properties) throws ApiException, Throwable {
String idString = properties.getProperty("id");
int id = 0;
try {
id = Integer.parseInt(idString);
} catch (NumberFormatException e) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Invalid number format for 'id' parameter - '" + idString + "'", Response.Status.CONFLICT);
}
DataObjectModel model = this.getDataObjectModelManager().getDataObjectModel(id);
if (null == model) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Model with id '" + idString + "' does not exist", Response.Status.CONFLICT);
}
return model;
}
Aggregations