Package org.exoplatform.portal.mop.user

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


    public static class AddDashboardActionListener extends EventListener<UITabPaneDashboard> {
        public void execute(Event<UITabPaneDashboard> event) throws Exception {
            UITabPaneDashboard tabPane = event.getSource();
            PortletRequestContext context = (PortletRequestContext) event.getRequestContext();
            String newTabLabel = context.getRequestParameter(UIComponent.OBJECTID);
            UserNode node = tabPane.getFirstAvailableNode();
            if (!tabPane.validateName(newTabLabel)) {
                Object[] args = { newTabLabel };
                context.getUIApplication().addMessage(new ApplicationMessage("UITabPaneDashboard.msg.wrongTabName", args));
            } else {
                UserNode createdNode = tabPane.createNewPageNode(newTabLabel);
                if (createdNode != null) {
                    node = createdNode;
                }
            }
View Full Code Here


            UITabPaneDashboard tabPane = event.getSource();
            PortletRequestContext context = (PortletRequestContext) event.getRequestContext();
            UIApplication rootUI = context.getUIApplication();

            String newTabLabel = context.getRequestParameter(RENAMED_TAB_LABEL_PARAMETER);
            UserNode node = tabPane.getFirstAvailableNode();
            if (!tabPane.validateName(newTabLabel)) {
                Object[] args = { newTabLabel };
                rootUI.addMessage(new ApplicationMessage("UITabPaneDashboard.msg.wrongTabName", args));
            } else {
                String nodeName = context.getRequestParameter(UIComponent.OBJECTID);
                UserNode renamedNode = tabPane.renamePageNode(nodeName, newTabLabel);
                if (renamedNode != null) {
                    node = renamedNode;
                }
            }
            PortalRequestContext prContext = Util.getPortalRequestContext();
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 = new PageState(page.getTitle(), page.getDescription(), page.isShowMaxWindow(),
                    page.getFactoryId(), page.getAccessPermissions() != null ? Arrays.asList(page.getAccessPermissions())
                            : null, page.getEditPermission());
            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

     *
     * @param firstIndex
     * @param secondIndex
     */
    public boolean permutePageNode(int firstIndex, int secondIndex) throws Exception {
        UserNode parentNode = getParentTab();
        List<UserNode> siblings = new ArrayList<UserNode>(getSameSiblingsNode());
        if (firstIndex == secondIndex) {
            return false;
        }

        try {
            UserNode firstNode = siblings.get(firstIndex);
            parentNode.addChild(secondIndex, firstNode);

            getUserPortal().saveNode(parentNode, null);
            return true;
        } catch (Exception ex) {
View Full Code Here

     * default path
     *
     * @throws Exception
     */
    public UserNode getFirstAvailableNode() throws Exception {
        UserNode parentTab = getParentTab();
        if (parentTab != null) {
            UserNode currNode = Util.getUIPortal().getSelectedUserNode();
            if (parentTab.getChildren().size() == 0 && parentTab.getURI() != null) {
                return parentTab;
            }

            if (parentTab.getChild(currNode.getName()) != null) {
                return currNode;
            } else {
                return parentTab.getChild(0);
            }
        }
View Full Code Here

    public JSONArray getChildrenAsJSON(String nodeURI) throws Exception {
        WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
        UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);

        Collection<UserNode> childs = null;
        UserNode userNode = uiPortalNavigation.resolvePath(nodeURI);
        if (userNode != null) {
            childs = userNode.getChildren();
        }

        JSONArray jsChilds = new JSONArray();
        if (childs == null) {
            return null;
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.