use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class UserServiceLegacyController method getAllGroups.
/**
* Returns all group names or an empty collection.
*
* @return the all groups
*/
public Collection<String> getAllGroups() {
Collection<Group> groups = GroupManager.getInstance().getGroups();
Collection<String> groupNames = new ArrayList<String>();
for (Group group : groups) {
groupNames.add(group.getName());
}
return groupNames;
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class UserServiceLegacyController method createUser.
/**
* Creates the user.
*
* @param username the username
* @param password the password
* @param name the name
* @param email the email
* @param groupNames the group names
* @throws UserAlreadyExistsException the user already exists exception
* @throws GroupAlreadyExistsException the group already exists exception
* @throws UserNotFoundException the user not found exception
* @throws GroupNotFoundException the group not found exception
*/
public void createUser(String username, String password, String name, String email, String groupNames) throws UserAlreadyExistsException, GroupAlreadyExistsException, UserNotFoundException, GroupNotFoundException {
userManager.createUser(username, password, name, email);
userManager.getUser(username);
if (groupNames != null) {
Collection<Group> groups = new ArrayList<Group>();
StringTokenizer tkn = new StringTokenizer(groupNames, ",");
while (tkn.hasMoreTokens()) {
String groupName = tkn.nextToken();
Group group = null;
try {
group = GroupManager.getInstance().getGroup(groupName);
} catch (GroupNotFoundException e) {
// Create this group ;
group = GroupManager.getInstance().createGroup(groupName);
group.getProperties().put("sharedRoster.showInRoster", "onlyGroup");
group.getProperties().put("sharedRoster.displayName", groupName);
group.getProperties().put("sharedRoster.groupList", "");
}
groups.add(group);
}
for (Group group : groups) {
group.getMembers().add(server.createJID(username, null));
}
}
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class UserServiceLegacyController method getUserGroups.
/**
* Returns all group names or an empty collection for specific user.
*
* @param username the username
* @return the user groups
* @throws UserNotFoundException the user not found exception
*/
public Collection<String> getUserGroups(String username) throws UserNotFoundException {
User user = getUser(username);
Collection<Group> groups = GroupManager.getInstance().getGroups(user);
Collection<String> groupNames = new ArrayList<String>();
for (Group group : groups) {
groupNames.add(group.getName());
}
return groupNames;
}
Aggregations