use of org.jivesoftware.openfire.plugin.rest.entity.GroupEntity in project Openfire by igniterealtime.
the class UserServiceController method addUserToGroups.
/**
* Adds the user to group.
*
* @param username
* the username
* @param userGroupsEntity
* the user groups entity
* @throws ServiceException
* the service exception
*/
public void addUserToGroups(String username, UserGroupsEntity userGroupsEntity) throws ServiceException {
if (userGroupsEntity != null) {
Collection<Group> groups = new ArrayList<Group>();
for (String groupName : userGroupsEntity.getGroupNames()) {
Group group = null;
try {
group = GroupManager.getInstance().getGroup(groupName);
} catch (GroupNotFoundException e) {
// Create this group
group = GroupController.getInstance().createGroup(new GroupEntity(groupName, ""));
}
groups.add(group);
}
for (Group group : groups) {
group.getMembers().add(server.createJID(username, null));
}
}
}
use of org.jivesoftware.openfire.plugin.rest.entity.GroupEntity in project Openfire by igniterealtime.
the class GroupController method getGroup.
/**
* Gets the group.
*
* @param groupName
* the group name
* @return the group
* @throws ServiceException
* the service exception
*/
public GroupEntity getGroup(String groupName) throws ServiceException {
Group group;
try {
group = GroupManager.getInstance().getGroup(groupName);
} catch (GroupNotFoundException e) {
throw new ServiceException("Could not find group", groupName, ExceptionType.GROUP_NOT_FOUND, Response.Status.NOT_FOUND, e);
}
GroupEntity groupEntity = new GroupEntity(group.getName(), group.getDescription());
groupEntity.setAdmins(MUCRoomUtils.convertJIDsToStringList(group.getAdmins()));
groupEntity.setMembers(MUCRoomUtils.convertJIDsToStringList(group.getMembers()));
return groupEntity;
}
use of org.jivesoftware.openfire.plugin.rest.entity.GroupEntity in project Openfire by igniterealtime.
the class GroupController method getGroups.
/**
* Gets the groups.
*
* @return the groups
* @throws ServiceException
* the service exception
*/
public List<GroupEntity> getGroups() throws ServiceException {
Collection<Group> groups = GroupManager.getInstance().getGroups();
List<GroupEntity> groupEntities = new ArrayList<GroupEntity>();
for (Group group : groups) {
GroupEntity groupEntity = new GroupEntity(group.getName(), group.getDescription());
groupEntities.add(groupEntity);
}
return groupEntities;
}
use of org.jivesoftware.openfire.plugin.rest.entity.GroupEntity in project Openfire by igniterealtime.
the class UserServiceController method addUserToGroup.
/**
* Adds the user to group.
*
* @param username the username
* @param groupName the group name
* @throws ServiceException the service exception
*/
public void addUserToGroup(String username, String groupName) throws ServiceException {
Group group = null;
try {
group = GroupManager.getInstance().getGroup(groupName);
} catch (GroupNotFoundException e) {
// Create this group
group = GroupController.getInstance().createGroup(new GroupEntity(groupName, ""));
}
group.getMembers().add(server.createJID(username, null));
}
Aggregations