Search in sources :

Example 16 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class RoomPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    // let's refresh user in client
    cm.update(getClient().updateUser(userDao));
    Component accessDenied = new WebMarkupContainer(ACCESS_DENIED_ID).setVisible(false);
    room.add(AttributeModifier.append(ATTR_CLASS, r.getType().name()));
    room.add(menu = new RoomMenuPanel("menu", this));
    room.add(AttributeModifier.append("data-room-id", r.getId()));
    if (interview) {
        room.add(new WebMarkupContainer("wb-area").add(wb));
    } else {
        Droppable<BaseFileItem> wbArea = new Droppable<BaseFileItem>("wb-area") {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("hoverClass", Options.asString("ui-state-hover"));
                behavior.setOption("accept", Options.asString(".recorditem, .fileitem, .readonlyitem"));
            }

            @Override
            public void onDrop(AjaxRequestTarget target, Component component) {
                Object o = component.getDefaultModelObject();
                if (wb.isVisible() && o instanceof BaseFileItem) {
                    BaseFileItem f = (BaseFileItem) o;
                    if (sidebar.getFilesPanel().isSelected(f)) {
                        for (Entry<String, BaseFileItem> e : sidebar.getFilesPanel().getSelected().entrySet()) {
                            wb.sendFileToWb(e.getValue(), false);
                        }
                    } else {
                        wb.sendFileToWb(f, false);
                    }
                }
            }
        };
        room.add(wbArea.add(wb));
    }
    room.add(roomEnter);
    room.add(sidebar = new RoomSidebar("sidebar", this));
    add(roomClosed = new RedirectMessageDialog("room-closed", "1098", r.isClosed(), r.getRedirectURL()));
    if (r.isClosed()) {
        room.setVisible(false);
    } else if (cm.listByRoom(r.getId()).size() >= r.getCapacity()) {
        accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, getString("99"), menu);
        room.setVisible(false);
    } else if (r.getId().equals(WebSession.get().getRoomId())) {
    // secureHash/invitationHash, already checked
    } else {
        boolean allowed = false;
        String deniedMessage = null;
        if (r.isAppointment()) {
            Appointment a = apptDao.getByRoom(r.getId());
            if (a != null && !a.isDeleted()) {
                boolean isOwner = a.getOwner().getId().equals(getUserId());
                allowed = isOwner;
                log.debug("appointed room, isOwner ? {}", isOwner);
                if (!allowed) {
                    for (MeetingMember mm : a.getMeetingMembers()) {
                        if (getUserId().equals(mm.getUser().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                }
                if (allowed) {
                    Calendar c = WebSession.getCalendar();
                    if (isOwner || c.getTime().after(a.getStart()) && c.getTime().before(a.getEnd())) {
                        eventDetail = new EventDetailDialog(EVENT_DETAILS_ID, a);
                    } else {
                        allowed = false;
                        deniedMessage = String.format("%s %s - %s", getString("error.hash.period"), getDateFormat().format(a.getStart()), getDateFormat().format(a.getEnd()));
                    }
                }
            }
        } else {
            allowed = r.getIspublic() || (r.getOwnerId() != null && r.getOwnerId().equals(getUserId()));
            log.debug("public ? " + r.getIspublic() + ", ownedId ? " + r.getOwnerId() + " " + allowed);
            if (!allowed) {
                User u = getClient().getUser();
                for (RoomGroup ro : r.getGroups()) {
                    for (GroupUser ou : u.getGroupUsers()) {
                        if (ro.getGroup().getId().equals(ou.getGroup().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                    if (allowed) {
                        break;
                    }
                }
            }
        }
        if (!allowed) {
            if (deniedMessage == null) {
                deniedMessage = getString("1599");
            }
            accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, deniedMessage, menu);
            room.setVisible(false);
        }
    }
    waitForModerator = new MessageDialog("wait-for-moderator", getString("204"), getString("696"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    waitApplyModeration = new MessageDialog("wait-apply-moderation", getString("204"), getString(r.isModerated() ? "641" : "498"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    add(room, accessDenied, eventDetail, waitForModerator, waitApplyModeration);
    if (r.isWaitForRecording()) {
        add(new MessageDialog("wait-for-recording", getString("1316"), getString("1315"), DialogButtons.OK, DialogIcon.LIGHT) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("autoOpen", true);
                behavior.setOption("resizable", false);
            }

            @Override
            public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            // no-op
            }
        });
    } else {
        add(new WebMarkupContainer("wait-for-recording").setVisible(false));
    }
    if (room.isVisible()) {
        add(new NicknameDialog("nickname", this));
        add(download);
        add(new BaseWebSocketBehavior("media"));
    } else {
        add(new WebMarkupContainer("nickname").setVisible(false));
    }
    add(clientKicked = new MessageDialog("client-kicked", getString("797"), getString("606"), DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            menu.exit(handler);
        }
    });
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) RoomSidebar(org.apache.openmeetings.web.room.sidebar.RoomSidebar) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) Component(org.apache.wicket.Component) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) Calendar(java.util.Calendar) RoomMenuPanel(org.apache.openmeetings.web.room.menu.RoomMenuPanel) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) BaseWebSocketBehavior(org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) JSONObject(com.github.openjson.JSONObject) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup)

Example 17 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class OmTreeProvider method refreshRoots.

public void refreshRoots(boolean all) {
    List<BaseFileItem> fRoot = new ArrayList<>(), rRoot = new ArrayList<>();
    if (all && roomId != null) {
        BaseFileItem r = createRoot(Application.getString("706"), FILES_MY, false);
        r.setOwnerId(getUserId());
        fRoot.add(r);
    }
    if (roomId != null) {
        BaseFileItem r = createRoot(Application.getString("707"), FILES_ROOM, false);
        r.setRoomId(roomId);
        fRoot.add(r);
    }
    if (all) {
        {
            BaseFileItem r = createRoot(Application.getString("860"), RECORDINGS_MY, true);
            r.setOwnerId(getUserId());
            rRoot.add(r);
        }
        {
            BaseFileItem r = createRoot(PUBLIC, RECORDINGS_PUBLIC, true);
            rRoot.add(r);
        }
    }
    for (GroupUser gu : userDao.get(getUserId()).getGroupUsers()) {
        Group g = gu.getGroup();
        boolean readOnly = g.isRestricted() && !hasAdminLevel(getRights()) && !gu.isModerator();
        if (all) {
            BaseFileItem r = createRoot(String.format("%s (%s)", GROUP_REC, g.getName()), String.format(RECORDINGS_GROUP, g.getId()), true);
            r.setReadOnly(readOnly);
            r.setGroupId(g.getId());
            rRoot.add(r);
        }
        BaseFileItem r = createRoot(String.format("%s (%s)", GROUP_FILE, g.getName()), String.format(FILES_GROUP, g.getId()), false);
        r.setGroupId(g.getId());
        // group videos are read-only in recordings tree
        r.setReadOnly(roomId == null || readOnly);
        fRoot.add(r);
    }
    roots.clear();
    if (roomId == null) {
        roots.addAll(rRoot);
        roots.addAll(fRoot);
    } else {
        roots.addAll(fRoot);
        roots.addAll(rRoot);
    }
}
Also used : BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Group(org.apache.openmeetings.db.entity.user.Group) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) ArrayList(java.util.ArrayList)

Example 18 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class BackupImport method importUsers.

/*
	 * ##################### Import Users
	 */
private void importUsers(File f, Long defaultLdapId) throws Exception {
    log.info("OAuth2 servers import complete, starting user import");
    String jNameTimeZone = getDefaultTimezone();
    // add existence email from database
    List<User> users = userDao.getAllUsers();
    final Map<String, Integer> userEmailMap = new HashMap<>();
    final Map<String, Integer> userLoginMap = new HashMap<>();
    for (User u : users) {
        if (u.getAddress() == null || u.getAddress().getEmail() == null || User.Type.user != u.getType()) {
            continue;
        }
        userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(-1));
        userLoginMap.put(u.getLogin(), Integer.valueOf(-1));
    }
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer ser = new Persister(strategy);
    registry.bind(Group.class, new GroupConverter(groupDao, groupMap));
    registry.bind(Salutation.class, SalutationConverter.class);
    registry.bind(Date.class, DateConverter.class);
    List<User> list = readList(ser, f, "users.xml", "users", User.class);
    int minLoginLength = getMinLoginLength(cfgDao);
    for (User u : list) {
        if (u.getLogin() == null) {
            continue;
        }
        // check that email is unique
        if (u.getAddress() != null && u.getAddress().getEmail() != null && User.Type.user == u.getType()) {
            if (userEmailMap.containsKey(u.getAddress().getEmail())) {
                log.warn("Email is duplicated for user " + u.toString());
                String updateEmail = String.format("modified_by_import_<%s>%s", UUID.randomUUID(), u.getAddress().getEmail());
                u.getAddress().setEmail(updateEmail);
            }
            userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(userEmailMap.size()));
        }
        if (userLoginMap.containsKey(u.getLogin())) {
            log.warn("Login is duplicated for user " + u.toString());
            String updateLogin = String.format("modified_by_import_<%s>%s", UUID.randomUUID(), u.getLogin());
            u.setLogin(updateLogin);
        }
        userLoginMap.put(u.getLogin(), Integer.valueOf(userLoginMap.size()));
        if (u.getGroupUsers() != null) {
            for (GroupUser gu : u.getGroupUsers()) {
                gu.setUser(u);
            }
        }
        if (u.getType() == User.Type.contact && u.getLogin().length() < minLoginLength) {
            u.setLogin(UUID.randomUUID().toString());
        }
        String tz = u.getTimeZoneId();
        if (tz == null) {
            u.setTimeZoneId(jNameTimeZone);
            u.setForceTimeZoneCheck(true);
        } else {
            u.setForceTimeZoneCheck(false);
        }
        Long userId = u.getId();
        u.setId(null);
        if (u.getSipUser() != null && u.getSipUser().getId() != 0) {
            u.getSipUser().setId(0);
        }
        if (LDAP_EXT_TYPE.equals(u.getExternalType()) && User.Type.external != u.getType()) {
            log.warn("Found LDAP user in 'old' format, external_type == 'LDAP':: " + u);
            u.setType(User.Type.ldap);
            u.setExternalType(null);
            if (u.getDomainId() == null) {
                // domainId was not supported in old versions of OM
                u.setDomainId(defaultLdapId);
            }
        }
        if (!Strings.isEmpty(u.getExternalType())) {
            u.setType(User.Type.external);
        }
        if (AuthLevelUtil.hasLoginLevel(u.getRights()) && !Strings.isEmpty(u.getActivatehash())) {
            u.setActivatehash(null);
        }
        userDao.update(u, Long.valueOf(-1));
        userMap.put(userId, u.getId());
    }
}
Also used : GroupConverter(org.apache.openmeetings.backup.converter.GroupConverter) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) HashMap(java.util.HashMap) Registry(org.simpleframework.xml.convert.Registry) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 19 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.

the class RecordingDao method getContainerData.

public RecordingContainerData getContainerData(long userId) {
    try {
        RecordingContainerData containerData = new RecordingContainerData();
        // User Home Recordings
        List<Recording> homes = getRootByOwner(userId);
        long homeFileSize = 0;
        for (Recording home : homes) {
            homeFileSize += getSize(home);
        }
        containerData.setUserHomeSize(homeFileSize);
        // Public Recordings
        long publicFileSize = 0;
        // get all groups the user can view
        for (GroupUser ou : userDao.get(userId).getGroupUsers()) {
            List<Recording> publicRecordings = getRootByPublic(ou.getGroup().getId());
            // get sizes
            for (Recording r : publicRecordings) {
                publicFileSize += getSize(r);
            }
        }
        containerData.setPublicFileSize(publicFileSize);
        return containerData;
    } catch (Exception ex2) {
        log.error("[getRecordingContainerData]: ", ex2);
    }
    return null;
}
Also used : GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) RecordingContainerData(org.apache.openmeetings.db.dto.record.RecordingContainerData) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 20 with GroupUser

use of org.apache.openmeetings.db.entity.user.GroupUser 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)

Aggregations

GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)28 User (org.apache.openmeetings.db.entity.user.User)19 Group (org.apache.openmeetings.db.entity.user.Group)9 Test (org.junit.Test)7 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)5 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Path (javax.ws.rs.Path)3 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)3 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)3 RoomGroup (org.apache.openmeetings.db.entity.room.RoomGroup)3 JSONObject (com.github.openjson.JSONObject)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)2 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 JSONArray (com.github.openjson.JSONArray)1