[OPENMEETINGS-1646] work with streams refactored (incomplete)

Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/117e8d6b
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/117e8d6b
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/117e8d6b

Branch: refs/heads/master
Commit: 117e8d6bcef5a17efdb4287a20ad6b7e1daf7049
Parents: 417fdd6
Author: Maxim Solodovnik <[email protected]>
Authored: Fri Jun 30 12:46:47 2017 +0700
Committer: Maxim Solodovnik <[email protected]>
Committed: Fri Jun 30 12:46:47 2017 +0700

----------------------------------------------------------------------
 .../openmeetings/core/remote/MobileService.java |  72 +-
 .../core/remote/RecordingService.java           | 116 ++--
 .../core/remote/ScopeApplicationAdapter.java    | 425 ++++--------
 .../openmeetings/core/remote/UserService.java   | 225 ------
 .../core/remote/util/SessionVariablesUtil.java  |  91 ---
 .../core/session/SessionManager.java            | 154 +----
 .../core/session/store/DatabaseStore.java       |  28 +-
 .../core/session/store/HashMapStore.java        |  63 +-
 .../session/store/IClientPersistenceStore.java  |  59 +-
 .../openmeetings/core/util/IClientUtil.java     |  55 ++
 .../openmeetings/core/util/RoomHelper.java      |  14 +-
 .../org/apache/openmeetings/IApplication.java   |  10 +-
 .../openmeetings/db/dao/room/ClientDao.java     |  60 +-
 .../db/dao/server/ISessionManager.java          |  59 +-
 .../openmeetings/db/dao/user/IUserManager.java  |   5 +-
 .../openmeetings/db/dao/user/IUserService.java  |  26 -
 .../openmeetings/db/entity/basic/Client.java    |  98 ++-
 .../db/entity/log/ConferenceLog.java            |   2 +-
 .../db/entity/room/StreamClient.java            | 684 ++++++-------------
 openmeetings-flash/src/main/flex/main.mxml      |   4 +-
 .../flex/org/apache/openmeetings/OmVideo.as     |   2 +-
 .../apache/openmeetings/screenshare/Core.java   |  30 +-
 .../src/main/jnlp/templates/template.jnlp       |   2 +-
 .../openmeetings/service/user/UserManager.java  |  74 +-
 .../web/admin/connection/ConnectionsPanel.java  |  15 +-
 .../openmeetings/web/admin/rooms/RoomForm.java  |   7 +-
 .../openmeetings/web/app/Application.java       | 126 ++--
 .../apache/openmeetings/web/app/WebSession.java |  27 +-
 .../openmeetings/web/common/MainPanel.java      |  23 +-
 .../openmeetings/web/room/RoomBroadcaster.java  |  10 +-
 .../apache/openmeetings/web/room/RoomPanel.java |  55 +-
 .../openmeetings/web/room/VideoSettings.java    |   9 +-
 .../web/room/menu/RoomMenuPanel.java            |   4 +-
 .../web/room/menu/StartSharingButton.java       |   6 +-
 .../org/apache/openmeetings/web/room/room.js    |  32 +-
 .../WEB-INF/classes/applicationContext.xml      |   1 -
 .../webapp/WEB-INF/classes/logback-config.xml   |   2 +-
 .../test/poll/TestClientListManager.java        |  43 --
 .../test/session/TestDbSession.java             | 109 +--
 .../test/session/TestDbSessionGetRoomIds.java   |  23 +-
 .../test/session/TestHashMapSession.java        |  50 +-
 .../openmeetings/webservice/RoomWebService.java |   2 +-
 .../openmeetings/webservice/UserWebService.java |  53 +-
 .../webservice/cluster/UserService.java         |   6 +-
 44 files changed, 1061 insertions(+), 1900 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/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 d6487e0..c3b7dac 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
@@ -39,7 +39,7 @@ import java.util.UUID;
 
 import org.apache.commons.lang3.time.FastDateFormat;
 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;
@@ -216,25 +216,40 @@ 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();
-                       StreamClient c = 
sessionManager.getClientByStreamId(streamId, null);
+                       StreamClient c = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
                        if (c == null) {
                                // Failed to create client
                                result.put("status", -1);
                        } else {
-                               Sessiondata sd = 
sessionDao.check(c.getSecurityCode());
+                               Sessiondata sd = 
sessionDao.check(c.getOwnerSid());
                                sd.setUserId(u.getId());
                                sd.setLanguageId(u.getLanguageId());
                                sessionDao.update(sd);
-                               
SessionVariablesUtil.initClient(conn.getClient(), c.getPublicSID());
                                c.setUserId(u.getId());
                                c.setFirstname(u.getFirstname());
                                c.setLastname(u.getLastname());
-                               //TODO rights
-                               sessionManager.updateClientByStreamId(streamId, 
c, false, null);
+                               /*TODO check this
+                               rcm.setMobile(true);
+                               rcm.setUserId(sd.getUserId());
+                               if (rcm.getUserId() != null) {
+                                       User u = userDao.get(rcm.getUserId());
+                                       if (u == null) {
+                                               _log.error("Attempt of 
unauthorized room enter: USER not found, client is rejected");
+                                               return rejectClient();
+                                       }
+                                       rcm.setUsername(u.getLogin());
+                                       rcm.setFirstname(u.getFirstname());
+                                       rcm.setLastname(u.getLastname());
+                                       rcm.setEmail(u.getAddress() == null ? 
null : u.getAddress().getEmail());
+                               }
+                               rcm.setSecurityCode(sd.getSessionId());
+                               rcm.setPublicSID(UUID.randomUUID().toString());
+                               */
+                               sessionManager.update(c);
+                               IClientUtil.init(conn.getClient(), c.getId(), 
false);
 
                                add(result, "sid", sd.getSessionId());
-                               add(result, "publicSid", c.getPublicSID());
+                               add(result, "uid", c.getUid());
                                add(result, "status", 0);
                                add(result, "userId", u.getId());
                                add(result, "firstname", u.getFirstname());
@@ -254,21 +269,22 @@ public class MobileService {
                IConnection current = Red5.getConnectionLocal();
                for (IConnection conn : 
current.getScope().getClientConnections()) {
                        if (conn != null && conn instanceof 
IServiceCapableConnection) {
-                               StreamClient c = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
-                               if (!Strings.isEmpty(c.getAvsettings()) && 
!c.isScreenClient()) {
+                               StreamClient c = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
+                               if (!Strings.isEmpty(c.getAvsettings()) && 
!c.isSharing()) {
+                                       //TODO duplicates !!!!!!!!!!!!!!
                                        Map<String, Object> map = new 
HashMap<>();
-                                       add(map, "streamId", c.getStreamid());
+                                       add(map, "id", c.getId());
                                        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, "uid", c.getUid());
                                        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());
+                                       add(map, "vWidth", c.getWidth());
+                                       add(map, "vHeight", c.getHeight());
                                        result.add(map);
                                }
                        }
@@ -296,7 +312,7 @@ public class MobileService {
                List<Map<String, Object>> result = new ArrayList<>();
                // FIXME duplicated code
                IConnection current = Red5.getConnectionLocal();
-               StreamClient 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<>();
@@ -333,25 +349,25 @@ public class MobileService {
        public Map<String, Object> roomConnect(String SID, Long userId) {
                // publicSid is changed on mobile room connect
                IConnection current = Red5.getConnectionLocal();
-               StreamClient 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());
+               //FIXME TODO result.put("publicSid", c.getPublicSID());
                return result;
        }
 
        public Map<String, Object> updateAvMode(String avMode, String width, 
String height, Integer interviewPodId) {
                IConnection current = Red5.getConnectionLocal();
-               StreamClient c = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
+               StreamClient c = 
sessionManager.get(IClientUtil.getId(current.getClient()));
                c.setAvsettings(avMode);
                if (!"n".equals(avMode)) {
-                       c.setIsBroadcasting(true);
+                       c.setBroadcasting(true);
                }
-               c.setVWidth(Double.valueOf(width).intValue());
-               c.setVHeight(Double.valueOf(height).intValue());
+               c.setWidth(Double.valueOf(width).intValue());
+               c.setHeight(Double.valueOf(height).intValue());
                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});
@@ -362,7 +378,7 @@ public class MobileService {
 
        public void sendChatMessage(String msg) {
                IConnection current = Red5.getConnectionLocal();
-               StreamClient c = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
+               StreamClient c = 
sessionManager.get(IClientUtil.getId(current.getClient()));
 
                ChatMessage m = new ChatMessage();
                m.setMessage(msg);
@@ -379,7 +395,7 @@ public class MobileService {
        }
 
        public void sendChatMessage(String uid, ChatMessage m, FastDateFormat 
fmt) {
-               sendChatMessage(sessionManager.getClientByPublicSID(uid, null), 
m, fmt);
+               sendChatMessage(sessionManager.getClientByUid(uid, null), m, 
fmt);
        }
 
        public void sendChatMessage(StreamClient c, ChatMessage m, 
FastDateFormat fmt) {
@@ -395,15 +411,15 @@ public class MobileService {
                new MessageSender(scopeAdapter.getRoomScope("" + roomId), 
"sendVarsToMessageWithClient", hsm, scopeAdapter) {
                        @Override
                        public boolean filter(IConnection conn) {
-                               StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
-                               return rcl.isScreenClient()
+                               StreamClient rcl = 
sessionManager.get(IClientUtil.getId(current.getClient()));
+                               return rcl.isSharing()
                                                || rcl.getRoomId() == null || 
!rcl.getRoomId().equals(roomId);
                        }
                }.start();
        }
 
        private static boolean isModerator(StreamClient c) {
-               return c.getIsMod() || c.getIsSuperModerator();
+               return c.isMod() || c.isSuperMod();
        }
 
        private static FastDateFormat getFmt(User u) {
@@ -426,7 +442,7 @@ public class MobileService {
                List<Map<String,Object>> myChatList = new ArrayList<>();
                try {
                        IConnection current = Red5.getConnectionLocal();
-                       StreamClient 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/117e8d6b/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 93ff702..14d584b 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;
@@ -46,7 +47,6 @@ import org.apache.openmeetings.util.message.RoomMessage;
 import org.apache.openmeetings.util.message.TextRoomMessage;
 import org.red5.logging.Red5LoggerFactory;
 import org.red5.server.api.IConnection;
-import org.red5.server.api.Red5;
 import org.red5.server.api.scope.IScope;
 import org.red5.server.api.service.IPendingServiceCall;
 import org.red5.server.api.service.IPendingServiceCallback;
@@ -121,8 +121,8 @@ public class RecordingService implements 
IPendingServiceCallback {
                        recording.setRoomId(roomId);
                        recording.setRecordStart(now);
 
-                       recording.setWidth(client.getVWidth());
-                       recording.setHeight(client.getVHeight());
+                       recording.setWidth(client.getWidth());
+                       recording.setHeight(client.getHeight());
 
                        recording.setOwnerId(ownerId);
                        recording.setStatus(Recording.Status.RECORDING);
@@ -132,35 +132,35 @@ public class RecordingService implements 
IPendingServiceCallback {
                        log.debug("##REC:: recording created by USER: " + 
ownerId);
 
                        // Update Client and set Flag
-                       client.setIsRecording(true);
+                       client.setRecordingStarted(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) {
-                                               StreamClient 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()));
+                                               WebSocketHelper.sendRoom(new 
TextRoomMessage(roomId, ownerId, RoomMessage.Type.recordingStarted, 
client.getOwnerSid()));
 
                                                // If its the recording client 
we need another type of Meta Data
-                                               if (rcl.isScreenClient()) {
-                                                       if 
(rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
-                                                               String 
streamName_Screen = generateFileName(recordingId, 
rcl.getStreamPublishName().toString());
+                                               if (rcl.isSharing()) {
+                                                       if 
(rcl.getRecordingId() != null && rcl.isSharingStarted()) {
+                                                               String 
streamName_Screen = generateFileName(recordingId, rcl.getBroadCastId());
 
                                                                Long metaDataId 
= metaDataDao.add(
                                                                                
recordingId, rcl.getFirstname() + " " + rcl.getLastname(), now, false,
                                                                                
false, true, streamName_Screen, rcl.getInterviewPodId());
 
                                                                // Start FLV 
Recording
-                                                               
recordShow(conn, rcl.getStreamPublishName(), streamName_Screen, metaDataId, 
true, isInterview);
+                                                               
recordShow(conn, rcl.getBroadCastId(), streamName_Screen, metaDataId, true, 
isInterview);
 
                                                                // Add Meta Data
-                                                               
rcl.setRecordingMetaDataId(metaDataId);
+                                                               
rcl.setMetaId(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
@@ -183,9 +183,9 @@ public class RecordingService implements 
IPendingServiceCallback {
                                                                        
rcl.getFirstname() + " " + rcl.getLastname(), now, isAudioOnly, isVideoOnly, 
false, streamName,
                                                                        
rcl.getInterviewPodId());
 
-                                                       
rcl.setRecordingMetaDataId(metaId);
+                                                       rcl.setMetaId(metaId);
 
-                                                       
sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+                                                       
sessionManager.update(rcl);
 
                                                        // Start FLV recording
                                                        recordShow(conn, 
broadcastId, streamName, metaId, !isAudioOnly, isInterview);
@@ -212,8 +212,8 @@ public class RecordingService implements 
IPendingServiceCallback {
         */
        private void recordShow(IConnection conn, String broadcastid, String 
streamName, Long metaId, boolean isScreenData, boolean isInterview) throws 
Exception {
                try {
-                       log.debug("Recording show for: " + 
conn.getScope().getContextPath());
-                       log.debug("Name of CLient and Stream to be recorded: " 
+ broadcastid);
+                       log.debug("Recording show for: {}", 
conn.getScope().getContextPath());
+                       log.debug("Name of CLient and Stream to be recorded: 
{}", broadcastid);
                        // 
log.debug("Application.getInstance()"+Application.getInstance());
                        log.debug("Scope " + conn);
                        log.debug("Scope " + conn.getScope());
@@ -309,33 +309,32 @@ public class RecordingService implements 
IPendingServiceCallback {
        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()));
+                       WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.recordingStoped, client.getOwnerSid()));
 
                        // get all stream and stop recording them
                        for (IConnection conn : scope.getClientConnections()) {
                                if (conn != null) {
                                        if (conn instanceof 
IServiceCapableConnection) {
-                                               StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+                                               StreamClient rcl = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
 
                                                if (rcl == null) {
                                                        continue;
                                                }
                                                log.debug("is this users still 
alive? stop it :" + rcl);
 
-                                               if (rcl.isScreenClient()) {
-                                                       if 
(rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
+                                               if (rcl.isSharing()) {
+                                                       if 
(rcl.getRecordingId() != null && rcl.isSharingStarted()) {
                                                                // Stop FLV 
Recording
-                                                               
stopRecordingShow(scope, rcl.getStreamPublishName(), 
rcl.getRecordingMetaDataId());
+                                                               
stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
 
                                                                // Update Meta 
Data
-                                                               
metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+                                                               
metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
                                                        }
                                                } else if 
(rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || 
rcl.getAvsettings().equals("v")) {
-
-                                                       
stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getRecordingMetaDataId());
+                                                       
stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
 
                                                        // Update Meta Data
-                                                       
metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+                                                       
metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
                                                }
                                        }
                                }
@@ -354,10 +353,10 @@ public class RecordingService implements 
IPendingServiceCallback {
 
                                // Reset values
                                client.setRecordingId(null);
-                               client.setIsRecording(false);
+                               client.setRecordingStarted(false);
 
-                               
sessionManager.updateClientByStreamId(client.getStreamid(), client, false, 
null);
-                               log.debug("recordingConverterTask ", 
recordingConverterTask);
+                               sessionManager.update(client);
+                               log.debug("recordingConverterTask {}", 
recordingConverterTask);
 
                                Recording recording = 
recordingDao.get(recordingId);
                                if (!recording.isInterview()) {
@@ -371,29 +370,7 @@ public class RecordingService implements 
IPendingServiceCallback {
                }
        }
 
-       public StreamClient checkLzRecording() {
-               try {
-                       IConnection current = Red5.getConnectionLocal();
-                       String streamid = current.getClient().getId();
-
-                       log.debug("getCurrentRoomClient -2- " + streamid);
-
-                       StreamClient currentClient = 
sessionManager.getClientByStreamId(streamid, null);
-
-                       log.debug("getCurrentRoomClient 
-#########################- " + currentClient.getRoomId());
-
-                       for (StreamClient rcl : 
sessionManager.getClientListByRoomAll(currentClient.getRoomId())) {
-                               if (rcl.getIsRecording()) {
-                                       return rcl;
-                               }
-                       }
-
-               } catch (Exception err) {
-                       log.error("[checkLzRecording]", err);
-               }
-               return null;
-       }
-
+       //TODO copy/paste
        public void stopRecordingShowForClient(IScope scope, StreamClient rcl) {
                try {
                        // this cannot be handled here, as to stop a stream and 
to leave a
@@ -403,28 +380,25 @@ public class RecordingService implements 
IPendingServiceCallback {
                        // rcl.getUserip(), false);
                        log.debug("### stopRecordingShowForClient: " + rcl);
 
-                       if (rcl.isScreenClient()) {
-
-                               if (rcl.getRecordingId() != null && 
rcl.isScreenPublishStarted()) {
+                       if (rcl.isSharing()) {
+                               if (rcl.getRecordingId() != null && 
rcl.isSharingStarted()) {
 
                                        // Stop FLV Recording
                                        // FIXME: Is there really a need to 
stop it manually if the
                                        // user just
                                        // stops the stream?
-                                       stopRecordingShow(scope, 
rcl.getStreamPublishName(), rcl.getRecordingMetaDataId());
+                                       stopRecordingShow(scope, 
rcl.getBroadCastId(), rcl.getMetaId());
 
                                        // Update Meta Data
-                                       
metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+                                       
metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
                                }
-
                        } else if (rcl.getAvsettings().equals("a") || 
rcl.getAvsettings().equals("v") || rcl.getAvsettings().equals("av")) {
-
                                // FIXME: Is there really a need to stop it 
manually if the user
                                // just stops the stream?
-                               stopRecordingShow(scope, rcl.getBroadCastId(), 
rcl.getRecordingMetaDataId());
+                               stopRecordingShow(scope, rcl.getBroadCastId(), 
rcl.getMetaId());
 
                                // Update Meta Data
-                               
metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+                               metaDataDao.updateEndDate(rcl.getMetaId(), new 
Date());
                        }
 
                } catch (Exception err) {
@@ -439,22 +413,22 @@ public class RecordingService implements 
IPendingServiceCallback {
                        Date now = new Date();
 
                        // If its the recording client we need another type of 
Meta Data
-                       if (rcl.isScreenClient()) {
-                               if (rcl.getRecordingId() != null && 
rcl.isScreenPublishStarted()) {
-                                       String streamName_Screen = 
generateFileName(recordingId, rcl.getStreamPublishName().toString());
+                       if (rcl.isSharing()) {
+                               if (rcl.getRecordingId() != null && 
rcl.isSharingStarted()) {
+                                       String streamName_Screen = 
generateFileName(recordingId, rcl.getBroadCastId().toString());
 
-                                       log.debug("##############  ADD SCREEN 
OF SHARER :: " + rcl.getStreamPublishName());
+                                       log.debug("##############  ADD SCREEN 
OF SHARER :: {}", rcl.getBroadCastId());
 
                                        Long metaDataId = 
metaDataDao.add(recordingId, rcl.getFirstname()
                                                        + " " + 
rcl.getLastname(), now, false, false, true, streamName_Screen, 
rcl.getInterviewPodId());
 
                                        // Start FLV Recording
-                                       recordShow(conn, 
rcl.getStreamPublishName(), streamName_Screen, metaDataId, true, 
recording.isInterview());
+                                       recordShow(conn, rcl.getBroadCastId(), 
streamName_Screen, metaDataId, true, recording.isInterview());
 
                                        // Add Meta Data
-                                       rcl.setRecordingMetaDataId(metaDataId);
+                                       rcl.setMetaId(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
@@ -478,12 +452,10 @@ public class RecordingService implements 
IPendingServiceCallback {
                                // Start FLV recording
                                recordShow(conn, rcl.getBroadCastId(), 
streamName, metaDataId, false, recording.isInterview());
 
-                               rcl.setRecordingMetaDataId(metaDataId);
-
-                               
sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+                               rcl.setMetaId(metaDataId);
 
+                               sessionManager.update(rcl);
                        }
-
                } catch (Exception err) {
                        log.error("[addRecordingByStreamId]", err);
                }

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/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 214883d..8a7085b 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
@@ -43,7 +43,7 @@ import java.util.Properties;
 import java.util.UUID;
 
 import org.apache.openmeetings.IApplication;
-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.label.LabelDao;
@@ -59,8 +59,6 @@ import org.apache.openmeetings.db.entity.log.ConferenceLog;
 import org.apache.openmeetings.db.entity.room.Room;
 import org.apache.openmeetings.db.entity.room.StreamClient;
 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.util.CalendarPatterns;
 import org.apache.openmeetings.util.InitializationContainer;
 import org.apache.openmeetings.util.OmFileHelper;
@@ -69,7 +67,6 @@ import org.apache.openmeetings.util.Version;
 import org.apache.openmeetings.util.message.RoomMessage;
 import org.apache.openmeetings.util.message.TextRoomMessage;
 import org.apache.wicket.Application;
-import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.string.Strings;
 import org.red5.logging.Red5LoggerFactory;
 import org.red5.server.adapter.MultiThreadedApplicationAdapter;
@@ -88,7 +85,7 @@ import com.github.openjson.JSONObject;
 
 public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter 
implements IPendingServiceCallback {
        private static final Logger _log = 
Red5LoggerFactory.getLogger(ScopeApplicationAdapter.class, webAppRootKey);
-       private static final String SECURITY_CODE_PARAM = "securityCode";
+       private static final String OWNER_SID_PARAM = "ownerSid";
        private static final String WIDTH_PARAM = "width";
        private static final String HEIGHT_PARAM = "height";
        public static final String FLASH_SECURE = "secure";
@@ -186,7 +183,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                IServiceCapableConnection service = (IServiceCapableConnection) 
conn;
                String streamId = conn.getClient().getId();
 
-               _log.debug("### Client connected to OpenMeetings, register 
Client StreamId: " + streamId + " scope " + conn.getScope().getName());
+               _log.debug("### Client connected to OpenMeetings, register 
Client StreamId: {} scope {}", streamId, conn.getScope().getName());
 
                // Set StreamId in Client
                service.invoke("setId", new Object[] { streamId }, this);
@@ -199,130 +196,40 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                if ("noclient".equals(uid)) {
                        return true;
                }
-               String securityCode = 
(String)connParams.get(SECURITY_CODE_PARAM);
-               String parentSid = (String)map.get("parentSid");
-               if (parentSid == null) {
-                       parentSid = (String)connParams.get("parentSid");
-               }
-               StringValue scn = 
StringValue.valueOf(conn.getScope().getName());
-               long roomId = scn.toLong(Long.MIN_VALUE);
-               StreamClient rcm = new StreamClient();
-               IApplication iapp = 
(IApplication)Application.get(wicketApplicationName);
-               if (!Strings.isEmpty(securityCode)) {
-                       //this is for external applications like ffmpeg 
[OPENMEETINGS-1574]
-                       if (roomId < 0) {
-                               _log.warn("Trying to enter invalid scope using 
security code, client is rejected:: " + roomId);
-                               return rejectClient();
-                       }
-                       String _uid = null;
-                       for (org.apache.openmeetings.db.entity.basic.Client wcl 
: iapp.getOmRoomClients(roomId)) {
-                               if (wcl.getSid().equals(securityCode)) {
-                                       _uid = wcl.getUid();
-                                       break;
-                               }
-                       }
-                       if (_uid == null) {
-                               _log.warn("Client is not found by security id, 
client is rejected");
-                               return rejectClient();
-                       }
-                       StreamClient parent = 
sessionManager.getClientByPublicSID(_uid, null);
-                       if (parent == null || 
!parent.getScope().equals(scn.toString())) {
-                               _log.warn("Security code is invalid, client is 
rejected");
-                               return rejectClient();
-                       }
-                       rcm.setUsername(parent.getUsername());
-                       rcm.setFirstname(parent.getFirstname());
-                       rcm.setLastname(parent.getLastname());
-                       rcm.setUserId(parent.getUserId());
-                       rcm.setPublicSID(UUID.randomUUID().toString());
-                       rcm.setSecurityCode(_uid);
-                       Number width = (Number)connParams.get(WIDTH_PARAM);
-                       Number height = (Number)connParams.get(HEIGHT_PARAM);
-                       if (width != null && height != null) {
-                               rcm.setVWidth(width.intValue());
-                               rcm.setVHeight(height.intValue());
-                       }
-               }
-               if (Strings.isEmpty(uid) && Strings.isEmpty(securityCode) && 
Strings.isEmpty(parentSid)) {
-                       _log.warn("No UIDs are provided, client is rejected");
+               String ownerSid = (String)connParams.get(OWNER_SID_PARAM);
+               if (Strings.isEmpty(ownerSid)) {
+                       _log.warn("No Owner SID is provided, client is 
rejected");
                        return rejectClient();
                }
-
-               if (map.containsKey("screenClient")) {
-                       org.apache.openmeetings.db.entity.basic.Client parent = 
iapp.getOmClient(uid);
-                       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());
-                       rcm.setStreamPublishName(uid);
-               }
-               rcm.setStreamid(conn.getClient().getId());
-               rcm.setScope(scn.toString());
-               boolean notHibernate = !"hibernate".equals(scn.toString());
-               if (Long.MIN_VALUE != roomId) {
-                       rcm.setRoomId(roomId);
-               } else if (notHibernate) {
+               StreamClient rcm = new StreamClient();
+               rcm.setScope(conn.getScope().getName());
+               if (rcm.getRoomId() == null && 
!"hibernate".equals(rcm.getScope())) {
                        _log.warn("Bad room specified, client is rejected");
                        return rejectClient();
                }
-               if (connParams.containsKey("mobileClient")) {
-                       Sessiondata sd = sessiondataDao.check(parentSid);
-                       if (sd.getUserId() == null && notHibernate) {
-                               _log.warn("Attempt of unauthorized room enter, 
client is rejected");
-                               return rejectClient();
-                       }
-                       rcm.setMobile(true);
-                       rcm.setUserId(sd.getUserId());
-                       if (rcm.getUserId() != null) {
-                               User u = userDao.get(rcm.getUserId());
-                               if (u == null) {
-                                       _log.error("Attempt of unauthorized 
room enter: USER not found, client is rejected");
-                                       return rejectClient();
-                               }
-                               rcm.setUsername(u.getLogin());
-                               rcm.setFirstname(u.getFirstname());
-                               rcm.setLastname(u.getLastname());
-                               rcm.setEmail(u.getAddress() == null ? null : 
u.getAddress().getEmail());
-                       }
-                       rcm.setSecurityCode(sd.getSessionId());
-                       rcm.setPublicSID(UUID.randomUUID().toString());
-               }
+               rcm.setUid(Strings.isEmpty(uid) ? UUID.randomUUID().toString() 
: uid);
+               rcm.setOwnerSid(ownerSid);
                rcm.setUserport(conn.getRemotePort());
                rcm.setUserip(conn.getRemoteAddress());
                rcm.setSwfurl(swfURL);
                rcm.setTcUrl(tcUrl);
-               if (!Strings.isEmpty(uid)) {
-                       rcm.setPublicSID(uid);
+               IApplication iapp = 
(IApplication)Application.get(wicketApplicationName);
+               Number width = (Number)connParams.get(WIDTH_PARAM);
+               Number height = (Number)connParams.get(HEIGHT_PARAM);
+               if (width != null && height != null) {
+                       //this is for external applications like ffmpeg 
[OPENMEETINGS-1574]
+                       rcm.setWidth(width.intValue());
+                       rcm.setHeight(height.intValue());
+               }
+               if (map.containsKey("screenClient")) {
+                       rcm.setSharing(true);
                }
                rcm = sessionManager.add(iapp.updateClient(rcm, false), 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
-                       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);
-                       }
-                       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);
-               }
+               IClientUtil.init(conn.getClient(), rcm.getId(), 
rcm.isSharing());
 
                // Log the User
                conferenceLogDao.add(ConferenceLog.Type.clientConnect,
@@ -337,31 +244,29 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        _log.debug("-----------  screenSharerAction ENTER");
                        IConnection current = Red5.getConnectionLocal();
 
-                       StreamClient client = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
+                       StreamClient client = 
sessionManager.get(IClientUtil.getId(current.getClient()));
 
                        if (client != null) {
                                boolean changed = false;
-                               if (Boolean.parseBoolean("" + 
map.get("stopStreaming")) && client.isStartStreaming()) {
+                               if (Boolean.parseBoolean("" + 
map.get("stopStreaming")) && client.isSharingStarted()) {
                                        changed = true;
-                                       client.setStartStreaming(false);
+                                       client.setSharingStarted(false);
                                        //Send message to all users
                                        
sendMessageToCurrentScope("stopScreenSharingMessage", client, false);
-                                       WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.sharingStoped, client.getStreamPublishName()));
 
                                        returnMap.put("result", 
"stopSharingOnly");
                                }
-                               if (Boolean.parseBoolean("" + 
map.get("stopRecording")) && client.getIsRecording()) {
+                               if (Boolean.parseBoolean("" + 
map.get("stopRecording")) && client.isRecordingStarted()) {
                                        changed = true;
-                                       client.setStartRecording(false);
-                                       client.setIsRecording(false);
+                                       client.setRecordingStarted(false);
 
                                        returnMap.put("result", 
"stopRecordingOnly");
 
                                        
recordingService.stopRecordAndSave(current.getScope(), client, null);
                                }
-                               if (Boolean.parseBoolean("" + 
map.get("stopPublishing")) && client.isScreenPublishStarted()) {
+                               if (Boolean.parseBoolean("" + 
map.get("stopPublishing")) && client.isPublishStarted()) {
                                        changed = true;
-                                       client.setScreenPublishStarted(false);
+                                       client.setPublishStarted(false);
                                        returnMap.put("result", 
"stopPublishingOnly");
 
                                        //Send message to all users
@@ -369,9 +274,9 @@ 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()) {
+                                       if (!client.isSharingStarted() && 
!client.isRecordingStarted() && !client.isPublishStarted()) {
                                                returnMap.put("result", 
"stopAll");
                                        }
                                }
@@ -394,41 +299,34 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        _log.debug("-----------  setConnectionAsSharingClient");
                        IConnection current = Red5.getConnectionLocal();
 
-                       StreamClient 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"));
                                boolean startStreaming = 
Boolean.parseBoolean("" + map.get("startStreaming"));
                                boolean startPublishing = 
Boolean.parseBoolean("" + map.get("startPublishing")) && (0 == 
sessionManager.getPublishingCount(client.getRoomId()));
 
-                               boolean alreadyStreaming = 
client.isStartStreaming();
+                               boolean alreadyStreaming = 
client.isSharingStarted();
                                if (startStreaming) {
-                                       client.setStartStreaming(true);
+                                       client.setSharingStarted(true);
                                }
-                               boolean alreadyRecording = 
client.isStartRecording();
+                               boolean alreadyRecording = 
client.isRecordingStarted();
                                if (startRecording) {
-                                       client.setStartRecording(true);
+                                       client.setRecordingStarted(true);
                                }
+                               boolean alreadyPublishing = 
client.isPublishStarted();
                                if (startPublishing) {
-                                       client.setStreamPublishStarted(true);
+                                       client.setPublishStarted(true);
                                }
 
-                               client.setVX(Double.valueOf("" + 
map.get("screenX")).intValue());
-                               client.setVY(Double.valueOf("" + 
map.get("screenY")).intValue());
-                               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);
+                               client.setWidth(Double.valueOf("" + 
map.get("screenWidth")).intValue());
+                               client.setHeight(Double.valueOf("" + 
map.get("screenHeight")).intValue());
+                               sessionManager.update(client);
 
                                Map<String, Object> returnMap = new HashMap<>();
-                               returnMap.put("alreadyPublished", false);
+                               returnMap.put("alreadyPublished", 
alreadyPublishing);
 
-                               // if is already started screen sharing, then 
there is no need to start it again
-                               if (client.isScreenPublishStarted()) {
-                                       returnMap.put("alreadyPublished", true);
-                               }
-
-                               _log.debug("screen x,y,width,height 
{},{},{},{}", client.getVX(), client.getVY(), client.getVWidth(), 
client.getVHeight());
+                               _log.debug("screen width,height {},{}", 
client.getWidth(), client.getHeight());
 
                                if (startStreaming) {
                                        if (!alreadyStreaming) {
@@ -438,9 +336,9 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
 
                                                //Send message to all users
                                                
sendMessageToCurrentScope("newScreenSharing", client, false);
-                                               WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.sharingStarted, client.getStreamPublishName()));
+                                               WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.sharingStarted, client.getUid()));
                                        } else {
-                                               _log.warn("Streaming is already 
started for the client id=" + client.getId() + ". Second request is ignored.");
+                                               _log.warn("Streaming is already 
started for the client id={}. Second request is ignored.", client.getId());
                                        }
                                }
                                if (startRecording) {
@@ -451,7 +349,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
 
                                                
recordingService.recordMeetingStream(current, client, recordingName, "", false);
                                        } else {
-                                               _log.warn("Recording is already 
started for the client id=" + client.getId() + ". Second request is ignored.");
+                                               _log.warn("Recording is already 
started for the client id={}. Second request is ignored.", client.getId());
                                        }
                                }
                                if (startPublishing) {
@@ -479,7 +377,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                try {
                        _log.debug("[roomLeave] {} {} {} {}", client.getId(), 
room.getClients().size(), room.getContextPath(), room.getName());
 
-                       StreamClient 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
@@ -493,7 +391,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        }
 
        public void roomLeaveByScope(String uid, Long roomId) {
-               StreamClient rcl = sessionManager.getClientByPublicSID(uid, 
null);
+               StreamClient rcl = sessionManager.getClientByUid(uid, null);
                IScope scope = getRoomScope("" + roomId);
                _log.debug("[roomLeaveByScope] {} {} {} {}", uid, roomId, rcl, 
scope);
                if (rcl != null && scope != null) {
@@ -514,30 +412,24 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        public void roomLeaveByScope(StreamClient client, IScope scope) {
                try {
                        _log.debug("[roomLeaveByScope] currentClient " + 
client);
-                       if (client.isScreenClient() && 
client.isStartStreaming()) {
-                               //TODO check others/find better way
-                               WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.sharingStoped, client.getStreamPublishName()));
+                       if (client.isSharing() && client.isSharingStarted()) {
+                               sendSharingStoped(client);
                        }
-                       if (client.getIsBroadcasting()) {
-                               WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.closeStream, client.getPublicSID()));
+                       if (client.isBroadcasting()) {
+                               WebSocketHelper.sendRoom(new 
TextRoomMessage(client.getRoomId(), client.getUserId(), 
RoomMessage.Type.closeStream, client.getUid()));
                        }
 
-                       _log.debug("removing Username " + client.getUsername() 
+ " "
-                                       + client.getConnectedSince() + " 
streamid: "
-                                       + client.getStreamid());
+                       _log.debug("removing Username {} {},  streamid: {}", 
client.getUsername()
+                                       , client.getConnectedSince(), 
client.getId());
 
                        // stop and save any recordings
-                       if (client.getIsRecording()) {
+                       if (client.isRecordingStarted()) {
                                _log.debug("*** roomLeave Current Client is 
Recording - stop that");
                                if (client.getInterviewPodId() != null) {
                                        //interview, TODO need better check
                                        _stopInterviewRecording(client, scope);
                                } else {
                                        
recordingService.stopRecordAndSave(scope, client, null);
-
-                                       // set to true and overwrite the 
default one cause otherwise no
-                                       // notification is send
-                                       client.setIsRecording(true);
                                }
                        }
                        recordingService.stopRecordingShowForClient(scope, 
client);
@@ -546,27 +438,11 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        // and room except the current disconnected cause it 
could throw an exception
                        _log.debug("currentScope " + scope);
 
-                       new MessageSender(scope, "roomDisconnect", client, 
this) {
-                               @Override
-                               public boolean filter(IConnection conn) {
-                                       StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
-                                       if (rcl == null) {
-                                               return true;
-                                       }
-                                       boolean isScreen = rcl.isScreenClient();
-                                       if (isScreen && 
client.getPublicSID().equals(rcl.getStreamPublishName())) {
-                                               //going to terminate screen 
sharing started by this client
-                                               ((IServiceCapableConnection) 
conn).invoke("stopStream", new Object[] { }, callback);
-                                       }
-                                       return isScreen;
-                               }
-                       }.start();
-
                        if (client.isMobile()) {
                                IApplication app = 
(IApplication)Application.get(wicketApplicationName);
-                               app.exit(client.getPublicSID());
+                               app.exit(client.getUid());
                        }
-                       sessionManager.removeClient(client.getStreamid(), null);
+                       sessionManager.remove(client.getId());
                } catch (Exception err) {
                        _log.error("[roomLeaveByScope]", err);
                }
@@ -585,73 +461,71 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                try {
                        _log.debug("-----------  streamPublishStart");
                        IConnection current = Red5.getConnectionLocal();
-                       final String streamid = current.getClient().getId();
-                       final StreamClient c = 
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
-                       StreamClient clientObjectSendToSync = c;
+                       final StreamClient c = 
sessionManager.get(IClientUtil.getId(current.getClient()));
 
                        // Notify all the clients that the stream had been 
started
                        String streamName = stream.getPublishedName();
-                       _log.debug("start streamPublishStart broadcast start: " 
+ streamName + " CONN " + current);
+                       _log.debug("start streamPublishStart broadcast start: 
{}, CONN {}", streamName, current);
                        c.setBroadCastId(streamName);
 
                        // 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);
+                       if (c.isSharing()) {
+                               c.setSharingStarted(true);
                        }
-                       if (!c.isMobile() && 
!Strings.isEmpty(c.getSecurityCode())) {
+                       /* TODO different handling is required for ext video 
source
+                       if (!c.isMobile() && !Strings.isEmpty(c.getOwnerSid())) 
{
                                c.setAvsettings("av");
-                               c.setIsBroadcasting(true);
-                               if (c.getVWidth() == 0 || c.getVHeight() == 0) {
-                                       c.setVWidth(320);
-                                       c.setVHeight(240);
+                               c.setBroadcasting(true);
+                               if (c.getWidth() == 0 || c.getHeight() == 0) {
+                                       c.setWidth(320);
+                                       c.setHeight(240);
                                }
-                               sessionManager.updateClientByStreamId(streamid, 
c, false, null);
                        }
+                       */
+                       sessionManager.update(c);
 
-                       _log.debug("newStream SEND: " + c);
+                       _log.debug("newStream SEND: {}", c);
 
                        // 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, this) {
+                       new MessageSender(current, "newStream", c, this) {
                                @Override
                                public boolean filter(IConnection conn) {
-                                       StreamClient 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");
                                                return true;
                                        }
 
-                                       _log.debug("check send to "+rcl);
+                                       _log.debug("check send to {}", rcl);
 
-                                       if 
(Strings.isEmpty(rcl.getPublicSID())) {
+                                       if (Strings.isEmpty(rcl.getUid())) {
                                                _log.debug("publicSID IS NULL 
newStream SEND");
                                                return true;
                                        }
-                                       if (rcl.getIsRecording()) {
+                                       if (rcl.isRecordingStarted()) {
                                                _log.debug("RCL getIsRecording 
newStream SEND");
                                                
recordingService.addRecordingByStreamId(current, c, rcl.getRecordingId());
                                        }
-                                       if (rcl.isScreenClient()) {
-                                               _log.debug("RCL 
getIsScreenClient newStream SEND");
+                                       if (rcl.isSharing()) {
+                                               _log.debug("RCL getisSharing 
newStream SEND");
                                                return true;
                                        }
 
-                                       if 
(rcl.getPublicSID().equals(c.getPublicSID())) {
+                                       if (rcl.getUid().equals(c.getUid())) {
                                                _log.debug("RCL publicSID is 
equal newStream SEND");
                                                return true;
                                        }
-                                       _log.debug("RCL SEND is equal newStream 
SEND "+rcl.getPublicSID()+" || "+rcl.getUserport());
+                                       _log.debug("RCL SEND is equal newStream 
SEND {} || {}", rcl.getUid(), rcl.getUserport());
                                        return false;
                                }
                        }.start();
                        JSONObject obj = new JSONObject()
-                                       .put("uid", c.getPublicSID())
-                                       .put("screenShare", c.isScreenClient())
+                                       .put("ownerSid", c.getOwnerSid())
+                                       .put("uid", c.getUid())
+                                       .put("screenShare", c.isSharing())
+                                       .put("streamClientId", c.getId())
                                        .put("stream", streamName);
                        WebSocketHelper.sendRoom(new 
TextRoomMessage(c.getRoomId(), c.getUserId(), RoomMessage.Type.newStream, 
obj.toString()));
                } catch (Exception err) {
@@ -670,11 +544,10 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        @Override
        public void streamBroadcastClose(IBroadcastStream stream) {
                // Notify all the clients that the stream had been closed
-               _log.debug("start streamBroadcastClose broadcast close: " + 
stream.getPublishedName());
+               _log.debug("start streamBroadcastClose broadcast close: {}", 
stream.getPublishedName());
                try {
                        IConnection current = Red5.getConnectionLocal();
-                       String streamId = current.getClient().getId();
-                       StreamClient rcl = 
sessionManager.getClientByStreamId(streamId, null);
+                       StreamClient rcl = 
sessionManager.get(IClientUtil.getId(current.getClient()));
 
                        if (rcl == null) {
 
@@ -688,36 +561,41 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
 
                        }
                        // Notify all the clients that the stream had been 
started
-                       _log.debug("streamBroadcastClose : " + rcl + " " + 
rcl.getStreamid());
+                       _log.debug("streamBroadcastClose : {} ", rcl);
                        // this close stream event, stop the recording of this 
stream
-                       if (rcl.getIsRecording()) {
+                       if (rcl.isRecordingStarted()) {
                                _log.debug("***  +++++++ ######## 
sendClientBroadcastNotifications Any Client is Recording - stop that");
                                
recordingService.stopRecordingShowForClient(current.getScope(), rcl);
                        }
                        if 
(stream.getPublishedName().equals(rcl.getBroadCastId())) {
-                               rcl.setBroadCastId("-1");
-                               rcl.setIsBroadcasting(false);
+                               rcl.setBroadCastId(null);
+                               rcl.setBroadcasting(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());
-                       if (rcl.isScreenClient()) {
-                               WebSocketHelper.sendRoom(new 
TextRoomMessage(rcl.getRoomId(), rcl.getUserId(), 
RoomMessage.Type.sharingStoped, rcl.getPublicSID()));
+                       if (rcl.isSharing()) {
+                               sendSharingStoped(rcl);
                        }
                } catch (Exception e) {
                        _log.error("[streamBroadcastClose]", e);
                }
        }
 
-       @SuppressWarnings("unchecked")
-       public void setNewCursorPosition(Object item) {
+       private void sendSharingStoped(StreamClient rcl) {
+               JSONObject obj = new JSONObject()
+                               .put("ownerSid", rcl.getOwnerSid())
+                               .put("uid", rcl.getUid());
+               WebSocketHelper.sendRoom(new TextRoomMessage(rcl.getRoomId(), 
rcl.getUserId(), RoomMessage.Type.sharingStoped, obj.toString()));
+       }
+
+       /** TODO need to be implemented in Flex
+       public void setNewCursorPosition(Map<String, Object> cursor) {
                try {
                        IConnection current = Red5.getConnectionLocal();
                        StreamClient c = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
 
-                       @SuppressWarnings("rawtypes")
-                       Map cursor = (Map) item;
                        cursor.put("streamPublishName", 
c.getStreamPublishName());
 
                        sendMessageToCurrentScope("newRed5ScreenCursor", 
cursor, true, false);
@@ -725,18 +603,19 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        _log.error("[setNewCursorPosition]", err);
                }
        }
+       */
 
        public long switchMicMuted(String publicSID, boolean mute) {
                try {
                        _log.debug("-----------  switchMicMuted: " + publicSID);
 
-                       StreamClient currentClient = 
sessionManager.getClientByPublicSID(publicSID, null);
+                       StreamClient currentClient = 
sessionManager.getClientByUid(publicSID, null);
                        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");
@@ -793,8 +672,8 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                new MessageSender(getRoomScope("" + roomId), method, obj, this) 
{
                        @Override
                        public boolean filter(IConnection conn) {
-                               StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
-                               return rcl == null || rcl.isScreenClient()
+                               StreamClient rcl = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
+                               return rcl == null || rcl.isSharing()
                                                || rcl.getRoomId() == null || 
!rcl.getRoomId().equals(roomId) || userDao.get(rcl.getUserId()) == null;
                        }
                }.start();
@@ -843,7 +722,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();
@@ -933,7 +812,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        public int sendMessageWithClientWithSyncObject(Object newMessage, 
boolean sync) {
                try {
                        IConnection current = Red5.getConnectionLocal();
-                       StreamClient 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);
@@ -957,9 +836,9 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
         * @param clientId
         * @return 1 in case of success, -1 otherwise
         */
-       public int sendMessageById(Object newMessage, String clientId, IScope 
scope) {
+       public int sendMessageById(Object newMessage, final Long id, IScope 
scope) {
                try {
-                       _log.debug("### sendMessageById ###" + clientId);
+                       _log.debug("### sendMessageById ### {}", id);
 
                        Map<String, Object> hsm = new HashMap<>();
                        hsm.put("message", newMessage);
@@ -968,7 +847,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        for (IConnection conn : scope.getClientConnections()) {
                                if (conn != null) {
                                        if (conn instanceof 
IServiceCapableConnection) {
-                                               if 
(conn.getClient().getId().equals(clientId)) {
+                                               if 
(id.equals(IClientUtil.getId(conn.getClient()))) {
                                                        
((IServiceCapableConnection) conn).invoke("sendVarsToMessageWithClient", new 
Object[] { hsm }, this);
                                                }
                                        }
@@ -991,7 +870,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        public int sendMessageWithClientById(Object newMessage, String 
clientId) {
                try {
                        IConnection current = Red5.getConnectionLocal();
-                       StreamClient 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);
@@ -1023,9 +902,9 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
 
                        for (IConnection conn : 
current.getScope().getClientConnections()) {
                                if (conn != null) {
-                                       StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+                                       StreamClient rcl = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
 
-                                       if (rcl.getIsRecording()) {
+                                       if (rcl != null && 
rcl.isRecordingStarted()) {
                                                return true;
                                        }
                                }
@@ -1048,19 +927,18 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
 
                        for (IConnection conn : 
current.getScope().getClientConnections()) {
                                if (conn != null) {
-                                       StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+                                       StreamClient rcl = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
 
-                                       if (rcl != null && 
rcl.getIsRecording()) {
+                                       if (rcl != null && 
rcl.isRecordingStarted()) {
                                                return false;
                                        }
                                }
                        }
-                       StreamClient current_rcl = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
+                       StreamClient 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);
+                       // Also set the Recording Flag to Record all 
Participants that enter later
+                       rcl.setRecordingStarted(true);
+                       sessionManager.update(rcl);
 
                        Map<String, String> interviewStatus = new HashMap<>();
                        interviewStatus.put("action", "start");
@@ -1068,7 +946,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;
                                        }
@@ -1079,7 +957,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        }
                        String recordingName = "Interview " + 
CalendarPatterns.getDateWithTimeByMiliSeconds(new Date());
 
-                       recordingService.recordMeetingStream(current, 
current_rcl, recordingName, "", true);
+                       recordingService.recordMeetingStream(current, rcl, 
recordingName, "", true);
 
                        return true;
                } catch (Exception err) {
@@ -1095,29 +973,12 @@ 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;
        }
 
-       private Long checkRecordingClient(IConnection conn) {
-               Long recordingId = null;
-               if (conn != null) {
-                       StreamClient rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
-                       if (rcl != null && rcl.getIsRecording()) {
-                               rcl.setIsRecording(false);
-                               recordingId = rcl.getRecordingId();
-                               rcl.setRecordingId(null);
-
-                               // Reset the Recording Flag to Record all
-                               // Participants that enter later
-                               
sessionManager.updateClientByStreamId(conn.getClient().getId(), rcl, false, 
null);
-                       }
-               }
-               return recordingId;
-       }
-
        /**
         * Stop the recording of the streams and send event to connected users 
of scope
         *
@@ -1125,7 +986,7 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
         */
        public boolean stopInterviewRecording() {
                IConnection current = Red5.getConnectionLocal();
-               StreamClient currentClient = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
+               StreamClient currentClient = 
sessionManager.get(IClientUtil.getId(current.getClient()));
                return _stopInterviewRecording(currentClient, 
current.getScope());
        }
 
@@ -1140,7 +1001,19 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                        Long clientRecordingId = currentClient.getRecordingId();
 
                        for (IConnection conn : 
currentScope.getClientConnections()) {
-                               Long recordingId = checkRecordingClient(conn);
+                               Long recordingId = null;
+                               if (conn != null) {
+                                       StreamClient rcl = 
sessionManager.get(IClientUtil.getId(conn.getClient()));
+                                       if (rcl != null && 
rcl.isRecordingStarted()) {
+                                               rcl.setRecordingStarted(false);
+                                               recordingId = 
rcl.getRecordingId();
+                                               rcl.setRecordingId(null);
+
+                                               // Reset the Recording Flag to 
Record all
+                                               // Participants that enter later
+                                               sessionManager.update(rcl);
+                                       }
+                               }
                                if (recordingId != null) {
                                        clientRecordingId = recordingId;
                                }
@@ -1221,16 +1094,15 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
        public synchronized int updateSipTransport() {
                _log.debug("-----------  updateSipTransport");
                IConnection current = Red5.getConnectionLocal();
-               String streamid = current.getClient().getId();
-               StreamClient client = 
sessionManager.getClientByStreamId(streamid, null);
+               StreamClient client = 
sessionManager.get(IClientUtil.getId(current.getClient()));
                Long roomId = client.getRoomId();
                Integer count = getSipConferenceMembersNumber(roomId);
                String newNumber = getSipTransportLastname(count);
                _log.debug("getSipConferenceMembersNumber: " + newNumber);
                if (!newNumber.equals(client.getLastname())) {
                        client.setLastname(newNumber);
-                       sessionManager.updateClientByStreamId(streamid, client, 
false, null);
-                       _log.debug("updateSipTransport: {}, {}, {}, {}, {}", 
new Object[] { client.getPublicSID(), client.getRoomId(),
+                       sessionManager.update(client);
+                       _log.debug("updateSipTransport: {}, {}, {}, {}, {}", 
new Object[] { client.getUid(), client.getRoomId(),
                                        client.getFirstname(), 
client.getLastname(), client.getAvsettings() });
                        sendMessageWithClient(new String[] { "personal", 
client.getFirstname(), client.getLastname() });
                }
@@ -1241,22 +1113,21 @@ public class ScopeApplicationAdapter extends 
MultiThreadedApplicationAdapter imp
                _log.debug("-----------  setSipTransport");
                IConnection current = Red5.getConnectionLocal();
                IClient c = current.getClient();
-               String streamid = c.getId();
                // Notify all clients of the same scope (room)
-               StreamClient currentClient = 
sessionManager.getClientByStreamId(streamid, null);
+               StreamClient currentClient = 
sessionManager.get(IClientUtil.getId(c));
                currentClient.setSipTransport(true);
-               currentClient.setRoomId(roomId);
+               currentClient.setScope("" + roomId);
                currentClient.setRoomEnter(new Date());
                currentClient.setFirstname("SIP Transport");
                currentClient.setLastname(getSipTransportLastname(roomId));
                currentClient.setBroadCastId(broadCastId);
-               currentClient.setIsBroadcasting(true);
-               currentClient.setPublicSID(publicSID);
-               currentClient.setVWidth(120);
-               currentClient.setVHeight(90);
+               currentClient.setBroadcasting(true);
+               currentClient.setUid(publicSID);
+               currentClient.setWidth(120);
+               currentClient.setHeight(90);
                currentClient.setPicture_uri("phone.png");
-               sessionManager.updateClientByStreamId(streamid, currentClient, 
false, null);
-               SessionVariablesUtil.initClient(c, publicSID);
+               sessionManager.update(currentClient);
+               IClientUtil.init(c, currentClient.getId(), false);
 
                sendMessageToCurrentScope("addNewUser", currentClient, false);
        }

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/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
deleted file mode 100644
index 6df8b37..0000000
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java
+++ /dev/null
@@ -1,225 +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 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.StreamClient;
-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;
-
-/**
- * Provides method to manipulate {@link User}
- *
- * @author sebawagner
- *
- */
-public class UserService implements IUserService {
-       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
-        *
-        * @param sid
-        * @param userId
-        * @return User with the id given
-        */
-       public User getUserById(String sid, long userId) {
-               Sessiondata sd = sessionDao.check(sid);
-               if 
(AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) {
-                       return userDao.get(userId);
-               }
-               return null;
-       }
-
-       /**
-        * refreshes the current SID
-        *
-        * @param SID
-        * @return "ok" string in case of success, "error" string in case of 
the error
-        */
-       public String refreshSession(String SID) {
-               try {
-                       sessionDao.check(SID);
-                       return "ok";
-               } catch (Exception err) {
-                       log.error("[refreshSession]", err);
-               }
-               return "error";
-       }
-
-       /**
-        * gets a whole user-list(admin-role only)
-        *
-        * @param sid
-        * @param start
-        * @param max
-        * @param orderby
-        * @return whole user-list
-        */
-       public List<User> getUserList(String sid, int start, int max, String 
orderby, boolean asc) {
-               Sessiondata sd = sessionDao.check(sid);
-               if 
(AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) {
-                       return userDao.get("", start, max, orderby + (asc ? " 
ASC" : " DESC"));
-               }
-               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) {
-                                       StreamClient 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);
-                                       StreamClient 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()))) {
-                               StreamClient 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/117e8d6b/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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
index 8e937d5..ef53bfb 100644
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
+++ 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
@@ -24,10 +24,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map.Entry;
-import java.util.UUID;
 
 import org.apache.openmeetings.core.session.store.IClientPersistenceStore;
 import org.apache.openmeetings.db.dao.server.ISessionManager;
@@ -35,7 +33,6 @@ import org.apache.openmeetings.db.dto.basic.SearchResult;
 import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
 import org.apache.openmeetings.db.entity.room.StreamClient;
 import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.wicket.util.string.Strings;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -84,53 +81,9 @@ public class SessionManager implements ISessionManager {
                }
                c.setConnectedSince(new Date());
                c.setRoomEnter(new Date());
-               if (Strings.isEmpty(c.getPublicSID())) {
-                       c.setPublicSID(UUID.randomUUID().toString());
-               }
                c.setServer(server);
 
-               if (cache.containsKey(null, c.getStreamid())) {
-                       log.error("Tried to add an existing Client " + 
c.getStreamid());
-                       return null;
-               }
-
-               cache.put(c.getStreamid(), c);
-               return c;
-       }
-
-       @Override
-       public StreamClient addClientListItem(String streamId, String scopeName,
-                       int remotePort, String remoteAddress, String swfUrl, 
Server server) {
-               if (server == null) {
-                       server = serverUtil.getCurrentServer();
-               }
-               try {
-
-                       // Store the Connection into a bean and add it to the 
HashMap
-                       StreamClient rcm = new StreamClient();
-                       rcm.setConnectedSince(new Date());
-                       rcm.setStreamid(streamId);
-                       rcm.setScope(scopeName);
-                       rcm.setPublicSID(UUID.randomUUID().toString());
-                       rcm.setServer(server);
-                       rcm.setUserport(remotePort);
-                       rcm.setUserip(remoteAddress);
-                       rcm.setSwfurl(swfUrl);
-                       rcm.setIsMod(false);
-                       rcm.setCanDraw(false);
-
-                       if (cache.containsKey(null, streamId)) {
-                               log.error("Tried to add an existing Client " + 
streamId);
-                               return null;
-                       }
-
-                       cache.put(rcm.getStreamid(), rcm);
-
-                       return rcm;
-               } catch (Exception err) {
-                       log.error("[addClientListItem]", err);
-               }
-               return null;
+               return cache.put(c);
        }
 
        @Override
@@ -144,16 +97,13 @@ public class SessionManager implements ISessionManager {
        }
 
        @Override
-       public StreamClient getClientByStreamId(String streamId, Server server) 
{
-               if (server == null) {
-                       server = serverUtil.getCurrentServer();
-               }
+       public StreamClient get(Long id) {
                try {
-                       if (!cache.containsKey(server, streamId)) {
-                               log.debug("Tried to get a non existing Client " 
+ streamId + " server " + server);
+                       if (!cache.containsKey(id)) {
+                               log.debug("Tried to get a non existing Client 
{}", id);
                                return null;
                        }
-                       return cache.get(server, streamId);
+                       return cache.get(id);
                } catch (Exception err) {
                        log.error("[getClientByStreamId]", err);
                }
@@ -161,12 +111,12 @@ public class SessionManager implements ISessionManager {
        }
 
        @Override
-       public StreamClient getClientByPublicSID(String publicSID, Server 
server) {
+       public StreamClient getClientByUid(String publicSID, Server server) {
                if (server == null) {
                        server = serverUtil.getCurrentServer();
                }
                try {
-                       List<StreamClient> list = 
cache.getClientsByPublicSID(server, publicSID);
+                       List<StreamClient> list = cache.getClientsByUid(server, 
publicSID);
                        return list == null || list.isEmpty() ? null : 
list.get(0);
                } catch (Exception err) {
                        log.error("[getClientByPublicSID]", err);
@@ -175,9 +125,9 @@ public class SessionManager implements ISessionManager {
        }
 
        @Override
-       public ClientSessionInfo getClientByPublicSIDAnyServer(String 
publicSID) {
+       public ClientSessionInfo getClientByUidAnyServer(String publicSID) {
                try {
-                       for (Entry<Long,List<StreamClient>> entry : 
cache.getClientsByPublicSID(publicSID).entrySet()) {
+                       for (Entry<Long,List<StreamClient>> entry : 
cache.getClientsByUid(publicSID).entrySet()) {
                                for (StreamClient rcl : entry.getValue()) {
                                        return new ClientSessionInfo(rcl, 
entry.getKey());
                                }
@@ -189,83 +139,51 @@ public class SessionManager implements ISessionManager {
        }
 
        @Override
-       public StreamClient getClientByUserId(Long userId) {
-               try {
-                       for (StreamClient rcl : cache.getClientsByUserId(null, 
userId)) {
-                               if (rcl.isScreenClient()) {
-                                       continue;
-                               }
-
-                               return rcl;
-                       }
-               } catch (Exception err) {
-                       log.error("[getClientByUserId]", err);
-               }
-               return null;
-       }
-
-       @Override
-       public boolean updateAVClientByStreamId(String streamId, StreamClient 
rcm, Server server) {
-               if (server == null) {
-                       server = serverUtil.getCurrentServer();
-               }
+       public boolean updateAVClient(StreamClient rcm) {
                try {
                        // get the corresponding user session object and update 
the settings
-                       StreamClient rclUsual = 
getClientByPublicSID(rcm.getPublicSID(), server);
+                       StreamClient rclUsual = get(rcm.getId());
                        if (rclUsual != null) {
                                rclUsual.setBroadCastId(rcm.getBroadCastId());
                                rclUsual.setAvsettings(rcm.getAvsettings());
-                               rclUsual.setVHeight(rcm.getVHeight());
-                               rclUsual.setVWidth(rcm.getVWidth());
-                               rclUsual.setVX(rcm.getVX());
-                               rclUsual.setVY(rcm.getVY());
-                               StreamClient rclSaved = cache.get(server, 
rclUsual.getStreamid());
-                               if (rclSaved != null) {
-                                       cache.put(rclUsual.getStreamid(), 
rclUsual);
-                               } else {
-                                       log.debug("Tried to update a non 
existing Client " + rclUsual.getStreamid());
-                               }
+                               rclUsual.setHeight(rcm.getHeight());
+                               rclUsual.setWidth(rcm.getWidth());
+                               cache.put(rclUsual);
+                       } else {
+                               log.debug("Tried to update a non existing 
Client {}", rclUsual);
                        }
 
-                       updateClientByStreamId(streamId, rcm, false, server);
+                       update(rcm);
                        return true;
                } catch (Exception err) {
-                       log.error("[updateAVClientByStreamId]", err);
+                       log.error("[updateAVClient]", err);
                }
                return false;
        }
 
        @Override
-       public boolean updateClientByStreamId(String streamId, StreamClient 
rcm, boolean updateRoomCount, Server server) {
-               if (server == null) {
-                       server = serverUtil.getCurrentServer();
-               }
+       public boolean update(StreamClient rcm) {
                try {
-                       StreamClient rclSaved = cache.get(server, streamId);
-
-                       if (rclSaved != null) {
-                               cache.put(streamId, rcm);
+                       if (cache.containsKey(rcm.getId())) {
+                               cache.put(rcm);
                                return true;
                        } else {
-                               log.debug("Tried to update a non existing 
Client " + streamId);
+                               log.debug("Tried to update a non existing 
Client {}", rcm.getId());
                        }
                } catch (Exception err) {
-                       log.error("[updateClientByStreamId]", err);
+                       log.error("[updateClient]", err);
                }
                return false;
        }
 
        @Override
-       public boolean removeClient(String streamId, Server server) {
-               if (server == null) {
-                       server = serverUtil.getCurrentServer();
-               }
+       public boolean remove(Long id) {
                try {
-                       if (cache.containsKey(server,streamId)) {
-                               cache.remove(server,streamId);
+                       if (cache.containsKey(id)) {
+                               cache.remove(id);
                                return true;
                        } else {
-                               log.debug("Tried to remove a non existing 
Client " + streamId);
+                               log.debug("Tried to remove a non existing 
Client {}", id);
                        }
                } catch (Exception err) {
                        log.error("[removeClient]", err);
@@ -278,7 +196,7 @@ public class SessionManager implements ISessionManager {
                List<StreamClient> roomClientList = new ArrayList<>();
                try {
                        for (StreamClient rcl : 
cache.getClientsByRoomId(roomId)) {
-                               if (rcl.isScreenClient()) {
+                               if (rcl.isSharing()) {
                                        continue;
                                }
 
@@ -304,18 +222,6 @@ public class SessionManager implements ISessionManager {
        }
 
        @Override
-       public List<StreamClient> getCurrentModeratorByRoom(Long roomId) {
-               List<StreamClient> rclList = new LinkedList<>();
-               List<StreamClient> currentClients = 
this.getClientListByRoom(roomId);
-               for (StreamClient rcl : currentClients) {
-                       if (rcl.getIsMod()) {
-                               rclList.add(rcl);
-                       }
-               }
-               return rclList;
-       }
-
-       @Override
        public SearchResult<StreamClient> getListByStartAndMax(int start, int 
max, String orderby, boolean asc) {
                SearchResult<StreamClient> sResult = new SearchResult<>();
                sResult.setObjectName(StreamClient.class.getName());
@@ -329,7 +235,7 @@ public class SessionManager implements ISessionManager {
                List<StreamClient> currentClients = 
this.getClientListByRoom(roomId);
                int numberOfRecordingUsers = 0;
                for (StreamClient rcl : currentClients) {
-                       if (rcl.isStartRecording()) {
+                       if (rcl.isRecordingStarted()) {
                                numberOfRecordingUsers++;
                        }
                }
@@ -341,7 +247,7 @@ public class SessionManager implements ISessionManager {
                List<StreamClient> currentClients = 
this.getClientListByRoom(roomId);
                int numberOfPublishingUsers = 0;
                for (StreamClient rcl : currentClients) {
-                       if (rcl.isStreamPublishStarted()) {
+                       if (rcl.isPublishStarted()) {
                                numberOfPublishingUsers++;
                        }
                }

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
index 84ce5b2..7319ecf 100644
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
+++ 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
@@ -40,33 +40,29 @@ public class DatabaseStore implements 
IClientPersistenceStore {
        }
 
        @Override
-       public void put(String streamId, StreamClient rcl) {
-               if (rcl.getId() != null) {
-                       clientDao.update(rcl);
-               } else {
-                       clientDao.add(rcl);
-               }
+       public StreamClient put(StreamClient rcl) {
+               return rcl.getId() == null ? clientDao.add(rcl) : 
clientDao.update(rcl);
        }
 
        @Override
-       public boolean containsKey(Server server, String streamId) {
-               return clientDao.countClientsByServerAndStreamId(server, 
streamId) > 0;
+       public boolean containsKey(Long id) {
+               return clientDao.get(id) != null;
        }
 
        @Override
-       public StreamClient get(Server server, String streamId) {
-               return clientDao.getClientByServerAndStreamId(server, streamId);
+       public StreamClient get(Long id) {
+               return clientDao.get(id);
        }
 
        @Override
-       public List<StreamClient> getClientsByPublicSID(Server server, String 
publicSID) {
-               return clientDao.getClientsByPublicSIDAndServer(server, 
publicSID);
+       public List<StreamClient> getClientsByUid(Server server, String 
publicSID) {
+               return clientDao.getClientsByUidAndServer(server, publicSID);
        }
 
        @Override
-       public Map<Long, List<StreamClient>> getClientsByPublicSID(String 
publicSID) {
+       public Map<Long, List<StreamClient>> getClientsByUid(String publicSID) {
                Map<Long, List<StreamClient>> returnMap = new HashMap<>();
-               List<StreamClient> clientList = 
clientDao.getClientsByPublicSID(publicSID);
+               List<StreamClient> clientList = 
clientDao.getClientsByUid(publicSID);
                for (StreamClient cl : clientList) {
                        if (cl.getServer() == null) {
                                List<StreamClient> clList = returnMap.get(null);
@@ -113,8 +109,8 @@ public class DatabaseStore implements 
IClientPersistenceStore {
        }
 
        @Override
-       public void remove(Server server, String streamId) {
-               clientDao.removeClientByServerAndStreamId(server, streamId);
+       public void remove(Long id) {
+               clientDao.remove(id);
        }
 
        @Override

Reply via email to