Search in sources :

Example 1 with ContentModel

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);
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 2 with ContentModel

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;
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 3 with ContentModel

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;
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) ApiError(org.entando.entando.aps.system.services.api.model.ApiError)

Example 4 with ContentModel

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);
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 5 with ContentModel

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;
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Aggregations

ContentModel (com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 RequestContext (com.agiletec.aps.system.RequestContext)2 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 SmallContentType (com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)1 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringListApiResponse (org.entando.entando.aps.system.services.api.model.StringListApiResponse)1 Cache (org.springframework.cache.Cache)1