Search in sources :

Example 1 with ContentRenderizationInfo

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

Example 2 with ContentRenderizationInfo

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;
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) ServletRequest(javax.servlet.ServletRequest) IContentViewerHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper) JspException(javax.servlet.jsp.JspException) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with ContentRenderizationInfo

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

Example 4 with ContentRenderizationInfo

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

Example 5 with ContentRenderizationInfo

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

Aggregations

ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)10 RequestContext (com.agiletec.aps.system.RequestContext)5 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 Widget (com.agiletec.aps.system.services.page.Widget)2 ApsProperties (com.agiletec.aps.util.ApsProperties)2 AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)1 Group (com.agiletec.aps.system.services.group.Group)1 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)1 ContentModel (com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)1 ServletRequest (javax.servlet.ServletRequest)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspException (javax.servlet.jsp.JspException)1