List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:org.apache.openmeetings.db.entity.user.User.java
License:Apache License
private String generateDisplayName() { StringBuilder sb = new StringBuilder(); String delim = ""; OmLanguage l = LabelDao.getLanguage(languageId); String first = l.isRtl() ? getLastname() : getFirstname(); String last = l.isRtl() ? getFirstname() : getLastname(); if (!Strings.isEmpty(first)) { sb.append(first);/*from w w w .jav a 2 s. co m*/ delim = " "; } if (!Strings.isEmpty(last)) { sb.append(delim).append(last); } if (Strings.isEmpty(sb) && address != null && !Strings.isEmpty(address.getEmail())) { sb.append(delim).append(address.getEmail()); } if (Strings.isEmpty(sb)) { sb.append("N/A"); } return escapeMarkup(sb).toString(); }
From source file:org.apache.openmeetings.db.util.DaoHelper.java
License:Apache License
public static String getSearchQuery(String table, String alias, String join, String search, boolean distinct, boolean filterDeleted, boolean count, String additionalWhere, String sort, String... fields) { StringBuilder sb = new StringBuilder("SELECT "); if (count) {/*from w w w. j ava2 s .co m*/ sb.append("COUNT("); } if (distinct) { sb.append("DISTINCT "); } sb.append(alias); if (count) { sb.append(")"); } sb.append(" FROM ").append(table).append(" ").append(alias); if (!Strings.isEmpty(join)) { sb.append(" ").append(join); } sb.append(" WHERE 1 = 1 "); if (filterDeleted) { sb.append("AND ").append(alias).append(".deleted = false "); } appendWhereClause(sb, search, alias, fields); if (!Strings.isEmpty(additionalWhere)) { sb.append("AND ").append(additionalWhere); } return appendSort(sb, alias, sort).toString(); }
From source file:org.apache.openmeetings.db.util.DaoHelper.java
License:Apache License
public static StringBuilder appendWhereClause(StringBuilder _sb, String search, String alias, String... fields) {//from w w w .j a v a2 s . co m if (!Strings.isEmpty(search) && fields != null) { boolean notEmpty = false; StringBuilder sb = new StringBuilder(); String[] searchItems = search.replace("\'", "").replace("\"", "").split(" "); for (int i = 0; i < searchItems.length; ++i) { if (searchItems[i].isEmpty()) { continue; } if (i == 0) { notEmpty = true; sb.append(" ("); } else { sb.append(" OR "); } StringBuilder placeholder = new StringBuilder(); placeholder.append("%").append(StringUtils.lowerCase(searchItems[i])).append("%"); sb.append("("); for (int j = 0; j < fields.length; ++j) { if (j != 0) { sb.append(" OR "); } sb.append("lower(").append(alias).append(".").append(fields[j]).append(") LIKE '") .append(placeholder).append("' "); } sb.append(")"); } if (notEmpty) { sb.append(") "); _sb.append(" AND").append(sb); } } return _sb; }
From source file:org.apache.openmeetings.db.util.DaoHelper.java
License:Apache License
public static StringBuilder appendSort(StringBuilder sb, String alias, String sort) { if (!Strings.isEmpty(sort)) { sb.append(" ORDER BY ").append(alias).append(".").append(sort); }// w w w . ja v a 2 s . c om return sb; }
From source file:org.apache.openmeetings.db.util.FormatHelper.java
License:Apache License
public static String formatUser(User u, boolean isHTMLEscape) { String user = ""; if (u != null) { String email = u.getAddress() == null ? "" : u.getAddress().getEmail(); if (Strings.isEmpty(u.getFirstname()) && Strings.isEmpty(u.getLastname())) { user = email;/*from w w w .ja va 2s.c o m*/ } else { user = String.format("\"%s %s\" <%s>", u.getFirstname(), u.getLastname(), email); } user = isHTMLEscape ? escapeHtml4(user) : user; } return user; }
From source file:org.apache.openmeetings.db.util.TimezoneUtil.java
License:Apache License
/** * * @param timeZoneId// w ww . j a v a2s . c o m * the ID for a TimeZone, either an abbreviation such as "PST", a * full name such as "America/Los_Angeles", or a custom ID such as * "GMT-8:00". Note that the support of abbreviations is for JDK * 1.1.x compatibility only and full names should be used. * @return the specified TimeZone, or the GMT zone if the given ID cannot be * understood. */ public static TimeZone getTimeZone(String timeZoneId) { return TimeZone.getTimeZone(Strings.isEmpty(timeZoneId) ? getDefaultTimezone() : timeZoneId); }
From source file:org.apache.openmeetings.remote.MainService.java
License:Apache License
/** * Attention! This SID is NOT the default session id! its the Session id * retrieved in the call from the SOAP Gateway! * /*from w ww . java 2 s . co m*/ * @param SID * @return - 1 in case of success, -1 otherwise */ public Long loginUserByRemote(String SID) { try { Long users_id = sessiondataDao.checkSession(SID); Long user_level = userManager.getUserLevelByID(users_id); if (AuthLevelUtil.checkWebServiceLevel(user_level)) { Sessiondata sd = sessiondataDao.getSessionByHash(SID); if (sd == null || sd.getSessionXml() == null) { return new Long(-37); } else { RemoteSessionObject userObject = RemoteSessionObject.fromXml(sd.getSessionXml()); log.debug(userObject.toString()); IConnection current = Red5.getConnectionLocal(); String streamId = current.getClient().getId(); Client currentClient = sessionManager.getClientByStreamId(streamId, null); // Check if this User is simulated in the OpenMeetings // Database if (!Strings.isEmpty(userObject.getExternalUserId())) { // If so we need to check that we create this user in // OpenMeetings and update its record User user = userManager.getUserByExternalIdAndType(userObject.getExternalUserId(), userObject.getExternalUserType()); if (user == null) { String iCalTz = configurationDao.getConfValue("default.timezone", String.class, ""); long userId = userManager.addUserWithExternalKey(1, 0, 0, userObject.getFirstname(), userObject.getUsername(), userObject.getLastname(), 1L, true, "", // password is empty by default null, null, "", userObject.getExternalUserId(), userObject.getExternalUserType(), true, userObject.getEmail(), iCalTz, userObject.getPictureUrl()); currentClient.setUser_id(userId); SessionVariablesUtil.setUserId(current.getClient(), userId); } else { user.setPictureuri(userObject.getPictureUrl()); userManager.updateUser(user); currentClient.setUser_id(user.getUser_id()); SessionVariablesUtil.setUserId(current.getClient(), user.getUser_id()); } } log.debug("userObject.getExternalUserId() -2- " + currentClient.getUser_id()); currentClient.setUserObject(userObject.getUsername(), userObject.getFirstname(), userObject.getLastname()); currentClient.setPicture_uri(userObject.getPictureUrl()); currentClient.setMail(userObject.getEmail()); log.debug("UPDATE USER BY STREAMID " + streamId); if (currentClient.getUser_id() != null) { sessiondataDao.updateUser(SID, currentClient.getUser_id()); } sessionManager.updateClientByStreamId(streamId, currentClient, false, null); return new Long(1); } } } catch (Exception err) { log.error("[loginUserByRemote] ", err); } return new Long(-1); }
From source file:org.apache.openmeetings.service.calendar.AppointmentLogic.java
License:Apache License
public Appointment getAppointment(String appointmentName, String appointmentLocation, String appointmentDescription, Calendar appointmentstart, Calendar appointmentend, Boolean isDaily, Boolean isWeekly, Boolean isMonthly, Boolean isYearly, String remind, String[] mmClient, Long roomType, Long languageId, boolean isPasswordProtected, String password, long roomId, Long userId) { Appointment a = new Appointment(); a.setTitle(appointmentName);// w ww . j av a 2 s . co m a.setLocation(appointmentLocation); a.setDescription(appointmentDescription); a.setStart(appointmentstart.getTime()); a.setEnd(appointmentend.getTime()); a.setIsDaily(isDaily); a.setIsWeekly(isWeekly); a.setIsMonthly(isMonthly); a.setIsYearly(isYearly); a.setReminder(Reminder.valueOf(remind)); if (roomId > 0) { a.setRoom(roomDao.get(roomId)); } else { a.setRoom(new Room()); a.getRoom().setComment(appointmentDescription); a.getRoom().setName(appointmentName); a.getRoom().setType(Room.Type.get(roomType)); a.getRoom().setAppointment(true); } a.setOwner(userDao.get(userId)); a.setPasswordProtected(isPasswordProtected); a.setPassword(password); a.setMeetingMembers(new ArrayList<MeetingMember>()); for (String singleClient : mmClient) { if (Strings.isEmpty(singleClient)) { continue; } MeetingMember mm = getMeetingMember(userId, languageId, singleClient); mm.setAppointment(a); a.getMeetingMembers().add(mm); } return a; }
From source file:org.apache.openmeetings.service.calendar.caldav.AppointmentManager.java
License:Apache License
/** * Adds the Credentials provided to the given client on the Calendar's URL. * * @param context Context of the Client which makes the connection. * @param calendar Calendar whose Host the Credentials are for. * @param credentials Credentials to add *///www. j a v a 2 s . c o m public void provideCredentials(HttpClientContext context, OmCalendar calendar, Credentials credentials) { // Done through creating a new Local context if (!Strings.isEmpty(calendar.getHref()) && credentials != null) { URI temp = URI.create(calendar.getHref()); context.getCredentialsProvider().setCredentials(new AuthScope(temp.getHost(), temp.getPort()), credentials); } }
From source file:org.apache.openmeetings.service.calendar.caldav.handler.EtagsHandler.java
License:Apache License
/** * {@inheritDoc}/*from www . jav a 2 s.c om*/ */ @Override public boolean updateItem(Appointment appointment) { OmCalendar calendar = appointment.getCalendar(); String href; if (calendar != null && calendar.getSyncType() != SyncType.NONE) { //Store new Appointment on the server HttpPutMethod putMethod = null; try { List<String> hrefs = null; CalendarOutputter calendarOutputter = new CalendarOutputter(); String temp = null; Calendar ical = utils.parseAppointmenttoCalendar(appointment); CalendarRequest cr = new CalendarRequest(ical); if (Strings.isEmpty(appointment.getHref())) { temp = this.path + appointment.getIcalId() + ".ics"; temp = UrlUtils.removeDoubleSlashes(temp); cr.setIfNoneMatch(true); cr.setAllEtags(true); } else { temp = getFullPath(URI.create(this.path), appointment.getHref()); cr.setIfMatch(true); cr.addEtag(appointment.getEtag()); } putMethod = new HttpPutMethod(temp, cr, calendarOutputter); HttpResponse httpResponse = client.execute(putMethod, context); if (putMethod.succeeded(httpResponse)) { href = putMethod.getURI().getPath(); // Set the href as the path appointment.setHref(href); //Check if the ETag header was returned. Header etagh = putMethod.getFirstHeader("ETag"); if (etagh == null) hrefs = Collections.singletonList(appointment.getHref()); else { appointment.setEtag(etagh.getValue()); appointmentDao.update(appointment, appointment.getOwner().getId()); } } else { //Appointment not created on the server return false; } //Get new etags for the ones which didn't return an ETag header MultigetHandler multigetHandler = new MultigetHandler(hrefs, true, path, calendar, client, context, appointmentDao, utils); multigetHandler.syncItems(); return true; } catch (IOException e) { log.error("Error executing OptionsMethod during testConnection.", e); } catch (Exception e) { log.error("Severe Error in executing OptionsMethod during testConnection.", e); } finally { releaseConnection(putMethod); } } return false; }