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.room.RoomResourceReference.java

License:Apache License

@Override
protected FileItem getFileItem(Attributes attr) {
    PageParameters params = attr.getParameters();
    StringValue _id = params.get("id");
    String uid = params.get("uid").toString();
    Long id = null;/* w w w .ja  va  2  s  .  c o  m*/
    try {
        id = _id.toOptionalLong();
    } catch (NumberFormatException e) {
        //no-op expected
    }
    WebSession ws = WebSession.get();
    Client c = cm.get(uid);
    if (id == null || !ws.isSignedIn() || c == null) {
        return null;
    }
    FileItem f = (FileItem) fileDao.getAny(id);
    if (f == null) {
        return null;
    }
    String ruid = params.get("ruid").toString();
    String wuid = params.get("wuid").toString();
    if (c.getRoom() != null) {
        Whiteboards wbs = wbManager.get(c.getRoom().getId());
        if (!Strings.isEmpty(wuid) && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
            for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
                JSONObject file = e.getValue().get(wuid);
                if (file != null && f.getId().equals(file.optLong(ATTR_FILE_ID))) {
                    return f; // item IS on WB
                }
            }
        }
    }
    if (f.getGroupId() != null && groupUserDao.isUserInGroup(f.getGroupId(), getUserId())) {
        return f;
    }
    return null;
}

From source file:org.apache.openmeetings.web.room.sidebar.UploadDialog.java

License:Apache License

public UploadDialog(String id, RoomPanel room, RoomFilePanel roomFiles) {
    super(id, "");
    this.roomFiles = roomFiles;
    this.room = room;
    add(form = new Form<>("form"));
    toWb.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override/*from   w ww. ja va2 s.c o  m*/
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(cleanBlock.setVisible(toWb.getModelObject()));
        }
    });
    form.add(feedback.setOutputMarkupId(true), toWb.setOutputMarkupId(true), cleanBlock
            .add(cleanWb.setOutputMarkupId(true)).setVisible(false).setOutputMarkupPlaceholderTag(true))
            .setOutputMarkupId(true);

    form.setMultiPart(true);
    form.setMaxSize(Bytes.bytes(getMaxUploadSize()));
    // Model is necessary here to avoid writing image to the User object
    form.add(uploadField = new FileUploadField("file", new IModel<List<FileUpload>>() {
        private static final long serialVersionUID = 1L;

        @Override
        public void setObject(List<FileUpload> object) {
            //no-op
        }

        @Override
        public List<FileUpload> getObject() {
            return new ArrayList<>();
        }
    }));
    Form<String> nameForm = new Form<>("name-form");
    fileName = new HiddenField<>("name", Model.of(""));
    fileName.add(new AjaxFormSubmitBehavior(nameForm, "change") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            if (!Strings.isEmpty(getComponent().getDefaultModelObjectAsString())) {
                upload.setEnabled(true, target);
            }
        }
    }).setOutputMarkupId(true);
    form.add(new UploadProgressBar("progress", form, uploadField));
    add(nameForm.add(fileName.setOutputMarkupId(true)));
    add(BootstrapFileUploadBehavior.INSTANCE);
}

From source file:org.apache.openmeetings.web.room.StartSharingEventBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    //TODO deny download in case other screen sharing is in progress
    String app = "";
    try (InputStream jnlp = getClass().getClassLoader().getResourceAsStream("APPLICATION.jnlp")) {
        ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
        app = IOUtils.toString(jnlp, StandardCharsets.UTF_8);
        String baseUrl = cfgDao.getBaseUrl();
        Room room = getBean(RoomDao.class).get(roomId);
        String publicSid = getParam(getComponent(), PARAM_PUBLIC_SID).toString();
        SessionManager sessionManager = getBean(SessionManager.class);
        Client rc = getClient(publicSid);
        if (rc == null) {
            throw new RuntimeException(String.format("Unable to find client by publicSID '%s'", publicSid));
        }/*  ww w  . ja  v  a 2s  . co  m*/
        String _url = rc.getTcUrl();
        URI url = new URI(_url);
        String path = url.getPath();
        path = path.substring(path.lastIndexOf('/') + 1);
        if (Strings.isEmpty(path) || rc.getRoomId() == null || !path.equals(rc.getRoomId().toString())
                || !rc.getRoomId().equals(roomId)) {
            throw new RuntimeException(String.format("Invalid room id passed %s, expected, %s", path, roomId));
        }
        Protocol protocol = Protocol.valueOf(url.getScheme());
        app = addKeystore(rc, app, protocol).replace("$codebase", baseUrl + "screenshare")
                .replace("$applicationName", cfgDao.getAppName()).replace("$url", _url)
                .replace("$publicSid", publicSid)
                .replace("$labels",
                        CDATA_BEGIN + getLabels(730, 731, 732, 733, 734, 735, 737, 738, 739, 740, 741, 742, 844,
                                869, 870, 871, 872, 878, 1089, 1090, 1091, 1092, 1093, 1465, 1466, 1467, 1468,
                                1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1589, 1598, 1078)
                                + CDATA_END)
                .replace("$defaultQuality", cfgDao.getConfValue(CONFIG_SCREENSHARING_QUALITY, String.class, ""))
                .replace("$defaultFps", cfgDao.getConfValue(CONFIG_SCREENSHARING_FPS, String.class, ""))
                .replace("$showFps", cfgDao.getConfValue(CONFIG_SCREENSHARING_FPS_SHOW, String.class, "true"))
                .replace("$allowRemote",
                        cfgDao.getConfValue(CONFIG_SCREENSHARING_ALLOW_REMOTE, String.class, "true"))
                .replace("$allowRecording",
                        "" + (rc.getUserId() > 0 && room.isAllowRecording() && rc.isAllowRecording()
                                && (0 == sessionManager.getRecordingCount(roomId))))
                .replace("$allowPublishing", "" + (0 == sessionManager.getPublishingCount(roomId)));
    } catch (Exception e) {
        log.error("Unexpected error while creating jnlp file", e);
    }
    StringResourceStream srs = new StringResourceStream(app, "application/x-java-jnlp-file");
    srs.setCharset(StandardCharsets.UTF_8);
    download.setResourceStream(srs);
    download.initiate(target);
}

From source file:org.apache.openmeetings.web.room.SwfPanel.java

License:Apache License

public String getInitFunction(PageParameters pp) {
    String initStr = null;/*from   w  ww  .  ja  v a 2s . c  o  m*/
    StringValue type = pp.get(SWF);
    String swf = getFlashFile(type);
    if (!Strings.isEmpty(swf)) {
        String lbls = null;
        if (SWF_TYPE_NETWORK.equals(type.toString())) {
            lbls = getStringLabels("network.test.ms", "network.test.mb", "network.test.sec",
                    "network.test.click.play", "network.test.copy.log", "network.test.report",
                    "network.test.report.start", "network.test.report.error", "network.test.report.con.err",
                    "network.test.ping", "network.test.ping.avg", "network.test.ping.rcv",
                    "network.test.ping.lost", "network.test.ping.load", "network.test.port",
                    "network.test.port.avail", "network.test.port.stopped", "network.test.jitter",
                    "network.test.jitter.avg", "network.test.jitter.min", "network.test.jitter.max",
                    "network.test.dwn", "network.test.dwn.bytes", "network.test.dwn.time",
                    "network.test.dwn.speed", "network.test.upl", "network.test.upl.bytes",
                    "network.test.upl.time", "network.test.upl.speed");
        } else if (SWF_TYPE_SETTINGS.equals(type.toString())) {
            lbls = getStringLabels("448", "449", "450", "451", "758", "447", "52", "53", "1429", "1430", "775",
                    "452", "767", "764", "765", "918", "54", "761", "762", "144", "203", "642", "save.success");
        }
        initStr = String.format("var labels = %s; initSwf(%s);", lbls, new JSONObject()
                .put("src", swf + new PageParametersEncoder().encodePageParameters(pp)).toString());
    }
    return initStr;
}

From source file:org.apache.openmeetings.web.user.chat.ChatForm.java

License:Apache License

public ChatForm(String id) {
    super(id);//from  w  ww  .j  ava  2  s . com
    final ChatToolbar toolbar = new ChatToolbar("toolbarContainer", this);
    final WysiwygEditor chatMessage = new WysiwygEditor("chatMessage", Model.of(""), toolbar);
    add(toolbar, activeTab.add(new AjaxFormSubmitBehavior(this, "change") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            toolbar.update(target);
        }
    }), chatMessage.setOutputMarkupId(true), new AjaxButton("send") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new IAjaxCallListener() {
                @Override
                public CharSequence getPrecondition(Component component) {
                    return "return Chat.validate();";
                }
            });
        }

        private Chat getChat() {
            return findParent(Chat.class);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            final String txt = chatMessage.getDefaultModelObjectAsString();
            if (Strings.isEmpty(txt)) {
                return;
            }
            final ChatMessage m = new ChatMessage();
            m.setMessage(txt);
            m.setSent(new Date());
            m.setFromUser(userDao.get(getUserId()));
            m.setFromName(getClient().getUser().getDisplayName());
            if (!process(() -> getChat().isShowDashboardChat(), r -> {
                if (cm.isInRoom(r.getId(), getUserId())) {
                    m.setToRoom(r);
                } else {
                    log.error("It seems like we are being hacked!!!!");
                    return false;
                }
                m.setNeedModeration(
                        r.isChatModerated() && !isModerator(cm, m.getFromUser().getId(), r.getId()));
                return true;
            }, u -> {
                m.setToUser(u);
                return true;
            })) {
                return;
            }
            ;
            chatDao.update(m);
            JSONObject msg = getChat().getMessage(Arrays.asList(m));
            if (m.getToRoom() != null) {
                ChatWebSocketHelper.sendRoom(m, msg);
            } else if (m.getToUser() != null) {
                ChatWebSocketHelper.sendUser(getUserId(), m, msg);
                msg = Chat.getMessage(m.getToUser(), Arrays.asList(m));
                ChatWebSocketHelper.sendUser(m.getToUser().getId(), m, msg);
            } else {
                ChatWebSocketHelper.sendAll(m, msg);
            }
            chatMessage.setDefaultModelObject("");
            target.appendJavaScript("Chat.clean();");
        };
    });
}

From source file:org.apache.openmeetings.web.user.chat.ChatForm.java

License:Apache License

boolean process(BooleanSupplier processAll, Predicate<Room> processRoom, Predicate<User> processUser) {
    try {//  w w w.ja  va 2s.  c o m
        final String scope = getScope();
        if (Strings.isEmpty(scope) || ID_ALL.equals(scope)) {
            return processAll.getAsBoolean();
        } else if (scope.startsWith(ID_ROOM_PREFIX)) {
            Room r = roomDao.get(Long.parseLong(scope.substring(ID_ROOM_PREFIX.length())));
            if (r != null) {
                return processRoom.test(r);
            }
        } else if (scope.startsWith(ID_USER_PREFIX)) {
            User u = userDao.get(Long.parseLong(scope.substring(ID_USER_PREFIX.length())));
            if (u != null) {
                return processUser.test(u);
            }
        }
    } catch (Exception e) {
        //no-op
    }
    return false;
}

From source file:org.apache.openmeetings.web.user.profile.EditProfileForm.java

License:Apache License

@Override
protected void onValidate() {
    if (checkPassword) {
        String p = passwd.getConvertedInput();
        if (!Strings.isEmpty(p) && !userDao.verifyPassword(getModelObject().getId(), p)) {
            error(getString("231"));
            // add random timeout
            try {
                Thread.sleep(6 + (long) (10 * Math.random() * 1000));
            } catch (InterruptedException e) {
                log.error("Unexpected exception while sleeping", e);
            }//from   ww  w. ja v  a 2  s . c o m
        }
    }
    super.onValidate();
}

From source file:org.apache.openmeetings.web.util.ExtendedClientProperties.java

License:Apache License

public JSONObject getSettings() {
    try {/*www  .j a  v  a2  s  . c o m*/
        return Strings.isEmpty(settings) ? new JSONObject() : new JSONObject(settings);
    } catch (Exception e) {
        //can throw, no op
    }
    return new JSONObject();
}

From source file:org.apache.openmeetings.web.util.UserChoiceProvider.java

License:Apache License

public static User getUser(String value) {
    User u = null;/*from  ww  w  . j a v a  2  s  . c  o  m*/
    if (!Strings.isEmpty(value)) {
        //FIXME refactor this
        String email = null;
        String fName = null;
        String lName = null;
        int idx = value.indexOf('<');
        if (idx > -1) {
            int idx1 = value.indexOf('>', idx);
            if (idx1 > -1) {
                email = value.substring(idx + 1, idx1);

                String name = value.substring(0, idx).replace("\"", "");
                int idx2 = name.indexOf(' ');
                if (idx2 > -1) {
                    fName = name.substring(0, idx2);
                    lName = name.substring(idx2 + 1);
                } else {
                    fName = "";
                    lName = name;
                }

            }
        } else {
            email = value;
        }
        Validatable<String> valEmail = new Validatable<String>(email);
        RfcCompliantEmailAddressValidator.getInstance().validate(valEmail);
        if (valEmail.isValid()) {
            u = getBean(UserDao.class).getContact(email, fName, lName, getUserId());
        }
    }
    return u;
}

From source file:org.apache.openmeetings.webservice.RoomWebService.java

License:Apache License

/**
 * Returns an Object of Type RoomsList which contains a list of
 * Room-Objects. Every Room-Object contains a Roomtype and all informations
 * about that Room. The List of current-users in the room is Null if you get
 * them via SOAP. The Roomtype can be 'conference', 'presentation' or 'interview'.
 *
 * @param sid/*  ww  w .  ja  v  a 2  s  .  c om*/
 *            The SID of the User. This SID must be marked as Loggedin
 * @param type
 *            Type of public rooms need to be retrieved
 * @return - list of public rooms
 */
@WebMethod
@GET
@Path("/public/{type}")
public List<RoomDTO> getPublic(@QueryParam("sid") @WebParam(name = "sid") String sid,
        @PathParam("type") @WebParam(name = "type") String type) {
    Room.Type t = Strings.isEmpty(type) ? null : Room.Type.valueOf(type);
    return performCall(sid, User.Right.Room, sd -> RoomDTO.list(roomDao.getPublicRooms(t)));
}