use of org.santfeliu.faces.menu.model.MenuItemCursor in project gdmatrix by gdmatrix.
the class NodeEditBean method isCustomCSS.
public boolean isCustomCSS() {
MenuItemCursor cursor = (MenuItemCursor) getValue("#{item}");
if (cursor == null)
cursor = getCursor();
String docId = (String) cursor.getDirectProperties().get(UserSessionBean.NODE_CSS);
return docId != null;
}
use of org.santfeliu.faces.menu.model.MenuItemCursor in project gdmatrix by gdmatrix.
the class NodeEditBean method getEditRoles.
public Set getEditRoles() {
HashSet roles = new HashSet();
MenuItemCursor mic = getCursor();
try {
roles.addAll(mic.getEditRoles());
} catch (Exception ex) {
}
return roles;
}
use of org.santfeliu.faces.menu.model.MenuItemCursor in project gdmatrix by gdmatrix.
the class NodeEditBean method getRootNodeId.
public String getRootNodeId() {
analyzeWorkspaceChange();
if (rootNodeId == null) {
MenuItemCursor root = getCursor().getRoot();
rootNodeId = root.getMid();
}
return rootNodeId;
}
use of org.santfeliu.faces.menu.model.MenuItemCursor in project gdmatrix by gdmatrix.
the class CMSListener method beforePhase.
@Override
public void beforePhase(PhaseEvent pe) {
if (pe.getPhaseId().equals(PhaseId.RESTORE_VIEW)) {
forcedLanguage = MatrixConfig.getProperty(FORCED_LANGUAGE_PROP);
if (forcedLanguage == null)
forcedLanguage = "ca";
try {
String value = MatrixConfig.getProperty(REDIRECTION_LIMIT_PROP);
redirectionLimit = (value != null ? Integer.valueOf(value) : 2);
} catch (NumberFormatException ex) {
// default value
redirectionLimit = 2;
}
String value = MatrixConfig.getProperty(CLIENT_SECURE_PORT_PROP);
if (value != null)
clientSecurePort = Integer.parseInt(value);
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
application = context.getApplication();
UserSessionBean userSessionBean = UserSessionBean.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
HttpSession session = request.getSession();
try {
// restore request charset encoding
String charset = (String) session.getAttribute(CHARSET_ATTR);
if (charset != null)
request.setCharacterEncoding(charset);
// securize session
enterSecureSession(session, request);
MenuItemCursor mic = getRequestedMenuItem(request, userSessionBean);
if (mic != null) {
redirectByUrl(context, userSessionBean, mic);
if (context.getResponseComplete() || context.getRenderResponse())
return;
loginFromParameters(context, userSessionBean);
if (context.getResponseComplete() || context.getRenderResponse())
return;
loginFromCertificate(context, userSessionBean);
if (context.getResponseComplete() || context.getRenderResponse())
return;
redirectSecure(context, userSessionBean, mic);
if (context.getResponseComplete() || context.getRenderResponse())
return;
requestAuthentication(context, userSessionBean, mic);
if (context.getResponseComplete() || context.getRenderResponse())
return;
executeRequestedMenuItem(context, userSessionBean, mic);
} else {
// Normal faces lifecycle
userChangeDetection(context, userSessionBean);
}
} catch (Exception ex) {
userSessionBean.getMenuModel().setAllVisible(false);
}
} else if (pe.getPhaseId().equals(PhaseId.RENDER_RESPONSE)) {
FacesContext context = FacesContext.getCurrentInstance();
if (!context.getResponseComplete()) {
UserSessionBean userSessionBean = UserSessionBean.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
response.setHeader(HttpUtils.X_USER_HEADER, userSessionBean.getUserId());
System.out.println("\n>>>> Render ---------------------------------\n");
}
}
}
use of org.santfeliu.faces.menu.model.MenuItemCursor in project gdmatrix by gdmatrix.
the class CMSListener method getRequestedMenuItem.
private MenuItemCursor getRequestedMenuItem(HttpServletRequest request, UserSessionBean userSessionBean) throws Exception {
// Do not execute menuItem in forward requests
if (request.getAttribute(FORWARD_REQUEST_URI) != null)
return null;
MenuItemCursor menuItem = null;
if (userSessionBean.getWorkspaceId() == null) {
userSessionBean.initDefaultWorkspaceId();
}
String workspaceId = (String) request.getParameter(WORKSPACEID_PARAM);
if (// change workspace
workspaceId != null) {
userSessionBean.setWorkspaceId(workspaceId);
}
String browserType = (String) request.getParameter(BROWSER_TYPE_PARAM);
if (// change browser type
browserType != null) {
userSessionBean.setBrowserType(browserType);
}
MenuModel menuModel = userSessionBean.getMenuModel();
menuModel.setAllVisible(true);
String mid = null;
String topic = (String) request.getParameter(TOPIC_PARAM);
if (// by topic
topic != null) {
try {
menuItem = menuModel.getMenuItemByTopic(topic);
} catch (// TopicNotFound or MenuItemNotFound
MenuException ex) {
menuItem = userSessionBean.getSelectedMenuItem();
}
} else // by mid
{
mid = (String) request.getParameter(XMID_PARAM);
if (mid == null) {
String method = request.getMethod();
if ("GET".equals(method)) {
mid = (String) request.getParameter(SMID_PARAM);
if (mid == null && !isPathException(request)) {
mid = userSessionBean.getSelectedMid();
}
}
}
if (mid != null) {
try {
menuItem = menuModel.getMenuItemByMid(mid);
} catch (// MenuItemNotFound
MenuException ex) {
menuItem = userSessionBean.getSelectedMenuItem();
}
}
}
// register menuItem in request attribute
request.setAttribute(NEXT_MENU_ITEM_ATTR, menuItem);
menuModel.setAllVisible(false);
return menuItem;
}
Aggregations