[OPENMEETINGS-1677] Hazelcast is added to handle cluster
Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/ca559564 Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/ca559564 Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/ca559564 Branch: refs/heads/3.3.x Commit: ca5595649e3b7c8fbdd60cb10a7e630abf59f2f0 Parents: 2c0468f Author: Maxim Solodovnik <[email protected]> Authored: Sun Jul 30 22:55:37 2017 +0700 Committer: Maxim Solodovnik <[email protected]> Committed: Sun Jul 30 22:55:37 2017 +0700 ---------------------------------------------------------------------- .../core/data/conference/RoomManager.java | 6 +- .../core/remote/ConferenceLibrary.java | 11 +- .../remote/ISlaveHTTPConnectionManager.java | 25 - .../openmeetings/core/remote/MainService.java | 20 +- .../openmeetings/core/remote/MobileService.java | 35 +- .../core/remote/RecordingService.java | 38 +- .../core/remote/ScopeApplicationAdapter.java | 226 ++--- .../openmeetings/core/remote/UserService.java | 132 +-- .../core/remote/WhiteboardService.java | 57 +- .../core/remote/util/SessionVariablesUtil.java | 91 -- .../openmeetings/core/session/ServerUtil.java | 82 -- .../core/session/SessionManager.java | 331 ++----- .../core/session/store/DatabaseStore.java | 146 --- .../core/session/store/HashMapStore.java | 207 ----- .../session/store/IClientPersistenceStore.java | 139 --- .../openmeetings/core/util/IClientUtil.java | 9 +- .../org/apache/openmeetings/IApplication.java | 19 +- .../openmeetings/db/dao/room/ClientDao.java | 177 ---- .../openmeetings/db/dao/room/RoomDao.java | 3 +- .../db/dao/server/ISessionManager.java | 140 +-- .../openmeetings/db/dao/server/ServerDao.java | 222 ----- .../db/dao/server/SessiondataDao.java | 4 +- .../openmeetings/db/dao/user/IUserManager.java | 6 +- .../openmeetings/db/dao/user/IUserService.java | 26 - .../openmeetings/db/dto/room/RoomStatus.java | 8 +- .../db/dto/server/ClientSessionInfo.java | 50 - .../openmeetings/db/dto/server/ServerDTO.java | 181 ---- .../openmeetings/db/entity/basic/Client.java | 29 +- .../openmeetings/db/entity/basic/IClient.java | 4 +- .../openmeetings/db/entity/room/Client.java | 916 ------------------- .../openmeetings/db/entity/room/Room.java | 6 +- .../db/entity/room/StreamClient.java | 607 ++++++++++++ .../openmeetings/db/entity/server/Server.java | 304 ------ .../swf/base/hibernate/hibRtmpConnection.lzx | 8 - .../openmeetings/backup/BackupExport.java | 9 - .../openmeetings/backup/BackupImport.java | 18 +- .../installation/ImportInitvalues.java | 3 +- .../src/site/xdoc/Clustering.xml | 18 +- .../service/quartz/scheduler/CleanupJob.java | 6 +- .../openmeetings/service/user/UserManager.java | 10 +- openmeetings-web/pom.xml | 5 + .../web/admin/connection/ConnectionsPanel.java | 25 +- .../openmeetings/web/admin/rooms/RoomForm.java | 17 +- .../web/admin/servers/ServerForm.java | 140 --- .../web/admin/servers/ServersPanel.html | 103 --- .../web/admin/servers/ServersPanel.java | 95 -- .../openmeetings/web/app/Application.java | 127 ++- .../openmeetings/web/room/RoomBroadcaster.java | 21 +- .../apache/openmeetings/web/room/RoomPanel.java | 16 +- .../apache/openmeetings/web/room/SwfPanel.java | 46 +- .../web/room/menu/RoomMenuPanel.java | 5 +- .../web/room/menu/StartSharingButton.java | 15 +- .../web/room/sidebar/RoomSidebar.java | 14 +- .../openmeetings/web/util/OmUrlFragment.java | 9 - .../classes/META-INF/db2_persistence.xml | 2 - .../classes/META-INF/derby_persistence.xml | 2 - .../classes/META-INF/mssql_persistence.xml | 2 - .../classes/META-INF/mysql_persistence.xml | 2 - .../classes/META-INF/oracle_persistence.xml | 2 - .../classes/META-INF/postgresql_persistence.xml | 2 - .../WEB-INF/classes/applicationContext.xml | 29 +- .../main/webapp/WEB-INF/classes/cxf-servlet.xml | 3 - .../main/webapp/WEB-INF/classes/hazelcast.xml | 32 + .../webapp/WEB-INF/classes/logback-config.xml | 7 +- .../webapp/WEB-INF/classes/rebel-remote.xml | 6 +- .../src/main/webapp/WEB-INF/classes/rebel.xml | 6 +- .../test/poll/TestClientListManager.java | 43 - .../test/session/TestDbSession.java | 194 ---- .../test/session/TestDbSessionGetRoomIds.java | 95 -- .../test/session/TestHashMapSession.java | 91 -- .../openmeetings/webservice/RoomWebService.java | 4 +- .../webservice/ServerWebService.java | 171 ---- .../openmeetings/webservice/UserWebService.java | 112 ++- .../webservice/cluster/RestClient.java | 196 ---- .../cluster/SlaveHTTPConnectionManager.java | 99 -- .../webservice/cluster/UserService.java | 160 ---- 76 files changed, 1247 insertions(+), 4980 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/RoomManager.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/RoomManager.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/RoomManager.java index 05c3172..d553739 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/RoomManager.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/RoomManager.java @@ -85,7 +85,7 @@ public class RoomManager { asc); for (Room room : rooms) { - room.setCurrentusers(sessionManager.getClientListByRoom(room.getId())); + room.setCurrentusers(sessionManager.listByRoom(room.getId())); } sResult.setResult(rooms); @@ -102,7 +102,7 @@ public class RoomManager { asc); for (Room room : rooms) { - room.setCurrentusers(sessionManager.getClientListByRoom(room.getId())); + room.setCurrentusers(sessionManager.listByRoom(room.getId())); } return rooms; @@ -117,7 +117,7 @@ public class RoomManager { List<Room> rooms = this.getRoomsInternatlbyType(start, max, orderby, asc, externalType); for (Room room : rooms) { - room.setCurrentusers(sessionManager.getClientListByRoom(room.getId())); + room.setCurrentusers(sessionManager.listByRoom(room.getId())); } return rooms; http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java index c7d93eb..ca77ff9 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ConferenceLibrary.java @@ -33,11 +33,10 @@ import org.apache.openmeetings.db.dao.file.FileExplorerItemDao; import org.apache.openmeetings.db.dao.server.ISessionManager; import org.apache.openmeetings.db.dao.server.SessiondataDao; import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.dto.server.ClientSessionInfo; import org.apache.openmeetings.db.entity.file.FileExplorerItem; import org.apache.openmeetings.db.entity.file.FileItem; import org.apache.openmeetings.db.entity.file.FileItem.Type; -import org.apache.openmeetings.db.entity.room.Client; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.util.AuthLevelUtil; import org.apache.openmeetings.util.OmFileHelper; @@ -113,13 +112,7 @@ public class ConferenceLibrary implements IPendingServiceCallback { * @param fi - FileItem of the Wml being loaded */ public void sendToWhiteboard(String uid, Long wbId, FileItem fi) { - ClientSessionInfo csi = sessionManager.getClientByPublicSIDAnyServer(uid); - if (csi == null) { - log.warn("No client was found to send Wml:: {}", uid); - return; - } - Client client = csi.getRcl(); - + StreamClient client = sessionManager.get(uid); if (client == null) { log.warn("No client was found to send Wml:: {}", uid); return; http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ISlaveHTTPConnectionManager.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ISlaveHTTPConnectionManager.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ISlaveHTTPConnectionManager.java deleted file mode 100644 index 8fc0957..0000000 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ISlaveHTTPConnectionManager.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.core.remote; - -import org.apache.openmeetings.db.entity.server.Server; - -public interface ISlaveHTTPConnectionManager { - void kickSlaveUser(Server server, String publicSID) throws Exception; -} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MainService.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MainService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MainService.java index a63b1af..2f90506 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MainService.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MainService.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import java.util.Set; -import org.apache.openmeetings.core.remote.util.SessionVariablesUtil; +import org.apache.openmeetings.core.util.IClientUtil; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.db.dao.calendar.AppointmentDao; import org.apache.openmeetings.db.dao.room.RoomDao; @@ -37,9 +37,9 @@ import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.entity.basic.Configuration; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.db.entity.calendar.MeetingMember; -import org.apache.openmeetings.db.entity.room.Client; import org.apache.openmeetings.db.entity.room.Room; import org.apache.openmeetings.db.entity.room.RoomGroup; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.GroupUser; import org.apache.openmeetings.db.entity.user.User; @@ -48,6 +48,7 @@ import org.apache.openmeetings.db.entity.user.Userdata; import org.apache.openmeetings.db.util.AuthLevelUtil; import org.apache.openmeetings.util.OpenmeetingsVariables; import org.red5.logging.Red5LoggerFactory; +import org.red5.server.api.IClient; import org.red5.server.api.IConnection; import org.red5.server.api.Red5; import org.red5.server.api.service.IPendingServiceCall; @@ -103,15 +104,14 @@ public class MainService implements IPendingServiceCallback { return users; } - public Client getCurrentRoomClient(String SID) { + public StreamClient getCurrentRoomClient(String SID) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); + IClient client = current.getClient(); - log.debug("getCurrentRoomClient -1- " + SID); - log.debug("getCurrentRoomClient -2- " + streamid); + log.debug("getCurrentRoomClient {}, {}", SID, client.getId()); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(client)); return currentClient; } catch (Exception err) { log.error("[getCurrentRoomClient]", err); @@ -177,21 +177,19 @@ public class MainService implements IPendingServiceCallback { log.debug("[loginWicket] user and roomid are not empty: " + userId + ", " + wicketroomid); if (wicketroomid.equals(sd.getRoomId()) || isRoomAllowedToUser(r, u)) { IConnection current = Red5.getConnectionLocal(); - String streamId = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamId, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); if (User.Type.user != u.getType() || (User.Type.user == u.getType() && !u.getGroupUsers().isEmpty())) { u.setSessionData(sd); currentClient.setUserId(u.getId()); currentClient.setRoomId(wicketroomid); - SessionVariablesUtil.setUserId(current.getClient(), u.getId()); currentClient.setUsername(u.getLogin()); currentClient.setFirstname(u.getFirstname()); currentClient.setLastname(u.getLastname()); currentClient.setPicture_uri(u.getPictureuri()); currentClient.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail()); - sessionManager.updateClientByStreamId(streamId, currentClient, false, null); + sessionManager.update(currentClient); scopeApplicationAdapter.sendMessageToCurrentScope("roomConnect", currentClient, false); http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java index 6ff394e..d007887 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java @@ -40,7 +40,7 @@ import java.util.UUID; import org.apache.commons.lang3.time.FastDateFormat; import org.apache.openmeetings.core.remote.LanguageService.Language; import org.apache.openmeetings.core.remote.ScopeApplicationAdapter.MessageSender; -import org.apache.openmeetings.core.remote.util.SessionVariablesUtil; +import org.apache.openmeetings.core.util.IClientUtil; import org.apache.openmeetings.core.util.WebSocketHelper; import org.apache.openmeetings.db.dao.basic.ChatDao; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; @@ -51,8 +51,8 @@ import org.apache.openmeetings.db.dao.server.SessiondataDao; import org.apache.openmeetings.db.dao.user.IUserManager; import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.entity.basic.ChatMessage; -import org.apache.openmeetings.db.entity.room.Client; import org.apache.openmeetings.db.entity.room.Room; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.Group; import org.apache.openmeetings.db.entity.user.GroupUser; @@ -217,8 +217,7 @@ public class MobileService { private Map<String, Object> login(User u, Map<String, Object> result) { if (u != null) { IConnection conn = Red5.getConnectionLocal(); - String streamId = conn.getClient().getId(); - Client c = sessionManager.getClientByStreamId(streamId, null); + StreamClient c = sessionManager.get(IClientUtil.getId(conn.getClient())); if (c == null) { // Failed to create client result.put("status", -1); @@ -227,12 +226,12 @@ public class MobileService { sd.setUserId(u.getId()); sd.setLanguageId(u.getLanguageId()); sessionDao.update(sd); - SessionVariablesUtil.initClient(conn.getClient(), c.getPublicSID()); + IClientUtil.init(conn.getClient(), c.getUid(), false); c.setUserId(u.getId()); c.setFirstname(u.getFirstname()); c.setLastname(u.getLastname()); //TODO rights - sessionManager.updateClientByStreamId(streamId, c, false, null); + sessionManager.update(c); add(result, "sid", sd.getSessionId()); add(result, "publicSid", c.getPublicSID()); @@ -255,7 +254,7 @@ public class MobileService { IConnection current = Red5.getConnectionLocal(); for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null && conn instanceof IServiceCapableConnection) { - Client c = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(conn.getClient())); if (!Strings.isEmpty(c.getAvsettings()) && !c.isScreenClient()) { Map<String, Object> map = new HashMap<>(); add(map, "streamId", c.getStreamid()); @@ -287,7 +286,7 @@ public class MobileService { room.put("org", org); } room.put("first", first); - room.put("users", sessionManager.getClientListByRoom(r.getId()).size()); + room.put("users", sessionManager.listByRoom(r.getId()).size()); room.put("total", r.getNumberOfPartizipants()); room.put("audioOnly", r.isAudioOnly()); result.add(room); @@ -297,7 +296,7 @@ public class MobileService { List<Map<String, Object>> result = new ArrayList<>(); // FIXME duplicated code IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); User u = userDao.get(c.getUserId()); //my rooms List<Room> myl = new ArrayList<>(); @@ -334,7 +333,7 @@ public class MobileService { public Map<String, Object> roomConnect(String SID, Long userId) { // publicSid is changed on mobile room connect IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); Map<String, Object> result = new HashMap<>(); result.put("publicSid", c.getPublicSID()); result.put("broadCastId", c.getBroadCastID()); @@ -343,7 +342,7 @@ public class MobileService { public Map<String, Object> updateAvMode(String avMode, String width, String height, Integer interviewPodId) { IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); c.setAvsettings(avMode); if (!"n".equals(avMode)) { c.setBroadCastID(nextBroadCastId()); @@ -354,7 +353,7 @@ public class MobileService { if (interviewPodId > 0) { c.setInterviewPodId(interviewPodId); } - sessionManager.updateClientByStreamId(c.getStreamid(), c, false, null); + sessionManager.update(c); Map<String, Object> hsm = new HashMap<>(); hsm.put("client", c); hsm.put("message", new String[]{"avsettings", "0", avMode}); @@ -369,7 +368,7 @@ public class MobileService { public void sendChatMessage(String msg) { IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); ChatMessage m = new ChatMessage(); m.setMessage(msg); @@ -386,10 +385,10 @@ public class MobileService { } public void sendChatMessage(String uid, ChatMessage m, FastDateFormat fmt) { - sendChatMessage(sessionManager.getClientByPublicSID(uid, null), m, fmt); + sendChatMessage(sessionManager.get(uid), m, fmt); } - public void sendChatMessage(Client c, ChatMessage m, FastDateFormat fmt) { + public void sendChatMessage(StreamClient c, ChatMessage m, FastDateFormat fmt) { Map<String, Object> hsm = new HashMap<>(); hsm.put("client", c); hsm.put("message", Arrays.asList("chat", encodeChatMessage(m, fmt))); @@ -399,14 +398,14 @@ public class MobileService { new MessageSender(scopeAdapter.getRoomScope("" + roomId), "sendVarsToMessageWithClient", hsm, scopeAdapter) { @Override public boolean filter(IConnection conn) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); return rcl.isScreenClient() || rcl.getRoomId() == null || !rcl.getRoomId().equals(roomId); } }.start(); } - private static boolean isModerator(Client c) { + private static boolean isModerator(StreamClient c) { return c.getIsMod() || c.getIsSuperModerator(); } @@ -430,7 +429,7 @@ public class MobileService { List<Map<String,Object>> myChatList = new ArrayList<>(); try { IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = c.getRoomId(); log.debug("GET CHATROOM: " + roomId); http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java index 9e90235..c6ebddc 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java @@ -29,6 +29,7 @@ import org.apache.openmeetings.core.converter.BaseConverter; import org.apache.openmeetings.core.data.record.converter.InterviewConverterTask; import org.apache.openmeetings.core.data.record.converter.RecordingConverterTask; import org.apache.openmeetings.core.data.record.listener.StreamListener; +import org.apache.openmeetings.core.util.IClientUtil; import org.apache.openmeetings.core.util.WebSocketHelper; import org.apache.openmeetings.db.dao.record.RecordingDao; import org.apache.openmeetings.db.dao.record.RecordingMetaDataDao; @@ -39,12 +40,13 @@ import org.apache.openmeetings.db.entity.file.FileItem.Type; import org.apache.openmeetings.db.entity.record.Recording; import org.apache.openmeetings.db.entity.record.RecordingMetaData; import org.apache.openmeetings.db.entity.record.RecordingMetaData.Status; -import org.apache.openmeetings.db.entity.room.Client; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.util.CalendarPatterns; import org.apache.openmeetings.util.message.RoomMessage; import org.apache.openmeetings.util.message.TextRoomMessage; import org.red5.logging.Red5LoggerFactory; +import org.red5.server.api.IClient; import org.red5.server.api.IConnection; import org.red5.server.api.Red5; import org.red5.server.api.scope.IScope; @@ -94,7 +96,7 @@ public class RecordingService implements IPendingServiceCallback { return "rec_" + recordingId + "_stream_" + streamid + "_" + dateString; } - public String recordMeetingStream(IConnection current, Client client, String roomRecordingName, String comment, boolean isInterview) { + public String recordMeetingStream(IConnection current, StreamClient client, String roomRecordingName, String comment, boolean isInterview) { try { log.debug("##REC:: recordMeetingStream ::"); @@ -134,13 +136,13 @@ public class RecordingService implements IPendingServiceCallback { // Update Client and set Flag client.setIsRecording(true); client.setRecordingId(recordingId); - sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null); + sessionManager.update(client); // get all stream and start recording them for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null) { if (conn instanceof IServiceCapableConnection) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); // Send every user a notification that the recording did start WebSocketHelper.sendRoom(new TextRoomMessage(roomId, ownerId, RoomMessage.Type.recordingStarted, client.getPublicSID())); @@ -160,7 +162,7 @@ public class RecordingService implements IPendingServiceCallback { // Add Meta Data rcl.setRecordingMetaDataId(metaDataId); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); } } else if (rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v")) { // if the user does publish av, a, v @@ -185,7 +187,7 @@ public class RecordingService implements IPendingServiceCallback { rcl.setRecordingMetaDataId(metaId); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); // Start FLV recording recordShow(conn, broadcastId, streamName, metaId, !isAudioOnly, isInterview); @@ -306,7 +308,7 @@ public class RecordingService implements IPendingServiceCallback { } } - public void stopRecordAndSave(IScope scope, Client client, Long storedRecordingId) { + public void stopRecordAndSave(IScope scope, StreamClient client, Long storedRecordingId) { try { log.debug("stopRecordAndSave " + client.getUsername() + "," + client.getUserip()); WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.recordingStoped, client.getPublicSID())); @@ -315,7 +317,7 @@ public class RecordingService implements IPendingServiceCallback { for (IConnection conn : scope.getClientConnections()) { if (conn != null) { if (conn instanceof IServiceCapableConnection) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl == null) { continue; @@ -356,7 +358,7 @@ public class RecordingService implements IPendingServiceCallback { client.setRecordingId(null); client.setIsRecording(false); - sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null); + sessionManager.update(client); log.debug("recordingConverterTask ", recordingConverterTask); Recording recording = recordingDao.get(recordingId); @@ -371,18 +373,18 @@ public class RecordingService implements IPendingServiceCallback { } } - public Client checkLzRecording() { + public StreamClient checkLzRecording() { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); + IClient client = current.getClient(); - log.debug("getCurrentRoomClient -2- " + streamid); + log.debug("getCurrentRoomClient -2- {} ", client.getId()); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(client)); log.debug("getCurrentRoomClient -#########################- " + currentClient.getRoomId()); - for (Client rcl : sessionManager.getClientListByRoomAll(currentClient.getRoomId())) { + for (StreamClient rcl : sessionManager.listByRoomAll(currentClient.getRoomId())) { if (rcl.getIsRecording()) { return rcl; } @@ -394,7 +396,7 @@ public class RecordingService implements IPendingServiceCallback { return null; } - public void stopRecordingShowForClient(IScope scope, Client rcl) { + public void stopRecordingShowForClient(IScope scope, StreamClient rcl) { try { // this cannot be handled here, as to stop a stream and to leave a // room is not @@ -432,7 +434,7 @@ public class RecordingService implements IPendingServiceCallback { } } - public void addRecordingByStreamId(IConnection conn, Client rcl, Long recordingId) { + public void addRecordingByStreamId(IConnection conn, StreamClient rcl, Long recordingId) { try { Recording recording = recordingDao.get(recordingId); @@ -454,7 +456,7 @@ public class RecordingService implements IPendingServiceCallback { // Add Meta Data rcl.setRecordingMetaDataId(metaDataId); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); } } else if (rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v")) { // if the user does publish av, a, v @@ -480,7 +482,7 @@ public class RecordingService implements IPendingServiceCallback { rcl.setRecordingMetaDataId(metaDataId); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); } http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java index 5f0efe0..9298545 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java @@ -48,7 +48,7 @@ import org.apache.openmeetings.IApplication; import org.apache.openmeetings.core.data.conference.RoomManager; import org.apache.openmeetings.core.data.whiteboard.WhiteboardCache; import org.apache.openmeetings.core.data.whiteboard.WhiteboardManager; -import org.apache.openmeetings.core.remote.util.SessionVariablesUtil; +import org.apache.openmeetings.core.util.IClientUtil; import org.apache.openmeetings.core.util.WebSocketHelper; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.db.dao.calendar.AppointmentDao; @@ -58,18 +58,16 @@ import org.apache.openmeetings.db.dao.record.RecordingDao; import org.apache.openmeetings.db.dao.room.RoomDao; import org.apache.openmeetings.db.dao.room.SipDao; import org.apache.openmeetings.db.dao.server.ISessionManager; -import org.apache.openmeetings.db.dao.server.ServerDao; import org.apache.openmeetings.db.dao.server.SessiondataDao; import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.dto.room.BrowserStatus; import org.apache.openmeetings.db.dto.room.RoomStatus; -import org.apache.openmeetings.db.dto.server.ClientSessionInfo; +import org.apache.openmeetings.db.entity.basic.Client; import org.apache.openmeetings.db.entity.file.FileItem; import org.apache.openmeetings.db.entity.log.ConferenceLog; -import org.apache.openmeetings.db.entity.room.Client; import org.apache.openmeetings.db.entity.room.Room; import org.apache.openmeetings.db.entity.room.Room.RoomElement; -import org.apache.openmeetings.db.entity.server.Server; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.util.AuthLevelUtil; @@ -134,8 +132,6 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp @Autowired private RecordingDao recordingDao; @Autowired - private ServerDao serverDao; - @Autowired private SipDao sipDao; private static AtomicLong broadCastCounter = new AtomicLong(0); @@ -172,7 +168,6 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp EXT_PROCESS_TTL = cfgDao.getConfValue(CONFIG_EXT_PROCESS_TTL, Integer.class, "" + EXT_PROCESS_TTL); Version.logOMStarted(); recordingDao.resetProcessingStatus(); //we are starting so all processing recordings are now errors - sessionManager.clearCache(); // 'sticky' clients should be cleaned up from DB } catch (Exception err) { _log.error("[appStart]", err); } @@ -210,7 +205,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp if (parentSid == null) { parentSid = (String)connParams.get("parentSid"); } - Client rcm = new Client(); + StreamClient rcm = new StreamClient(); rcm.setScope(conn.getScope().getName()); rcm.setOwnerSid(ownerSid); boolean hibernate = HIBERNATE_SCOPE.equals(rcm.getScope()); @@ -222,7 +217,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp return rejectClient(); } String _uid = null; - for (org.apache.openmeetings.db.entity.basic.Client wcl : iapp.getOmRoomClients(rcm.getRoomId())) { + for (Client wcl : iapp.getOmRoomClients(rcm.getRoomId())) { if (wcl.getSid().equals(securityCode)) { _uid = wcl.getUid(); break; @@ -232,7 +227,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp _log.warn("Client is not found by security id, client is rejected"); return rejectClient(); } - Client parent = sessionManager.getClientByPublicSID(_uid, null); + StreamClient parent = sessionManager.get(_uid); if (parent == null || !parent.getScope().equals(rcm.getScope())) { _log.warn("Security code is invalid, client is rejected"); return rejectClient(); @@ -259,12 +254,11 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } if (map.containsKey("screenClient")) { - Client parent = sessionManager.getClientByPublicSID(parentSid, null); + StreamClient parent = sessionManager.get(parentSid); if (parent == null) { _log.warn("Bad parent for screen-sharing client, client is rejected"); return rejectClient(); } - SessionVariablesUtil.setIsScreenClient(conn.getClient()); rcm.setUserId(parent.getUserId()); rcm.setScreenClient(true); rcm.setPublicSID(UUID.randomUUID().toString()); @@ -308,19 +302,18 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp if (!Strings.isEmpty(uid)) { rcm.setPublicSID(uid); } - rcm = sessionManager.add(iapp.updateClient(rcm, false), null); + rcm = sessionManager.add(iapp.updateClient(rcm, false)); if (rcm == null) { _log.warn("Failed to create Client on room connect"); return false; } - SessionVariablesUtil.initClient(conn.getClient(), rcm.getPublicSID()); + IClientUtil.init(conn.getClient(), rcm.getUid(), rcm.isScreenClient()); //TODO add similar code for other connections, merge with above block if (map.containsKey("screenClient")) { //TODO add check for room rights User u = null; Long userId = rcm.getUserId(); - SessionVariablesUtil.setUserId(conn.getClient(), userId); if (userId != null) { long _uid = userId.longValue(); u = userDao.get(_uid < 0 ? -_uid : _uid); @@ -331,7 +324,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp rcm.setLastname(u.getLastname()); } _log.debug("publishName :: " + rcm.getStreamPublishName()); - sessionManager.updateClientByStreamId(streamId, rcm, false, null); + sessionManager.update(rcm); } // Log the User @@ -347,7 +340,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp _log.debug("----------- screenSharerAction ENTER"); IConnection current = Red5.getConnectionLocal(); - Client client = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); if (client != null) { boolean changed = false; @@ -379,7 +372,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } if (changed) { - sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null); + sessionManager.update(client); if (!client.isStartStreaming() && !client.isStartRecording() && !client.isStreamPublishStarted()) { returnMap.put("result", "stopAll"); @@ -393,18 +386,18 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp return returnMap; } - public List<Client> checkScreenSharing() { + public List<StreamClient> checkScreenSharing() { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); + IClient client = current.getClient(); - _log.debug("checkScreenSharing -2- " + streamid); + _log.debug("checkScreenSharing -2- {}", client.getId()); - List<Client> screenSharerList = new LinkedList<>(); + List<StreamClient> screenSharerList = new LinkedList<>(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(client)); - for (Client rcl : sessionManager.getClientListByRoomAll(currentClient.getRoomId())) { + for (StreamClient rcl : sessionManager.listByRoomAll(currentClient.getRoomId())) { if (rcl.isStartStreaming()) { screenSharerList.add(rcl); } @@ -429,7 +422,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp _log.debug("----------- setConnectionAsSharingClient"); IConnection current = Red5.getConnectionLocal(); - Client client = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); if (client != null) { boolean startRecording = Boolean.parseBoolean("" + map.get("startRecording")); @@ -453,7 +446,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp client.setVWidth(Double.valueOf("" + map.get("screenWidth")).intValue()); client.setVHeight(Double.valueOf("" + map.get("screenHeight")).intValue()); client.setStreamPublishName("" + map.get("publishName")); - sessionManager.updateClientByStreamId(current.getClient().getId(), client, false, null); + sessionManager.update(client); Map<String, Object> returnMap = new HashMap<>(); returnMap.put("alreadyPublished", false); @@ -511,7 +504,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp String streamid = current.getClient().getId(); for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl == null) { // continue; } else if (rcl.isScreenClient()) { @@ -536,30 +529,6 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } /** - * this function is invoked after a reconnect - * - * @param newPublicSID - */ - public boolean overwritePublicSID(String newPublicSID) { - try { - _log.debug("----------- overwritePublicSID"); - IConnection current = Red5.getConnectionLocal(); - IClient c = current.getClient(); - Client currentClient = sessionManager.getClientByStreamId(c.getId(), null); - if (currentClient == null) { - return false; - } - SessionVariablesUtil.initClient(c, newPublicSID); - currentClient.setPublicSID(newPublicSID); - sessionManager.updateClientByStreamId(c.getId(), currentClient, false, null); - return true; - } catch (Exception err) { - _log.error("[overwritePublicSID]", err); - } - return false; - } - - /** * Logic must be before roomDisconnect cause otherwise you cannot throw a * message to each one * @@ -569,7 +538,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { _log.debug("[roomLeave] {} {} {} {}", client.getId(), room.getClients().size(), room.getContextPath(), room.getName()); - Client rcl = sessionManager.getClientByStreamId(client.getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(client)); // The Room Client can be null if the Client left the room by using // logicalRoomLeave @@ -583,7 +552,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } public void roomLeaveByScope(String uid, Long roomId) { - Client rcl = sessionManager.getClientByPublicSID(uid, null); + StreamClient rcl = sessionManager.get(uid); IScope scope = getRoomScope("" + roomId); _log.debug("[roomLeaveByScope] {} {} {} {}", uid, roomId, rcl, scope); if (rcl != null && scope != null) { @@ -601,7 +570,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * @param client * @param scope */ - public void roomLeaveByScope(Client client, IScope scope) { + public void roomLeaveByScope(StreamClient client, IScope scope) { try { _log.debug("[roomLeaveByScope] currentClient " + client); Long roomId = client.getRoomId(); @@ -643,7 +612,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp new MessageSender(scope, "roomDisconnect", client, this) { @Override public boolean filter(IConnection conn) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl == null) { return true; } @@ -660,7 +629,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp IApplication app = (IApplication)Application.get(wicketApplicationName); app.exit(client.getPublicSID()); } - sessionManager.removeClient(client.getStreamid(), null); + sessionManager.remove(client.getUid()); } catch (Exception err) { _log.error("[roomLeaveByScope]", err); } @@ -679,12 +648,11 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { _log.debug("----------- streamPublishStart"); IConnection current = Red5.getConnectionLocal(); - final String streamid = current.getClient().getId(); - final Client c = sessionManager.getClientByStreamId(streamid, null); + final StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); //We make a second object the has the reference to the object //that we will use to send to all participents - Client clientObjectSendToSync = c; + StreamClient clientObjectSendToSync = c; // Notify all the clients that the stream had been started _log.debug("start streamPublishStart broadcast start: " + stream.getPublishedName() + " CONN " + current); @@ -692,7 +660,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp // In case its a screen sharing we start a new Video for that if (c.isScreenClient()) { c.setScreenPublishStarted(true); - sessionManager.updateClientByStreamId(streamid, c, false, null); + sessionManager.update(c); } if (!c.isMobile() && !Strings.isEmpty(c.getSecurityCode())) { c.setBroadCastID(Long.parseLong(stream.getPublishedName())); @@ -702,7 +670,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp c.setVWidth(320); c.setVHeight(240); } - sessionManager.updateClientByStreamId(streamid, c, false, null); + sessionManager.update(c); } _log.debug("newStream SEND: " + c); @@ -712,7 +680,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp new MessageSender(current, "newStream", clientObjectSendToSync, this) { @Override public boolean filter(IConnection conn) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl == null) { _log.debug("RCL IS NULL newStream SEND"); @@ -770,8 +738,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp _log.debug("start streamBroadcastClose broadcast close: " + stream.getPublishedName()); try { IConnection current = Red5.getConnectionLocal(); - String streamId = current.getClient().getId(); - Client rcl = sessionManager.getClientByStreamId(streamId, null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(current.getClient())); if (rcl == null) { @@ -796,7 +763,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp rcl.setIsBroadcasting(false); rcl.setAvsettings("n"); } - sessionManager.updateClientByStreamId(streamId, rcl, false, null); + sessionManager.update(rcl); // Notify all clients of the same scope (room) sendMessageToCurrentScope("closeStream", rcl, rcl.isMobile()); } catch (Exception e) { @@ -808,7 +775,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public void setNewCursorPosition(Object item) { try { IConnection current = Red5.getConnectionLocal(); - Client c = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); @SuppressWarnings("rawtypes") Map cursor = (Map) item; @@ -824,7 +791,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { _log.debug("----------- removeModerator: " + publicSID); - Client currentClient = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient currentClient = sessionManager.get(publicSID); if (currentClient == null) { return -1L; @@ -833,9 +800,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp currentClient.setIsMod(false); // Put the mod-flag to true for this client - sessionManager.updateClientByStreamId(currentClient.getStreamid(), currentClient, false, null); + sessionManager.update(currentClient); - List<Client> currentMods = sessionManager.getCurrentModeratorByRoom(roomId); + List<StreamClient> currentMods = sessionManager.listModeratorByRoom(roomId); sendMessageToCurrentScope("setNewModeratorByList", currentMods, true); } catch (Exception err) { @@ -848,13 +815,13 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { _log.debug("----------- switchMicMuted: " + publicSID); - Client currentClient = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient currentClient = sessionManager.get(publicSID); if (currentClient == null) { return -1L; } currentClient.setMicMuted(mute); - sessionManager.updateClientByStreamId(currentClient.getStreamid(), currentClient, false, null); + sessionManager.update(currentClient); Map<Integer, Object> newMessage = new HashMap<>(); newMessage.put(0, "updateMuteStatus"); @@ -868,7 +835,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public boolean getMicMutedByPublicSID(String publicSID) { try { - Client currentClient = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient currentClient = sessionManager.get(publicSID); if (currentClient == null) { return true; } @@ -896,14 +863,14 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { String streamid = Red5.getConnectionLocal().getClient().getId(); _log.debug("----------- setUserAVSettings {}", streamid); - Client rcl = sessionManager.getClientByStreamId(streamid, null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(Red5.getConnectionLocal().getClient())); if (rcl == null) { _log.warn("Failed to find appropriate clients"); return -1; } if (updateBroadcastId) { rcl.setBroadCastID(nextBroadCastId()); - sessionManager.updateAVClientByStreamId(streamid, rcl, null); + sessionManager.update(rcl); } return rcl.getBroadCastID(); } catch (Exception err) { @@ -925,7 +892,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp if (!room.isAppointment() && room.isModerated()) { // if this is a Moderated Room then the Room can be only // locked off by the Moderator Bit - List<Client> clientModeratorListRoom = sessionManager.getCurrentModeratorByRoom(roomId); + List<StreamClient> clientModeratorListRoom = sessionManager.listModeratorByRoom(roomId); // If there is no Moderator yet and we are asking for it // then deny it @@ -981,8 +948,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp try { _log.debug("----------- setRoomValues"); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client client = sessionManager.getClientByStreamId(streamid, null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); client.setRoomId(roomId); client.setRoomEnter(new Date()); @@ -1000,10 +966,10 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp if (!r.isHidden(RoomElement.MicrophoneStatus)) { client.setCanGiveAudio(true); } - sessionManager.updateClientByStreamId(streamid, client, true, null); // first save to get valid room count + sessionManager.update(client); // first save to get valid room count // Check for Moderation LogicalRoom ENTER - List<Client> roomClients = sessionManager.getClientListByRoom(roomId); + List<StreamClient> roomClients = sessionManager.listByRoom(roomId); // Return Object RoomStatus roomStatus = new RoomStatus(); @@ -1019,9 +985,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } if (client.getIsMod()) { // Update the Client List - sessionManager.updateClientByStreamId(streamid, client, false, null); + sessionManager.update(client); - List<Client> modRoomList = sessionManager.getCurrentModeratorByRoom(client.getRoomId()); + List<StreamClient> modRoomList = sessionManager.listModeratorByRoom(client.getRoomId()); //Sync message to everybody sendMessageToCurrentScope("setNewModeratorByList", modRoomList, false); @@ -1060,16 +1026,14 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * @param lastname - lastname of the user * @return RoomClient in case of everything is OK, null otherwise */ - public Client setUsernameAndSession(String SID, Long userId, String username, String firstname, String lastname) { + public StreamClient setUsernameAndSession(String SID, Long userId, String username, String firstname, String lastname) { try { _log.debug("----------- setUsernameAndSession"); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); currentClient.setUsername(username); currentClient.setUserId(userId); - SessionVariablesUtil.setUserId(current.getClient(), userId); currentClient.setUserObject(userId, username, firstname, lastname); // Update Session Data @@ -1091,7 +1055,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp // set Picture-URI currentClient.setPicture_uri(us.getPictureuri()); } - sessionManager.updateClientByStreamId(streamid, currentClient, false, null); + sessionManager.update(currentClient); return currentClient; } catch (Exception err) { _log.error("[setUsername]", err); @@ -1106,8 +1070,8 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * @param message * @return the list of room clients */ - public Map<String, Client> sendMessageByRoomAndDomain(Long roomId, Object message) { - Map<String, Client> roomClientList = new HashMap<>(); + public Map<String, StreamClient> sendMessageByRoomAndDomain(Long roomId, Object message) { + Map<String, StreamClient> roomClientList = new HashMap<>(); try { _log.debug("sendMessageByRoomAndDomain " + roomId); @@ -1118,7 +1082,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp @Override public boolean filter(IConnection conn) { IClient client = conn.getClient(); - return SessionVariablesUtil.isScreenClient(client); + return IClientUtil.isSharing(client); } }.start(); } catch (Exception err) { @@ -1127,14 +1091,14 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp return roomClientList; } - public List<Client> getCurrentModeratorList() { + public List<StreamClient> getCurrentModeratorList() { try { IConnection current = Red5.getConnectionLocal(); - Client client = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = client.getRoomId(); Room r = roomDao.get(roomId); if (r != null) { - return sessionManager.getCurrentModeratorByRoom(roomId); + return sessionManager.listModeratorByRoom(roomId); } } catch (Exception err) { _log.error("[getCurrentModerator]", err); @@ -1152,7 +1116,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public int sendVarsByWhiteboardId(List<?> whiteboardObjParam, Long whiteboardId) { try { IConnection current = Red5.getConnectionLocal(); - Client client = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); return sendToWhiteboard(client, whiteboardObjParam, whiteboardId); } catch (Exception err) { _log.error("[sendVarsByWhiteboardId]", err); @@ -1251,12 +1215,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } public void sendToWhiteboard(String uid, Long wbId, FileItem fi, String url, boolean clean) { - ClientSessionInfo csi = sessionManager.getClientByPublicSIDAnyServer(uid); - if (csi == null) { - _log.warn("No client was found to send Wml:: {}", uid); - return; - } - Client client = csi.getRcl(); + StreamClient client = sessionManager.get(uid); List<?> wbObject = new ArrayList<>(); switch (fi.getType()) { @@ -1284,7 +1243,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp sendToWhiteboard(client, Arrays.asList("whiteboard", new Date(), "draw", wbObject), wbId); } - private int sendToWhiteboard(Client client, List<?> wbObj, Long wbId) { + private int sendToWhiteboard(StreamClient client, List<?> wbObj, Long wbId) { try { // Check if this User is the Mod: if (client == null) { @@ -1430,7 +1389,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp new MessageSender(getRoomScope("" + roomId), method, obj, this) { @Override public boolean filter(IConnection conn) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); return rcl == null || rcl.isScreenClient() || rcl.getRoomId() == null || !rcl.getRoomId().equals(roomId) || userDao.get(rcl.getUserId()) == null; } @@ -1480,7 +1439,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp @Override public boolean filter(IConnection conn) { IClient client = conn.getClient(); - return (!sendScreen && SessionVariablesUtil.isScreenClient(client)) + return (!sendScreen && IClientUtil.isSharing(client)) || (!sendSelf && current != null && client.getId().equals(current.getClient().getId())); } }.start(); @@ -1570,7 +1529,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public int sendMessageWithClientWithSyncObject(Object newMessage, boolean sync) { try { IConnection current = Red5.getConnectionLocal(); - Client currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Map<String, Object> hsm = new HashMap<>(); hsm.put("client", currentClient); @@ -1628,7 +1587,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public int sendMessageWithClientById(Object newMessage, String clientId) { try { IConnection current = Red5.getConnectionLocal(); - Client currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Map<String, Object> hsm = new HashMap<>(); hsm.put("client", currentClient); @@ -1655,7 +1614,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp } // Get Room Id to send it to the correct Scope - Client currentClient = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient currentClient = sessionManager.get(publicSID); if (currentClient == null) { throw new Exception("Could not Find RoomClient on List publicSID: " + publicSID); @@ -1669,12 +1628,12 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp for (IConnection conn : scope.getClientConnections()) { IClient client = conn.getClient(); - if (SessionVariablesUtil.isScreenClient(client)) { + if (IClientUtil.isSharing(client)) { // screen sharing clients do not receive events continue; } - if (publicSID.equals(SessionVariablesUtil.getPublicSID(client))) { + if (publicSID.equals(IClientUtil.getId(client))) { ((IServiceCapableConnection) conn).invoke("newMessageByRoomAndDomain", new Object[] { message }, this); } } @@ -1699,7 +1658,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl.getIsRecording()) { return true; @@ -1724,19 +1683,19 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl != null && rcl.getIsRecording()) { return false; } } } - Client current_rcl = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient current_rcl = sessionManager.get(IClientUtil.getId(current.getClient())); // Also set the Recording Flag to Record all Participants that enter // later current_rcl.setIsRecording(true); - sessionManager.updateClientByStreamId(current.getClient().getId(), current_rcl, false, null); + sessionManager.update(current_rcl); Map<String, String> interviewStatus = new HashMap<>(); interviewStatus.put("action", "start"); @@ -1744,7 +1703,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp for (IConnection conn : current.getScope().getClientConnections()) { if (conn != null) { IClient client = conn.getClient(); - if (SessionVariablesUtil.isScreenClient(client)) { + if (IClientUtil.isSharing(client)) { // screen sharing clients do not receive events continue; } @@ -1771,7 +1730,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp @Override public boolean filter(IConnection conn) { IClient client = conn.getClient(); - return !SessionVariablesUtil.isScreenClient(client) || !conn.getClient().getId().equals(streamid); + return !IClientUtil.isSharing(client) || !conn.getClient().getId().equals(streamid); } }.start(); return true; @@ -1780,7 +1739,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp private Long checkRecordingClient(IConnection conn) { Long recordingId = null; if (conn != null) { - Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null); + StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient())); if (rcl != null && rcl.getIsRecording()) { rcl.setIsRecording(false); recordingId = rcl.getRecordingId(); @@ -1788,7 +1747,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp // Reset the Recording Flag to Record all // Participants that enter later - sessionManager.updateClientByStreamId(conn.getClient().getId(), rcl, false, null); + sessionManager.update(rcl); } } return recordingId; @@ -1801,7 +1760,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp */ public boolean stopInterviewRecording() { IConnection current = Red5.getConnectionLocal(); - Client currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); return _stopInterviewRecording(currentClient, current.getScope()); } @@ -1810,7 +1769,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * * @return true if interview was found */ - private boolean _stopInterviewRecording(Client currentClient, IScope currentScope) { + private boolean _stopInterviewRecording(StreamClient currentClient, IScope currentScope) { try { _log.debug("----------- stopInterviewRecording"); Long clientRecordingId = currentClient.getRecordingId(); @@ -1846,12 +1805,12 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * * @return all ClientList Objects of that room */ - public List<Client> getClientListScope() { + public List<StreamClient> getClientListScope() { try { IConnection current = Red5.getConnectionLocal(); - Client currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); - return sessionManager.getClientListByRoom(currentClient.getRoomId()); + return sessionManager.listByRoom(currentClient.getRoomId()); } catch (Exception err) { _log.debug("[getClientListScope]", err); } @@ -1881,12 +1840,12 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp * SIP transport methods */ - private List<Long> getVerifiedActiveRoomIds(Server s) { - List<Long> result = new ArrayList<>(sessionManager.getActiveRoomIdsByServer(s)); + private List<Long> getVerifiedActiveRoomIds() { + List<Long> result = new ArrayList<>(sessionManager.getActiveRoomIds()); //verify for (Iterator<Long> i = result.iterator(); i.hasNext();) { Long id = i.next(); - List<Client> rcs = sessionManager.getClientListByRoom(id); + List<StreamClient> rcs = sessionManager.listByRoom(id); if (rcs.size() == 0 || (rcs.size() == 1 && rcs.get(0).isSipTransport())) { i.remove(); } @@ -1913,28 +1872,24 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public List<Long> getActiveRoomIds() { Set<Long> ids = new HashSet<>(); - ids.addAll(getVerifiedActiveRoomIds(null)); - for (Server s : serverDao.getActiveServers()) { - ids.addAll(getVerifiedActiveRoomIds(s)); - } + ids.addAll(getVerifiedActiveRoomIds()); return new ArrayList<>(ids); } public synchronized int updateSipTransport() { _log.debug("----------- updateSipTransport"); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client client = sessionManager.getClientByStreamId(streamid, null); + StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = client.getRoomId(); Integer count = roomManager.getSipConferenceMembersNumber(roomId); String newNumber = getSipTransportLastname(count); _log.debug("getSipConferenceMembersNumber: " + newNumber); if (!newNumber.equals(client.getLastname())) { IApplication iapp = (IApplication)Application.get(wicketApplicationName); - org.apache.openmeetings.db.entity.basic.Client cl = iapp.getOmOnlineClient(client.getPublicSID()); + Client cl = iapp.getOmOnlineClient(client.getPublicSID()); cl.getUser().setLastname(newNumber); client.setLastname(newNumber); - sessionManager.updateClientByStreamId(streamid, client, false, null); + sessionManager.update(client); _log.debug("updateSipTransport: {}, {}, {}, {}, {}", new Object[] { client.getPublicSID(), client.getRoomId(), client.getFirstname(), client.getLastname(), client.getAvsettings() }); WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.rightUpdated, client.getPublicSID())); @@ -1946,16 +1901,15 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp public void setSipTransport(String broadCastId) { _log.debug("----------- setSipTransport"); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); // Notify all clients of the same scope (room) - Client c = sessionManager.getClientByStreamId(streamid, null); + StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient())); IApplication iapp = (IApplication)Application.get(wicketApplicationName); - org.apache.openmeetings.db.entity.basic.Client cl = iapp.getOmOnlineClient(c.getPublicSID()); + Client cl = iapp.getOmOnlineClient(c.getPublicSID()); String newNumber = getSipTransportLastname(c.getRoomId()); cl.getUser().setLastname(newNumber); c.setLastname(newNumber); c.setBroadCastID(Long.parseLong(broadCastId)); - sessionManager.updateClientByStreamId(streamid, c, false, null); + sessionManager.update(c); WebSocketHelper.sendRoom(new TextRoomMessage(c.getRoomId(), c.getUserId(), RoomMessage.Type.rightUpdated, c.getPublicSID())); sendMessageToCurrentScope("addNewUser", c, false); http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java index 7cc741a..8959396 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java @@ -19,26 +19,15 @@ package org.apache.openmeetings.core.remote; import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; -import static org.apache.openmeetings.util.OpenmeetingsVariables.wicketApplicationName; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import org.apache.openmeetings.IApplication; -import org.apache.openmeetings.db.dao.server.ISessionManager; -import org.apache.openmeetings.db.dao.server.ServerDao; import org.apache.openmeetings.db.dao.server.SessiondataDao; -import org.apache.openmeetings.db.dao.user.IUserService; import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.room.Client; -import org.apache.openmeetings.db.entity.server.Server; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.util.AuthLevelUtil; -import org.apache.wicket.Application; import org.red5.logging.Red5LoggerFactory; -import org.red5.server.api.scope.IScope; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -48,21 +37,13 @@ import org.springframework.beans.factory.annotation.Autowired; * @author sebawagner * */ -public class UserService implements IUserService { +public class UserService { private static final Logger log = Red5LoggerFactory.getLogger(UserService.class, webAppRootKey); @Autowired - private ISessionManager sessionManager; - @Autowired - private ScopeApplicationAdapter scopeApplicationAdapter; - @Autowired private SessiondataDao sessionDao; @Autowired private UserDao userDao; - @Autowired - private ServerDao serverDao; - @Autowired - private ISlaveHTTPConnectionManager slaveHTTPConnectionManager; /** * get user by id, admin only @@ -111,115 +92,4 @@ public class UserService implements IUserService { } return null; } - - /** - * kicks a user from the server, also from slaves if needed, this method is - * only invoked by the connection administration UI - * - * @param sid - * @param streamid - * @param serverId - * 0 means the session is locally, otherwise we have to perform a - * REST call - * @return - true if user has sufficient permissions, false otherwise - */ - @Override - public boolean kickUserByStreamId(String sid, String streamid, long serverId) { - try { - Sessiondata sd = sessionDao.check(sid); - // admins only - if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) { - if (serverId == 0) { - Client rcl = sessionManager.getClientByStreamId(streamid, null); - - if (rcl == null) { - return true; - } - String scopeName = "hibernate"; - if (rcl.getRoomId() != null) { - scopeName = rcl.getRoomId().toString(); - } - IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName); - - Map<Integer, String> messageObj = new HashMap<>(); - messageObj.put(0, "kick"); - scopeApplicationAdapter.sendMessageById(messageObj, streamid, currentScope); - - scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope); - - return true; - } else { - Server server = serverDao.get(serverId); - Client rcl = sessionManager.getClientByStreamId( - streamid, server); - slaveHTTPConnectionManager.kickSlaveUser(server, rcl.getPublicSID()); - - // true means only the REST call is performed, it is no - // confirmation that the user is really kicked from the - // slave - return true; - } - } - } catch (Exception err) { - log.error("[kickUserByStreamId]", err); - } - return false; - } - - /** - * Kick a user by its publicSID.<br/> - * <br/> - * <i>Note:</i> - * This method will not perform a call to the slave, cause this call can only be - * invoked from inside the conference room, that means all clients are on the - * same server, no matter if clustered or not. - * - * @param sid - * @param publicSID - * @return - true in case user have sufficient permissions, null otherwise - */ - public boolean kickUserByPublicSID(String sid, String publicSID) { - try { - Sessiondata sd = sessionDao.check(sid); - // users only - if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) { - Client rcl = sessionManager.getClientByPublicSID(publicSID, null); - - if (rcl == null) { - return true; - } - String scopeName = "hibernate"; - if (rcl.getRoomId() != null) { - scopeName = rcl.getRoomId().toString(); - } - IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName); - - Map<Integer, String> messageObj = new HashMap<>(); - messageObj.put(0, "kick"); - - scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope); - scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope); - - return true; - } - } catch (Exception err) { - log.error("[kickUserByPublicSID]", err); - } - return false; - } - - @Override - public boolean kickUserBySessionId(String sid, long userId, String sessionId) { - try { - Sessiondata sd = sessionDao.check(sid); - // admin only - if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) { - ((IApplication)Application.get(wicketApplicationName)).invalidateClient(userId, sessionId); - return true; - } - } catch (Exception err) { - log.error("[kickUserBySessionId]", err); - } - return false; - } } http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/WhiteboardService.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/WhiteboardService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/WhiteboardService.java index d597aa3..73cc162 100644 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/WhiteboardService.java +++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/WhiteboardService.java @@ -34,6 +34,7 @@ import java.util.Map; import org.apache.commons.collections4.ComparatorUtils; import org.apache.openmeetings.core.data.whiteboard.WhiteboardCache; import org.apache.openmeetings.core.data.whiteboard.WhiteboardObjectSyncManager; +import org.apache.openmeetings.core.util.IClientUtil; import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.db.dao.label.LabelDao; import org.apache.openmeetings.db.dao.server.ISessionManager; @@ -43,7 +44,7 @@ import org.apache.openmeetings.db.dto.room.Cliparts; import org.apache.openmeetings.db.dto.room.Whiteboard; import org.apache.openmeetings.db.dto.room.WhiteboardSyncLockObject; import org.apache.openmeetings.db.dto.room.Whiteboards; -import org.apache.openmeetings.db.entity.room.Client; +import org.apache.openmeetings.db.entity.room.StreamClient; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.util.AuthLevelUtil; @@ -82,8 +83,7 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean getNewWhiteboardId(String name) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); Long whiteBoardId = wbCache.getNewWhiteboardId(roomId, name); @@ -98,8 +98,7 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean deleteWhiteboard(Long whiteBoardId) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); Whiteboards whiteboards = wbCache.get(roomId); @@ -122,8 +121,7 @@ public class WhiteboardService implements IPendingServiceCallback { Map<Long, Whiteboard> result = new LinkedHashMap<>(); try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); log.debug("getRoomItems: " + roomId); @@ -155,8 +153,7 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean rename(Long wbId, String name) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); Whiteboards whiteboards = wbCache.get(roomId); @@ -185,17 +182,16 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean setCanDraw(String sid, String publicSID, boolean canDraw) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Sessiondata sd = sessionDao.check(sid); if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) { if (currentClient.getIsMod()) { - Client rcl = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient rcl = sessionManager.get(publicSID); if (rcl != null) { rcl.setCanDraw(canDraw); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); Map<Integer, Object> newMessage = new HashMap<>(); newMessage.put(0, "updateDrawStatus"); @@ -214,17 +210,16 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean setCanShare(String sid, String publicSID, boolean canShare) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Sessiondata sd = sessionDao.check(sid); if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) { if (currentClient.getIsMod()) { - Client rcl = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient rcl = sessionManager.get(publicSID); if (rcl != null) { rcl.setCanShare(canShare); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); Map<Integer, Object> newMessage = new HashMap<>(); newMessage.put(0, "updateDrawStatus"); @@ -243,17 +238,16 @@ public class WhiteboardService implements IPendingServiceCallback { public boolean setCanRemote(String sid, String publicSID, boolean canRemote) { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Sessiondata sd = sessionDao.check(sid); if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) { if (currentClient.getIsMod()) { - Client rcl = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient rcl = sessionManager.get(publicSID); if (rcl != null) { rcl.setCanRemote(canRemote); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); Map<Integer, Object> newMessage = new HashMap<>(); newMessage.put(0, "updateDrawStatus"); @@ -273,17 +267,16 @@ public class WhiteboardService implements IPendingServiceCallback { try { log.debug("[setCanGiveAudio] " + sid + ", " + publicSID + ", " + canGiveAudio); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Sessiondata sd = sessionDao.check(sid); if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) { if (currentClient.getIsMod()) { - Client rcl = sessionManager.getClientByPublicSID(publicSID, null); + StreamClient rcl = sessionManager.get(publicSID); if (rcl != null) { rcl.setCanGiveAudio(canGiveAudio); - sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null); + sessionManager.update(rcl); Map<Integer, Object> newMessage = new HashMap<>(); newMessage.put(0, "updateGiveAudioStatus"); @@ -302,8 +295,7 @@ public class WhiteboardService implements IPendingServiceCallback { public WhiteboardSyncLockObject startNewSyncprocess() { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); WhiteboardSyncLockObject wSyncLockObject = new WhiteboardSyncLockObject(); @@ -332,8 +324,7 @@ public class WhiteboardService implements IPendingServiceCallback { public void sendCompletedSyncEvent() { try { IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); Map<String, WhiteboardSyncLockObject> syncListRoom = wbListManager.getWhiteBoardSyncListByRoomid(roomId); @@ -384,8 +375,7 @@ public class WhiteboardService implements IPendingServiceCallback { log.debug("startNewObjectSyncprocess: " + objectId); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); WhiteboardSyncLockObject wSyncLockObject = new WhiteboardSyncLockObject(); @@ -412,8 +402,7 @@ public class WhiteboardService implements IPendingServiceCallback { log.debug("sendCompletedObjectSyncEvent: " + objectId); IConnection current = Red5.getConnectionLocal(); - String streamid = current.getClient().getId(); - Client currentClient = sessionManager.getClientByStreamId(streamid, null); + StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient())); Long roomId = currentClient.getRoomId(); Map<String, WhiteboardSyncLockObject> syncListImage = wbListManager.getWhiteBoardObjectSyncListByRoomAndObjectId(roomId, objectId); @@ -449,7 +438,7 @@ public class WhiteboardService implements IPendingServiceCallback { return -1; } - public synchronized void removeUserFromAllLists(IScope scope, Client currentClient) { + public synchronized void removeUserFromAllLists(IScope scope, StreamClient currentClient) { try { Long roomId = currentClient.getRoomId(); http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java ---------------------------------------------------------------------- diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java deleted file mode 100644 index 41502dd..0000000 --- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.core.remote.util; - -import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; - -import org.red5.logging.Red5LoggerFactory; -import org.red5.server.api.IClient; -import org.slf4j.Logger; - -public class SessionVariablesUtil { - private static final Logger log = Red5LoggerFactory.getLogger(SessionVariablesUtil.class, webAppRootKey); - - private enum SESSION_VARIABLES { - isScreenClient, // if the client connection is from a Java Web-Start application - PUBLIC_SID, // the public SID of the client - USER_ID, // the userId of the user that is using this connection (if there is any) - } - - public static void initClient(IClient client, String publicSID) { - client.setAttribute(SESSION_VARIABLES.PUBLIC_SID.toString(), publicSID); - } - - public static String getPublicSID(IClient client) { - try { - if (client.getAttribute(SESSION_VARIABLES.PUBLIC_SID.toString()) == null) { - throw new Exception("Connection has no publicSID client: " + client); - } - return (String) client.getAttribute(SESSION_VARIABLES.PUBLIC_SID.toString()); - } catch (Exception err) { - log.error("[getPublicSID]", err); - } - return null; - } - - public static void setIsScreenClient(IClient client) { - client.setAttribute(SESSION_VARIABLES.isScreenClient.toString(), true); - } - - public static boolean isScreenClient(IClient client) { - try { - if (client.getAttribute(SESSION_VARIABLES.isScreenClient.toString()) == null) { - return false; - } - if ((Boolean) client.getAttribute(SESSION_VARIABLES.isScreenClient.toString())) { - return true; - } - } catch (Exception err) { - log.error("[isScreenClient]", err); - } - return false; - } - - public static void setUserId(IClient client, Long userId) { - client.setAttribute(SESSION_VARIABLES.USER_ID.toString(), userId); - } - - /** - * if there is no user id set, it will return Long.MIN_VALUE - * - * @param client - * @return - user id set or Long.MIN_VALUE or null if any exception happens - */ - public static Long getUserId(IClient client) { - try { - if (client.getAttribute(SESSION_VARIABLES.USER_ID.toString()) == null) { - return Long.MIN_VALUE; - } - return (Long) client.getAttribute(SESSION_VARIABLES.USER_ID.toString()); - } catch (Exception err) { - log.error("[getUserId]", err); - } - return null; - } -}
