Search in sources :

Example 6 with ContentRenderizationInfo

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

the class TestCacheInfoManager method testGetRenderedContent_3.

public void testGetRenderedContent_3() 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);
        ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
        assertNotNull(outputInfo);
        assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
        // -----------
        ContentModel contentModel = this._contentModelManager.getContentModel(modelId);
        contentModel.setDescription("Modified model description");
        this._contentModelManager.updateContentModel(contentModel);
        super.waitNotifyingThread();
        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));
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteMockContentObject(contentId, modelId);
    }
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) RequestContext(com.agiletec.aps.system.RequestContext)

Example 7 with ContentRenderizationInfo

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

the class TestCacheInfoManager method testGetRenderedContent_2.

public void testGetRenderedContent_2() 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);
        ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
        assertNotNull(outputInfo);
        assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
        // -----------
        Content content = this._contentManager.loadContent(contentId, true);
        content.setDescription("Modified content description");
        this._contentManager.insertOnLineContent(content);
        super.waitNotifyingThread();
        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));
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteMockContentObject(contentId, modelId);
    }
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) RequestContext(com.agiletec.aps.system.RequestContext)

Example 8 with ContentRenderizationInfo

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

the class ContentPreviewDispenser method getBaseRenderizationInfo.

@Override
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx) {
    ContentRenderizationInfo renderInfo = null;
    try {
        List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
        if (authInfo.isUserAllowed(userGroups)) {
            Content contentOnSession = this.extractContentOnSession(reqCtx);
            String renderedContent = this.buildRenderedContent(contentOnSession, modelId, langCode, reqCtx);
            if (null != renderedContent && renderedContent.trim().length() > 0) {
                List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
                renderInfo = new ContentRenderizationInfo(contentOnSession, renderedContent, modelId, langCode, roles);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error while rendering content {}", contentId, t);
        return null;
    }
    return renderInfo;
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) Group(com.agiletec.aps.system.services.group.Group) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) AttributeRole(com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)

Example 9 with ContentRenderizationInfo

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

the class ContentPreviewViewerHelper method getRenderedContent.

@Override
public String getRenderedContent(String contentId, String modelId, RequestContext reqCtx) throws ApsSystemException {
    String renderedContent = "";
    HttpServletRequest request = reqCtx.getRequest();
    try {
        String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
        if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
            contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
        }
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
        contentId = (contentOnSession.getId() == null ? contentOnSession.getTypeCode() + "123" : contentOnSession.getId());
        ApsProperties widgetConfig = widget.getConfig();
        modelId = this.extractModelId(contentId, modelId, widgetConfig);
        if (null != contentId && null != modelId) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            ContentRenderizationInfo renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx);
            if (null == renderizationInfo) {
                _logger.warn("Null Renderization informations: content={}", contentId);
            } else {
                this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
                renderedContent = renderizationInfo.getRenderedContent();
            }
        } else {
            _logger.warn("Parametri visualizzazione contenuto incompleti: contenuto={} modello={}", contentId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("error loading rendered content for preview", t);
        // ApsSystemUtils.logThrowable(t, this, "getRenderedContent");
        throw new ApsSystemException("error loading rendered content for preview", t);
    }
    return renderedContent;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 10 with ContentRenderizationInfo

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

the class ContentViewerHelper method getRenderizationInfo.

@Override
public ContentRenderizationInfo getRenderizationInfo(String contentId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    ContentRenderizationInfo renderizationInfo = null;
    try {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties widgetConfig = widget.getConfig();
        contentId = this.extractContentId(contentId, widgetConfig, reqCtx);
        modelId = this.extractModelId(contentId, modelId, widgetConfig, reqCtx);
        if (contentId != null && modelId != null) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx, true);
            if (null == renderizationInfo) {
                _logger.info("Null Renderization informations: content={}", contentId);
                return null;
            }
            this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
            this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
        } else {
            _logger.warn("Parametri visualizzazione contenuto incompleti: " + "contenuto={} modello={}", contentId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting renderization info", t);
        throw new ApsSystemException("Error extracting renderization info", t);
    }
    return renderizationInfo;
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

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