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);
}
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;
}
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);
}
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;
}
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));
}
Aggregations