Example usage for org.apache.wicket.util.string Strings isEmpty

List of usage examples for org.apache.wicket.util.string Strings isEmpty

Introduction

In this page you can find the example usage for org.apache.wicket.util.string Strings isEmpty.

Prototype

public static boolean isEmpty(final CharSequence string) 

Source Link

Document

Checks whether the string is considered empty.

Usage

From source file:org.apache.openmeetings.web.admin.rooms.RoomForm.java

License:Apache License

public RoomForm(String id, WebMarkupContainer roomList, final Room room) {
    super(id, new CompoundPropertyModel<Room>(room));
    this.roomList = roomList;
    setOutputMarkupId(true);//w w  w.  ja va2s .  com
    RequiredTextField<String> name = new RequiredTextField<String>("name");
    name.setLabel(new Model<String>(Application.getString(193)));
    add(name);

    add(new DropDownChoice<Long>("numberOfPartizipants", //
            DROPDOWN_NUMBER_OF_PARTICIPANTS, //
            new ChoiceRenderer<Long>() {
                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(Long id) {
                    return id;
                }

                @Override
                public String getIdValue(Long id, int index) {
                    return "" + id;
                }
            }));

    add(new RoomTypeDropDown("type").setRequired(true).setLabel(Model.of(Application.getString(194))));

    add(new TextArea<String>("comment"));

    add(new CheckBox("appointment").setEnabled(false));
    add(new CheckBox("ispublic"));

    List<Group> orgList = Application.getBean(GroupDao.class).get(0, Integer.MAX_VALUE);
    final List<RoomGroup> orgRooms = new ArrayList<RoomGroup>(orgList.size());
    for (Group org : orgList) {
        orgRooms.add(new RoomGroup(org, getModelObject()));
    }
    add(new Select2MultiChoice<RoomGroup>("roomGroups", null, new ChoiceProvider<RoomGroup>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(RoomGroup choice) {
            String name = choice.getGroup().getName();
            return name == null ? "" : name;
        }

        @Override
        public String getIdValue(RoomGroup choice) {
            Long id = choice.getGroup().getId();
            return id == null ? null : "" + id;
        }

        @Override
        public void query(String term, int page, Response<RoomGroup> response) {
            for (RoomGroup or : orgRooms) {
                if (Strings.isEmpty(term) || or.getGroup().getName().contains(term)) {
                    response.add(or);
                }
            }
        }

        @Override
        public Collection<RoomGroup> toChoices(Collection<String> _ids) {
            List<Long> ids = new ArrayList<Long>();
            for (String id : _ids) {
                ids.add(Long.valueOf(id));
            }
            List<RoomGroup> list = new ArrayList<RoomGroup>();
            for (Group o : getBean(GroupDao.class).get(ids)) {
                list.add(new RoomGroup(o, RoomForm.this.getModelObject()));
            }
            return list;
        }
    }));

    add(new CheckBox("isDemoRoom"));
    TextField<Integer> demoTime = new TextField<Integer>("demoTime");
    demoTime.setLabel(new Model<String>(Application.getString(637)));
    add(demoTime);
    add(new CheckBox("allowUserQuestions"));
    add(new CheckBox("audioOnly"));
    add(new CheckBox("allowFontStyles"));
    add(new CheckBox("closed"));
    add(new TextField<String>("redirectURL"));
    add(new CheckBox("waitForRecording"));
    add(new CheckBox("allowRecording"));

    add(new CheckBox("hideTopBar"));
    add(new CheckBox("chatHidden"));
    add(new CheckBox("activitiesHidden"));
    add(new CheckBox("hideFilesExplorer"));
    add(new CheckBox("hideActionsMenu"));
    add(new CheckBox("hideScreenSharing"));
    add(new CheckBox("hideWhiteboard"));
    add(new CheckBox("showMicrophoneStatus"));
    add(new CheckBox("chatModerated"));
    add(new CheckBox("chatOpened"));
    add(new CheckBox("filesOpened"));
    add(new CheckBox("autoVideoSelect"));

    // Users in this Room 
    clients = new ListView<Client>("clients", clientsInRoom) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Client> item) {
            Client client = item.getModelObject();
            item.add(new Label("clientId", "" + client.getId()))
                    .add(new Label("clientLogin", "" + client.getUsername()))
                    .add(new ConfirmableAjaxBorder("clientDelete", getString("80"), getString("833")) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                            Client c = item.getModelObject();
                            getBean(IUserService.class).kickUserByStreamId(getSid(), c.getStreamid(),
                                    c.getServer() == null ? 0 : c.getServer().getId());

                            updateClients(target);
                        }
                    });
        }
    };
    add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true));

    // Moderators
    final Select2Choice<User> moderatorChoice = new Select2Choice<User>("moderator2add", moderator2add,
            new AdminUserChoiceProvider() {
                private static final long serialVersionUID = 1L;

                @Override
                public void query(String term, int page, Response<User> response) {
                    response.addAll(getBean(UserDao.class).get(term, false, page * PAGE_SIZE, PAGE_SIZE));
                    response.setHasMore(PAGE_SIZE == response.getResults().size());
                }

                @Override
                public String getDisplayValue(User choice) {
                    Address a = choice.getAddress();
                    return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(),
                            a == null ? "" : a.getEmail());
                }
            });
    add(moderatorChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Room r = RoomForm.this.getModelObject();
            User u = moderator2add.getObject();
            boolean found = false;
            if (u != null) {
                if (r.getModerators() == null) {
                    r.setModerators(new ArrayList<RoomModerator>());
                }
                for (RoomModerator rm : r.getModerators()) {
                    if (rm.getUser().getId().equals(u.getId())) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    RoomModerator rm = new RoomModerator();
                    rm.setRoomId(r.getId());
                    rm.setUser(u);
                    r.getModerators().add(0, rm);
                    moderator2add.setObject(null);
                    target.add(moderatorContainer, moderatorChoice);
                }
            }
        }
    }).setOutputMarkupId(true));
    add(moderatorContainer.add(new ListView<RoomModerator>("moderators") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<RoomModerator> item) {
            RoomModerator moderator = item.getModelObject();
            Label name = new Label("uName",
                    moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname());
            if (moderator.getId() == null) {
                name.add(AttributeAppender.append("class", "newItem"));
            }
            item.add(new CheckBox("superModerator", new PropertyModel<Boolean>(moderator, "superModerator")))
                    .add(new Label("userId", "" + moderator.getUser().getId())).add(name)
                    .add(new Label("email", moderator.getUser().getAddress().getEmail()))
                    .add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                            RoomForm.this.getModelObject().getModerators().remove(item.getIndex());
                            target.add(moderatorContainer);
                        }
                    });
        }
    }).setOutputMarkupId(true));

    add(new CheckBox("moderated"));

    add(new TextField<String>("confno").setEnabled(false));
    add(pin = new TextField<String>("pin"));
    pin.setEnabled(room.isSipEnabled());
    add(new TextField<String>("ownerId").setEnabled(false));
    add(new AjaxCheckBox("sipEnabled") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateView(target);
        }
    }.setOutputMarkupId(true));

    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}

From source file:org.apache.openmeetings.web.admin.users.UserForm.java

License:Apache License

/**
 * Add the fields to the form/*from w  w w.ja v a2 s . c o m*/
 */
private void addFormFields() {
    ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
    login.setLabel(Model.of(Application.getString(132)));
    add(login.add(minimumLength(getMinLoginLength(cfgDao))));

    add(generalForm = new GeneralUserForm("general", getModel(), true));

    add(new DropDownChoice<Type>("type", Arrays.asList(Type.values())).add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateDomain(target);
        }
    }));
    update(null);
    add(domain.add(domainId).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(new Label("ownerId"));
    add(forDatePattern("inserted", WEB_DATE_PATTERN));
    add(forDatePattern("updated", WEB_DATE_PATTERN));

    add(new CheckBox("forceTimeZoneCheck"));

    add(new Select2MultiChoice<Right>("rights", null, new ChoiceProvider<Right>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(Right choice) {
            return choice.name();
        }

        @Override
        public String getIdValue(Right choice) {
            return choice.name();
        }

        @Override
        public void query(String term, int page, Response<Right> response) {
            for (Right r : Right.values()) {
                if (Strings.isEmpty(term) || r.name().contains(term)) {
                    response.add(r);
                }
            }
        }

        @Override
        public Collection<Right> toChoices(Collection<String> ids) {
            Collection<Right> rights = new ArrayList<>(ids.size());
            for (String id : ids) {
                rights.add(Right.valueOf(id));
            }
            return rights;
        }
    }));
    add(new ComunityUserForm("comunity", getModel()));
}

From source file:org.apache.openmeetings.web.app.MessageTagHandler.java

License:Apache License

@Override
protected final MarkupElement onComponentTag(ComponentTag tag) throws ParseException {
    if (tag.isClose()) {
        return tag;
    }/*from w  w w  .  j  a  va  2 s. c o  m*/

    final String wicketMessageAttribute = tag.getAttributes().getString(getWicketMessageAttrName());

    if (Strings.isEmpty(wicketMessageAttribute) == false) {
        // check if this tag is raw markup
        if (tag.getId() == null) {
            // if this is a raw tag we need to set the id to something so
            // that wicket will not merge this as raw markup and instead
            // pass it on to a resolver
            tag.setId(getWicketMessageIdPrefix());
            tag.setAutoComponentTag(true);
            tag.setModified(true);
        }
        tag.addBehavior(new AttributeLocalizer(getWicketMessageAttrName()));
    }

    return tag;
}

From source file:org.apache.openmeetings.web.app.OmAuthenticationStrategy.java

License:Apache License

/**
 * @see DefaultAuthenticationStrategy#decode(String value)
 * Additionally decodes stored login type and domain
 *///from w  ww.java 2s  .c o  m
@Override
protected String[] decode(String value) {
    if (!Strings.isEmpty(value)) {
        String username = null;
        String password = null;
        String type = null;
        String domainId = null;

        String[] values = value.split(VALUE_SEPARATOR);
        if (values.length > 0 && !Strings.isEmpty(values[0])) {
            username = values[0];
        }
        if (values.length > 1 && !Strings.isEmpty(values[1])) {
            password = values[1];
        }
        if (values.length > 2 && !Strings.isEmpty(values[2])) {
            type = values[2];
        }
        if (values.length > 3 && !Strings.isEmpty(values[3])) {
            domainId = values[3];
        }

        return new String[] { username, password, type, domainId };
    }
    return null;
}

From source file:org.apache.openmeetings.web.app.UserManager.java

License:Apache License

private static boolean sendConfirmation() {
    String baseURL = getBaseUrl();
    return !Strings.isEmpty(baseURL) && isSendVerificationEmail();
}

From source file:org.apache.openmeetings.web.app.UserManager.java

License:Apache License

/**
 * @param u - User with basic parametrs set
 * @param password - user password/*w  w  w. jav a 2  s  .  com*/
 * @param hash - activation hash
 * @return {@link User} of code of error as {@link String}
 * @throws NoSuchAlgorithmException in case password hashing algorithm is not found
 * @throws OmException in case of any issues with provided data
 */
@Override
public Object registerUser(User u, String password, String hash) throws OmException, NoSuchAlgorithmException {
    // Check for required data
    String login = u.getLogin();
    if (!Strings.isEmpty(login) && login.length() >= getMinLoginLength()) {
        // Check for duplicates
        boolean checkName = userDao.checkLogin(login, User.Type.user, null, null);
        String email = u.getAddress() == null ? null : u.getAddress().getEmail();
        boolean checkEmail = Strings.isEmpty(email) || userDao.checkEmail(email, User.Type.user, null, null);
        if (checkName && checkEmail) {
            String ahash = Strings.isEmpty(hash) ? randomUUID().toString() : hash;
            if (Strings.isEmpty(u.getExternalType())) {
                if (!Strings.isEmpty(email)) {
                    emailManager.sendMail(login, email, ahash, sendConfirmation(), u.getLanguageId());
                }
            } else {
                u.setType(Type.external);
            }

            // If this user needs first to click his E-Mail verification
            // code then set the status to 0
            if (sendConfirmation() && u.getRights().contains(Right.Login)) {
                u.getRights().remove(Right.Login);
            }

            u.setActivatehash(ahash);
            if (!Strings.isEmpty(password)) {
                u.updatePassword(password);
            }
            u = userDao.update(u, null);
            log.debug("Added user-Id {}", u.getId());

            if (u.getId() != null) {
                return u;
            }
        } else {
            if (!checkName) {
                return "error.login.inuse";
            } else {
                return "error.email.inuse";
            }
        }
    } else {
        return "error.short.login";
    }
    return UNKNOWN.getKey();
}

From source file:org.apache.openmeetings.web.app.WebSession.java

License:Apache License

public boolean signIn(String secureHash, boolean markUsed) {
    //FIXME code is duplicated from MainService, need to be unified
    SOAPLoginDao soapDao = getBean(SOAPLoginDao.class);
    SOAPLogin soapLogin = soapDao.get(secureHash);
    if (soapLogin == null) {
        return false;
    }/*  w w w  .j av a 2 s.c  o m*/
    if (!soapLogin.isUsed() || soapLogin.getAllowSameURLMultipleTimes()) {
        SessiondataDao sessionDao = getBean(SessiondataDao.class);
        Sessiondata sd = sessionDao.get(soapLogin.getSessionHash());
        if (sd != null && sd.getXml() != null) {
            RemoteSessionObject remoteUser = RemoteSessionObject.fromXml(sd.getXml());
            if (remoteUser != null && !Strings.isEmpty(remoteUser.getExternalUserId())) {
                UserDao userDao = getBean(UserDao.class);
                User user = userDao.getExternalUser(remoteUser.getExternalUserId(),
                        remoteUser.getExternalUserType());
                if (user == null) {
                    user = userDao.getNewUserInstance(null);
                    user.setFirstname(remoteUser.getFirstname());
                    user.setLastname(remoteUser.getLastname());
                    user.setLogin(remoteUser.getUsername()); //FIXME check if login UNIQUE
                    user.setType(Type.external);
                    user.setExternalId(remoteUser.getExternalUserId());
                    user.setExternalType(remoteUser.getExternalUserType());
                    user.getRights().clear();
                    user.getRights().add(Right.Room);
                    user.getAddress().setEmail(remoteUser.getEmail());
                    user.setPictureuri(remoteUser.getPictureUrl());
                } else {
                    user.setFirstname(remoteUser.getFirstname());
                    user.setLastname(remoteUser.getLastname());
                    user.setPictureuri(remoteUser.getPictureUrl());
                }
                user = userDao.update(user, null);
                if (markUsed) {
                    soapLogin.setUsed(true);
                    soapLogin.setUseDate(new Date());
                    //soapLogin.setClientURL(clientURL); //FIXME
                    soapDao.update(soapLogin);
                }
                sessionDao.updateUser(SID, user.getId());
                setUser(user, null);
                roomId = soapLogin.getRoomId();
                recordingId = soapLogin.getRecordingId();
                return true;
            }
        }
    }
    return false;
}

From source file:org.apache.openmeetings.web.common.GeneralUserForm.java

License:Apache License

public GeneralUserForm(String id, IModel<User> model, boolean isAdminForm) {
    super(id, model);

    //TODO should throw exception if non admin User edit somebody else (or make all fields read-only)
    add(passwordField = new PasswordTextField("password", new Model<String>()));
    ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
    passwordField.setRequired(false).add(minimumLength(getMinPasswdLength(cfgDao)));

    updateModelObject(getModelObject(), isAdminForm);
    add(new DropDownChoice<Salutation>("salutation", Arrays.asList(Salutation.values()),
            new ChoiceRenderer<Salutation>() {
                private static final long serialVersionUID = 1L;

                @Override/*from w  w w.j a  v a 2  s.c  o m*/
                public Object getDisplayValue(Salutation object) {
                    return getString("user.salutation." + object.name());
                }

                @Override
                public String getIdValue(Salutation object, int index) {
                    return object.name();
                }
            }));
    add(new TextField<String>("firstname"));
    add(new TextField<String>("lastname"));

    add(new DropDownChoice<String>("timeZoneId", AVAILABLE_TIMEZONES));

    add(new LanguageDropDown("languageId"));

    add(email = new RequiredTextField<String>("address.email"));
    email.setLabel(Model.of(Application.getString(137)));
    email.add(RfcCompliantEmailAddressValidator.getInstance());
    add(new TextField<String>("address.phone"));
    add(new CheckBox("sendSMS"));
    add(new AjaxDatePicker("age", new PropertyModel<LocalDate>(this, "age"), WebSession.get().getLocale()) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onValueChanged(IPartialPageRequestHandler target) {
            User u = GeneralUserForm.this.getModelObject();
            u.setAge(CalendarHelper.getDate(age, u.getTimeZoneId()));
        }
    });
    add(new TextField<String>("address.street"));
    add(new TextField<String>("address.additionalname"));
    add(new TextField<String>("address.zip"));
    add(new TextField<String>("address.town"));
    add(new CountryDropDown("address.country"));
    add(new TextArea<String>("address.comment"));

    add(new Select2MultiChoice<GroupUser>("groupUsers", null, new ChoiceProvider<GroupUser>() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(GroupUser choice) {
            return choice.getGroup().getName();
        }

        @Override
        public String getIdValue(GroupUser choice) {
            Long id = choice.getGroup().getId();
            return id == null ? null : "" + id;
        }

        @Override
        public void query(String term, int page, Response<GroupUser> response) {
            for (GroupUser ou : grpUsers) {
                if (Strings.isEmpty(term) || ou.getGroup().getName().contains(term)) {
                    response.add(ou);
                }
            }
        }

        @Override
        public Collection<GroupUser> toChoices(Collection<String> _ids) {
            List<Long> ids = new ArrayList<Long>();
            for (String id : _ids) {
                ids.add(Long.parseLong(id));
            }
            List<GroupUser> list = new ArrayList<GroupUser>();
            User u = GeneralUserForm.this.getModelObject();
            for (Group g : getBean(GroupDao.class).get(ids)) {
                GroupUser gu = new GroupUser(g, u);
                int idx = grpUsers.indexOf(gu);
                list.add(idx < 0 ? gu : grpUsers.get(idx));
            }
            return list;
        }
    }).setEnabled(isAdminForm));
}

From source file:org.apache.openmeetings.web.common.GroupChoiceProvider.java

License:Apache License

@Override
public void query(String term, int page, Response<Group> response) {
    if (WebSession.getRights().contains(User.Right.Admin)) {
        List<Group> groups = groupDao.get(0, Integer.MAX_VALUE);
        for (Group g : groups) {
            if (Strings.isEmpty(term)
                    || g.getName().toLowerCase(Locale.ROOT).contains(term.toLowerCase(Locale.ROOT))) {
                response.add(g);/* www . ja  v a 2 s.c o  m*/
            }
        }
    } else {
        User u = userDao.get(getUserId());
        for (GroupUser ou : u.getGroupUsers()) {
            if (Strings.isEmpty(term) || ou.getGroup().getName().toLowerCase(Locale.ROOT)
                    .contains(term.toLowerCase(Locale.ROOT))) {
                response.add(ou.getGroup());
            }
        }
    }
}

From source file:org.apache.openmeetings.web.common.HeaderPanel.java

License:Apache License

public HeaderPanel(String id, String appName) {
    super(id);//  w w  w.  j  a  v  a  2  s.co  m
    setOutputMarkupPlaceholderTag(true);
    add(new Label("appName", Strings.isEmpty(appName) ? "&nbsp;" : appName).setEscapeModelStrings(false));
}