Search in sources :

Example 1 with UserNode

use of org.exoplatform.portal.mop.user.UserNode in project social by Meeds-io.

the class UISpaceMenu method isAppNameExisted.

/**
 * Checks the input name is existed or not.<br>
 *
 * @param pageNav
 * @param nodeName
 * @return true if input name is existed. false if it not.
 * @throws Exception
 */
private boolean isAppNameExisted(UserNode homeNode, String nodeName) throws Exception {
    Collection<UserNode> nodes = homeNode.getChildren();
    // Check in case new name is duplicated with space name
    for (UserNode node : nodes) {
        if (node.getName().equals(nodeName)) {
            return true;
        }
    }
    // space home application name is not UserNode so we alse need to check this name
    String spaceHomeAppName = WebuiRequestContext.getCurrentInstance().getApplicationResourceBundle().getString(SPACE_HOME_APP_NAME);
    return nodeName.equals(spaceHomeAppName);
}
Also used : UserNode(org.exoplatform.portal.mop.user.UserNode)

Example 2 with UserNode

use of org.exoplatform.portal.mop.user.UserNode in project social by Meeds-io.

the class UISpaceMenu method getApps.

/**
 * Gets page node list for displaying as application links.
 *
 * @return page node list
 * @throws Exception
 */
public List<UserNode> getApps() throws Exception {
    String spaceUrl = Utils.getSpaceUrlByContext();
    space = spaceService.getSpaceByUrl(spaceUrl);
    if (space == null) {
        return new ArrayList<UserNode>(0);
    }
    List<UserNode> userNodeArraySorted = new ArrayList<UserNode>();
    try {
        UserNode spaceUserNode = SpaceUtils.getSpaceUserNode(space);
        UserNode hiddenNode = spaceUserNode.getChild(SPACE_SETTINGS);
        if (!hasSettingPermission() && (hiddenNode != null)) {
            spaceUserNode.removeChild(hiddenNode.getName());
        }
        userNodeArraySorted.addAll(spaceUserNode.getChildren());
        removeNonePageNodes(userNodeArraySorted);
    } catch (Exception e) {
        LOG.warn("Get UserNode of Space failed.");
    }
    // Collections.sort(userNodeArraySorted, new ApplicationComparator());
    return userNodeArraySorted;
}
Also used : ArrayList(java.util.ArrayList) UserNode(org.exoplatform.portal.mop.user.UserNode) SpaceException(org.exoplatform.social.core.space.SpaceException)

Example 3 with UserNode

use of org.exoplatform.portal.mop.user.UserNode in project social by Meeds-io.

the class UISpaceMenu method removeNonePageNodes.

/**
 * Removes nodes that have no page.
 *
 * @param nodes
 * @since 4.0.1-GA
 */
private void removeNonePageNodes(List<UserNode> nodes) {
    List<UserNode> nonePageNodes = new ArrayList<UserNode>();
    UserACL userACL = SpaceUtils.getUserACL();
    boolean noPageNode;
    for (UserNode node : nodes) {
        PageKey currentPage = node.getPageRef();
        if (currentPage == null) {
            nonePageNodes.add(node);
        } else {
            PageContext currentPageContext = getApplicationComponent(PageService.class).loadPage(currentPage);
            if (currentPageContext == null || !userACL.hasPermission(currentPageContext)) {
                nonePageNodes.add(node);
            }
        }
    }
    nodes.removeAll(nonePageNodes);
}
Also used : PageService(org.exoplatform.portal.mop.page.PageService) PageKey(org.exoplatform.portal.mop.page.PageKey) UserNode(org.exoplatform.portal.mop.user.UserNode) ArrayList(java.util.ArrayList) PageContext(org.exoplatform.portal.mop.page.PageContext) UserACL(org.exoplatform.portal.config.UserACL)

Example 4 with UserNode

use of org.exoplatform.portal.mop.user.UserNode in project social by Meeds-io.

the class TreeNode method getChildren.

public List<TreeNode> getChildren() {
    if (children == null) {
        children = new LinkedList<TreeNode>();
        for (UserNode child : node.getChildren()) {
            String key = child.getId() == null ? String.valueOf(child.hashCode()) : child.getId();
            TreeNode node = findNode(key);
            if (node == null) {
                throw new IllegalStateException("Can' find node " + child.getURI() + " in the cache");
            }
            children.add(node);
        }
    }
    return children;
}
Also used : UserNode(org.exoplatform.portal.mop.user.UserNode)

Example 5 with UserNode

use of org.exoplatform.portal.mop.user.UserNode in project social by Meeds-io.

the class TreeNode method addChild.

public TreeNode addChild(String childName) {
    children = null;
    UserNode child = node.addChild(childName);
    return addToCached(new TreeNode(nav, child, this.rootNode));
}
Also used : UserNode(org.exoplatform.portal.mop.user.UserNode)

Aggregations

UserNode (org.exoplatform.portal.mop.user.UserNode)70 UserNavigation (org.exoplatform.portal.mop.user.UserNavigation)26 UserPortal (org.exoplatform.portal.mop.user.UserPortal)22 JSONArray (org.json.JSONArray)10 ArrayList (java.util.ArrayList)9 UserPortalConfigService (org.exoplatform.portal.config.UserPortalConfigService)9 WebuiRequestContext (org.exoplatform.webui.application.WebuiRequestContext)8 UserPortalConfig (org.exoplatform.portal.config.UserPortalConfig)7 NodeURL (org.exoplatform.web.url.navigation.NodeURL)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ConversationState (org.exoplatform.services.security.ConversationState)6 MimeResponse (javax.portlet.MimeResponse)5 ResourceURL (javax.portlet.ResourceURL)5 PortalRequestContext (org.exoplatform.portal.application.PortalRequestContext)5 UIPortal (org.exoplatform.portal.webui.portal.UIPortal)5 JSONObject (org.json.JSONObject)5 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 PageContext (org.exoplatform.portal.mop.page.PageContext)4 PageKey (org.exoplatform.portal.mop.page.PageKey)4