org.apache.wicket.util.string.Strings Java Examples
The following examples show how to use
org.apache.wicket.util.string.Strings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Client.java From openmeetings with Apache License 2.0 | 6 votes |
private JSONObject addUserJson(JSONObject o) { JSONObject u = new JSONObject(); if (user != null) { JSONObject a = new JSONObject(); u.put("id", user.getId()) .put("firstName", user.getFirstname()) .put("lastName", user.getLastname()) .put("displayName", user.getDisplayName()) .put("address", a) .put("pictureUri", pictureUri); if (user.getAddress() != null) { if (Strings.isEmpty(user.getFirstname()) && Strings.isEmpty(user.getLastname())) { a.put("email", user.getAddress().getEmail()); } a.put("country", user.getAddress().getCountry()); } } return o.put("user", u) .put("level", hasRight(Right.MODERATOR) ? 5 : (hasRight(Right.WHITEBOARD) ? 3 : 1)); }
Example #2
Source File: FormComponent.java From onedev with MIT License | 6 votes |
/** * Gets current value for a form component, which can be either input data entered by the user, * or the component's model object if no input was provided. * * @return The value */ public final String getValue() { if (NO_RAW_INPUT.equals(rawInput)) { return getModelValue(); } else { if (getEscapeModelStrings() && rawInput != null) { return Strings.escapeMarkup(rawInput).toString(); } return rawInput; } }
Example #3
Source File: RedirectMessageDialog.java From openmeetings with Apache License 2.0 | 6 votes |
private void startTimer(IPartialPageRequestHandler handler) { getLabel().add(new OmTimerBehavior(DELAY, labelId) { private static final long serialVersionUID = 1L; @Override protected void onFinish(AjaxRequestTarget target) { if (Strings.isEmpty(url)) { throw new RestartResponseException(Application.get().getHomePage()); } else { throw new RedirectToUrlException(url); } } }).setOutputMarkupId(true); if (handler != null) { handler.add(getLabel()); } }
Example #4
Source File: ThreadHelper.java From openmeetings with Apache License 2.0 | 6 votes |
public static void startRunnable(Runnable r, String name) { final Application app = Application.get(); final WebSession session = WebSession.get(); final RequestCycle rc = RequestCycle.get(); Thread t = new Thread(() -> { ThreadContext.setApplication(app); ThreadContext.setSession(session); ThreadContext.setRequestCycle(rc); r.run(); ThreadContext.detach(); }); if (!Strings.isEmpty(name)) { t.setName(name); } t.start(); }
Example #5
Source File: BasePage.java From Orienteer with Apache License 2.0 | 6 votes |
public BasePage(PageParameters parameters) { super(parameters); if(parameters!=null && !parameters.isEmpty()) { IModel<T> model = resolveByPageParameters(parameters); if(model!=null) setModel(model); String perspective = parameters.get("_perspective").toOptionalString(); if(!Strings.isEmpty(perspective)) { perspectivesModule.getPerspectiveByAliasAsDocument(getDatabase(), perspective) .ifPresent(perspectiveDoc -> OrienteerWebSession.get().setPerspecive(perspectiveDoc)); } } initialize(); }
Example #6
Source File: OClassIntrospector.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public OQueryDataProvider<ODocument> getDataProviderForGenericSearch(OClass oClass, IModel<String> queryModel) { String searchSql = CustomAttribute.SEARCH_QUERY.getValue(oClass); String sql=null; if(!Strings.isEmpty(searchSql)) { String upper = searchSql.toUpperCase().trim(); if(upper.startsWith("SELECT")) sql = searchSql; else if(upper.startsWith("WHERE")) sql = "select from "+oClass.getName()+" "+searchSql; else { LOG.error("Unrecognized search sql: "+searchSql); } } if(sql==null) sql = "select from "+oClass.getName()+" where any() containstext :query"; return new OQueryDataProvider<ODocument>(sql).setParameter("query", queryModel); }
Example #7
Source File: JobEntityHandler.java From Orienteer with Apache License 2.0 | 6 votes |
@Statement public List<JobEntity> selectJobsByConfiguration(OPersistenceSession session, ListQueryParameterObject query) { Map<String, Object> params = (Map<String, Object>) query.getParameter(); String config = (String) params.get("handlerConfiguration"); String followUpConfig = (String) params.get("handlerConfigurationWithFollowUpJobCreatedProperty"); String type = (String) params.get("handlerType"); List<String> args = new ArrayList<>(); Query q = new Query().from(getSchemaClass()); q.where(Clause.clause("jobHandlerType", Operator.EQ, Parameter.PARAMETER)); args.add(type); Clause eqConfig = Clause.clause("JobHandlerConfigurationRaw", Operator.EQ, Parameter.PARAMETER); if(Strings.isEmpty(followUpConfig)) { q.where(eqConfig); args.add(config); } else { q.where(Clause.or(eqConfig, eqConfig)); args.add(config); args.add(followUpConfig); } return queryList(session, q.toString(), args.toArray()); }
Example #8
Source File: UrlImporter.java From webanno with Apache License 2.0 | 6 votes |
private Optional<Import> resolvePackageDependency(String url) { if (Strings.isEmpty(scopeClass)) { throw new IllegalStateException( "Cannot resolve dependency '" + url + "' without a scope class!"); } LOG.debug("Going to resolve an import from the package: {}", url); String resourceName = url.startsWith(PACKAGE_SCHEME) ? url.substring(PACKAGE_SCHEME.length()) : url; if (resourceName.indexOf(0) == '/') { resourceName = resourceName.substring(1); } Class<?> scope = WicketObjects.resolveClass(scopeClass); URL importUrl = scope.getResource(resourceName); return Optional.ofNullable(importUrl).map(this::buildImport); }
Example #9
Source File: ChatForm.java From openmeetings with Apache License 2.0 | 6 votes |
boolean process(BooleanSupplier processAll, Predicate<Room> processRoom, Predicate<User> processUser) { try { 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; }
Example #10
Source File: OrienteerLocalizationModule.java From Orienteer with Apache License 2.0 | 6 votes |
public String loadStringResource(final String key, Locale locale, final String style, final String variation) { if(Strings.isEmpty(key)) { System.out.println("Empty!"); } final String language = locale!=null?locale.getLanguage():null; return new DBClosure<String>() { @Override protected String execute(ODatabaseDocument db) { String ret = sudoLoadStringResource(db, true, key, language, style, variation); return ret!=null || DEFAULT_LANGUAGE.equals(language) ? ret : sudoLoadStringResource(db, false, key, DEFAULT_LANGUAGE, style, variation); } }.execute(); }
Example #11
Source File: UserDTO.java From openmeetings with Apache License 2.0 | 6 votes |
public User get(UserDao userDao, GroupDao groupDao) { User u = id == null ? new User() : userDao.get(id); u.setLogin(login); u.setFirstname(firstname); u.setLastname(lastname); u.setRights(rights); u.setLanguageId(languageId); u.setAddress(address); u.setTimeZoneId(timeZoneId); if (Type.EXTERNAL == type || (!Strings.isEmpty(externalId) && !Strings.isEmpty(externalType))) { type = Type.EXTERNAL; if (u.getGroupUsers().stream().filter(gu -> gu.getGroup().isExternal() && gu.getGroup().getName().equals(externalType)).count() == 0) { u.addGroup(groupDao.getExternal(externalType)); } u.setExternalId(externalId); } u.setType(type); u.setPictureUri(pictureUri); return u; }
Example #12
Source File: AbstractNamingModel.java From wicket-orientdb with Apache License 2.0 | 6 votes |
/** * Returns name * @param component component to look associated localization * @return name */ public String getObject(Component component) { if(objectModel!=null) { T object = objectModel.getObject(); if(object==null) return null; resourceKey = getResourceKey(object); } String defaultValue = getDefault(); if(defaultValue==null) defaultValue = Strings.lastPathComponent(resourceKey, '.'); if(defaultValue!=null) defaultValue = buitify(defaultValue); return Application.get() .getResourceSettings() .getLocalizer() .getString(resourceKey, null, defaultValue); }
Example #13
Source File: ReminderJob.java From openmeetings with Apache License 2.0 | 6 votes |
public void loadRss() { log.trace("ReminderJob.loadRss"); if (!isInitComplete()) { return; } if (!cfgDao.getBool(CONFIG_DASHBOARD_SHOW_RSS, false)) { log.debug("Rss disabled by Admin"); return; } JSONArray feed = new JSONArray(); for (String url : new String[] {cfgDao.getString(CONFIG_DASHBOARD_RSS_FEED1, ""), cfgDao.getString(CONFIG_DASHBOARD_RSS_FEED2, "")}) { if (!Strings.isEmpty(url)) { AtomReader.load(url, feed); } } if (feed.length() > 0) { setRss(feed); } }
Example #14
Source File: ClientIpResolver.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
public static String getClientIp(final ServletRequest request) { String remoteAddr = null; if (request instanceof HttpServletRequest) { remoteAddr = ((HttpServletRequest) request).getHeader("X-Forwarded-For"); } if (remoteAddr != null) { if (remoteAddr.contains(",")) { // sometimes the header is of form client ip,proxy 1 ip,proxy 2 ip,...,proxy n ip, // we just want the client remoteAddr = Strings.split(remoteAddr, ',')[0].trim(); } try { // If ip4/6 address string handed over, simply does pattern validation. InetAddress.getByName(remoteAddr); } catch (final UnknownHostException e) { remoteAddr = request.getRemoteAddr(); } } else { remoteAddr = request.getRemoteAddr(); } return remoteAddr; }
Example #15
Source File: StrongPasswordValidator.java From openmeetings with Apache License 2.0 | 6 votes |
private void error(IValidatable<String> pass, String key, Map<String, Object> params) { if (web) { ValidationError err = new ValidationError().addKey(key); if (params != null) { err.setVariables(params); } pass.error(err); } else { String msg = LabelDao.getString(key, 1L); if (params != null && !params.isEmpty() && !Strings.isEmpty(msg)) { for (Map.Entry<String, Object> e : params.entrySet()) { msg = msg.replace(String.format("${%s}", e.getKey()), "" + e.getValue()); } } log.warn(msg); pass.error(new ValidationError(msg)); } }
Example #16
Source File: GroupChoiceProvider.java From openmeetings with Apache License 2.0 | 6 votes |
@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); } } } 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()); } } } }
Example #17
Source File: StrongPasswordValidator.java From openmeetings with Apache License 2.0 | 6 votes |
private boolean hasStopWords(String password) { if (checkWord(password, u.getLogin())) { return true; } if (u.getAddress() != null) { String email = u.getAddress().getEmail(); if (!Strings.isEmpty(email)) { for (String part : email.split("[.@]")) { if (checkWord(password, part)) { return true; } } } } return false; }
Example #18
Source File: AddTabCommand.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected void initializeContent(final ModalWindow modal) { modal.setTitle(new ResourceModel("command.add.tab")); modal.setContent(new AddTabDialog<T>(modal.getContentId()) { private static final long serialVersionUID = 1L; @Override protected void onCreateTab(String name, Optional<AjaxRequestTarget> targetOptional) { targetOptional.ifPresent(modal::close); if(Strings.isEmpty(name)) { name = getLocalizer().getString("command.add.tab.modal.defaultname", null); } AbstractWidgetPage<T> page = (AbstractWidgetPage<T>)findPage(); page.getCurrentDashboard().setModeObject(DisplayMode.VIEW); //Close action on current tab page.addTab(name); page.selectTab(name, targetOptional); send(page, Broadcast.DEPTH, new SwitchDashboardTabEvent(targetOptional)); page.getCurrentDashboard().setModeObject(DisplayMode.EDIT); //Open action on new tab targetOptional.ifPresent(target -> target.add(page.getCurrentDashboardComponent())); } }); modal.setAutoSize(true); modal.setMinimalWidth(300); }
Example #19
Source File: BinaryViewPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public BinaryViewPanel(String id, final IModel<ODocument> docModel, final IModel<OProperty> propModel, IModel<V> valueModel) { super(id, valueModel); nameModel = new LoadableDetachableModel<String>() { @Override protected String load() { String filename = docModel.getObject().field(propModel.getObject().getName()+BinaryEditPanel.FILENAME_SUFFIX, String.class); if(Strings.isEmpty(filename)){ filename = oClassIntrospector.getDocumentName(docModel.getObject()); filename += "."+propModel.getObject().getName()+".bin"; } return filename; } @Override public void detach() { super.detach(); docModel.detach(); propModel.detach(); } }; initialize(); }
Example #20
Source File: OLoggerModule.java From Orienteer with Apache License 2.0 | 6 votes |
private void installOLogger(OrienteerWebApplication app, Module module) { IOLoggerConfiguration config = new DefaultOLoggerConfiguration(); config.setApplicationName(app.getResourceSettings().getLocalizer().getString("application.name", null)); //If collector URL was not overwriten from system properties: lets get it from module if (Strings.isEmpty(config.getCollectorUrl())) { config.setCollectorUrl(module.getCollectorUrl()); } if (module.getCorrelationIdGenerator() != null) { config.setCorrelationIdGenerator(module.getCorrelationIdGenerator().createCorrelationIdGenerator()); } OLoggerBuilder builder = new OLoggerBuilder(); builder.setLoggerEventDispatcher(module.getLoggerEventDispatcher().createDispatcherClassInstance()); module.getLoggerEnhancersInstances().forEach(builder::addEnhancer); builder.addDefaultEnhancers(); OLogger.set(builder.create(config)); }
Example #21
Source File: PFAutoCompleteBehavior.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * Render autocomplete init javascript and other head contributions * * @param response */ private void renderAutocompleteHead(final IHeaderResponse response) { final String id = getComponent().getMarkupId(); String indicatorId = findIndicatorId(); if (Strings.isEmpty(indicatorId)) { indicatorId = "null"; } else { indicatorId = "'" + indicatorId + "'"; } final StringBuffer buf = new StringBuffer(); buf.append("var favorite" + id + " = "); final List<T> favorites = getFavorites(); final MyJsonBuilder builder = new MyJsonBuilder(); if (favorites != null) { buf.append(builder.append(favorites).getAsString()); } else { buf.append(builder.append(getRecentUserInputs()).getAsString()); } buf.append(";").append("var z = $(\"#").append(id).append("\");\n").append("z.autocomplete(\"").append(getCallbackUrl()).append("\",{"); boolean first = true; for (final String setting : getSettingsJS()) { if (first == true) first = false; else buf.append(", "); buf.append(setting); } if (first == true) first = false; else buf.append(", "); buf.append("favoriteEntries:favorite" + id); buf.append("});"); if (settings.isHasFocus() == true) { buf.append("\nz.focus();"); } final String initJS = buf.toString(); // String initJS = String.format("new Wicket.AutoComplete('%s','%s',%s,%s);", id, getCallbackUrl(), constructSettingsJS(), indicatorId); response.render(OnDomReadyHeaderItem.forScript(initJS)); }
Example #22
Source File: RecordingStatusAdapter.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public Recording.Status unmarshal(String v) throws Exception { if ("PROCESSING".equalsIgnoreCase(v)) { return Recording.Status.CONVERTING; } Recording.Status result = Status.NONE; if (!Strings.isEmpty(v)) { try { result = Recording.Status.valueOf(v); } catch (Exception e) { //no-op } } return result; }
Example #23
Source File: AjaxTextFieldITCase.java From syncope with Apache License 2.0 | 5 votes |
@Test public void valueAttribute() { TestPage<String, AjaxTextFieldPanel> testPage = new TestPage.Builder<String, AjaxTextFieldPanel>().build( new AjaxTextFieldPanel(TestPage.FIELD, TestPage.FIELD, TEXT_MODEL)); String text = "sometext"; TEXT_MODEL.setObject(text); TESTER.startPage(testPage); assertTrue(TESTER.getLastResponseAsString().contains(Strings.escapeMarkup(text))); }
Example #24
Source File: StartupPropertiesLoader.java From Orienteer with Apache License 2.0 | 5 votes |
public static String getRuntime() { String runtime = System.getenv(ENV_ORIENTEER_RUNTIME); if(Strings.isEmpty(runtime)) { String appHome = getAppHome(); return appHome.equals("./")? appHome : appHome +"runtime/"; } else return runtime.endsWith("/") ? runtime : runtime+"/"; }
Example #25
Source File: RoomMenuPanel.java From openmeetings with Apache License 2.0 | 5 votes |
public void update(IPartialPageRequestHandler handler) { if (!isVisible()) { return; } Room r = room.getRoom(); boolean isInterview = Room.Type.INTERVIEW == r.getType(); User u = room.getClient().getUser(); boolean notExternalUser = u.getType() != User.Type.CONTACT; exitMenuItem.setVisible(notExternalUser); filesMenu.setVisible(!isInterview && room.getSidebar().isShowFiles()); boolean moder = room.getClient().hasRight(Room.Right.MODERATOR); actionsSubMenu.update(moder, notExternalUser); pollsSubMenu.update(moder, notExternalUser, r); menuPanel.update(handler); StringBuilder roomClass = new StringBuilder("room name"); String roomTitle = ""; if (streamProcessor.isRecording(r.getId())) { JSONObject ru = kHandler.getRecordingUser(r.getId()); if (!Strings.isEmpty(ru.optString("login"))) { roomTitle += getString("419") + " " + ru.getString("login"); if (!Strings.isEmpty(ru.optString("firstName"))) { roomTitle += " " + ru.getString("firstName"); } if (!Strings.isEmpty(ru.optString("lastName"))) { roomTitle += " " + ru.getString("lastName"); } roomTitle += " " + df.format(new Date(ru.getLong("started"))); roomClass.append(" screen"); } } handler.add(roomName.add(AttributeModifier.replace(ATTR_CLASS, roomClass), AttributeModifier.replace(ATTR_TITLE, roomTitle))); handler.add(askBtn.setVisible(!moder && r.isAllowUserQuestions())); handler.add(shareBtn.setVisible(room.screenShareAllowed())); handler.appendJavaScript("$('#share-dlg-btn').off().click(Sharer.open);"); }
Example #26
Source File: PasswordsPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public void convertInput() { if(Strings.isEmpty(password.getConvertedInput())){ setConvertedInput(""); //strange,but validator think - "wow, this is not empty value" }else{ setConvertedInput(password.getConvertedInput()); } }
Example #27
Source File: CommandWrapperMethod.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public Command<?> createCommand(String id) { if (displayComponent==null){ displayComponent = getWrappedCommand(id); applySettings(displayComponent); if (!Strings.isEmpty(getDefinition().getTitleKey())){ displayComponent.setLabelModel(getTitleModel()); } } return displayComponent; }
Example #28
Source File: AbstractHtmlJsPaneWidget.java From Orienteer with Apache License 2.0 | 5 votes |
public String getHtml() { String html = getWidgetDocument().field("html"); if(!Strings.isEmpty(html)) { html = interpolateHtml(html); } return html; }
Example #29
Source File: EnablingCheckBox.java From sakai with Educational Community License v2.0 | 5 votes |
public boolean isChecked() { final String value = getValue(); if (value != null) { try { return Strings.isTrue(value); } catch (StringValueConversionException e) { return false; } } return false; }
Example #30
Source File: IcalUtils.java From openmeetings with Apache License 2.0 | 5 votes |
/** * Convenience function to parse date from {@link net.fortuna.ical4j.model.Property} to * {@link Date} * * @param dt DATE-TIME Property from which we parse. * @param timeZone Timezone of the Date. * @return {@link java.util.Date} representation of the iCalendar value. */ public Date parseDate(Property dt, TimeZone timeZone) { if (dt == null || Strings.isEmpty(dt.getValue())) { return null; } String[] acceptedFormats = {"yyyyMMdd'T'HHmmss", "yyyyMMdd'T'HHmmss'Z'", "yyyyMMdd"}; Parameter tzid = dt.getParameter(Parameter.TZID); if (tzid == null) { return parseDate(dt.getValue(), acceptedFormats, timeZone); } else { return parseDate(dt.getValue(), acceptedFormats, getTimeZone(tzid.getValue())); } }