Issue #427 more cleanup

Change-Id: I82018bb21bed8c2e0d948da915f80ef33061615e

Former-commit-id: 1d24813371c2dec40ff90657705048083e03a9db
This commit is contained in:
Nate Jensen 2012-04-18 16:20:39 -05:00
parent c33cf2538c
commit a54660c377
6 changed files with 184 additions and 130 deletions

View file

@ -75,7 +75,7 @@ public interface ISession extends IEventPublisher {
*
* @return
*/
IQualifiedID getUserID();
public IQualifiedID getUserID();
/**
* Gets the connection status of the session.

View file

@ -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.
*

View file

@ -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.

View file

@ -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 ----------------
/**
@ -211,7 +209,6 @@ public class SessionManager implements IEventPublisher {
eventBus.register(rosterEventHandler);
// Debug -- event viewer ----------------
sessions = new HashMap<String, ISession>();
try {
@ -385,8 +382,6 @@ public class SessionManager implements IEventPublisher {
}
}
/**
*
*/
@ -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) {

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 18, 2012 njensen Initial creation
*
* </pre>
*
* @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;
}
}

View file

@ -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;
}
}