Package org.jboss.dashboard.ui

Examples of org.jboss.dashboard.ui.NavigationManager


        super(commandName);
    }

    public String execute() throws Exception {
        LocaleManager localeMgr = LocaleManager.lookup();
        NavigationManager navMgr = NavigationManager.lookup();
        UserStatus userCtx = navMgr.getUserStatus();
        String commandName = getName();

        if (WORKSPACE_ID.equals(commandName)) return navMgr.getCurrentWorkspaceId();
        if (WORKSPACE_TITLE.equals(commandName)) return localeMgr.localize(navMgr.getCurrentWorkspace().getTitle()).toString();
        if (PAGE_ID.equals(commandName)) return navMgr.getCurrentSectionId().toString();
        if (PAGE_TITLE.equals(commandName)) return localeMgr.localize(navMgr.getCurrentSection().getTitle()).toString();
        if (LANGUAGE.equals(commandName)) return localeMgr.getCurrentLang();
        if (USER_LOGIN.equals(commandName)) return userCtx.getUserLogin();
        if (USER_NAME.equals(commandName)) return userCtx.getUserName();
        if (USER_EMAIL.equals(commandName)) return userCtx.getUserEmail();
        return null;
View Full Code Here


    public LoggedUserCommand(String commandName) {
        super(commandName);
    }

    public String execute() throws Exception {
        NavigationManager navMgr = NavigationManager.lookup();
        UserStatus userCtx = navMgr.getUserStatus();
        String commandName = getName();

        if (LOGGED_USER_LOGIN.equals(commandName)) return userCtx.getUserLogin();
        if (LOGGED_USER_NAME.equals(commandName)) return userCtx.getUserName();
        if (LOGGED_USER_EMAIL.equals(commandName)) return userCtx.getUserEmail();
View Full Code Here

        return DashboardHandler.lookup().getDashboard(getDrillDownPage());
    }

    public Section getDrillDownPage() {
        if (!isDrillDownEnabled()) return null;
        NavigationManager navMgr = NavigationManager.lookup();
        return navMgr.getCurrentWorkspace().getSection(sectionId);
    }
View Full Code Here

     * @see javax.servlet.jsp.tagext.TagSupport
     */
    public int doEndTag() throws JspTagException {
        Panel panel;
        if (this.panel != null) {
            NavigationManager navigationManager = NavigationManager.lookup();
            panel = navigationManager.getCurrentSection().getPanel(this.panel);
        } else {
            panel = RequestContext.lookup().getActivePanel();
        }
        URLMarkupGenerator markupGenerator = UIServices.lookup().getUrlMarkupGenerator();
        String linkStr = markupGenerator.getLinkToPanelAction(panel, getAction(), params, Boolean.valueOf(useFriendlyUrl).booleanValue());
View Full Code Here

            for (int i = 0; i < getHeaderIncludePages().length; i++) {
                result.add(getHeaderIncludePages()[i]);
            }
        }

        NavigationManager navigationManager = NavigationManager.lookup();
        if (navigationManager != null && navigationManager.getCurrentSection() != null) {
            Set<Panel> panels = navigationManager.getCurrentSection().getPanels();
            if (panels != null) {
                for (Panel panel : panels) {
                    String page = panel.getProvider().getPage(PanelDriver.PAGE_HEADER);
                    if (page != null && !"".equals(page.trim()) && !result.contains(page)) result.add(page);
                }
View Full Code Here

     * @return true if processing must continue, false otherwise.
     */
    public boolean processRequest() throws Exception {
        HttpServletRequest request = getHttpRequest();
        String servletPath = request.getServletPath();
        NavigationManager navigationManager = NavigationManager.lookup();
        UserStatus userStatus = UserStatus.lookup();
        RequestContext requestContext = RequestContext.lookup();

        // ---- Apply locale information, --------------
        LocaleManager localeManager = LocaleManager.lookup();
        // First check if a locale parameter is present in the URI query string.
        Locale localeToSet = null;
        String localeParam = request.getParameter(LOCALE_PARAMETER);
        if (localeParam != null && localeParam.trim().length() > 0)  {
            localeToSet = localeManager.getLocaleById(localeParam);
            if (localeToSet != null) {
                localeManager.setCurrentLocale(localeToSet);
            }
        }

        // No friendly -> nothing to do.
        if (!servletPath.startsWith(FRIENDLY_MAPPING)) return true;

        String contextPath = request.getContextPath();
        requestContext.consumeURIPart(FRIENDLY_MAPPING);
        navigationManager.setShowingConfig(false);
        String requestUri = request.getRequestURI();
        String relativeUri = requestUri.substring(contextPath == null ? 0 : (contextPath.length()));
        relativeUri = relativeUri.substring(servletPath == null ? 0 : (servletPath.length()));

        // Empty URI -> nothing to do.
        if (StringUtils.isBlank(relativeUri)) return true;

        /*
        * Check if the locale information is in the URI value in order to consume it.
        * Locale information is expected in the URI after "/workspace".
        * Examples:
        * - /workspace/en/....
        * - /workspace/es/....
        * - /workspace/en_ES/....
        * NOTES:
        * - Available locales matched in the URI parameter are obtained from JVM available locales.
        * - If the locale is found as platform available, the locale is set.
        * - Otherwise, do nothing, the locale used will be the last one set or default.
        * - In both cases URI locale parameter will be consumed.
        */
        int startLocaleUri = relativeUri.indexOf("/");
        int endLocaleUri = relativeUri.indexOf("/", startLocaleUri + 1);
        endLocaleUri = endLocaleUri > 0 ? endLocaleUri : relativeUri.length();
        String localeUri = relativeUri.substring(startLocaleUri + 1, endLocaleUri);
        Locale uriLocale = localeManager.getLocaleById(localeUri);
        if (uriLocale != null) {
            requestContext.consumeURIPart("/" + localeUri);
            relativeUri = relativeUri.substring(localeUri.length() + 1);
            // Use the locale specified in the URI value only if no locale specified in the qeury string.
            if (localeToSet == null) localeManager.setCurrentLocale(uriLocale);
        }

        // Tokenize the friendly URI.
        StringTokenizer tokenizer = new StringTokenizer(relativeUri, "/", false);
        List tokens = new ArrayList();
        int i = 0;
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            if (i < 2) {
                tokens.add(token);
                i++;
            } else if (tokens.size() == 2) {
                tokens.add("/" + token);
            } else {
                tokens.set(2, tokens.get(2) + "/" + token);
            }
        }
        try {
            // Get the target workspace/section spècified.
            log.debug("Tokens=" + tokens);
            String workspaceCandidate = null;
            String sectionCandidate = null;
            if (tokens.size() > 0) workspaceCandidate = (String) tokens.get(0);
            if (tokens.size() > 1) sectionCandidate = (String) tokens.get(1);
            if (log.isDebugEnabled()) {
                log.debug("workspaceCandidate=" + workspaceCandidate);
                log.debug("sectionCandidate=" + sectionCandidate);
            }
            WorkspaceImpl workspace = null;
            Section section = null;
            if (workspaceCandidate != null) {
                boolean canbeWorkspaceId = canBeWorkspaceId(workspaceCandidate);
                if (canbeWorkspaceId) workspace = (WorkspaceImpl) UIServices.lookup().getWorkspacesManager().getWorkspace(workspaceCandidate);
                if (workspace == null) workspace = (WorkspaceImpl) UIServices.lookup().getWorkspacesManager().getWorkspaceByUrl(workspaceCandidate);
            }
            if (workspace != null && sectionCandidate != null) {
                try {
                    section = workspace.getSection(Long.decode(sectionCandidate));
                } catch (NumberFormatException nfe) {
                    section = workspace.getSectionByUrl(sectionCandidate);
                }
            }
            // Check the user has access permissions to the target workspace.
            if (workspace != null && section == null) {
                try {
                    Workspace currentWorkspace = navigationManager.getCurrentWorkspace();
                    log.debug("currentWorkspace = " + (currentWorkspace == null ? "null" : currentWorkspace.getId()) + " workspaceCandidate = " + workspaceCandidate);
                    if (!workspace.equals(currentWorkspace)) {

                        WorkspacePermission workspacePerm = WorkspacePermission.newInstance(workspace, WorkspacePermission.ACTION_LOGIN);
                        if (userStatus.hasPermission(workspacePerm)) {
                            navigationManager.setCurrentWorkspace(workspace);
                            log.debug("SessionManager.setWorkspace(" + workspace.getId() + ")");
                        } else {
                            if (log.isDebugEnabled()) log.debug("User has no " + WorkspacePermission.ACTION_LOGIN + " permission in workspace " + workspaceCandidate);
                            if (isShowLoginBackDoorOnPermissionDenied()) {
                                navigationManager.setUserRequiresLoginBackdoor(true);
                                navigationManager.setCurrentWorkspace(workspace);
                            }
                        }
                    }
                    requestContext.consumeURIPart("/" + workspaceCandidate);
                } catch (Exception e) {
                    log.error("Cannot set current workspace.", e);
                }
            }
            // Check the user has access permissions to the target section.
            else if (section != null) {
                try {
                    if (!section.equals(navigationManager.getCurrentSection())) {

                        WorkspacePermission workspacePerm = WorkspacePermission.newInstance(section.getWorkspace(), WorkspacePermission.ACTION_LOGIN);
                        SectionPermission sectionPerm = SectionPermission.newInstance(section, SectionPermission.ACTION_VIEW);
                        if (userStatus.hasPermission(workspacePerm) && userStatus.hasPermission(sectionPerm)) {
                            if (log.isDebugEnabled()) log.debug("SessionManager.setSection(" + section.getId() + ")");
                            navigationManager.setCurrentSection(section);
                        }
                        else {
                            if (log.isDebugEnabled()) log.debug("User has no " + WorkspacePermission.ACTION_LOGIN + " permission in workspace " + workspaceCandidate);
                            if (isShowLoginBackDoorOnPermissionDenied()) {
                                navigationManager.setUserRequiresLoginBackdoor(true);
                                navigationManager.setCurrentSection(section);
                            }
                        }
                    }
                    requestContext.consumeURIPart("/" + workspaceCandidate);
                    requestContext.consumeURIPart("/" + sectionCandidate);
View Full Code Here

    public synchronized void deleteSection(final WorkspaceImpl workspace, final Section section) {
        SectionPermission sectionPerm = SectionPermission.newInstance(section, SectionPermission.ACTION_DELETE);
        try {
            if (getUserStatus().hasPermission(sectionPerm)) {
                NavigationManager navigationManager = getNavigationManager();
                if (navigationManager.getCurrentSectionId() != null) {
                    if (navigationManager.getCurrentSectionId().equals(section.getDbid())) {
                        navigationManager.setCurrentSection(null);
                    }
                    navigationManager.setCurrentWorkspace(workspace);
                }

                workspace.removeSection(section);
                UIServices.lookup().getWorkspacesManager().store(workspace);
            }
View Full Code Here

    /**
     * Get the dashboard for the current page.
     */
    public synchronized Dashboard getCurrentDashboard() {
        NavigationManager navMgr = NavigationManager.lookup();
        Dashboard dashboard = getDashboard(navMgr.getCurrentSection());
        if (dashboard == null) return null// When a section is being deleted the current section is null.
       
        if (currentDashboard == null) return currentDashboard = dashboard;
        if (dashboard.equals(currentDashboard)) return currentDashboard;

View Full Code Here

        boolean modalSwitchedOff = modalOnBeforeRequest && !modalOn;

         // Check if the navigation has changed (f.i: URL typing) and so auto-close the modal (if was opened).
        if (modalOn) {
            if (!modalSwitchedOn) {
                NavigationManager navMgr = NavigationManager.lookup();
                boolean navigationChanged = false;
                boolean configEnabled = navMgr.isShowingConfig();
                boolean wasConfigEnabled = modalStatus.isConfigEnabled();
                String currentWorkspaceId = navMgr.getCurrentWorkspaceId();
                String oldWorkspaceId = modalStatus.getCurrentWorkspaceId();
                Long currentSectionId = navMgr.getCurrentSectionId();
                Long oldSectionId = modalStatus.getCurrentSectionId();
                if (configEnabled != wasConfigEnabled) navigationChanged = true;
                if (ComparatorUtils.compare(currentWorkspaceId, oldWorkspaceId, 1) != 0) navigationChanged = true;
                if (ComparatorUtils.compare(currentSectionId, oldSectionId, 1) != 0) navigationChanged = true;
View Full Code Here

    protected Panel getCurrentPanel(HttpServletRequest request) throws Exception {
        final String idPanel = request.getParameter(Parameters.DISPATCH_IDPANEL);
        if (idPanel == null) return null;
        Long id = Long.decode(idPanel);

        NavigationManager navMgr = NavigationManager.lookup();
        Panel[] panels =  navMgr.getCurrentSection().getAllPanels();
        for (int i = 0; i < panels.length; i++) {
            Panel panel = panels[i];
            if (panel.getPanelId().equals(id)) return panel;
        }
        return null;
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.ui.NavigationManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.