use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ApiContentInterface method getRenderedContent.
protected String getRenderedContent(String id, int modelId, String langCode) {
String renderedContent = null;
ContentRenderizationInfo renderizationInfo = this.getContentDispenser().getRenderizationInfo(id, modelId, langCode, null, true);
if (null != renderizationInfo) {
this.getContentDispenser().resolveLinks(renderizationInfo, null);
renderedContent = renderizationInfo.getRenderedContent();
}
return renderedContent;
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ContentTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
IContentViewerHelper helper = (IContentViewerHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_VIEWER_HELPER, this.pageContext);
String contentId = (this.getContentId() != null && this.getContentId().trim().length() > 0) ? this.getContentId() : null;
ContentRenderizationInfo renderInfo = helper.getRenderizationInfo(contentId, this.getModelId(), this.isPublishExtraTitle(), reqCtx);
String renderedContent = (null != renderInfo) ? renderInfo.getRenderedContent() : "";
if (null != this.getVar()) {
this.pageContext.setAttribute(this.getVar(), renderedContent);
} else {
this.pageContext.getOut().print(renderedContent);
}
if (null != renderInfo && null != this.getAttributeValuesByRoleVar()) {
this.pageContext.setAttribute(this.getAttributeValuesByRoleVar(), renderInfo.getAttributeValues());
}
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
throw new JspException("Error detected while initialising the tag", t);
}
return EVAL_PAGE;
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ContentViewerHelper method getRenderedContent.
/**
* Restituisce il contenuto da visualizzare nel widget.
*
* @param contentId
* L'identificativo del contenuto ricavato dal tag.
* @param modelId
* Il modello del contenuto ricavato dal tag.
* @param publishExtraTitle
* @param reqCtx
* Il contesto della richiesta.
* @return Il contenuto da visualizzare nella widget.
* @throws ApsSystemException
* In caso di errore.
*/
@Override
public String getRenderedContent(String contentId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
String renderedContent = null;
ContentRenderizationInfo renderInfo = this.getRenderizationInfo(contentId, modelId, publishExtraTitle, reqCtx);
if (null != renderInfo) {
renderedContent = renderInfo.getRenderedContent();
}
if (null == renderedContent) {
renderedContent = "";
}
return renderedContent;
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContent_1.
public void testGetRenderedContent_1() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String contentId = null;
String langCode = "en";
long modelId = -1;
try {
modelId = this.createMockContentModel();
contentId = this.createMockContent();
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
ContentRenderizationInfo cachedOutputInfo = (ContentRenderizationInfo) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey);
assertNotNull(cachedOutputInfo);
assertEquals(outputInfo.hashCode(), cachedOutputInfo.hashCode());
assertEquals(outputInfo.getContentId(), cachedOutputInfo.getContentId());
assertEquals(outputInfo.getModelId(), cachedOutputInfo.getModelId());
assertEquals(outputInfo.getCachedRenderedContent(), cachedOutputInfo.getCachedRenderedContent());
} catch (Throwable t) {
throw t;
} finally {
this.deleteMockContentObject(contentId, modelId);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContentsGroup.
protected void testGetRenderedContentsGroup(String contentId, long modelId, String cacheGroupId) throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String langCode = "en";
try {
String groupsCsv = BaseContentDispenser.getRenderizationInfoCacheGroupsCsv(contentId, modelId);
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
assertTrue(groupsCsv.indexOf(cacheGroupId) > -1);
this._cacheInfoManager.flushGroup(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheGroupId);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
} catch (Throwable t) {
throw t;
}
}
Aggregations