@Test public void testGetPermissionByUser() throws Exception { organizationService.addMemberships("user1", "*:/platform/users"); organizationService.addMemberships("user3", "*:/platform/users"); assertEquals(1, ForumServiceUtils.getUserPermission(new String[] { "user1" }).size()); AssertUtils.assertContains(ForumServiceUtils.getUserPermission(new String[] { "user1" }), "user1"); assertEquals(1, ForumServiceUtils.getUserPermission(new String[] { "user2" }).size()); AssertUtils.assertContains(ForumServiceUtils.getUserPermission(new String[] { "user2" }), "user2"); AssertUtils.assertContains(ForumServiceUtils.getUserPermission(new String[] { "user1", "user2" }), "user1", "user2"); AssertUtils.assertNotContains(ForumServiceUtils.getUserPermission(new String[] { "user1", "user2" }), "user3"); AssertUtils.assertContains(ForumServiceUtils.getUserPermission(new String[] { "user1", "user2" }), "user1", "user2"); }
@SuppressWarnings("unchecked") public static List<String> getUserPermission(String[] userGroupMembership) throws Exception { List<String> users = getFromCache(userGroupMembership); if (users != null) { return users; } users = new ArrayList<String>(); if (userGroupMembership == null || userGroupMembership.length <= 0 || (userGroupMembership.length == 1 && userGroupMembership[0].equals(" "))) return users; OrganizationService organizationService = (OrganizationService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class); for (String str : userGroupMembership) { str = str.trim(); if (isMembershipExpression(str)) { String[] array = str.split(":"); PageList pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; if (array[0].length() > 1) { List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { Collection<Membership> memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName()); for (Membership member : memberships) { if (member.getMembershipType().equals(array[0])) { users.add(user.getUserName()); break; } } } } } } else { if (array[0].charAt(0) == 42) { pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } } } else if (isGroupExpression(str)) { PageList pageList = getUserByGroup(organizationService, str); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } else { if (!users.contains(str)) { users.add(str); } } } storeInCache(userGroupMembership, users); return users; }
ForumServiceUtils { @SuppressWarnings("unchecked") public static List<String> getUserPermission(String[] userGroupMembership) throws Exception { List<String> users = getFromCache(userGroupMembership); if (users != null) { return users; } users = new ArrayList<String>(); if (userGroupMembership == null || userGroupMembership.length <= 0 || (userGroupMembership.length == 1 && userGroupMembership[0].equals(" "))) return users; OrganizationService organizationService = (OrganizationService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class); for (String str : userGroupMembership) { str = str.trim(); if (isMembershipExpression(str)) { String[] array = str.split(":"); PageList pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; if (array[0].length() > 1) { List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { Collection<Membership> memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName()); for (Membership member : memberships) { if (member.getMembershipType().equals(array[0])) { users.add(user.getUserName()); break; } } } } } } else { if (array[0].charAt(0) == 42) { pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } } } else if (isGroupExpression(str)) { PageList pageList = getUserByGroup(organizationService, str); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } else { if (!users.contains(str)) { users.add(str); } } } storeInCache(userGroupMembership, users); return users; } }
ForumServiceUtils { @SuppressWarnings("unchecked") public static List<String> getUserPermission(String[] userGroupMembership) throws Exception { List<String> users = getFromCache(userGroupMembership); if (users != null) { return users; } users = new ArrayList<String>(); if (userGroupMembership == null || userGroupMembership.length <= 0 || (userGroupMembership.length == 1 && userGroupMembership[0].equals(" "))) return users; OrganizationService organizationService = (OrganizationService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class); for (String str : userGroupMembership) { str = str.trim(); if (isMembershipExpression(str)) { String[] array = str.split(":"); PageList pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; if (array[0].length() > 1) { List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { Collection<Membership> memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName()); for (Membership member : memberships) { if (member.getMembershipType().equals(array[0])) { users.add(user.getUserName()); break; } } } } } } else { if (array[0].charAt(0) == 42) { pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } } } else if (isGroupExpression(str)) { PageList pageList = getUserByGroup(organizationService, str); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } else { if (!users.contains(str)) { users.add(str); } } } storeInCache(userGroupMembership, users); return users; }  }
ForumServiceUtils { @SuppressWarnings("unchecked") public static List<String> getUserPermission(String[] userGroupMembership) throws Exception { List<String> users = getFromCache(userGroupMembership); if (users != null) { return users; } users = new ArrayList<String>(); if (userGroupMembership == null || userGroupMembership.length <= 0 || (userGroupMembership.length == 1 && userGroupMembership[0].equals(" "))) return users; OrganizationService organizationService = (OrganizationService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class); for (String str : userGroupMembership) { str = str.trim(); if (isMembershipExpression(str)) { String[] array = str.split(":"); PageList pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; if (array[0].length() > 1) { List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { Collection<Membership> memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName()); for (Membership member : memberships) { if (member.getMembershipType().equals(array[0])) { users.add(user.getUserName()); break; } } } } } } else { if (array[0].charAt(0) == 42) { pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } } } else if (isGroupExpression(str)) { PageList pageList = getUserByGroup(organizationService, str); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } else { if (!users.contains(str)) { users.add(str); } } } storeInCache(userGroupMembership, users); return users; }  static boolean hasPermission(String[] userGroupMembership, String userId); @SuppressWarnings("unchecked") static List<String> getUserPermission(String[] userGroupMembership); static void reparePermissions(Node node, String owner); static SessionProvider getSessionProvider(); static SessionManager getSessionManager(); }
ForumServiceUtils { @SuppressWarnings("unchecked") public static List<String> getUserPermission(String[] userGroupMembership) throws Exception { List<String> users = getFromCache(userGroupMembership); if (users != null) { return users; } users = new ArrayList<String>(); if (userGroupMembership == null || userGroupMembership.length <= 0 || (userGroupMembership.length == 1 && userGroupMembership[0].equals(" "))) return users; OrganizationService organizationService = (OrganizationService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(OrganizationService.class); for (String str : userGroupMembership) { str = str.trim(); if (isMembershipExpression(str)) { String[] array = str.split(":"); PageList pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; if (array[0].length() > 1) { List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { Collection<Membership> memberships = organizationService.getMembershipHandler().findMembershipsByUser(user.getUserName()); for (Membership member : memberships) { if (member.getMembershipType().equals(array[0])) { users.add(user.getUserName()); break; } } } } } } else { if (array[0].charAt(0) == 42) { pageList = getUserByGroup(organizationService, array[1]); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } } } else if (isGroupExpression(str)) { PageList pageList = getUserByGroup(organizationService, str); if (pageList == null) continue; List<User> userList = new ArrayList<User>(); for (int i = 1; i <= pageList.getAvailablePage(); i++) { userList.clear(); userList.addAll(pageList.getPage(i)); for (User user : userList) { if (!users.contains(user.getUserName())) { users.add(user.getUserName()); } } } } else { if (!users.contains(str)) { users.add(str); } } } storeInCache(userGroupMembership, users); return users; }  static boolean hasPermission(String[] userGroupMembership, String userId); @SuppressWarnings("unchecked") static List<String> getUserPermission(String[] userGroupMembership); static void reparePermissions(Node node, String owner); static SessionProvider getSessionProvider(); static SessionManager getSessionManager();  }