use of org.apache.openmeetings.db.entity.room.RoomGroup in project openmeetings by apache.
the class AuthLevelUtil method getRoomRight.
public static Set<Room.Right> getRoomRight(User u, Room r, Appointment a, int userCount) {
Set<Room.Right> result = new HashSet<>();
if (u == null) {
return result;
}
if (hasAdminLevel(u.getRights())) {
// admin user get superModerator level, no-one can kick him/her
result.add(Room.Right.superModerator);
} else if (r.isAppointment() && a != null && u.getId().equals(a.getOwner().getId())) {
// appointment owner is super moderator
result.add(Room.Right.superModerator);
}
if (result.isEmpty()) {
if (!r.isModerated() && 1 == userCount) {
// room is not moderated, first user is moderator!
result.add(Room.Right.moderator);
}
// performing loop here to set possible 'superModerator' right
for (RoomModerator rm : r.getModerators()) {
if (u.getId().equals(rm.getUser().getId())) {
result.add(rm.isSuperModerator() ? Room.Right.superModerator : Room.Right.moderator);
break;
}
}
// no need to loop if client is moderator
if (result.isEmpty() && r.getGroups() != null && !r.getGroups().isEmpty()) {
for (RoomGroup rg : r.getGroups()) {
for (GroupUser gu : u.getGroupUsers()) {
if (gu.getGroup().getId().equals(rg.getGroup().getId()) && gu.isModerator()) {
result.add(Room.Right.moderator);
break;
}
}
if (!result.isEmpty()) {
break;
}
}
}
}
if (Room.Type.conference == r.getType() && !result.contains(Room.Right.superModerator) && !result.contains(Room.Right.moderator) && !result.contains(Room.Right.video)) {
result.add(Room.Right.audio);
result.add(Room.Right.video);
}
return result;
}
use of org.apache.openmeetings.db.entity.room.RoomGroup in project openmeetings by apache.
the class GroupWebService method addRoom.
/**
* Adds a room to an group
*
* @param sid - The SID of the User. This SID must be marked as Loggedin
* @param id - Id of group that the room is being paired with
* @param roomid - Id of room to be added
*
* @return {@link ServiceResult} with result type
*/
@POST
@Path("/{id}/rooms/add/{roomid}")
public ServiceResult addRoom(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("roomid") @WebParam(name = "roomid") Long roomid) {
return performCall(sid, User.Right.Soap, sd -> {
Room r = roomDao.get(roomid);
if (r != null) {
if (r.getGroups() == null) {
r.setGroups(new ArrayList<RoomGroup>());
}
boolean found = false;
for (RoomGroup ro : r.getGroups()) {
if (ro.getGroup().getId().equals(id)) {
found = true;
}
}
if (!found) {
r.getGroups().add(new RoomGroup(groupDao.get(id), r));
roomDao.update(r, sd.getUserId());
return new ServiceResult("Success", Type.SUCCESS);
}
}
return new ServiceResult("Not added", Type.ERROR);
});
}
Aggregations