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();
}
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;
}
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);
}
}
}
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;
}
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;
}
}
Aggregations