use of org.entando.entando.apsadmin.system.services.shortcut.IShortcutManager in project entando-core by entando.
the class ShortcutListTag method doStartTag.
@Override
public int doStartTag() throws JspException {
UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
try {
Object retval = null;
IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext);
List<Shortcut> myShortcuts = shortcutManager.getAllowedShortcuts(currentUser);
if (this.getType().equalsIgnoreCase(TYPE_LIST_OBJECT)) {
retval = (Object) myShortcuts;
} else if (this.getType().equalsIgnoreCase(TYPE_LIST_ITEMS)) {
retval = (Object) this.getAllowedShortcutSelectItems(myShortcuts, currentUser);
} else {
_logger.warn("Invalid param for attribute 'value'. Expected '{}' or '{}' but was {}", TYPE_LIST_ITEMS, TYPE_LIST_OBJECT, this.getType());
}
ValueStack stack = super.getStack();
stack.getContext().put(this.getVar(), retval);
stack.setValue("#attr['" + this.getVar() + "']", retval, false);
} catch (Throwable t) {
_logger.error("Error extracting shortcuts for user '{}'", currentUser.getUsername(), t);
throw new JspException("Error extracting shortcuts", t);
}
return super.doStartTag();
}
use of org.entando.entando.apsadmin.system.services.shortcut.IShortcutManager in project entando-core by entando.
the class UserShortcutsConfigTag method doEndTag.
@Override
public int doEndTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
try {
UserConfigBean config = (UserConfigBean) request.getSession().getAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
if (null == config || !currentUser.getUsername().equals(config.getUsername())) {
request.getSession().removeAttribute(MyShortcutConfigAction.SESSION_PARAM_MY_SHORTCUTS);
IShortcutManager shortcutManager = (IShortcutManager) ApsWebApplicationUtils.getBean(ApsAdminSystemConstants.SHORTCUT_MANAGER, this.pageContext);
config = shortcutManager.getUserConfigBean(currentUser);
}
if (null != this.getVar()) {
ValueStack stack = this.getStack();
stack.getContext().put(this.getVar(), config);
stack.setValue("#attr['" + this.getVar() + "']", config, false);
}
} catch (Throwable t) {
_logger.error("Error on doStartTag", t);
throw new JspException("Error on doStartTag", t);
}
return super.doEndTag();
}
Aggregations