Search in sources :

Example 11 with DataObjectModel

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

Example 12 with DataObjectModel

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

Example 13 with 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;
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 14 with DataObjectModel

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;
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 15 with DataObjectModel

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;
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

DataObjectModel (org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)24 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 RequestContext (com.agiletec.aps.system.RequestContext)1 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringListApiResponse (org.entando.entando.aps.system.services.api.model.StringListApiResponse)1 SmallDataType (org.entando.entando.aps.system.services.dataobject.model.SmallDataType)1 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)1 Cache (org.springframework.cache.Cache)1