Search in sources :

Example 6 with RoomGroup

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;
}
Also used : GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) RoomModerator(org.apache.openmeetings.db.entity.room.RoomModerator) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) HashSet(java.util.HashSet)

Example 7 with RoomGroup

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);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) Room(org.apache.openmeetings.db.entity.room.Room) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

RoomGroup (org.apache.openmeetings.db.entity.room.RoomGroup)7 Room (org.apache.openmeetings.db.entity.room.Room)5 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 RoomModerator (org.apache.openmeetings.db.entity.room.RoomModerator)2 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)2 User (org.apache.openmeetings.db.entity.user.User)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 JSONObject (com.github.openjson.JSONObject)1 JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)1 JQueryIcon (com.googlecode.wicket.jquery.ui.JQueryIcon)1 AjaxButton (com.googlecode.wicket.jquery.ui.form.button.AjaxButton)1 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1