/**
  * Copy to groups.
  *
  * @param currentUser the current user
  * @param newUser the new user
  */
 private static void copyToGroups(String currentUser, String newUser) {
   GroupManager groupManager = GroupManager.getInstance();
   for (Group group : groupManager.getGroups()) {
     if (group.isUser(currentUser)) {
       group.getMembers().add(XMPPServer.getInstance().createJID(newUser, null));
     }
   }
 }
  /**
   * True if the specified bookmark should be appended to the users list of bookmarks.
   *
   * @param jid the jid of the user.
   * @param bookmark the bookmark.
   * @return true if bookmark should be appended.
   */
  private static boolean isBookmarkForJID(JID jid, Bookmark bookmark) {
    String username = jid.getNode();

    if (bookmark.getUsers().contains(username)) {
      return true;
    }

    Collection<String> groups = bookmark.getGroups();

    if (groups != null && !groups.isEmpty()) {
      GroupManager groupManager = GroupManager.getInstance();
      for (String groupName : groups) {
        try {
          Group group = groupManager.getGroup(groupName);
          if (group.isUser(jid.getNode())) {
            return true;
          }
        } catch (GroupNotFoundException e) {
          Log.debug(e.getMessage(), e);
        }
      }
    }
    return false;
  }
示例#3
0
 public boolean isUserInGroup(String jid, String groupName) throws GroupNotFoundException {
   Group group = groupManager.getGroup(groupName, true);
   return group.isUser(jid);
 }