From a54660c377df8cf242ac24c7a950fc1d2784a80e Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Wed, 18 Apr 2012 16:20:39 -0500 Subject: [PATCH] Issue #427 more cleanup Change-Id: I82018bb21bed8c2e0d948da915f80ef33061615e Former-commit-id: 1d24813371c2dec40ff90657705048083e03a9db --- .../collaboration/comm/identity/ISession.java | 2 +- .../comm/identity/ISharedDisplaySession.java | 9 +- .../comm/identity/IVenueSession.java | 3 +- .../comm/provider/session/SessionManager.java | 39 +++-- .../session/SharedDisplaySession.java | 151 ++++++++++++++++++ .../comm/provider/session/VenueSession.java | 110 ++----------- 6 files changed, 184 insertions(+), 130 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISession.java index ede5bc889c..7d3bf02d76 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISession.java @@ -75,7 +75,7 @@ public interface ISession extends IEventPublisher { * * @return */ - IQualifiedID getUserID(); + public IQualifiedID getUserID(); /** * Gets the connection status of the session. diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java index 1df13d1a2e..390e3f1197 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/ISharedDisplaySession.java @@ -19,7 +19,6 @@ **/ package com.raytheon.uf.viz.collaboration.comm.identity; -import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; @@ -61,7 +60,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; * @version 1.0 */ -public interface ISharedDisplaySession extends IEventPublisher { +public interface ISharedDisplaySession extends IVenueSession { /** * Sends the object to the other collaborators on the session. The object @@ -124,12 +123,6 @@ public interface ISharedDisplaySession extends IEventPublisher { */ public boolean hasRole(ParticipantRole role); - /** - * - * @return - */ - public IQualifiedID getUserID(); - /** * Gets the connection status of the session. * diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java index 1c517c4d10..c3d895bc07 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java @@ -21,7 +21,6 @@ package com.raytheon.uf.viz.collaboration.comm.identity; import java.util.List; -import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue; /** @@ -55,7 +54,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue; * @version 1.0 */ -public interface IVenueSession extends ISession, IEventPublisher { +public interface IVenueSession extends ISession { /** * Returns information about a venue. diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java index d6902c1608..af47823d2e 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java @@ -55,6 +55,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; +import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; @@ -114,10 +115,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; public class SessionManager implements IEventPublisher { - private enum SessionType { - SESSION_P2P, SESSION_CHAT_ONLY, SESSION_COLLABORATION; - } - private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(SessionManager.class); @@ -153,6 +150,7 @@ public class SessionManager implements IEventPublisher { // Debug -- event viewer ---------------- private IRosterEventSubscriber rosterEventHandler = null; + // Debug -- event viewer ---------------- /** @@ -210,8 +208,7 @@ public class SessionManager implements IEventPublisher { rosterEventHandler = new RosterEventHandler(); eventBus.register(rosterEventHandler); // Debug -- event viewer ---------------- - - + sessions = new HashMap(); try { @@ -376,17 +373,15 @@ public class SessionManager implements IEventPublisher { if (rosterEventSubscriber != null) { eventBus.unregister(rosterEventSubscriber); } - if(container != null) { - + if (container != null) { + chatInstance = null; // Get rid of the account and roster managers container.dispose(); container = null; } } - - - + /** * */ @@ -419,13 +414,14 @@ public class SessionManager implements IEventPublisher { return chatInstance; } - public IVenueSession joinCollaborationVenue(IVenueInvitationEvent invitation) - throws CollaborationException { - VenueSession session = null; + public ISharedDisplaySession joinCollaborationVenue( + IVenueInvitationEvent invitation) throws CollaborationException { + SharedDisplaySession session = null; try { String venueName = invitation.getRoomId().getName(); String sessionId = invitation.getInvite().getSessionId(); - session = new VenueSession(container, eventBus, this, sessionId); + session = new SharedDisplaySession(container, eventBus, this, + sessionId); if (session != null) { session.joinVenue(venueName); @@ -441,7 +437,8 @@ public class SessionManager implements IEventPublisher { sessions.put(session.getSessionId(), session); } } catch (Exception e) { - + // TODO fix + e.printStackTrace(); } return session; } @@ -464,7 +461,8 @@ public class SessionManager implements IEventPublisher { } } catch (Exception e) { - + // TODO + e.printStackTrace(); } return session; } @@ -475,12 +473,12 @@ public class SessionManager implements IEventPublisher { * @return * @throws CollaborationException */ - public IVenueSession createCollaborationVenue(String venueName, + public ISharedDisplaySession createCollaborationVenue(String venueName, String subject) throws CollaborationException { - VenueSession session = null; + SharedDisplaySession session = null; int errorStatus = -1; try { - session = new VenueSession(container, eventBus, this); + session = new SharedDisplaySession(container, eventBus, this); if (session != null) { errorStatus = session.createVenue(venueName, subject); if (errorStatus == Errors.NO_ERROR) { @@ -497,6 +495,7 @@ public class SessionManager implements IEventPublisher { } } } catch (Exception e) { + // TODO e.printStackTrace(); } finally { if (errorStatus != Errors.NO_ERROR) { diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java new file mode 100644 index 0000000000..812c0dd30b --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java @@ -0,0 +1,151 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import org.eclipse.ecf.core.IContainer; + +import com.google.common.eventbus.EventBus; +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; +import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; +import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; +import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; +import com.raytheon.uf.viz.collaboration.comm.provider.Tools; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 18, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class SharedDisplaySession extends VenueSession implements + ISharedDisplaySession { + + private IVenueParticipant sessionLeader = null; + + private IVenueParticipant dataProvider = null; + + public SharedDisplaySession(IContainer container, EventBus externalBus, + SessionManager manager) throws CollaborationException { + super(container, externalBus, manager); + } + + public SharedDisplaySession(IContainer container, EventBus externalBus, + SessionManager manager, String sessionId) + throws CollaborationException { + super(container, externalBus, manager, sessionId); + } + + @Override + public void sendObjectToVenue(Object obj) throws CollaborationException { + if (obj != null) { + String message = Tools.marshallData(obj); + if (message != null) { + sendMessageToVenue(message); + } + } + } + + @Override + public void sendObjectToPeer( + com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant, + Object obj) throws CollaborationException { + PeerToPeerChat session = getP2PSession(); + if (session != null) { + String message = Tools.marshallData(obj); + if (message != null) { + + TextMessage msg = new TextMessage(participant, message); + msg.setProperty(Tools.PROP_SESSION_ID, getSessionId()); + + session.sendPeerToPeer(msg); + } + } + } + + /** + * Get the identification of the user who is the DataProvider. + * + * @return The DataProvider user identification. + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentDataProvider() + */ + @Override + public IVenueParticipant getCurrentDataProvider() { + return dataProvider; + } + + /** + * Get the identification of the user who is the Session Leader. + * + * @return The Session Leader user identification. + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentSessionLeader() + */ + @Override + public IVenueParticipant getCurrentSessionLeader() { + return sessionLeader; + } + + /** + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#hasRole(com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole) + */ + @Override + public boolean hasRole(ParticipantRole role) { + boolean result = true; + if (role.equals(ParticipantRole.DATA_PROVIDER) + && !this.getUserID().equals(this.getCurrentDataProvider())) { + result = false; + } else if (role.equals(ParticipantRole.SESSION_LEADER) + && !this.getUserID().equals(this.getCurrentSessionLeader())) { + result = false; + } + return result; + } + + @Override + public void setCurrentSessionLeader(IVenueParticipant id) { + sessionLeader = id; + } + + @Override + public void setCurrentDataProvider(IVenueParticipant id) { + dataProvider = id; + } + + @Override + protected VenueInvite buildInvite(String msg) { + VenueInvite invite = super.buildInvite(msg); + invite.setDataProvider(this.getCurrentDataProvider()); + invite.setSessionLeader(this.getCurrentSessionLeader()); + return invite; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index c6046317c9..c36bd50ec7 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -44,7 +44,6 @@ import com.google.common.eventbus.EventBus; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; -import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; @@ -52,7 +51,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue; import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; -import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole; import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage; import com.raytheon.uf.viz.collaboration.comm.provider.Errors; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; @@ -96,8 +94,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * @see com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage */ -public class VenueSession extends BaseSession implements IVenueSession, - ISharedDisplaySession { +public class VenueSession extends BaseSession implements IVenueSession { private static final String SEND_CMD = "[[COMMAND"; @@ -115,10 +112,6 @@ public class VenueSession extends BaseSession implements IVenueSession, private IQualifiedID userID = null; - private IVenueParticipant sessionLeader = null; - - private IVenueParticipant dataProvider = null; - private String subject; /** @@ -244,12 +237,7 @@ public class VenueSession extends BaseSession implements IVenueSession, IChatRoomInvitationSender sender = getConnectionPresenceAdapter() .getChatRoomManager().getInvitationSender(); if (sender != null) { - VenueInvite invite = new VenueInvite(); - invite.setDataProvider(this.getCurrentDataProvider()); - invite.setSessionLeader(this.getCurrentSessionLeader()); - invite.setMessage(body); - invite.setSessionId(this.sessionId); - invite.setSubject(this.getSubject()); + VenueInvite invite = buildInvite(body); String msgBody = Tools.marshallData(invite); ID roomId = venueInfo.getConnectedID(); @@ -299,81 +287,6 @@ public class VenueSession extends BaseSession implements IVenueSession, return sessionId; } - // *************************** - // ISharedDisplaySession - // *************************** - - @Override - public void sendObjectToVenue(Object obj) throws CollaborationException { - if (obj != null) { - String message = Tools.marshallData(obj); - if (message != null) { - sendMessageToVenue(message); - } - } - } - - @Override - public void sendObjectToPeer( - com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant, - Object obj) throws CollaborationException { - PeerToPeerChat session = getP2PSession(); - if (session != null) { - String message = Tools.marshallData(obj); - if (message != null) { - - TextMessage msg = new TextMessage(participant, message); - msg.setProperty(Tools.PROP_SESSION_ID, getSessionId()); - - session.sendPeerToPeer(msg); - } - } - } - - /** - * Get the identification of the user who is the DataProvider. - * - * @return The DataProvider user identification. - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentDataProvider() - */ - @Override - public IVenueParticipant getCurrentDataProvider() { - return dataProvider; - } - - /** - * Get the identification of the user who is the Session Leader. - * - * @return The Session Leader user identification. - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentSessionLeader() - */ - @Override - public IVenueParticipant getCurrentSessionLeader() { - return sessionLeader; - } - - /** - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#hasRole(com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole) - */ - @Override - public boolean hasRole(ParticipantRole role) { - boolean result = true; - if (role.equals(ParticipantRole.DATA_PROVIDER) - && !this.getUserID().equals(this.getCurrentDataProvider())) { - result = false; - } else if (role.equals(ParticipantRole.SESSION_LEADER) - && !this.getUserID().equals(this.getCurrentSessionLeader())) { - result = false; - } - System.out - .println(this.getUserID() + " hasRole " + role + " " + result); - return result; - } - - // *************************** - // ISharedDisplaySession - // *************************** - public void sendChatMessage(String message) throws CollaborationException { this.sendMessageToVenue(message); } @@ -396,16 +309,6 @@ public class VenueSession extends BaseSession implements IVenueSession, } } - @Override - public void setCurrentSessionLeader(IVenueParticipant id) { - sessionLeader = id; - } - - @Override - public void setCurrentDataProvider(IVenueParticipant id) { - dataProvider = id; - } - protected void setUserId(IVenueParticipant id) { this.userID = id; } @@ -431,6 +334,7 @@ public class VenueSession extends BaseSession implements IVenueSession, } } catch (Exception e) { + // TODO fix System.out.println(String.format("joinVenue(%s)", venueName)); e.printStackTrace(); } @@ -640,4 +544,12 @@ public class VenueSession extends BaseSession implements IVenueSession, } return message; } + + protected VenueInvite buildInvite(String msg) { + VenueInvite invite = new VenueInvite(); + invite.setMessage(msg); + invite.setSessionId(this.sessionId); + invite.setSubject(this.getSubject()); + return invite; + } }