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