Search in sources :

Example 71 with User

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

the class NicknameDialog method onConfigure.

@Override
public void onConfigure(JQueryBehavior behavior) {
    super.onConfigure(behavior);
    User u = form.getModelObject();
    boolean visible = isVisible(u);
    if (visible) {
        u.setFirstname(getString("433"));
        u.setLastname(String.format("%s %s", u.getFirstname(), TIME_DF.format(new Date())));
    }
    behavior.setOption("autoOpen", visible);
    behavior.setOption("resizable", false);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) Date(java.util.Date)

Example 72 with User

use of org.apache.openmeetings.db.entity.user.User 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 73 with User

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

the class RoomClientPanel method getName.

private static String getName(Client c) {
    String delim = "";
    StringBuilder sb = new StringBuilder();
    User u = c.getUser();
    if (!Strings.isEmpty(u.getFirstname())) {
        sb.append(u.getFirstname());
        delim = " ";
    }
    if (!Strings.isEmpty(u.getLastname())) {
        sb.append(delim).append(u.getLastname());
        delim = " ";
    }
    if (Strings.isEmpty(sb) && u.getAddress() != null && !Strings.isEmpty(u.getAddress().getEmail())) {
        sb.append(delim).append(u.getAddress().getEmail());
    }
    if (Strings.isEmpty(sb)) {
        sb.append("N/A");
    }
    return sb.toString();
}
Also used : User(org.apache.openmeetings.db.entity.user.User)

Example 74 with User

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

the class BackupExport method exportUsers.

/*
	 * ##################### Backup Users
	 */
private void exportUsers(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer ser = new Persister(strategy);
    registry.bind(Group.class, GroupConverter.class);
    registry.bind(Salutation.class, SalutationConverter.class);
    List<User> list = userDao.getAllBackupUsers();
    bindDate(registry, list);
    writeList(ser, zos, "users.xml", "users", list);
    progressHolder.setProgress(10);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 75 with User

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

Aggregations

User (org.apache.openmeetings.db.entity.user.User)101 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)29 Test (org.junit.Test)25 Date (java.util.Date)11 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)10 ArrayList (java.util.ArrayList)8 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)8 OmException (org.apache.openmeetings.util.OmException)8 Path (javax.ws.rs.Path)7 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)7 Room (org.apache.openmeetings.db.entity.room.Room)7 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)6 Client (org.apache.openmeetings.db.entity.basic.Client)6 Address (org.apache.openmeetings.db.entity.user.Address)5 Group (org.apache.openmeetings.db.entity.user.Group)5 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)4 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)4 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)4 Recording (org.apache.openmeetings.db.entity.record.Recording)4 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3