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.core.converter.RecordingConverter.java
License:Apache License
@Override public void startConversion(Recording r) { if (r == null) { log.warn("Conversion is NOT started. Recording passed is NULL"); return;/* w w w .ja v a 2 s . c o m*/ } ProcessResultList logs = new ProcessResultList(); List<File> waveFiles = new ArrayList<>(); try { log.debug("recording {}", r.getId()); File streamFolder = getStreamFolder(r); RecordingChunk screenChunk = chunkDao.getScreenByRecording(r.getId()); if (screenChunk == null) { throw new ConversionException("screenMetaData is Null recordingId " + r.getId()); } if (screenChunk.getStreamStatus() == Status.NONE) { printChunkInfo(screenChunk, "StartConversion"); throw new ConversionException("Stream has not been started, error in recording"); } if (Strings.isEmpty(r.getHash())) { r.setHash(randomUUID().toString()); } r.setStatus(Recording.Status.CONVERTING); r = recordingDao.update(r); screenChunk = waitForTheStream(screenChunk.getId()); // Merge Wave to Full Length File wav = new File(streamFolder, screenChunk.getStreamName() + "_FINAL_WAVE.wav"); createWav(r, logs, streamFolder, waveFiles, wav, null); chunkDao.update(screenChunk); // Merge Audio with Video / Calculate resulting FLV String inputScreenFullFlv = getRecordingChunk(r.getRoomId(), screenChunk.getStreamName()) .getCanonicalPath(); // ffmpeg -vcodec flv -qscale 9.5 -r 25 -ar 22050 -ab 32k -s 320x240 // -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17_FINAL_WAVE.wav // -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17.flv // final1.flv int flvWidth = r.getWidth(); int flvHeight = r.getHeight(); log.debug("flvWidth -1- {}", flvWidth); log.debug("flvHeight -1- {}", flvHeight); flvWidth = (int) (16. * flvWidth / 16); flvHeight = (int) (16. * flvHeight / 16); log.debug("flvWidth -2- {}", flvWidth); log.debug("flvHeight -2- {}", flvHeight); r.setWidth(flvWidth); r.setHeight(flvHeight); String mp4path = convertToMp4(r, Arrays.asList("-itsoffset", formatMillis(diff(screenChunk.getStart(), r.getRecordStart())), "-i", inputScreenFullFlv, "-i", wav.getCanonicalPath()), logs); finalizeRec(r, mp4path, logs); } catch (Exception err) { log.error("[startConversion]", err); r.setStatus(Recording.Status.ERROR); } postProcess(r, logs); postProcess(waveFiles); recordingDao.update(r); }
From source file:org.apache.openmeetings.core.ldap.LdapLoginManagement.java
License:Apache License
private static void bindAdmin(LdapConnection conn, LdapOptions options) throws LdapException { if (!Strings.isEmpty(options.adminDn)) { conn.bind(options.adminDn, options.adminPasswd); } else {//ww w . j av a 2 s .c om conn.bind(); } }
From source file:org.apache.openmeetings.core.ldap.LdapLoginManagement.java
License:Apache License
private static Attribute getAttr(Properties config, Entry entry, String aliasCode, String defaultAlias) throws LdapInvalidAttributeValueException { String alias = config.getProperty(aliasCode, ""); Attribute a = entry.get(Strings.isEmpty(alias) ? defaultAlias : alias); return a == null ? null : a; }
From source file:org.apache.openmeetings.core.ldap.LdapLoginManager.java
License:Apache License
private static Attribute getAttr(Properties config, Entry entry, String aliasCode, String defaultAlias) { String alias = config.getProperty(aliasCode, ""); if (Strings.isEmpty(alias)) { alias = defaultAlias;// w w w .j a v a2 s . c om } Attribute a = Strings.isEmpty(alias) ? null : entry.get(alias); return a == null ? null : a; }
From source file:org.apache.openmeetings.core.mail.MailHandler.java
License:Apache License
public MimeMessage getBasicMimeMessage() throws Exception { log.debug("getBasicMimeMessage"); if (smtpServer == null) { init();//from www . j a va2 s . c om } Properties props = new Properties(System.getProperties()); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.port", smtpPort); if (mailTls) { props.put("mail.smtp.starttls.enable", "true"); } props.put("mail.smtp.connectiontimeout", smtpConnectionTimeOut); props.put("mail.smtp.timeout", smtpTimeOut); // Check for Authentication Session session = null; if (!Strings.isEmpty(mailAuthUser) && !Strings.isEmpty(mailAuthPass)) { // use SMTP Authentication props.put("mail.smtp.auth", "true"); session = Session.getDefaultInstance(props, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(mailAuthUser, mailAuthPass); } }); } else { // not use SMTP Authentication session = Session.getInstance(props, null); } // Building MimeMessage MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); return msg; }
From source file:org.apache.openmeetings.core.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! * /*w w w. j av a 2 s .c o m*/ * @param SID * @return - 1 in case of success, -1 otherwise */ public Long loginUserByRemote(String SID) { try { Long users_id = sessiondataDao.check(SID); Set<Right> _rights = userDao.getRights(users_id); if (AuthLevelUtil.hasAdminLevel(_rights) || AuthLevelUtil.hasWebServiceLevel(_rights)) { Sessiondata sd = sessiondataDao.get(SID); if (sd == null || sd.getXml() == null) { return -37L; } else { RemoteSessionObject userObject = RemoteSessionObject.fromXml(sd.getXml()); if (userObject == null) { log.warn("Failed to get user object by XML"); return -1L; } 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 = userDao.getExternalUser(userObject.getExternalUserId(), userObject.getExternalUserType()); if (user == null) { String iCalTz = configurationDao.getConfValue("default.timezone", String.class, ""); Address a = userDao.getAddress(null, null, null, Locale.getDefault().getCountry(), null, null, null, userObject.getEmail()); Set<Right> rights = UserDao.getDefaultRights(); rights.remove(Right.Login); rights.remove(Right.Dashboard); User u = userDao.addUser(rights, userObject.getFirstname(), userObject.getUsername(), userObject.getLastname(), 1L, "" // password is empty by default , a, false, null, null, timezoneUtil.getTimeZone(iCalTz), false, null, null, false, false, userObject.getExternalUserId(), userObject.getExternalUserType(), null, userObject.getPictureUrl()); long userId = u.getId(); currentClient.setUserId(userId); SessionVariablesUtil.setUserId(current.getClient(), userId); } else { user.setPictureuri(userObject.getPictureUrl()); userDao.update(user, users_id); currentClient.setUserId(user.getId()); SessionVariablesUtil.setUserId(current.getClient(), user.getId()); } } log.debug("userObject.getExternalUserId() -2- " + currentClient.getUserId()); currentClient.setUserObject(userObject.getUsername(), userObject.getFirstname(), userObject.getLastname()); currentClient.setPicture_uri(userObject.getPictureUrl()); currentClient.setEmail(userObject.getEmail()); log.debug("UPDATE USER BY STREAMID " + streamId); if (currentClient.getUserId() != null) { sessiondataDao.updateUser(SID, currentClient.getUserId()); } sessionManager.updateClientByStreamId(streamId, currentClient, false, null); return 1L; } } } catch (Exception err) { log.error("[loginUserByRemote] ", err); } return -1L; }
From source file:org.apache.openmeetings.core.remote.MobileService.java
License:Apache License
public Map<String, Object> registerUser(Map<String, String> umap) { Map<String, Object> result = getResult(); try {// w w w. j av a 2 s . c o m if ("1".equals(cfgDao.getConfValue(CONFIG_FRONTEND_REGISTER_KEY, String.class, "0"))) { String login = umap.get("login"); String email = umap.get("email"); String lastname = umap.get("lastname"); String firstname = umap.get("firstname"); if (firstname == null) { firstname = ""; } if (lastname == null) { lastname = ""; } String password = umap.get("password"); String tzId = umap.get("tzId"); String country = umap.get("stateId"); Long langId = Long.valueOf(umap.get("langId")); //FIXME TODO unify with Register dialog String hash = UUID.randomUUID().toString(); String baseURL = cfgDao.getBaseUrl(); boolean sendConfirmation = !Strings.isEmpty(baseURL) && 1 == cfgDao.getConfValue("sendEmailWithVerficationCode", Integer.class, "0"); Long userId = userManager.registerUserInit(UserDao.getDefaultRights(), login, password, lastname, firstname, email, null /* age/birthday */, "" /* street */ , "" /* additionalname */, "" /* fax */, "" /* zip */, country, "" /* town */, langId, true /* sendWelcomeMessage */ , Arrays.asList(cfgDao.getConfValue(CONFIG_DEFAULT_GROUP_ID, Long.class, null)), "" /* phone */, false, sendConfirmation, TimeZone.getTimeZone(tzId), false /* forceTimeZoneCheck */, "" /* userOffers */, "" /* userSearchs */, false /* showContactData */, true /* showContactDataToContacts */, hash); if (userId == null) { //do nothing } else if (userId > 0) { User u = userDao.get(userId); if (sendConfirmation) { add(result, "status", -666L); } else { result = login(u, result); } } else { add(result, "status", userId); } } } catch (Exception e) { log.error("[registerUser]", e); } return result; }
From source file:org.apache.openmeetings.core.remote.MobileService.java
License:Apache License
public List<Map<String, Object>> getVideoStreams() { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); // Notify all clients of the same scope (room) IConnection current = Red5.getConnectionLocal(); for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null && conn instanceof IServiceCapableConnection) { Client c = sessionManager.getClientByStreamId(conn.getClient().getId(), null); if (!Strings.isEmpty(c.getAvsettings()) && !c.isScreenClient()) { Map<String, Object> map = new Hashtable<String, Object>(); add(map, "streamId", c.getStreamid()); add(map, "broadCastId", c.getBroadCastID()); add(map, "userId", c.getUserId()); add(map, "firstname", c.getFirstname()); add(map, "lastname", c.getLastname()); add(map, "publicSid", c.getPublicSID()); add(map, "login", c.getUsername()); add(map, "email", c.getEmail()); add(map, "avsettings", c.getAvsettings()); add(map, "interviewPodId", c.getInterviewPodId()); add(map, "vWidth", c.getVWidth()); add(map, "vHeight", c.getVHeight()); result.add(map);//www . ja v a2s. c om } } } return result; }
From source file:org.apache.openmeetings.core.remote.red5.ScopeApplicationAdapter.java
License:Apache License
@Override public boolean roomConnect(IConnection conn, Object[] params) { log.debug("roomConnect : "); IServiceCapableConnection service = (IServiceCapableConnection) conn; String streamId = conn.getClient().getId(); log.debug("### Client connected to OpenMeetings, register Client StreamId: " + streamId + " scope " + conn.getScope().getName()); // Set StreamId in Client service.invoke("setId", new Object[] { streamId }, this); Map<String, Object> map = conn.getConnectParams(); String swfURL = map.containsKey("swfUrl") ? (String) map.get("swfUrl") : ""; String tcUrl = map.containsKey("tcUrl") ? (String) map.get("tcUrl") : ""; Map<String, Object> connParams = getConnParams(params); String uid = (String) connParams.get("uid"); String securityCode = (String) connParams.get(SECURITY_CODE_PARAM); if (!Strings.isEmpty(securityCode)) { //FIXME TODO add better mechanism, this is for external applications like ffmpeg Client parent = sessionManager.getClientByPublicSID(securityCode, null); if (parent == null || !parent.getScope().equals(conn.getScope().getName())) { return rejectClient(); }/*from w ww . j a va 2 s . c o m*/ } if ("networktest".equals(uid)) { return true; } Client parentClient = null; //TODO add similar code for other connections if (map.containsKey("screenClient")) { String parentSid = (String) map.get("parentSid"); parentClient = sessionManager.getClientByPublicSID(parentSid, null); if (parentClient == null) { return rejectClient(); } } Client rcm = new Client(); rcm.setStreamid(conn.getClient().getId()); StringValue scn = StringValue.valueOf(conn.getScope().getName()); rcm.setScope(scn.toString()); long roomId = scn.toLong(Long.MIN_VALUE); if (Long.MIN_VALUE != roomId) { rcm.setRoomId(roomId); } else if (!"hibernate".equals(scn.toString())) { return rejectClient(); } rcm.setUserport(conn.getRemotePort()); rcm.setUserip(conn.getRemoteAddress()); rcm.setSwfurl(swfURL); rcm.setTcUrl(tcUrl); rcm.setNativeSsl(Boolean.TRUE.equals(connParams.get(NATIVE_SSL_PARAM))); rcm.setPublicSID(uid); rcm.setSecurityCode(securityCode); rcm = sessionManager.add(rcm, null); if (rcm == null) { log.warn("Failed to create Client on room connect"); return false; } SessionVariablesUtil.initClient(conn.getClient(), rcm.getPublicSID()); //TODO add similar code for other connections, merge with above block if (map.containsKey("screenClient")) { //TODO add check for room rights String parentSid = parentClient.getPublicSID(); rcm.setRoomId(Long.valueOf(conn.getScope().getName())); rcm.setScreenClient(true); SessionVariablesUtil.setIsScreenClient(conn.getClient()); rcm.setUserId(parentClient.getUserId()); Long userId = rcm.getUserId(); SessionVariablesUtil.setUserId(conn.getClient(), userId); rcm.setStreamPublishName(parentSid); User u = null; if (userId != null) { long _uid = userId.longValue(); u = userDao.get(_uid < 0 ? -_uid : _uid); } if (u != null) { rcm.setUsername(u.getLogin()); rcm.setFirstname(u.getFirstname()); rcm.setLastname(u.getLastname()); } log.debug("publishName :: " + rcm.getStreamPublishName()); sessionManager.updateClientByStreamId(streamId, rcm, false, null); } // Log the User conferenceLogDao.add(ConferenceLog.Type.clientConnect, rcm.getUserId(), streamId, null, rcm.getUserip(), rcm.getScope()); return true; }
From source file:org.apache.openmeetings.core.remote.red5.ScopeApplicationAdapter.java
License:Apache License
/** * This method handles the Event after a stream has been added all connected * Clients in the same room will get a notification * /* ww w . j a va 2 s .c om*/ */ /* (non-Javadoc) * @see org.red5.server.adapter.MultiThreadedApplicationAdapter#streamPublishStart(org.red5.server.api.stream.IBroadcastStream) */ @Override public void streamPublishStart(IBroadcastStream stream) { try { log.debug("----------- streamPublishStart"); IConnection current = Red5.getConnectionLocal(); final String streamid = current.getClient().getId(); final Client currentClient = sessionManager.getClientByStreamId(streamid, null); //We make a second object the has the reference to the object //that we will use to send to all participents Client clientObjectSendToSync = currentClient; // Notify all the clients that the stream had been started log.debug( "start streamPublishStart broadcast start: " + stream.getPublishedName() + " CONN " + current); // In case its a screen sharing we start a new Video for that if (currentClient.isScreenClient()) { currentClient.setScreenPublishStarted(true); sessionManager.updateClientByStreamId(streamid, currentClient, false, null); } if (!Strings.isEmpty(currentClient.getSecurityCode())) { currentClient.setBroadCastID(Long.parseLong(stream.getPublishedName())); currentClient.setIsBroadcasting(true); currentClient.setVWidth(320); currentClient.setVHeight(240); sessionManager.updateClientByStreamId(streamid, currentClient, false, null); } log.debug("newStream SEND: " + currentClient); // Notify all users of the same Scope // We need to iterate through the streams to catch if anybody is recording new MessageSender(current, "newStream", clientObjectSendToSync) { @Override public boolean filter(IConnection conn) { Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); if (rcl == null) { log.debug("RCL IS NULL newStream SEND"); return true; } log.debug("check send to " + rcl); if (rcl.getPublicSID() == "") { log.debug("publicSID IS NULL newStream SEND"); return true; } if (rcl.getIsRecording()) { log.debug("RCL getIsRecording newStream SEND"); recordingService.addRecordingByStreamId(current, streamid, currentClient, rcl.getRecordingId()); } if (rcl.isScreenClient()) { log.debug("RCL getIsScreenClient newStream SEND"); return true; } if (rcl.getPublicSID().equals(currentClient.getPublicSID())) { log.debug("RCL publicSID is equal newStream SEND"); return true; } log.debug( "RCL SEND is equal newStream SEND " + rcl.getPublicSID() + " || " + rcl.getUserport()); return false; } }.start(); } catch (Exception err) { log.error("[streamPublishStart]", err); } }