Search in sources :

Example 1 with IContentViewerHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper 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 2 with IContentViewerHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper in project entando-core by entando.

the class ContentPreviewTag 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_PREVIEW_VIEWER_HELPER, this.pageContext);
        String renderedContent = helper.getRenderedContent(null, null, reqCtx);
        this.pageContext.getOut().print(renderedContent);
    } catch (Throwable t) {
        _logger.error("error in doStartTag", t);
        throw new JspException("Error detected during tag initialisation", t);
    }
    return EVAL_PAGE;
}
Also used : 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 IContentViewerHelper

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper in project entando-core by entando.

the class ContentInfoTag 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);
        PublicContentAuthorizationInfo authInfo = helper.getAuthorizationInfo(this.getContentId(), reqCtx);
        if (null == authInfo) {
            return super.doStartTag();
        }
        if (null == this.getParam() && null != this.getVar()) {
            this.pageContext.setAttribute(this.getVar(), authInfo);
        } else if (null != this.getParam()) {
            Object value = null;
            if ("contentId".equals(this.getParam())) {
                value = authInfo.getContentId();
            } else if ("modelId".equals(this.getParam())) {
                value = this.extractModelId(authInfo, reqCtx);
            } else if ("mainGroup".equals(this.getParam())) {
                value = authInfo.getMainGroup();
            } else if ("authToEdit".equals(this.getParam())) {
                IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
                HttpSession session = this.pageContext.getSession();
                UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
                boolean isAuth = contentAuthHelper.isAuthToEdit(currentUser, authInfo);
                value = Boolean.valueOf(isAuth);
            }
            if (null != value) {
                String var = this.getVar();
                if (null == var || "".equals(var)) {
                    this.pageContext.getOut().print(value);
                } else {
                    this.pageContext.setAttribute(this.getVar(), value);
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error detected while initializing the tag", t);
        // ApsSystemUtils.logThrowable(t, this, "doStartTag");
        throw new JspException("Error detected while initializing the tag", t);
    }
    return super.doStartTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) IContentViewerHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper) JspException(javax.servlet.jsp.JspException) PublicContentAuthorizationInfo(com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo) UserDetails(com.agiletec.aps.system.services.user.UserDetails) HttpSession(javax.servlet.http.HttpSession) RequestContext(com.agiletec.aps.system.RequestContext) IContentAuthorizationHelper(com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)3 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)3 ServletRequest (javax.servlet.ServletRequest)3 JspException (javax.servlet.jsp.JspException)3 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 IContentAuthorizationHelper (com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)1 PublicContentAuthorizationInfo (com.agiletec.plugins.jacms.aps.system.services.content.helper.PublicContentAuthorizationInfo)1 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)1 HttpSession (javax.servlet.http.HttpSession)1