use of com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper in project entando-core by entando.
the class ContentInfoTag method doStartTag.
@Override
public int doStartTag() throws JspException {
int result = super.doStartTag();
try {
if (null != this.getMasterObject()) {
HttpSession session = this.pageContext.getSession();
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
boolean isAuthOnEdit = false;
if (this.isRecord()) {
// PENSARE ALL'OPPORTUNITA'... meno prestante nel caso di oggetto contenuto!
String keyValue = (String) super.findValue(this.getKey(), String.class);
isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, keyValue, false);
} else {
isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, (Content) this.getMasterObject());
}
if (isAuthOnEdit) {
if (null != this.getAuthToEditVar()) {
ValueStack stack = this.getStack();
stack.getContext().put(this.getAuthToEditVar(), isAuthOnEdit);
stack.setValue("#attr['" + this.getAuthToEditVar() + "']", isAuthOnEdit, false);
}
result = EVAL_BODY_INCLUDE;
}
}
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag", "Error on doStartTag");
throw new JspException("Error on doStartTag", t);
}
return result;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper in project entando-core by entando.
the class ContentTypeInfoTag method getPropertyValue.
@Override
protected Object getPropertyValue(Object masterObject, String propertyValue) {
if (null == propertyValue || !propertyValue.equals("isAuthToEdit")) {
return super.getPropertyValue(masterObject, propertyValue);
}
try {
HttpSession session = this.pageContext.getSession();
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
Content prototype = (Content) masterObject;
IContentAuthorizationHelper helper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
return helper.isAuthToEdit(currentUser, prototype);
} catch (Throwable t) {
_logger.error("Error extracting property value : Master Object '{}' - property '{}'", masterObject.getClass().getName(), propertyValue, t);
}
return null;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper 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