Package org.exoplatform.portal.mop.user

Examples of org.exoplatform.portal.mop.user.UserNode


        String nodeId = node.getId();

        json.put("label", node.getEncodedResolvedLabel());
        json.put("hasChild", node.getChildrenCount() > 0);

        UserNode selectedNode = Util.getUIPortal().getNavPath();
        json.put("isSelected", nodeId.equals(selectedNode.getId()));
        json.put("icon", node.getIcon());

        ResourceURL rsURL = res.createResourceURL();
        rsURL.setResourceID(node.getURI());
        json.put("getNodeURL", rsURL.toString());
View Full Code Here


        PortletPreferences pref = pcontext.getRequest().getPreferences();
        return pref.getValue("url", "");
    }

    public String getNavigationTitle() throws Exception {
        UserNode navPath = Util.getUIPortal().getNavPath();
        UserNavigation nav = navPath.getNavigation();
        if (nav.getKey().getType().equals(SiteType.GROUP)) {
            return OrganizationUtils.getGroupLabel(nav.getKey().getName());
        } else if (nav.getKey().getType().equals(SiteType.USER)) {
            ConversationState state = ConversationState.getCurrent();
            User user = (User) state.getAttribute(CacheUserProfileFilter.USER_PROFILE);
View Full Code Here

        List<TreeNode> childs = null;

        UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
        TreeNode tnode = uiPortalNavigation.getTreeNodes().findNodes(nodeID);
        if (tnode != null) {
            UserNode userNode = uiPortalNavigation.updateNode(tnode.getNode());
            if (userNode != null) {
                tnode.setExpanded(true);
                tnode.setChildren(userNode.getChildren());
                childs = tnode.getChildren();
            }
        }

        JSONArray jsChilds = new JSONArray();
View Full Code Here

    }

    private JSONObject toJSON(TreeNode tnode, MimeResponse res) throws Exception {
        UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
        JSONObject json = new JSONObject();
        UserNode node = tnode.getNode();
        String nodeId = node.getId();

        json.put("label", node.getEncodedResolvedLabel());
        json.put("hasChild", tnode.hasChild());
        json.put("isExpanded", tnode.isExpanded());
        json.put("collapseURL", uiPortalNavigation.url("CollapseNode", nodeId));

        ResourceURL rsURL = res.createResourceURL();
        rsURL.setResourceID(nodeId);
        json.put("getNodeURL", rsURL.toString());

        if (node.getPageRef() != null) {
            NavigationResource resource = new NavigationResource(node);
            NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
            url.setAjax(isUseAjax());
            json.put("actionLink", url.toString());
        }
View Full Code Here

        PortletPreferences prefers = prequest.getPreferences();
        return Boolean.valueOf(prefers.getValue("useAJAX", "true"));
    }

    public List<UserNode> getSelectedPath() throws Exception {
        UserNode node = Util.getUIPortal().getSelectedUserNode();
        UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal();
        UserNavigation nav = userPortal.getNavigation(node.getNavigation().getKey());

        UserNode targetNode = userPortal.resolvePath(nav, null, node.getURI());
        LinkedList<UserNode> paths = new LinkedList<UserNode>();

        do {
            paths.addFirst(targetNode);
            targetNode = targetNode.getParent();
        } while (targetNode != null && targetNode.getParent() != null);

        return paths;
    }
View Full Code Here

        }
    }

    public UserNode getParentTab() throws Exception {
        UserPortal userPortal = getUserPortal();
        UserNode selectedNode = uiPortal.getSelectedUserNode();
        UserNode currParent = selectedNode.getParent();

        UserNode parent = null;
        if ("".equals(currParent.getURI())) {
            parent = userPortal.getNode(currParent.getNavigation(), TAB_PANE_DASHBOARD_SCOPE, filterConfig, null);
        } else {
            parent = userPortal.resolvePath(currParent.getNavigation(), filterConfig, currParent.getURI());
        }
View Full Code Here

        //
        return parent;
    }

    public Collection<UserNode> getSameSiblingsNode() throws Exception {
        UserNode parentTab = getParentTab();

        if (parentTab == null) {
            return Collections.emptyList();
        }
        return parentTab.getChildren();
    }
View Full Code Here

     * @param nodeName - name of the Node that will be remove
     * @return return the node that should be selected after remove node
     */
    public UserNode removePageNode(String nodeName) {
        try {
            UserNode parentNode = getParentTab();
            if (parentNode == null || parentNode.getChild(nodeName) == null) {
                return null;
            }

            UserNode tobeRemoved = parentNode.getChild(nodeName);
            UserNode prevNode = null;

            if (parentNode.getChildrenCount() >= 2) {
                for (UserNode child : parentNode.getChildren()) {
                    if (child.getName().equals(nodeName)) {
                        parentNode.removeChild(nodeName);
                        break;
                    }
                    prevNode = child;
                }

                PageKey pageRef = tobeRemoved.getPageRef();
                if (pageRef != null) {
                    PageContext page = configService.getPageService().loadPage(pageRef);
                    if (page != null) {
                        configService.getPageService().destroyPage(pageRef);
                    }
                    UIPortal uiPortal = Util.getUIPortal();
                    // Remove from cache
                    uiPortal.setUIPage(pageRef.format(), null);
                }
                getUserPortal().saveNode(parentNode, null);
            } else {
                getAncestorOfType(UIApplication.class).addMessage(
                        new ApplicationMessage("UITabPaneDashboard.msg.cannotDeleteLastTab", null));
                return null;
            }

            UserNode selectedNode = uiPortal.getSelectedUserNode();
            if (nodeName.equals(selectedNode.getName())) {
                selectedNode = prevNode != null ? prevNode : parentNode.getChildren().iterator().next();
            }
            return selectedNode;
        } catch (Exception ex) {
            return null;
View Full Code Here

    }

    public UserNode createNewPageNode(String nodeLabel) {
        try {
            UserNavigation userNav = getCurrentUserNavigation();
            UserNode parentNode = getParentTab();
            if (userNav == null || parentNode == null) {
                return null;
            }

            String uniqueNodeName = buildName(nodeLabel);
            SiteKey siteKey = userNav.getKey();
            Page page = configService.createPageTemplate(UITabPaneDashboard.PAGE_TEMPLATE, siteKey.getTypeName(),
                    siteKey.getName());
            page.setTitle(HTMLEntityEncoder.getInstance().encode(nodeLabel));
            page.setName(uniqueNodeName + page.hashCode());

            //
            PageKey pageKey = new PageKey(siteKey, page.getName());
            PageState pageState = PageUtils.toPageState(page);
            configService.getPageService().savePage(new PageContext(pageKey, pageState));

            //
            dataService.save(page);

            if (parentNode.getChild(uniqueNodeName) != null) {
                uniqueNodeName = uniqueNodeName + "_" + System.currentTimeMillis();
            }

            UserNode tabNode = parentNode.addChild(uniqueNodeName);
            tabNode.setLabel(nodeLabel);
            tabNode.setPageRef(page.getPageKey());

            getUserPortal().saveNode(parentNode, null);

            return tabNode;
        } catch (Exception ex) {
View Full Code Here

        return nodeName.toString();
    }

    public UserNode renamePageNode(String nodeName, String newNodeLabel) {
        try {
            UserNode parentNode = getParentTab();
            if (parentNode == null || parentNode.getChild(nodeName) == null) {
                return null;
            }

            String newNodeName = buildName(newNodeLabel);
            if (parentNode.getChild(newNodeName) != null) {
                newNodeName = newNodeName + "_" + System.currentTimeMillis();
            }

            UserNode renamedNode = parentNode.getChild(nodeName);
            renamedNode.setName(newNodeName);

            // Distinguish between "Extended label mode" and basic label mode.
            // In "Extended label mode" node.getLabel() == null.
            if (renamedNode.getLabel() != null) {
                renamedNode.setLabel(newNodeLabel);
            } else {
                renamedNode.setResolvedLabel(newNodeLabel);
            }

            // Rename the page only in basic label mode.
            // For "Extended label mode" use page editor.
            if (renamedNode.getPageRef() != null && renamedNode.getLabel() != null) {
                PageContext page = configService.getPageService().loadPage(renamedNode.getPageRef());
                if (page != null) {
                    PageState state = page.getState();
                    String encodedLabel = HTMLEntityEncoder.getInstance().encode(newNodeLabel);
                    page.setState(state.builder().displayName(encodedLabel).build());
                    configService.getPageService().savePage(page);
                    // Update UIPage cache on UIPortal.
                    uiPortal.setUIPage(renamedNode.getPageRef().format(), null);
                }
            }

            getUserPortal().saveNode(parentNode, null);
            return renamedNode;
View Full Code Here

TOP

Related Classes of org.exoplatform.portal.mop.user.UserNode

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.