Merge "Issue #232 - Added guava lib project - Adding error checking/reporting - Added VenueInitationListener" into 11-Collaboration

Former-commit-id: 62d92c57d9d004427a74fc0353e2ca94411bf488
This commit is contained in:
Nate Jensen 2012-03-14 11:23:55 -05:00 committed by Gerrit Code Review
commit dc62171533
14 changed files with 596 additions and 332 deletions

View file

@ -101,4 +101,10 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="com.google.guava"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature> </feature>

View file

@ -8,7 +8,8 @@ Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf;bundle-version="3.1.300", org.eclipse.ecf;bundle-version="3.1.300",
org.eclipse.ecf.presence;bundle-version="2.0.0", org.eclipse.ecf.presence;bundle-version="2.0.0",
org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0" org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0",
com.google.guava;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.collaboration, Export-Package: com.raytheon.uf.viz.collaboration,

View file

@ -32,12 +32,16 @@ import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.security.ConnectContextFactory; import org.eclipse.ecf.core.security.ConnectContextFactory;
import org.eclipse.ecf.presence.IPresenceContainerAdapter; import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo; import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationListener;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager; import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IVenueInvitationListener;
import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationSession; import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationSession;
import com.raytheon.uf.viz.collaboration.comm.provider.Errors;
import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter; import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter;
/** /**
@ -71,8 +75,11 @@ public class SessionManager {
private String password; private String password;
private IContainer container = null; private IChatRoomInvitationListener intInvitationListener;
private IVenueInvitationListener invitationListener;
private IContainer container = null;
/** /**
* @throws ContainerCreateException * @throws ContainerCreateException
@ -84,14 +91,11 @@ public class SessionManager {
this.password = password; this.password = password;
} }
/** /**
* *
* @return * @return
*/ */
public ISession createPeerToPeerSession() { public ISession createPeerToPeerSession() throws CollaborationException {
return (ISession) createSession(SESSION_P2P); return (ISession) createSession(SESSION_P2P);
} }
@ -99,16 +103,15 @@ public class SessionManager {
* *
* @return * @return
*/ */
public IVenueSession createChatOnlySession() { public IVenueSession createChatOnlySession() throws CollaborationException {
return (IVenueSession) createSession(SESSION_CHAT_ONLY); return (IVenueSession) createSession(SESSION_CHAT_ONLY);
} }
/** /**
* *
* @return * @return
*/ */
public IVenueSession createCollaborationSession() { public IVenueSession createCollaborationSession() throws CollaborationException {
return (IVenueSession) createSession(SESSION_COLLABORATION); return (IVenueSession) createSession(SESSION_COLLABORATION);
} }
@ -117,7 +120,7 @@ public class SessionManager {
* @param sessionKind * @param sessionKind
* @return * @return
*/ */
public ISession createSession(String sessionKind) { public ISession createSession(String sessionKind) throws CollaborationException {
ISession session = null; ISession session = null;
if(sessionKind != null) { if(sessionKind != null) {
@ -133,9 +136,14 @@ public class SessionManager {
} }
} }
if(session != null) { if(session != null) {
session.connect(account, password); int errorCode = session.connect(account, password);
if(errorCode == Errors.BAD_NAME) {
throw new CollaborationException(String.format("Bad name [%s]", account));
} else if (errorCode == Errors.CANNOT_CONNECT) {
throw new CollaborationException(String.format("Count not connect using name [%s]", account));
}
} else { } else {
System.out.println("Could not connect session"); throw new CollaborationException(String.format("Count not connect using name [%s]", account));
} }
return session; return session;
} }
@ -164,6 +172,43 @@ public class SessionManager {
return info; return info;
} }
public IVenueInvitationListener setVenueInvitationListener(IVenueInvitationListener listener) {
connectToContainer();
IPresenceContainerAdapter presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
IChatRoomManager venueManager = presence.getChatRoomManager();
invitationListener = listener;
if(invitationListener != null) {
// Do we already have one set?
if(intInvitationListener != null) {
venueManager.removeInvitationListener(intInvitationListener);
}
intInvitationListener = new IChatRoomInvitationListener() {
@Override
public void handleInvitationReceived(ID roomID, ID from,
String subject, String body) {
invitationListener.handleInvitation(null, null, subject, body);
}
};
venueManager.addInvitationListener(intInvitationListener);
}
return listener;
}
public IVenueInvitationListener removeVenueInvitationListener(IVenueInvitationListener listener) {
connectToContainer();
IPresenceContainerAdapter presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
IChatRoomManager venueManager = presence.getChatRoomManager();
invitationListener = listener;
if(invitationListener != null) {
venueManager.removeInvitationListener(intInvitationListener);
}
return listener;
}
private void connectToContainer() { private void connectToContainer() {
if(container.getConnectedID() == null) { if(container.getConnectedID() == null) {

View file

@ -73,8 +73,9 @@ public interface ISession {
* *
* @param userName * @param userName
* @param password * @param password
* @return An error status.
*/ */
void connect(String userName, String password); int connect(String userName, String password);
/** /**
* *
@ -106,6 +107,18 @@ public interface ISession {
*/ */
IRosterManager getRosterManager(); IRosterManager getRosterManager();
/**
*
* @param handler
*/
void registerEventHandler(Object handler);
/**
*
* @param handler
*/
void unRegisterEventHandler(Object handler);
/** /**
* Send a Text message. * Send a Text message.
* @param message * @param message

View file

@ -0,0 +1,53 @@
/**
* 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.identity.listener;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 13, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueInvitationListener {
/**
*
* @param roomId
* @param from
* @param subject
* @param body
*/
void handleInvitation(IQualifiedID roomId, IChatID from, String subject, String body);
}

View file

@ -0,0 +1,73 @@
/**
* 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;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 8, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class CollaborationException extends Exception {
private static final long serialVersionUID = 2897604473798379699L;
/**
*
*/
public CollaborationException() {
}
/**
* @param message
*/
public CollaborationException(String message) {
super(message);
}
/**
*
* @param message
* @param cause
*/
public CollaborationException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param cause
*/
public CollaborationException(Throwable cause) {
super(cause);
}
}

View file

@ -27,9 +27,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.ecf.core.ContainerConnectException; import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerFactory;
import org.eclipse.ecf.core.IContainer; import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory; import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace; import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.security.ConnectContextFactory; import org.eclipse.ecf.core.security.ConnectContextFactory;
@ -52,7 +52,7 @@ import org.eclipse.ecf.presence.im.IChatMessage;
import org.eclipse.ecf.presence.im.IChatMessageSender; import org.eclipse.ecf.presence.im.IChatMessageSender;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID; import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import com.raytheon.uf.viz.collaboration.comm.SessionManager; import com.google.common.eventbus.EventBus;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; 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.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied.Property; import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied.Property;
@ -87,70 +87,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
* @version 1.0 * @version 1.0
*/ */
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class CollaborationSession implements IVenueSession { public class CollaborationSession implements IVenueSession {
/** /**
@ -193,8 +129,7 @@ public class CollaborationSession implements IVenueSession {
* @param listener * @param listener
* @param filter * @param filter
*/ */
public InternalListener(IPresenceListener listener, public InternalListener(IPresenceListener listener, IMessageFilter filter) {
IMessageFilter filter) {
presenceListener = listener; presenceListener = listener;
this.filter = filter; this.filter = filter;
} }
@ -226,7 +161,7 @@ public class CollaborationSession implements IVenueSession {
} }
private IContainer container = null; private IContainer connectionContainer = null;
private IPresenceContainerAdapter presence = null; private IPresenceContainerAdapter presence = null;
@ -236,10 +171,10 @@ public class CollaborationSession implements IVenueSession {
private IChatRoomManager venueManager = null; private IChatRoomManager venueManager = null;
private IChatRoomContainer venueContainer = null;
private IChatRoomInfo venueInfo = null; private IChatRoomInfo venueInfo = null;
private IChatRoomContainer venueContainer = null;
private List<InternalListener> messageListeners = null; private List<InternalListener> messageListeners = null;
private List<IVenueParticipantListener> venueParticipantListeners = null; private List<IVenueParticipantListener> venueParticipantListeners = null;
@ -250,19 +185,25 @@ public class CollaborationSession implements IVenueSession {
private IIMMessageListener intListener = null; private IIMMessageListener intListener = null;
private IChatRoomParticipantListener participantListener = null;
private IQualifiedID receiver = null; private IQualifiedID receiver = null;
private IQualifiedID userID = null; private IQualifiedID userID = null;
private EventBus eventBus = new EventBus();
/** /**
* *
*/ */
public CollaborationSession(IContainer container) { public CollaborationSession(IContainer container) {
this.container = container; this.connectionContainer = container;
initListeners();
try { try {
setup(); setup();
} catch (ECFException e) { } catch (ECFException e) {
} finally {
initListeners();
} }
} }
@ -270,26 +211,43 @@ public class CollaborationSession implements IVenueSession {
* *
* @param userName * @param userName
* @param password * @param password
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#connect(java.lang.String, * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#connect(java.lang.String, java.lang.String)
* java.lang.String)
*/ */
@Override @Override
public void connect(String userName, String password) { public int connect(String userName, String password) {
int errorStatus = Errors.NO_ERROR;
// Make sure we're not already connected.
if(!isConnected()) { if(!isConnected()) {
ID targetID = IDFactory.getDefault().createID(namespace, userName);
// Now connect
try { try {
container.connect(targetID, ConnectContextFactory ID targetID = createID(userName);
.createPasswordConnectContext(password)); // Now connect
connectionContainer.connect(targetID, ConnectContextFactory.createPasswordConnectContext(password));
System.out.println("Container connected as " } catch(IDCreateException e) {
+ container.getConnectedID()); errorStatus = Errors.BAD_NAME;
} catch (ContainerConnectException e) { } catch (ContainerConnectException e) {
System.out.println("Error attempting to connect"); errorStatus = Errors.CANNOT_CONNECT;
e.printStackTrace(); e.printStackTrace();
} }
} else {
errorStatus = Errors.ALREADY_CONNECTED;
}
return errorStatus;
}
/**
*
* @throws ECFException
*/
private void setup() throws ECFException {
// Check if the container has been set up previously.
if (connectionContainer != null) {
namespace = connectionContainer.getConnectNamespace();
presence = (IPresenceContainerAdapter) connectionContainer
.getAdapter(IPresenceContainerAdapter.class);
chatSender = presence.getChatManager().getChatMessageSender();
} else {
} }
} }
@ -309,24 +267,29 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public boolean isConnected() { public boolean isConnected() {
boolean connected = false; boolean connected = false;
if (container != null) { if(connectionContainer != null) {
connected = (container.getConnectedID() != null); connected = (connectionContainer.getConnectedID() != null);
} }
return connected; return connected;
} }
/** /**
* * Close this session. Closing clears all listeners and disposes of
* the container. No errors for attempting to close an already closed session.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#close() * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#close()
*/ */
@Override @Override
public void close() { public void close() {
if (container != null) { if(connectionContainer != null) {
// Ensure the listeners are cleared first. // Ensure the listeners are cleared first.
// unhook the internal listener first. // unhook the internal listener first.
if(intListener != null) { if(intListener != null) {
venueContainer.removeMessageListener(intListener); venueContainer.removeMessageListener(intListener);
} }
if(participantListener != null) {
venueContainer.removeChatRoomParticipantListener(participantListener);
}
messageListeners.clear(); messageListeners.clear();
messageListeners = null; messageListeners = null;
@ -337,29 +300,21 @@ public class CollaborationSession implements IVenueSession {
presenceListeners.clear(); presenceListeners.clear();
presenceListeners = null; presenceListeners = null;
venueContainer.disconnect();
venueContainer = null;
presence = null;
chatSender = null;
namespace = null;
venueManager = null;
venueInfo = null;
// Now dispose of the comm container. // Now dispose of the comm container.
container.dispose(); connectionContainer = null;
container = null;
}
}
/**
*
* @throws ECFException
*/
private void setup() throws ECFException {
if (container == null) {
container = ContainerFactory.getDefault().createContainer(
SessionManager.PROVIDER);
}
if (container != null) {
namespace = container.getConnectNamespace();
presence = (IPresenceContainerAdapter) container
.getAdapter(IPresenceContainerAdapter.class);
chatSender = presence.getChatManager().getChatMessageSender();
} }
} }
@ -368,9 +323,12 @@ public class CollaborationSession implements IVenueSession {
* @param name * @param name
* @return * @return
*/ */
private ID createID(String name) { private ID createID(String name) throws IDCreateException {
return IDFactory.getDefault().createID(container.getConnectNamespace(), ID id = null;
name); if(namespace != null) {
id = IDFactory.getDefault().createID(namespace, name);
}
return id;
} }
/** /**
@ -383,11 +341,16 @@ public class CollaborationSession implements IVenueSession {
try { try {
// Create chat room container from manager // Create chat room container from manager
venueManager = presence.getChatRoomManager(); venueManager = presence.getChatRoomManager();
if(venueManager != null) {
venueInfo = venueManager.getChatRoomInfo(venueName); venueInfo = venueManager.getChatRoomInfo(venueName);
if(venueInfo != null) { if(venueInfo != null) {
errorStatus = completeVenueConnection(venueInfo); errorStatus = completeVenueConnection(venueInfo);
} else { } else {
// Could not join venue. // Could not join venue.
}
} else {
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(String.format("joinVenue(%s)", venueName)); System.out.println(String.format("joinVenue(%s)", venueName));
@ -400,8 +363,7 @@ public class CollaborationSession implements IVenueSession {
* *
* @param venueName * @param venueName
* @throws Exception * @throws Exception
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String, * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String, java.lang.String)
* java.lang.String)
*/ */
@Override @Override
public int createVenue(String venueName, String subject) { public int createVenue(String venueName, String subject) {
@ -409,6 +371,7 @@ public class CollaborationSession implements IVenueSession {
try { try {
// Create chat room container from manager // Create chat room container from manager
venueManager = presence.getChatRoomManager(); venueManager = presence.getChatRoomManager();
if(venueManager != null) {
venueInfo = venueManager.getChatRoomInfo(venueName); venueInfo = venueManager.getChatRoomInfo(venueName);
if(venueInfo == null) { if(venueInfo == null) {
Map<String, String> props = null; Map<String, String> props = null;
@ -419,8 +382,11 @@ public class CollaborationSession implements IVenueSession {
venueInfo = venueManager.createChatRoom(venueName, props); venueInfo = venueManager.createChatRoom(venueName, props);
errorStatus = completeVenueConnection(venueInfo); errorStatus = completeVenueConnection(venueInfo);
} else { } else {
// The venue already exists. errorStatus = Errors.VENUE_EXISTS;
errorStatus = -2; }
} else {
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(String.format("createVenue(%s)", venueName)); System.out.println(String.format("createVenue(%s)", venueName));
@ -434,7 +400,7 @@ public class CollaborationSession implements IVenueSession {
* @return * @return
*/ */
private int completeVenueConnection(IChatRoomInfo venueInfo) { private int completeVenueConnection(IChatRoomInfo venueInfo) {
int errorStatus = 0; int errorStatus = Errors.NO_ERROR;
if (venueInfo != null) { if (venueInfo != null) {
try { try {
@ -458,9 +424,8 @@ public class CollaborationSession implements IVenueSession {
IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() { IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() {
@Override @Override
public void handleArrived(IUser participant) { public void handleArrived(IUser participant) {
IVenueParticipant p = new VenueParticipant( IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
participant.getName(), eventBus.post(p);
participant.getNickname());
for(IVenueParticipantListener listener : venueParticipantListeners) { for(IVenueParticipantListener listener : venueParticipantListeners) {
listener.handleArrived(p); listener.handleArrived(p);
} }
@ -468,9 +433,8 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public void handleUpdated(IUser participant) { public void handleUpdated(IUser participant) {
IVenueParticipant p = new VenueParticipant( IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
participant.getName(), eventBus.post(p);
participant.getNickname());
for(IVenueParticipantListener listener : venueParticipantListeners) { for(IVenueParticipantListener listener : venueParticipantListeners) {
listener.handleUpdated(p); listener.handleUpdated(p);
} }
@ -478,16 +442,16 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public void handleDeparted(IUser participant) { public void handleDeparted(IUser participant) {
IVenueParticipant p = new VenueParticipant( IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
participant.getName(), eventBus.post(p);
participant.getNickname());
for(IVenueParticipantListener listener : venueParticipantListeners) { for(IVenueParticipantListener listener : venueParticipantListeners) {
listener.handleDeparted(p); listener.handleDeparted(p);
} }
} }
@Override @Override
public void handlePresenceUpdated(ID fromID, public void handlePresenceUpdated(
ID fromID,
org.eclipse.ecf.presence.IPresence presence) { org.eclipse.ecf.presence.IPresence presence) {
fromID.getName(); fromID.getName();
@ -495,7 +459,7 @@ public class CollaborationSession implements IVenueSession {
vp.setName(fromID.getName()); vp.setName(fromID.getName());
IPresence p = Presence.convertPresence(presence); IPresence p = Presence.convertPresence(presence);
eventBus.post(p);
for(IVenueParticipantListener listener : venueParticipantListeners) { for(IVenueParticipantListener listener : venueParticipantListeners) {
listener.handlePresenceUpdated(vp, p); listener.handlePresenceUpdated(vp, p);
} }
@ -512,12 +476,12 @@ public class CollaborationSession implements IVenueSession {
/** /**
* *
* @return The information about this venue. May return a null reference if * @return The information about this venue. May return a null reference
* the venue is not connected. * if the venue is not connected.
*/ */
public IVenue getVenue() { public IVenue getVenue() {
IVenue venue = null; IVenue venue = null;
if (isConnected()) { if(isConnected() && (venueContainer != null)) {
venue = new Venue(); venue = new Venue();
ID [] ids = venueContainer.getChatRoomParticipants(); ID [] ids = venueContainer.getChatRoomParticipants();
for(ID id : ids) { for(ID id : ids) {
@ -538,13 +502,11 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public int sendPresence(IPresence userPresence) { public int sendPresence(IPresence userPresence) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
IPresenceSender sender = presence.getRosterManager() IPresenceSender sender = presence.getRosterManager().getPresenceSender();
.getPresenceSender();
try { try {
sender.sendPresenceUpdate(null, sender.sendPresenceUpdate(null, Presence.convertPresence(userPresence));
Presence.convertPresence(userPresence));
} catch (ECFException e) { } catch (ECFException e) {
status = -1; status = -1;
} }
@ -559,13 +521,31 @@ public class CollaborationSession implements IVenueSession {
return null; return null;
} }
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#registerEventHandler(java.lang.Object)
*/
public void registerEventHandler(Object handler) {
eventBus.register(handler);
}
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#unRegisterEventHandler(java.lang.Object)
*/
public void unRegisterEventHandler(Object handler) {
eventBus.unregister(handler);
}
/** /**
* *
*/ */
@Override @Override
public int sendTextMessage(IMessage message) { public int sendTextMessage(IMessage message) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
if(chatSender != null) { if(chatSender != null) {
ID toID = createID(message.getTo().getName()); ID toID = createID(message.getTo().getName());
String subject = message.getSubject(); String subject = message.getSubject();
@ -579,8 +559,7 @@ public class CollaborationSession implements IVenueSession {
} }
} }
try { try {
chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT, chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT, subject, body, props);
subject, body, props);
} catch (ECFException e) { } catch (ECFException e) {
System.out.println("Error sending message"); System.out.println("Error sending message");
e.printStackTrace(); e.printStackTrace();
@ -598,7 +577,7 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public int sendTextMessage(String to, String message) { public int sendTextMessage(String to, String message) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
ID toID = createID(to); ID toID = createID(to);
try { try {
chatSender.sendChatMessage(toID, message); chatSender.sendChatMessage(toID, message);
@ -625,15 +604,13 @@ public class CollaborationSession implements IVenueSession {
} }
/** /**
* @param message * @param message A message to send.
* A message to send.
*/ */
public int sendMessageToVenue(String message) { public int sendMessageToVenue(String message) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
if(venueContainer != null) { if(venueContainer != null) {
IChatRoomMessageSender sender = venueContainer IChatRoomMessageSender sender = venueContainer.getChatRoomMessageSender();
.getChatRoomMessageSender();
try { try {
sender.sendMessage(message); sender.sendMessage(message);
} catch (ECFException e) { } catch (ECFException e) {
@ -651,7 +628,7 @@ public class CollaborationSession implements IVenueSession {
@Override @Override
public int sendCollaborationMessage(IMessage message) { public int sendCollaborationMessage(IMessage message) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
// for now we're sending everything via regular messages. // for now we're sending everything via regular messages.
return sendMessageToVenue(message.getBody()); return sendMessageToVenue(message.getBody());
} }
@ -669,32 +646,22 @@ public class CollaborationSession implements IVenueSession {
/** /**
* Send an invitation from this venue to another user. * Send an invitation from this venue to another user.
* * @param room The target venue for this invitation.
* @param room * @param id The target user for this invitation.
* The target venue for this invitation. * @param subject The intended subject of the venue conversation.
* @param id * @param body Any text that the user may wish to include.
* The target user for this invitation.
* @param subject
* The intended subject of the venue conversation.
* @param body
* Any text that the user may wish to include.
* @return * @return
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
* java.lang.String, java.lang.String, java.lang.String)
*/ */
@Override @Override
public int sendInvitation(String room, String id, String subject, public int sendInvitation(String room, String id, String subject, String body) {
String body) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
IChatRoomInvitationSender sender = presence.getChatRoomManager() IChatRoomInvitationSender sender = presence.getChatRoomManager().getInvitationSender();
.getInvitationSender();
if(sender != null) { if(sender != null) {
ID roomId = presence.getChatRoomManager().getChatRoomInfo(room) ID roomId = presence.getChatRoomManager().getChatRoomInfo(room).getConnectedID();
.getConnectedID(); ID userId = IDFactory.getDefault().createID(namespace, id + "@awipscm.omaha.us.ray.com");
ID userId = IDFactory.getDefault().createID(namespace,
id + "@awipscm.omaha.us.ray.com");
try { try {
sender.sendInvitation(roomId, userId, subject, body); sender.sendInvitation(roomId, userId, subject, body);
@ -707,24 +674,17 @@ public class CollaborationSession implements IVenueSession {
/** /**
* Send an invitation from this venue to another user. * Send an invitation from this venue to another user.
* * @param room The target venue for this invitation.
* @param room * @param id The target user for this invitation.
* The target venue for this invitation. * @param subject The intended subject of the venue conversation.
* @param id * @param body Any text that the user may wish to include.
* The target user for this invitation.
* @param subject
* The intended subject of the venue conversation.
* @param body
* Any text that the user may wish to include.
* @return * @return
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
* java.lang.String, java.lang.String, java.lang.String)
*/ */
@Override @Override
public int sendInvitation(String room, List<String> ids, String subject, public int sendInvitation(String room, List<String> ids, String subject, String body) {
String body) {
// Assume success // Assume success
int status = 0; int status = Errors.NO_ERROR;
if(ids != null) { if(ids != null) {
for(String id : ids) { for(String id : ids) {
sendInvitation(room, id, subject, body); sendInvitation(room, id, subject, body);
@ -735,11 +695,11 @@ public class CollaborationSession implements IVenueSession {
return status; return status;
} }
@Override @Override
public IMessageListener addMessageListener(IMessageListener listener, public IMessageListener addMessageListener(IMessageListener listener, IMessageFilter filter) {
IMessageFilter filter) { InternalListener messageListener = new InternalListener(listener, filter);
InternalListener messageListener = new InternalListener(listener,
filter);
messageListeners.add(messageListener); messageListeners.add(messageListener);
return listener; return listener;
} }
@ -774,8 +734,7 @@ public class CollaborationSession implements IVenueSession {
* *
*/ */
@Override @Override
public IVenueParticipantListener addVenueParticipantListener( public IVenueParticipantListener addVenueParticipantListener(IVenueParticipantListener listener) {
IVenueParticipantListener listener) {
if(listener != null) { if(listener != null) {
venueParticipantListeners.add(listener); venueParticipantListeners.add(listener);
} else { } else {
@ -802,8 +761,7 @@ public class CollaborationSession implements IVenueSession {
* *
*/ */
@Override @Override
public IVenueParticipantListener removeVenueParticipantListener( public IVenueParticipantListener removeVenueParticipantListener(IVenueParticipantListener listener) {
IVenueParticipantListener listener) {
IVenueParticipantListener removed = null; IVenueParticipantListener removed = null;
if(venueParticipantListeners.remove(listener)) { if(venueParticipantListeners.remove(listener)) {
removed = listener; removed = listener;
@ -815,10 +773,8 @@ public class CollaborationSession implements IVenueSession {
* *
*/ */
@Override @Override
public IMessageListener addCollaborationListener(IMessageListener listener, public IMessageListener addCollaborationListener(IMessageListener listener, IMessageFilter filter) {
IMessageFilter filter) { InternalListener messageListener = new InternalListener(listener, filter);
InternalListener messageListener = new InternalListener(listener,
filter);
collaborationListeners.add(messageListener); collaborationListeners.add(messageListener);
return listener; return listener;
} }
@ -841,8 +797,7 @@ public class CollaborationSession implements IVenueSession {
* *
*/ */
@Override @Override
public IMessageListener removeCollaborationListener( public IMessageListener removeCollaborationListener(IMessageListener listener) {
IMessageListener listener) {
IMessageListener removed = null; IMessageListener removed = null;
if(collaborationListeners.remove(listener)) { if(collaborationListeners.remove(listener)) {
removed = listener; removed = listener;
@ -854,10 +809,8 @@ public class CollaborationSession implements IVenueSession {
* *
*/ */
@Override @Override
public IPresenceListener addPresenceListener(IPresenceListener listener, public IPresenceListener addPresenceListener(IPresenceListener listener, IMessageFilter filter) {
IMessageFilter filter) { InternalListener presenceListener = new InternalListener(listener, filter);
InternalListener presenceListener = new InternalListener(listener,
filter);
presenceListeners.add(presenceListener); presenceListeners.add(presenceListener);
return listener; return listener;
} }
@ -886,17 +839,14 @@ public class CollaborationSession implements IVenueSession {
} }
/** /**
* Set up the various message listener lists. * Set up the various message listener lists. Ensures that all listener collections
* are not null prior to use.
*/ */
private void initListeners() { private void initListeners() {
messageListeners = Collections messageListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
.synchronizedList(new ArrayList<InternalListener>()); venueParticipantListeners = Collections.synchronizedList(new ArrayList<IVenueParticipantListener>());
venueParticipantListeners = Collections presenceListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
.synchronizedList(new ArrayList<IVenueParticipantListener>()); collaborationListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
presenceListeners = Collections
.synchronizedList(new ArrayList<InternalListener>());
collaborationListeners = Collections
.synchronizedList(new ArrayList<InternalListener>());
} }
/** /**
@ -907,11 +857,11 @@ public class CollaborationSession implements IVenueSession {
if(message != null) { if(message != null) {
fireMessageListeners(message); fireMessageListeners(message);
eventBus.post(message);
// if(IMessage.MessageType.CHAT.equals(message.getMessageType())) { // if(IMessage.MessageType.CHAT.equals(message.getMessageType())) {
// fireMessageListeners(message); // fireMessageListeners(message);
// } else if // } else if (IMessage.MessageType.COLLABORATION.equals(message.getMessageType())) {
// (IMessage.MessageType.COLLABORATION.equals(message.getMessageType()))
// {
// fireCollaborationListeners(message); // fireCollaborationListeners(message);
// } // }
} }
@ -1008,8 +958,7 @@ public class CollaborationSession implements IVenueSession {
XMPPRoomID rID = (XMPPRoomID) msg.getChatRoomID(); XMPPRoomID rID = (XMPPRoomID) msg.getChatRoomID();
System.out.println("nickname = " + rID.getNickname()); System.out.println("nickname = " + rID.getNickname());
IQualifiedID id = new VenueUserId(cID.getUsername(), IQualifiedID id = new VenueUserId(cID.getUsername(), rID.getHostname());
rID.getHostname());
message.setFrom(id); message.setFrom(id);
} }
return message; return message;

View file

@ -0,0 +1,57 @@
/**
* 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;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 8, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class Errors {
public static final int NO_ERROR = 0;
public static final int CANNOT_CONNECT = -50;
public static final int ALREADY_CONNECTED = -51;
public static final int BAD_NAME = -52;
// Error - An attempt to use a Venue that has been disposed.
public static final int VENUE_DISPOSED = -100;
// Error - Venue exists when attempting to create a new venue.
public static final int VENUE_EXISTS = -101;
// Error - Venue not found when attempting to join an existing venue.
public static final int VENUE_NOT_FOUND = -102;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="guava-11.0.2.jar" />
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.google.guava</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
#Thu Mar 26 11:28:33 CDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,23 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Google Common (Guava)
Bundle-SymbolicName: com.google.guava
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: GOOGLE
Require-Bundle: org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: guava-11.0.2.jar
Export-Package:
com.google.common.annotations,
com.google.common.base,
com.google.common.base.internal,
com.google.common.cache,
com.google.common.collect,
com.google.common.eventbus,
com.google.common.hash,
com.google.common.io,
com.google.common.math,
com.google.common.net,
com.google.common.primitives,
com.google.common.util.concurrent
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -0,0 +1,2 @@
bin.includes = META-INF/,\
guava-11.0.2.jar

Binary file not shown.