use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.
the class ApiContentModelInterface method deleteModel.
public void deleteModel(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);
}
ContentModel model = this.getContentModelManager().getContentModel(id);
if (null == model) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Model with id '" + idString + "' does not exist", Response.Status.CONFLICT);
}
try {
this.getContentModelManager().removeContentModel(model);
} catch (Throwable t) {
_logger.error("Error deleting model", t);
// ApsSystemUtils.logThrowable(t, this, "deleteModel");
throw new ApsSystemException("Error deleting model", t);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.
the class ApiContentModelInterface method getModel.
public ContentModel 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);
}
ContentModel model = this.getContentModelManager().getContentModel(id);
if (null == model) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Model with id '" + idString + "' does not exist", Response.Status.CONFLICT);
}
return model;
}
use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.
the class ApiContentTypeInterface method checkContentModel.
private boolean checkContentModel(Integer modelId, Content contentType, StringApiResponse response) {
if (null == modelId) {
return true;
}
ContentModel contentModel = this.getContentModelManager().getContentModel(modelId);
if (null == contentModel) {
ApiError error = new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, "Content model with id '" + modelId + "' does not exist", Response.Status.ACCEPTED);
response.addError(error);
return false;
}
if (!contentType.getTypeCode().equals(contentModel.getContentType())) {
ApiError error = new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, "Content model with id '" + modelId + "' is for contents of type '" + contentModel.getContentType() + "'", Response.Status.ACCEPTED);
response.addError(error);
return false;
}
return true;
}
use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.
the class TestContentDispenser method addNewContentModel.
public void addNewContentModel(int id, String shape, String contentTypeCode) throws Throwable {
ContentModel model = new ContentModel();
model.setContentType(contentTypeCode);
model.setDescription("test");
model.setId(id);
model.setContentShape(shape);
this._contentModelManager.addContentModel(model);
}
use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.
the class BaseContentRenderer method getModelShape.
protected String getModelShape(long modelId) {
ContentModel model = this.getContentModelManager().getContentModel(modelId);
String shape = null;
if (model != null) {
shape = model.getContentShape();
}
if (shape == null) {
shape = "Content model " + modelId + " undefined";
_logger.error("Content model {} undefined", modelId);
}
return shape;
}
Aggregations