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;
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class IQSharedGroupHandler method handleIQ.
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
IQ result = IQ.createResultIQ(packet);
String username = packet.getFrom().getNode();
if (!serverName.equals(packet.getFrom().getDomain()) || username == null) {
// Users of remote servers are not allowed to get their "shared groups". Users of
// remote servers cannot have shared groups in this server.
// Besides, anonymous users do not belong to shared groups so answer an error
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.not_allowed);
return result;
}
Collection<Group> groups = rosterManager.getSharedGroups(username);
Element sharedGroups = result.setChildElement("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup");
for (Group sharedGroup : groups) {
String displayName = sharedGroup.getProperties().get("sharedRoster.displayName");
if (displayName != null) {
sharedGroups.addElement("group").setText(displayName);
}
}
return result;
}
use of org.jivesoftware.openfire.group.Group in project Openfire by igniterealtime.
the class UserServicePlugin method getAllGroups.
/**
* Returns all group names or an empty collection.
*
*/
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;
}
Aggregations