Search in sources :

Example 16 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestCacheInfoManager method createMockContentModel.

protected long createMockContentModel() throws Throwable {
    ContentModel contentModel = this._contentModelManager.getContentModel(2);
    contentModel.setId(200);
    contentModel.setDescription("Test Content Model");
    this._contentModelManager.addContentModel(contentModel);
    return contentModel.getId();
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 17 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class ApiContentModelInterface method getModels.

public StringListApiResponse getModels(Properties properties) throws ApiException, Throwable {
    StringListApiResponse response = new StringListApiResponse();
    try {
        List<ContentModel> models = null;
        String contentTypeParam = properties.getProperty("contentType");
        String contentType = (null != contentTypeParam && contentTypeParam.trim().length() > 0) ? contentTypeParam.trim() : null;
        if (null != contentType && null == this.getContentManager().getSmallContentTypesMap().get(contentType)) {
            ApiError error = new ApiError(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type " + contentType + " does not exist", Response.Status.CONFLICT);
            response.addError(error);
            contentType = null;
        }
        if (null != contentType) {
            models = this.getContentModelManager().getModelsForContentType(contentType);
        } else {
            models = this.getContentModelManager().getContentModels();
        }
        List<String> list = new ArrayList<String>();
        if (null != models) {
            for (int i = 0; i < models.size(); i++) {
                ContentModel model = models.get(i);
                list.add(String.valueOf(model.getId()));
            }
        }
        response.setResult(list, null);
    } catch (Throwable t) {
        _logger.error("Error loading models", t);
        // ApsSystemUtils.logThrowable(t, this, "getModels");
        throw new ApsSystemException("Error loading models", t);
    }
    return response;
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) StringListApiResponse(org.entando.entando.aps.system.services.api.model.StringListApiResponse) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiError(org.entando.entando.aps.system.services.api.model.ApiError)

Example 18 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentDispenser method testGetRenderedContent_4.

public void testGetRenderedContent_4() throws Throwable {
    String contentId = "ART120";
    String contentShapeModel = "title (Text): testo=$content.Titolo.getText()";
    int modelId = 1972;
    try {
        this.addNewContentModel(modelId, contentShapeModel, "ART");
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, "en", reqCtx);
        assertEquals("title (Text): testo=Title of Administrator's Content", outputInfo.getCachedRenderedContent());
        ContentModel model = this._contentModelManager.getContentModel(modelId);
        String newContentShapeModel = "title: testo=$content.Titolo.getText()";
        model.setContentShape(newContentShapeModel);
        this._contentModelManager.updateContentModel(model);
        this.waitNotifyingThread();
        outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, "en", reqCtx);
        assertEquals("title: testo=Title of Administrator's Content", outputInfo.getCachedRenderedContent());
    } catch (Throwable t) {
        throw t;
    } finally {
        ContentModel model = this._contentModelManager.getContentModel(modelId);
        if (null != model) {
            this._contentModelManager.removeContentModel(model);
        }
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) RequestContext(com.agiletec.aps.system.RequestContext)

Example 19 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class RowContentListViewerWidgetAction method getContentModel.

public ContentModel getContentModel(String modelId) {
    ContentModel contentModel = null;
    try {
        Integer modelIdInteger = Integer.parseInt(modelId);
        contentModel = this.getContentModelManager().getContentModel(modelIdInteger);
    } catch (Throwable t) {
        _logger.error("error in getContentModel for content model {}", modelId, t);
        throw new RuntimeException("error in getContentModel", t);
    }
    return contentModel;
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 20 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelAction method testDeleteModel.

public void testDeleteModel() throws Throwable {
    List<ContentModel> eventModels = this._contentModelManager.getModelsForContentType("EVN");
    assertEquals(0, eventModels.size());
    long modelId = 99;
    this.addModelForTest(modelId, "EVN");
    eventModels = this._contentModelManager.getModelsForContentType("EVN");
    assertEquals(1, eventModels.size());
    ContentModel model = (ContentModel) eventModels.get(0);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/jacms/ContentModel", "delete");
        this.addParameter("modelId", String.valueOf(modelId));
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        model = this._contentModelManager.getContentModel(modelId);
        assertNull(model);
        eventModels = this._contentModelManager.getModelsForContentType("EVN");
        assertEquals(0, eventModels.size());
    } catch (Throwable t) {
        model = this._contentModelManager.getContentModel(modelId);
        if (null != model) {
            this._contentModelManager.removeContentModel(model);
        }
        eventModels = this._contentModelManager.getModelsForContentType("EVN");
        assertEquals(0, eventModels.size());
        throw t;
    }
}
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