From 08704e35ea65afc0f3089ac341c1ba8a16870a70 Mon Sep 17 00:00:00 2001 From: James Korman Date: Thu, 29 Mar 2012 10:16:15 -0500 Subject: [PATCH] Issue #232 - Added message routing/corrected roster creation Former-commit-id: 6149d30b13a5d977f09553b8a3bd44cb803d4bbf [formerly b45ea1e0a75101b8e346195d5b4bd9213455f714 [formerly b7040976e3c8fd029a0d821511f977cfd4b4888e]] Former-commit-id: b45ea1e0a75101b8e346195d5b4bd9213455f714 Former-commit-id: 8dde3a07982dfa476f1c8fbe8ac560e63a38254f --- .../uf/viz/collaboration/Activator.java | 69 +- .../collaboration/comm/identity/ISession.java | 42 +- .../identity/event/IVenueInvitationEvent.java | 2 +- .../comm/provider/BaseMessage.java | 26 +- .../comm/provider/CollaborationMessage.java | 16 +- .../collaboration/comm/provider/Errors.java | 19 +- .../collaboration/comm/provider/Presence.java | 153 +-- .../comm/provider/SerializationMode.java | 15 +- .../comm/provider/TextMessage.java | 16 +- .../collaboration/comm/provider/Tools.java | 16 +- .../comm/provider/event/ChatMessageEvent.java | 17 +- .../provider/event/VenueInvitationEvent.java | 32 +- .../provider/event/VenueParticipantEvent.java | 29 +- .../comm/provider/info/InfoAdapter.java | 66 +- .../comm/provider/info/Venue.java | 18 +- .../comm/provider/info/VenueInfo.java | 14 +- .../provider/roster/IMutableRosterEntry.java | 12 +- .../comm/provider/roster/Roster.java | 14 +- .../comm/provider/roster/RosterEntry.java | 61 +- .../comm/provider/roster/RosterGroup.java | 20 +- .../comm/provider/roster/RosterItem.java | 26 +- .../comm/provider/roster/RosterManager.java | 15 +- .../comm/provider/session/AccountManager.java | 106 ++- .../comm/provider/session/BaseSession.java | 97 +- .../comm/provider/session/DataHandler.java | 22 +- .../comm/provider/session/PeerToPeerChat.java | 63 +- .../session/PeerToPeerCommHelper.java | 171 ++++ .../comm/provider/session/SessionManager.java | 187 ++-- .../comm/provider/session/TestJAXBObject.java | 6 +- .../comm/provider/session/TestObject.java | 22 +- .../comm/provider/session/VenueSession.java | 895 ++++++++---------- .../comm/provider/user/IDConverter.java | 68 ++ .../comm/provider/user/RosterId.java | 29 +- .../comm/provider/user/UserId.java | 29 +- .../comm/provider/user/VenueParticipant.java | 24 +- .../comm/provider/user/VenueUserId.java | 24 +- 36 files changed, 1361 insertions(+), 1080 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java create mode 100644 cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java index feb47d39c7..a766227ec3 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/Activator.java @@ -1,30 +1,63 @@ +/** + * 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; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 27, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ public class Activator implements BundleActivator { - private static BundleContext context; + private static BundleContext context; - static BundleContext getContext() { - return context; - } + static BundleContext getContext() { + return context; + } - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext bundleContext) throws Exception { - Activator.context = bundleContext; - } + /** + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext bundleContext) throws Exception { - Activator.context = null; - } + /** + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } } 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 9c487452c4..3089c3b0b4 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 @@ -38,6 +38,7 @@ **/ 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; /** @@ -45,26 +46,28 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; * * * Implementations of ISession do not support polling for messages but instead - * make exclusive use of listener based callbacks to make incoming data available. + * make exclusive use of listener based callbacks to make incoming data + * available. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 24, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ -public interface ISession { +public interface ISession extends IEventPublisher { /** - * Close and clean up this session. After a close, isConnected must return false. + * Close and clean up this session. After a close, isConnected must return + * false. */ void close(); @@ -73,16 +76,33 @@ public interface ISession { * @return */ IQualifiedID getUserID(); - + /** * Gets the connection status of the session. + * * @return The connection status. */ boolean isConnected(); - + /** * Get the session identifier. - * @return The session identifier. + * + * @return The session identifier. */ String getSessionId(); + + /** + * Get the session identifier of a remote session this session is following. + * + * @return The remote session id. + */ + String getFollowingSessionId(); + + /** + * Set the session identifier of a remote session this session is following. + * + * @param id + * The remote session identifier. + */ + void setFollowingSessionId(String id); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IVenueInvitationEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IVenueInvitationEvent.java index d7ab6c7955..a0060e3dd1 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IVenueInvitationEvent.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IVenueInvitationEvent.java @@ -51,7 +51,7 @@ public interface IVenueInvitationEvent { * * @return */ - IChatID getInvitor(); + IQualifiedID getInvitor(); /** * diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/BaseMessage.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/BaseMessage.java index ef7c466148..7d1734c0be 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/BaseMessage.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/BaseMessage.java @@ -62,7 +62,7 @@ public abstract class BaseMessage implements Serializable, IMessage { private String status; private final long timeStamp; - + /** * * @param to @@ -74,7 +74,7 @@ public abstract class BaseMessage implements Serializable, IMessage { initProperties(); timeStamp = setTimeStamp(); } - + /** * @return the to */ @@ -162,7 +162,7 @@ public abstract class BaseMessage implements Serializable, IMessage { public String getProperty(String key, String defaultValue) { String retValue = defaultValue; if (properties != null) { - if(properties.containsKey(key)) { + if (properties.containsKey(key)) { retValue = properties.get(key); } } @@ -170,16 +170,17 @@ public abstract class BaseMessage implements Serializable, IMessage { } /** - * Gets the message properties as a collection of key, value - * pairs. Always returns a not-null value. + * Gets the message properties as a collection of key, value pairs. Always + * returns a not-null value. + * * @return A Collection of properties associated with this message. * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getProperties() */ @Override public Collection getProperties() { Collection p = new ArrayList(); - for(String s : properties.keySet()) { - p.add(new Property(s,properties.get(s))); + for (String s : properties.keySet()) { + p.add(new Property(s, properties.get(s))); } return p; } @@ -221,12 +222,11 @@ public abstract class BaseMessage implements Serializable, IMessage { public void setStatus(String status) { this.status = status; } - - + /** - * Get the receipt time for this message in milliseconds from - * Jan 1, 1970. - * @return The receipt time stamp. + * Get the receipt time for this message in milliseconds from Jan 1, 1970. + * + * @return The receipt time stamp. * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getTimeStamp() */ @Override @@ -243,5 +243,5 @@ public abstract class BaseMessage implements Serializable, IMessage { properties.put(TIMESTAMP, Long.toHexString(timestamp)); return timestamp; } - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/CollaborationMessage.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/CollaborationMessage.java index d46582e86a..657342dd20 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/CollaborationMessage.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/CollaborationMessage.java @@ -25,21 +25,21 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 24, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class CollaborationMessage extends BaseMessage { - + private static final long serialVersionUID = 1L; /** @@ -48,7 +48,7 @@ public class CollaborationMessage extends BaseMessage { * @param body */ public CollaborationMessage(IQualifiedID to, String body) { - super(to,body); + super(to, body); } /** @@ -67,5 +67,5 @@ public class CollaborationMessage extends BaseMessage { @Override public void getBodyAsBinary(byte[] body) { } - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Errors.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Errors.java index 26d2fd3818..408464e593 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Errors.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Errors.java @@ -23,17 +23,17 @@ package com.raytheon.uf.viz.collaboration.comm.provider; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 8, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public abstract class Errors { @@ -43,15 +43,16 @@ public abstract class Errors { 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; - - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java index 4cff4a9138..e19210e582 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Presence.java @@ -29,51 +29,65 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class Presence implements IPresence { - private static Map TYPE_MAP = new HashMap(); + private static Map TYPE_MAP = new HashMap(); static { - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.AVAILABLE, IPresence.Type.AVAILABLE); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.ERROR, IPresence.Type.ERROR); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.SUBSCRIBE, IPresence.Type.SUBSCRIBE); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.SUBSCRIBED, IPresence.Type.SUBSCRIBED); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNAVAILABLE, IPresence.Type.UNAVAILABLE); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNSUBSCRIBE, IPresence.Type.UNSUBSCRIBE); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNSUBSCRIBED, IPresence.Type.UNSUBSCRIBED); - TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNKNOWN, IPresence.Type.UNKNOWN); - } - - private static Map MODE_MAP = new HashMap(); - static { - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.AVAILABLE, IPresence.Mode.AVAILABLE); - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.AWAY, IPresence.Mode.AWAY); - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.CHAT, IPresence.Mode.CHAT); - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.DND, IPresence.Mode.DND); - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.EXTENDED_AWAY, IPresence.Mode.EXTENDED_AWAY); - MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.INVISIBLE, IPresence.Mode.INVISIBLE); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.AVAILABLE, + IPresence.Type.AVAILABLE); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.ERROR, + IPresence.Type.ERROR); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.SUBSCRIBE, + IPresence.Type.SUBSCRIBE); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.SUBSCRIBED, + IPresence.Type.SUBSCRIBED); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNAVAILABLE, + IPresence.Type.UNAVAILABLE); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNSUBSCRIBE, + IPresence.Type.UNSUBSCRIBE); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNSUBSCRIBED, + IPresence.Type.UNSUBSCRIBED); + TYPE_MAP.put(org.eclipse.ecf.presence.IPresence.Type.UNKNOWN, + IPresence.Type.UNKNOWN); } - private Map properties = null; - + private static Map MODE_MAP = new HashMap(); + static { + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.AVAILABLE, + IPresence.Mode.AVAILABLE); + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.AWAY, + IPresence.Mode.AWAY); + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.CHAT, + IPresence.Mode.CHAT); + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.DND, + IPresence.Mode.DND); + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.EXTENDED_AWAY, + IPresence.Mode.EXTENDED_AWAY); + MODE_MAP.put(org.eclipse.ecf.presence.IPresence.Mode.INVISIBLE, + IPresence.Mode.INVISIBLE); + } + + private Map properties = null; + private Mode mode; - + private Type type; - + private String statusMessage; - + /** * */ @@ -116,45 +130,49 @@ public class Presence implements IPresence { /** * Get the status message for this presence. + * * @return The status message. */ public String getStatusMessage() { return statusMessage; } - + /** - * Set the status message for this presence. - * @param statusMessage The status message. + * Set the status message for this presence. + * + * @param statusMessage + * The status message. */ public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } - private void ensureProperties() { - if(properties == null) { - properties = new HashMap(); + if (properties == null) { + properties = new HashMap(); } } /** * - * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#setProperty(java.lang.String, java.lang.String) + * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#setProperty(java.lang.String, + * java.lang.String) */ @Override public void setProperty(String key, String value) { ensureProperties(); - properties.put(key, new Property(key,value)); + properties.put(key, new Property(key, value)); } - + /** * - * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getProperty(java.lang.String, java.lang.String) + * @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getProperty(java.lang.String, + * java.lang.String) */ @Override public String getProperty(String key, String defaultValue) { String retValue = defaultValue; - if(properties != null) { + if (properties != null) { Property property = properties.get(key); retValue = (property != null) ? property.getValue() : defaultValue; } @@ -168,24 +186,27 @@ public class Presence implements IPresence { public Collection getProperties() { return properties.values(); } - - + /** - * Convert from an ECF presence to this presence. - * @param presence The ECF presnce to convert from. + * Convert from an ECF presence to this presence. + * + * @param presence + * The ECF presnce to convert from. * @return */ - public static IPresence convertPresence(org.eclipse.ecf.presence.IPresence presence) { + public static IPresence convertPresence( + org.eclipse.ecf.presence.IPresence presence) { IPresence newPresence = null; - if(presence != null) { + if (presence != null) { newPresence = new Presence(); newPresence.setType(TYPE_MAP.get(presence.getType())); newPresence.setMode(MODE_MAP.get(presence.getMode())); newPresence.setStatusMessage(presence.getStatus()); @SuppressWarnings("unchecked") - Map properties = (Map) presence.getProperties(); - if(properties != null) { - for(String key : properties.keySet()) { + Map properties = (Map) presence + .getProperties(); + if (properties != null) { + for (String key : properties.keySet()) { newPresence.setProperty(key, properties.get(key)); } } @@ -193,36 +214,26 @@ public class Presence implements IPresence { return newPresence; } - /** * * @param presence * @return */ - public static org.eclipse.ecf.presence.IPresence convertPresence(IPresence presence) { + public static org.eclipse.ecf.presence.IPresence convertPresence( + IPresence presence) { org.eclipse.ecf.presence.IPresence newPresence = null; - if(presence != null) { + if (presence != null) { newPresence = new org.eclipse.ecf.presence.Presence(); - -// Map properties = presence.getProperties(); -// if(properties != null) { -// for(String key : properties.keySet()) { -// newPresence.setProperty(key, properties.get(key)); -// } -// } - - - - - + + // Map properties = presence.getProperties(); + // if(properties != null) { + // for(String key : properties.keySet()) { + // newPresence.setProperty(key, properties.get(key)); + // } + // } + } return newPresence; } - - - - - - - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/SerializationMode.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/SerializationMode.java index 0c93b9e1e7..cc624dcc5d 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/SerializationMode.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/SerializationMode.java @@ -24,33 +24,32 @@ import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlRootElement; -import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; /** * * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 23, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public enum SerializationMode { THRIFT, JAXB, JAVA, STRING, NONE, ISNULL; - + public static SerializationMode getMode(Object object) { SerializationMode mode = ISNULL; if (object != null) { - if(object instanceof String) { + if (object instanceof String) { mode = STRING; } else if (object instanceof Serializable) { mode = JAVA; diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/TextMessage.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/TextMessage.java index 7ec1047064..e0270cd0ad 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/TextMessage.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/TextMessage.java @@ -25,30 +25,30 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 24, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class TextMessage extends BaseMessage { - + private static final long serialVersionUID = 1L; - + /** * * @param to * @param body */ public TextMessage(IQualifiedID to, String body) { - super(to,body); + super(to, body); } /** diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java index 75f80fa7a2..66d661b106 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/Tools.java @@ -48,19 +48,25 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; public abstract class Tools { - private static final String ENV_THRIFT = "[[COMMAND#" + public static final String TAG_INVITE_ID = "[[INVITEID#%s]]%s"; + + public static final String PROP_SESSION_ID = "sessionId"; + + public static final String CMD_PREAMBLE = "[[COMMAND#"; + + private static final String ENV_THRIFT = CMD_PREAMBLE + SerializationMode.THRIFT.name() + "]]"; - private static final String ENV_JAXB = "[[COMMAND#" + private static final String ENV_JAXB = CMD_PREAMBLE + SerializationMode.JAXB.name() + "]]"; - private static final String ENV_STRING = "[[COMMAND#" + private static final String ENV_STRING = CMD_PREAMBLE + SerializationMode.STRING.name() + "]]"; - private static final String ENV_JAVA = "[[COMMAND#" + private static final String ENV_JAVA = CMD_PREAMBLE + SerializationMode.JAVA.name() + "]]"; - private static final String ENV_NONE = "[[COMMAND#" + private static final String ENV_NONE = CMD_PREAMBLE + SerializationMode.NONE.name() + "]]"; public static final String VENUE_SUBJECT_PROP = "subject"; diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java index 13416d0057..824eff289e 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/ChatMessageEvent.java @@ -26,23 +26,23 @@ import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class ChatMessageEvent implements ITextMessageEvent { - + private final TextMessage message; - + /** * * @param msg @@ -51,13 +51,12 @@ public class ChatMessageEvent implements ITextMessageEvent { message = msg; } - /** * * @return * */ public TextMessage getMessage() { - return message; + return message; } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java index 05b6699d47..69abe946f2 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueInvitationEvent.java @@ -20,34 +20,33 @@ package com.raytheon.uf.viz.collaboration.comm.provider.event; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; -import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; /** * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class VenueInvitationEvent implements IVenueInvitationEvent { - + private IQualifiedID venueId; - - private IChatID invitor; - + + private IQualifiedID invitor; + private String subject; - + private String body; /** @@ -57,16 +56,17 @@ public class VenueInvitationEvent implements IVenueInvitationEvent { * @param subject * @param body */ - public VenueInvitationEvent(IQualifiedID venueId, IChatID invitor, String subject, String body) { + public VenueInvitationEvent(IQualifiedID venueId, IQualifiedID invitor, + String subject, String body) { this.venueId = venueId; this.invitor = invitor; this.subject = subject; this.body = body; } - - + /** - * Get the room identifier + * Get the room identifier + * * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getRoomId() */ @Override @@ -78,7 +78,7 @@ public class VenueInvitationEvent implements IVenueInvitationEvent { * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getInvitor() */ @Override - public IChatID getInvitor() { + public IQualifiedID getInvitor() { return invitor; } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueParticipantEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueParticipantEvent.java index 82c5f90f6b..b18860445f 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueParticipantEvent.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/VenueParticipantEvent.java @@ -28,38 +28,40 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 20, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class VenueParticipantEvent implements IVenueParticipantEvent { private final ParticipantEventType eventType; - + private final IVenueParticipant participant; - + private IPresence presence; - - public VenueParticipantEvent(IVenueParticipant participant, ParticipantEventType eventType) { + + public VenueParticipantEvent(IVenueParticipant participant, + ParticipantEventType eventType) { this.participant = participant; this.eventType = eventType; } - - public VenueParticipantEvent(IVenueParticipant participant, IPresence presence, ParticipantEventType eventType) { + + public VenueParticipantEvent(IVenueParticipant participant, + IPresence presence, ParticipantEventType eventType) { this.participant = participant; this.eventType = eventType; this.presence = presence; } - + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent#getEventType() */ @@ -83,6 +85,5 @@ public class VenueParticipantEvent implements IVenueParticipantEvent { public IPresence getPresence() { return presence; } - - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/InfoAdapter.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/InfoAdapter.java index fe18d6e296..fda8382bc5 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/InfoAdapter.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/InfoAdapter.java @@ -27,17 +27,17 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 1, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class InfoAdapter { @@ -45,44 +45,44 @@ public class InfoAdapter { * TODO Add Description * *
-     *
+     * 
      * SOFTWARE HISTORY
-     *
+     * 
      * Date         Ticket#    Engineer    Description
      * ------------ ---------- ----------- --------------------------
      * Mar 1, 2012            jkorman     Initial creation
-     *
+     * 
      * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ /** * TODO Add Description * *
-     *
+     * 
      * SOFTWARE HISTORY
-     *
+     * 
      * Date         Ticket#    Engineer    Description
      * ------------ ---------- ----------- --------------------------
      * Mar 1, 2012            jkorman     Initial creation
-     *
+     * 
      * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ private static class MutableVenueInfo implements IVenueInfo { - + private String description; - + private String name; - + private String subject; - + private String id; - + private int participantCount; private boolean isModerated = false; @@ -90,7 +90,7 @@ public class InfoAdapter { private boolean isPersistent = false; private boolean requiresPassword = false; - + /** * * @param description @@ -98,7 +98,7 @@ public class InfoAdapter { public void setVenueDescription(String description) { this.description = description; } - + /** * * @param name @@ -106,7 +106,7 @@ public class InfoAdapter { public void setVenueName(String name) { this.name = name; } - + /** * * @param subject @@ -122,7 +122,7 @@ public class InfoAdapter { public void setVenueID(String id) { this.id = id; } - + /** * * @param count @@ -130,7 +130,7 @@ public class InfoAdapter { public void setParticipantCount(int count) { participantCount = count; } - + /** * * @param moderated @@ -138,6 +138,7 @@ public class InfoAdapter { public void setModerated(boolean moderated) { isModerated = moderated; } + /** * * @param persistent @@ -145,6 +146,7 @@ public class InfoAdapter { public void setPersistent(boolean persistent) { isPersistent = persistent; } + public void setRequiresPassword(boolean requiresPassword) { this.requiresPassword = requiresPassword; } @@ -215,7 +217,7 @@ public class InfoAdapter { public boolean requiresPassword() { return requiresPassword; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -223,10 +225,11 @@ public class InfoAdapter { sb.append(String.format("[%s]:", id)); sb.append(String.format("mod[%s]:", (isModerated) ? "T" : "F")); sb.append(String.format("pers[%s]:", (isPersistent) ? "T" : "F")); - sb.append(String.format("pass[%s]:", (requiresPassword) ? "T" : "F")); + sb.append(String + .format("pass[%s]:", (requiresPassword) ? "T" : "F")); sb.append(String.format("\n subject : %s", subject)); sb.append(String.format("\n description : %s", description)); - + return sb.toString(); } @@ -234,20 +237,21 @@ public class InfoAdapter { /** * Convert ECF room into to a VenueInfo instance. + * * @param info * @return */ public static IVenueInfo createVenueInfo(IChatRoomInfo info) { MutableVenueInfo venue = null; - if(info != null) { - + if (info != null) { + venue = new MutableVenueInfo(); venue.setVenueDescription(info.getDescription()); venue.setVenueName(info.getName()); venue.setVenueSubject(info.getSubject()); venue.setVenueID(info.getRoomID().toExternalForm()); venue.setParticipantCount(info.getParticipantsCount()); - + venue.setModerated(info.isModerated()); venue.setPersistent(info.isPersistent()); venue.setRequiresPassword(info.requiresPassword()); diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java index cc8c4b4c61..be608c3685 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java @@ -31,32 +31,32 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 1, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class Venue implements IVenue { private IVenueInfo info; - + private Map participants; - + /** * */ public Venue() { participants = new HashMap(); } - + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue#getInfo() */ @@ -73,7 +73,7 @@ public class Venue implements IVenue { public void setInfo(IVenueInfo info) { this.info = info; } - + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue#getParticipants() */ diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/VenueInfo.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/VenueInfo.java index 9f2f001819..974b06a1fd 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/VenueInfo.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/info/VenueInfo.java @@ -41,15 +41,15 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; public class VenueInfo implements IVenueInfo { private String description; - + private String name; - + private String subject; - + private String id; - + private int participantCount; - + private boolean isModerated = false; private boolean isPersistent = false; @@ -96,7 +96,7 @@ public class VenueInfo implements IVenueInfo { public int getParticipantCount() { return participantCount; } - + /** * * @see com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo#isModerated() @@ -134,7 +134,7 @@ public class VenueInfo implements IVenueInfo { sb.append(String.format("pass[%s]:", (requiresPassword) ? "T" : "F")); sb.append(String.format("\n subject : %s", subject)); sb.append(String.format("\n description : %s", description)); - + return sb.toString(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/IMutableRosterEntry.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/IMutableRosterEntry.java index 1572a586e8..7d9b64206d 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/IMutableRosterEntry.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/IMutableRosterEntry.java @@ -26,21 +26,21 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ interface IMutableRosterEntry extends IRosterEntry { void setPresence(IPresence presence); - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java index 6c6db37e1c..d0a2bf43d2 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java @@ -31,8 +31,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; import com.raytheon.uf.viz.collaboration.comm.identity.user.ID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; +import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId; -import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId; /** * TODO Add Description @@ -232,7 +232,12 @@ public class Roster extends RosterItem implements IRoster { if (o instanceof org.eclipse.ecf.presence.roster.IRosterEntry) { org.eclipse.ecf.presence.roster.IRosterEntry entry = (org.eclipse.ecf.presence.roster.IRosterEntry) o; - IChatID id = VenueUserId.convertFrom(entry.getUser()); + IChatID id = IDConverter.convertFrom(entry.getUser()); + System.out.println(" " + + entry.getUser().getID().getName()); + System.out.println("Group:" + group.getName() + " id:" + + id.getFQName()); + RosterEntry re = new RosterEntry(id); // Check to see if we already have an entry IRosterEntry reCurrent = getRosterEntry(re); @@ -242,7 +247,12 @@ public class Roster extends RosterItem implements IRoster { } IPresence p = Presence.convertPresence(entry.getPresence()); re.setPresence(p); + System.out.println(" entry:" + re.getName() + " presence:" + + re.getPresence().getMode() + + re.getPresence().getType()); + re.addGroup(group); + group.addEntry(re); internalEntries.put(re.getUser(), re); } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterEntry.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterEntry.java index 31fb5afdd3..b61012208c 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterEntry.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterEntry.java @@ -33,23 +33,24 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Presence; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ -public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRosterEntry { +public class RosterEntry extends RosterItem implements IRosterEntry, + IMutableRosterEntry { private IChatID userId = null; - + private IPresence presence = null; private Map groups = null; @@ -60,6 +61,7 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos */ public RosterEntry(IChatID id) { userId = id; + setName(id.getFQName()); groups = new HashMap(); } @@ -69,15 +71,15 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos @Override public IChatID getUser() { return userId; - } + } /** * * @param group */ public void addGroup(IRosterGroup group) { - if(group != null) { - if(!groups.containsKey(group)) { + if (group != null) { + if (!groups.containsKey(group)) { groups.put(group, group); } } @@ -98,10 +100,10 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos public void setPresence(IPresence presence) { this.presence = presence; } - + /** * - * @return + * @return */ @Override public IPresence getPresence() { @@ -141,19 +143,18 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos return true; } + public static final void main(String[] args) { - public static final void main(String [] args) { - IChatID id = new IChatID() { private String name = null; - + private String nickName = null; - + private String host = null; - + private String resource = null; - + @Override public void setName(String userName) { name = userName; @@ -172,9 +173,9 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos @Override public String getNickname() { return nickName; - + } - + @Override public void setHost(String hostName) { host = hostName; @@ -184,44 +185,42 @@ public class RosterEntry extends RosterItem implements IRosterEntry, IMutableRos public String getHost() { return host; } - + @Override public String getResource() { return resource; } - + @Override public void setResource(String resource) { this.resource = resource; } - @Override public String getFQName() { StringBuilder sb = new StringBuilder(name); sb.append("@"); sb.append(host); - if(resource != null) { + if (resource != null) { sb.append("/"); sb.append(resource); } - - + return sb.toString(); } - + }; id.setName("fred"); id.setHost("awipscm.omaha.us.ray.com"); id.setResource("smack"); - + IMutableRosterEntry entry = new RosterEntry(id); entry.setPresence(new Presence()); - + IRosterEntry en = entry; - + System.out.println(id.getFQName()); } - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterGroup.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterGroup.java index 2f82a14a60..2ad4d4c976 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterGroup.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterGroup.java @@ -31,36 +31,36 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class RosterGroup extends RosterItem implements IRosterGroup { private Collection entries = null; - + private Collection groups = null; - + /** * */ public RosterGroup(String name, IRosterItem parent, IRoster roster) { super(name, parent, roster); entries = new ArrayList(); - if(roster.supportsNestedGroups()) { + if (roster.supportsNestedGroups()) { groups = new ArrayList(); } } - + /** * * @param entry @@ -68,7 +68,7 @@ public class RosterGroup extends RosterItem implements IRosterGroup { public void addEntry(IRosterEntry entry) { entries.add(entry); } - + /** * * @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup#getEntries() diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterItem.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterItem.java index 2d704bf49c..4549e42f74 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterItem.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterItem.java @@ -43,26 +43,26 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 29, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class RosterItem implements IRosterItem { // private String name = null; - + // private IRosterItem parent = null; - + // private IRoster roster = null; @@ -82,9 +82,9 @@ public class RosterItem implements IRosterItem { * */ public RosterItem() { - this(null,null,null); + this(null, null, null); } - + /** * * @param name @@ -101,7 +101,7 @@ public class RosterItem implements IRosterItem { public void setName(String name) { this.name = name; } - + /** * * @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem#getName() @@ -118,7 +118,7 @@ public class RosterItem implements IRosterItem { public void setParent(IRosterItem item) { parent = item; } - + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem#getParent() */ @@ -134,7 +134,7 @@ public class RosterItem implements IRosterItem { public void setRoster(IRoster roster) { this.roster = roster; } - + /** * * @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem#getRoster() @@ -176,5 +176,5 @@ public class RosterItem implements IRosterItem { return false; return true; } - + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java index e8e451bdc3..7404985ad1 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java @@ -24,12 +24,11 @@ import java.util.Collection; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster; -import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; +import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId; -import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId; /** * TODO Add Description @@ -118,7 +117,7 @@ public class RosterManager implements IRosterManager { Roster newRoster = null; if (roster != null) { - IChatID id = VenueUserId.convertFrom(roster.getUser()); + IChatID id = IDConverter.convertFrom(roster.getUser()); newRoster = new Roster(id); @SuppressWarnings("rawtypes") @@ -127,12 +126,22 @@ public class RosterManager implements IRosterManager { if (o instanceof org.eclipse.ecf.presence.roster.IRosterEntry) { org.eclipse.ecf.presence.roster.IRosterEntry entry = (org.eclipse.ecf.presence.roster.IRosterEntry) o; + System.out.println("RosterEntry "); + System.out.println(" -- " + entry.getUser().getName()); + System.out.println(" " + + entry.getUser().getID().getName()); + id = RosterId.convertFrom(entry.getUser()); RosterEntry re = new RosterEntry(id); if (!newRoster.getEntries().contains(re)) { IPresence p = Presence.convertPresence(entry .getPresence()); re.setPresence(p); + + System.out.println(" entry:" + re.getName() + + " presence:" + re.getPresence().getMode() + + re.getPresence().getType()); + newRoster.addRosterEntry(re); } } else if (o instanceof org.eclipse.ecf.presence.roster.IRosterGroup) { diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java index 330b2824ab..8b83ccc26c 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java @@ -41,21 +41,22 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; * *
    * EventBus subscription events. - *
  • ISubscriptionResponseEvent : This event is posted when a subscription request has - * been responded to.
  • + *
  • ISubscriptionResponseEvent : This event is posted when a subscription + * request has been responded to.
  • *
+ * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 16, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class AccountManager implements IAccountManager { @@ -64,21 +65,24 @@ public class AccountManager implements IAccountManager { @Override public void handleSubscribeRequest(ID fromID) { - + IQualifiedID fromId = null; - - IPresence.Type subscribedType = IPresence.Type.UNKNOWN; - if(responder != null) { + + IPresence.Type subscribedType = IPresence.Type.UNKNOWN; + if (responder != null) { subscribedType = responder.handleSubscribeRequest(fromId); } else { subscribedType = IPresence.Type.SUBSCRIBED; } - org.eclipse.ecf.presence.Presence.Type sType = Tools.convertPresenceType(subscribedType); + org.eclipse.ecf.presence.Presence.Type sType = Tools + .convertPresenceType(subscribedType); + + org.eclipse.ecf.presence.IPresence presence = new org.eclipse.ecf.presence.Presence( + sType); - org.eclipse.ecf.presence.IPresence presence = new org.eclipse.ecf.presence.Presence(sType); - try { - presenceAdapter.getRosterManager().getPresenceSender().sendPresenceUpdate(fromID, presence); + presenceAdapter.getRosterManager().getPresenceSender() + .sendPresenceUpdate(fromID, presence); } catch (ECFException e) { // Will have to do something with this sooner or later. } @@ -92,32 +96,35 @@ public class AccountManager implements IAccountManager { public void handleUnsubscribed(ID fromID) { } }; - + private boolean autoRespond = true; - + private IPresenceContainerAdapter presenceAdapter; - + private ISubscriptionResponder responder; - + /** * * @param adapter */ AccountManager(IPresenceContainerAdapter adapter) { presenceAdapter = adapter; - presenceAdapter.getRosterManager().addRosterSubscriptionListener(autoResponder); + presenceAdapter.getRosterManager().addRosterSubscriptionListener( + autoResponder); } - + /** - * Set the auto subscription mode to ON or OFF. If set to off then any currently assigned - * autoresponder is set to null. - * @param mode The auto subscription mode. + * Set the auto subscription mode to ON or OFF. If set to off then any + * currently assigned autoresponder is set to null. + * + * @param mode + * The auto subscription mode. * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#setAutoSubscriptionMode(boolean) */ @Override public void setAutoSubscriptionMode(boolean auto) { autoRespond = auto; - if(!auto) { + if (!auto) { responder = null; } } @@ -151,20 +158,23 @@ public class AccountManager implements IAccountManager { /** * - * @param password The new password. For security the password is a character array that will - * be zero'd after use. + * @param password + * The new password. For security the password is a character + * array that will be zero'd after use. * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#changePassword(char[]) */ @Override public void changePassword(char[] password) throws CollaborationException { - org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter.getAccountManager(); - if(manager != null) { + org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter + .getAccountManager(); + if (manager != null) { try { manager.changePassword(new String(password)); // all done so clear the password. Arrays.fill(password, (char) 0); } catch (ECFException e) { - throw new CollaborationException("Could not change account password"); + throw new CollaborationException( + "Could not change account password"); } } } @@ -175,8 +185,9 @@ public class AccountManager implements IAccountManager { */ @Override public void deleteAccount() throws CollaborationException { - org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter.getAccountManager(); - if(manager != null) { + org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter + .getAccountManager(); + if (manager != null) { try { manager.deleteAccount(); } catch (ECFException e) { @@ -187,18 +198,21 @@ public class AccountManager implements IAccountManager { /** * Determines if the server allows new accounts to be created by the user. - * @throws CollaborationException + * + * @throws CollaborationException * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#canCreateAccount() */ @Override public boolean canCreateAccount() throws CollaborationException { boolean canCreate = false; - org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter.getAccountManager(); - if(manager != null) { + org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter + .getAccountManager(); + if (manager != null) { try { canCreate = manager.isAccountCreationSupported(); } catch (ECFException e) { - throw new CollaborationException("Error attempting to determine if accounts may be created."); + throw new CollaborationException( + "Error attempting to determine if accounts may be created."); } } return canCreate; @@ -208,16 +222,16 @@ public class AccountManager implements IAccountManager { * TODO : Body of method * * @param password - * @param attributes - * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#createAccount(java.lang.String, char[], java.util.Map) + * @param attributes + * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#createAccount(java.lang.String, + * char[], java.util.Map) */ @Override - public void createAccount(String name, char[] password, Map attributes) - throws CollaborationException { + public void createAccount(String name, char[] password, + Map attributes) throws CollaborationException { if (name != null) { if (password != null) { - // all done so clear the password. Arrays.fill(password, (char) 0); } @@ -231,14 +245,16 @@ public class AccountManager implements IAccountManager { * @throws CollaborationException */ @Override - public void sendPresence(IPresence userPresence) throws CollaborationException { - IPresenceSender sender = presenceAdapter.getRosterManager().getPresenceSender(); + public void sendPresence(IPresence userPresence) + throws CollaborationException { + IPresenceSender sender = presenceAdapter.getRosterManager() + .getPresenceSender(); try { - sender.sendPresenceUpdate(null, Presence.convertPresence(userPresence)); + sender.sendPresenceUpdate(null, + Presence.convertPresence(userPresence)); } catch (ECFException e) { // TODO : Exception handing.... } } - } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java index 4060c8a9af..94da96cd79 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/BaseSession.java @@ -19,7 +19,6 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.session; -import java.lang.annotation.Annotation; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -29,51 +28,46 @@ 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.Namespace; -import org.eclipse.ecf.core.util.Base64; import org.eclipse.ecf.core.util.ECFException; import org.eclipse.ecf.presence.IPresenceContainerAdapter; import com.google.common.eventbus.EventBus; -import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; -import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; /** * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 21, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ - -public abstract class BaseSession implements ISession, IEventPublisher { +public abstract class BaseSession implements ISession { protected final String sessionId; - + + private String followingId; + private EventBus managerEventBus; private EventBus eventBus; - + private Map eventSubscribers; private IContainer connectionContainer; private IPresenceContainerAdapter connectionPresence = null; - + private Namespace connectionNamespace = null; // The session manager that created this session. @@ -85,42 +79,41 @@ public abstract class BaseSession implements ISession, IEventPublisher { * @param externalBus * @param manager */ - protected BaseSession(IContainer container, EventBus externalBus, SessionManager manager) { + protected BaseSession(IContainer container, EventBus externalBus, + SessionManager manager) throws CollaborationException { // Set the session identifier. sessionId = UUID.randomUUID().toString(); managerEventBus = externalBus; eventBus = new EventBus(); connectionContainer = container; sessionManager = manager; - eventSubscribers = new HashMap(); - + eventSubscribers = new HashMap(); + setup(); } - + /** * * @throws ECFException */ - void setup() throws ECFException { + void setup() { // Check if the container has been set up previously. if (connectionContainer != null) { - connectionNamespace = connectionContainer.getConnectNamespace(); connectionPresence = (IPresenceContainerAdapter) connectionContainer .getAdapter(IPresenceContainerAdapter.class); - } else { - } } - + /** * Get access to the peer to peer session instance. + * * @return The peer to peer chat session instance. * @throws CollaborationException */ PeerToPeerChat getP2PSession() throws CollaborationException { return (PeerToPeerChat) sessionManager.getPeerToPeerSession(); } - + /** * * @return @@ -145,7 +138,6 @@ public abstract class BaseSession implements ISession, IEventPublisher { return connectionPresence; } - /** * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID() */ @@ -161,7 +153,7 @@ public abstract class BaseSession implements ISession, IEventPublisher { @Override public boolean isConnected() { boolean connected = false; - if(connectionContainer != null) { + if (connectionContainer != null) { connected = (connectionContainer.getConnectedID() != null); } return connected; @@ -174,13 +166,16 @@ public abstract class BaseSession implements ISession, IEventPublisher { public void close() { // Unregister any handlers added using this session -// for(Object o : eventSubscribers.values()) { -// managerEventBus.unregister(o); -// } + // for(Object o : eventSubscribers.values()) { + // managerEventBus.unregister(o); + // } sessionManager.removeSession(this); } /** + * Get the session identifier. + * + * @return The session id for this session. * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getSessionId() */ @Override @@ -188,9 +183,31 @@ public abstract class BaseSession implements ISession, IEventPublisher { return sessionId; } - //***************** + /** + * Get the session identifier of a remote session this session is following. + * + * @param id + * The remote session identifier. + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getFollowingSessionId() + */ + @Override + public String getFollowingSessionId() { + return followingId; + } + + /** + * Set the session identifier of a remote session this session is following. + * + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#setFollowingSessionId(java.lang.String) + */ + @Override + public void setFollowingSessionId(String id) { + followingId = id; + } + + // ***************** // Implement IEventPublisher methods - //***************** + // ***************** /** * @@ -199,12 +216,12 @@ public abstract class BaseSession implements ISession, IEventPublisher { */ @Override public void registerEventHandler(Object handler) { - if(!eventSubscribers.containsKey(handler)) { + if (!eventSubscribers.containsKey(handler)) { eventBus.register(handler); eventSubscribers.put(handler, handler); } } - + /** * * @param handler @@ -223,11 +240,11 @@ public abstract class BaseSession implements ISession, IEventPublisher { public EventBus getEventPublisher() { return eventBus; } - + EventBus getManagerEventPublisher() { return managerEventBus; } - + /** * * @param name @@ -235,8 +252,8 @@ public abstract class BaseSession implements ISession, IEventPublisher { */ public ID createID(String name) throws IDCreateException { ID id = null; - if(connectionNamespace != null) { - id = IDFactory.getDefault().createID(connectionNamespace, name); + if (connectionNamespace != null) { + id = IDFactory.getDefault().createID(connectionNamespace, name); } return id; } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java index 7060afe34e..2ba75c9c4a 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/DataHandler.java @@ -22,34 +22,42 @@ package com.raytheon.uf.viz.collaboration.comm.provider.session; import com.google.common.eventbus.Subscribe; import com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; /** * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 27, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class DataHandler { @Subscribe public void handle(IInitData initdata) { - System.out.println("Handling IInitData " + initdata); + System.out.println("DataHandler---------------------------------"); + System.out.println(" Handling IInitData " + initdata); } - + @Subscribe public void handle(IDisplayEvent event) { + System.out.println("DataHandler---------------------------------"); System.out.println("Handling IDisplayEvent " + event); } + @Subscribe + public void handle(IVenueInvitationEvent event) { + System.out.println("DataHandler---------------------------------"); + System.out.println("Received invitation " + event.getBody()); + } } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java index 296a7e6493..54eabb2fdd 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerChat.java @@ -26,10 +26,7 @@ import java.util.Map; import org.eclipse.ecf.core.IContainer; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.ecf.presence.IIMMessageEvent; -import org.eclipse.ecf.presence.IIMMessageListener; import org.eclipse.ecf.presence.im.IChatMessage; -import org.eclipse.ecf.presence.im.IChatMessageEvent; import org.eclipse.ecf.presence.im.IChatMessageSender; import com.google.common.eventbus.EventBus; @@ -37,11 +34,7 @@ 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.IPeerToPeer; import com.raytheon.uf.viz.collaboration.comm.identity.IPropertied.Property; -import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent; import com.raytheon.uf.viz.collaboration.comm.provider.Errors; -import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; -import com.raytheon.uf.viz.collaboration.comm.provider.Tools; -import com.raytheon.uf.viz.collaboration.comm.provider.event.ChatMessageEvent; /** * @@ -73,9 +66,8 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer { * @param manager */ PeerToPeerChat(IContainer container, EventBus externalBus, - SessionManager manager) { + SessionManager manager) throws CollaborationException { super(container, externalBus, manager); - setup(); chatSender = getConnectionPresenceAdapter().getChatManager() .getChatMessageSender(); } @@ -132,49 +124,14 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer { return status; } - - void setup() { - try { - super.setup(); - - getConnectionPresenceAdapter().getChatManager().addMessageListener( - new IIMMessageListener() { - - @Override - public void handleMessageEvent( - IIMMessageEvent messageEvent) { - if (messageEvent instanceof IChatMessageEvent) { - IChatMessageEvent event = (IChatMessageEvent) messageEvent; - - IChatMessage msg = event.getChatMessage(); - String body = msg.getBody(); - if (body != null) { - if (body.startsWith("[[COMMAND#")) { - Object object = null; - try { - object = Tools.unMarshallData(body); - } catch (CollaborationException e) { - System.out - .println("Error unmarshalling PeerToPeer data"); - } - if (object != null) { - getEventPublisher().post(object); - } - } else { - // anything else pass to the normal text - TextMessage textMsg = null; - - ITextMessageEvent chatEvent = new ChatMessageEvent( - textMsg); - - getEventPublisher().post(chatEvent); - } - } - } - } - }); - } catch (ECFException ecfe) { - System.out.println("Error setting up PeerToPeer chat listeners"); - } + + /** + * + * @return + */ + @Override + public EventBus getEventPublisher() { + return getManagerEventPublisher(); } + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java new file mode 100644 index 0000000000..ca7d80793e --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/PeerToPeerCommHelper.java @@ -0,0 +1,171 @@ +/** + * 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 java.util.Map; + +import org.eclipse.ecf.presence.IIMMessageEvent; +import org.eclipse.ecf.presence.IIMMessageListener; +import org.eclipse.ecf.presence.IPresenceContainerAdapter; +import org.eclipse.ecf.presence.im.IChatMessage; +import org.eclipse.ecf.presence.im.IChatMessageEvent; + +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.identity.ISession; +import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; +import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; +import com.raytheon.uf.viz.collaboration.comm.provider.Tools; +import com.raytheon.uf.viz.collaboration.comm.provider.event.ChatMessageEvent; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 28, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class PeerToPeerCommHelper implements IIMMessageListener { + + private SessionManager manager; + + private IPresenceContainerAdapter presenceAdapter; + + /** + * + * @param manager + * @param presenceAdapter + */ + PeerToPeerCommHelper(SessionManager manager, + IPresenceContainerAdapter presenceAdapter) { + this.presenceAdapter = presenceAdapter; + this.manager = manager; + } + + /** + * + */ + @Override + public void handleMessageEvent(IIMMessageEvent messageEvent) { + + System.out.println("Handling event " + + messageEvent.getClass().getName()); + + if (messageEvent instanceof IChatMessageEvent) { + IChatMessageEvent event = (IChatMessageEvent) messageEvent; + System.out.println(" message event.body " + + event.getChatMessage().getBody()); + + IChatMessage msg = event.getChatMessage(); + String body = msg.getBody(); + if (body != null) { + if (body.startsWith(Tools.CMD_PREAMBLE)) { + routeData(msg); + + } else { + // anything else pass to the normal text + routeMessage(msg); + } + } + } + } + + /** + * + * @param message + */ + private void routeData(IChatMessage message) { + Object object = null; + try { + object = Tools.unMarshallData(message.getBody()); + } catch (CollaborationException e) { + System.out.println("Error unmarshalling PeerToPeer data"); + } + if (object != null) { + String sessionId = (String) message.getProperties().get( + Tools.PROP_SESSION_ID); + if (sessionId == null) { + manager.getEventPublisher().post(object); + } else { + // Ok, we have a session id. + ISession session = manager.getSession(sessionId); + if (session != null) { + session.getEventPublisher().post(object); + } else { + System.out.println("ERROR: Unknown sessionid [" + sessionId + + "]"); + } + } + manager.getEventPublisher().post(object); + } + } + + /** + * + * @param message + */ + private void routeMessage(IChatMessage message) { + String from = message.getFromID().getName(); + IQualifiedID fromId = new UserId(Tools.parseName(from), + Tools.parseHost(from)); + fromId.setResource(Tools.parseResource(message.getFromID().getName())); + TextMessage textMsg = new TextMessage(fromId, message.getBody()); + textMsg.setFrom(fromId); + textMsg.setBody(message.getBody()); + textMsg.setSubject(message.getSubject()); + @SuppressWarnings("unchecked") + Map props = message.getProperties(); + for (Object o : props.keySet()) { + if (o instanceof String) { + String key = (String) o; + Object v = props.get(key); + if (v instanceof String) { + textMsg.setProperty(key, (String) v); + } + } + } + ITextMessageEvent chatEvent = new ChatMessageEvent(textMsg); + + String sessionId = (String) message.getProperties().get( + Tools.PROP_SESSION_ID); + // Now find out who gets the message. If the message doesn't contain + // a session id then assume its a straight text chat message. + if (sessionId == null) { + manager.getEventPublisher().post(chatEvent); + } else { + // Ok, we have a session id. + ISession session = manager.getSession(sessionId); + if (session != null) { + session.getEventPublisher().post(chatEvent); + } + } + } +} 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 e269061ea7..effb3e7691 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 @@ -22,9 +22,7 @@ package com.raytheon.uf.viz.collaboration.comm.provider.session; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import org.eclipse.ecf.core.ContainerConnectException; import org.eclipse.ecf.core.ContainerCreateException; @@ -48,17 +46,20 @@ 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.IVenueInvitationEvent; 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.identity.roster.IRosterManager; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; import com.raytheon.uf.viz.collaboration.comm.provider.Tools; import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEvent; import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter; import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager; +import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId; /** * @@ -87,13 +88,17 @@ import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager; * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent */ -public class SessionManager { +public class SessionManager implements IEventPublisher { - private enum SessionType { SESSION_P2P, SESSION_CHAT_ONLY, SESSION_COLLABORATION; } + private enum SessionType { + SESSION_P2P, SESSION_CHAT_ONLY, SESSION_COLLABORATION; + } private static final String PROVIDER = "ecf.xmpp.smack"; - private Map sessions = null; + private Map sessions; + + private Map following; private String account; @@ -101,10 +106,10 @@ public class SessionManager { private IChatRoomInvitationListener intInvitationListener; - private IVenueInvitationListener invitationListener; + private IPresenceContainerAdapter presenceAdapter; private PeerToPeerChat chatInstance = null; - + private IAccountManager accountManager = null; private IRosterManager rosterManager = null; @@ -118,7 +123,7 @@ public class SessionManager { * */ public SessionManager(String account, String password) throws Exception { - // XMPPConnection.DEBUG_ENABLED = true; + XMPPConnection.DEBUG_ENABLED = true; try { container = ContainerFactory.getDefault().createContainer(PROVIDER); @@ -131,29 +136,36 @@ public class SessionManager { try { connectToContainer(); } catch (Exception e) { - + throw new Exception("Error creating SessionManager", e); } setupAccountManager(); - + eventBus = new EventBus(); sessions = new HashMap(); + following = new HashMap(); setupInternalConnectionListeners(); setupInternalVenueInvitationListener(); + setupP2PComm(presenceAdapter); + getPeerToPeerSession(); } /** * - * @param account The account name to connect to. - * @param password The password to use for connection. - * @param initialPresence The initial presence for the account name. + * @param account + * The account name to connect to. + * @param password + * The password to use for connection. + * @param initialPresence + * The initial presence for the account name. * @throws ContainerCreateException * */ - public SessionManager(String account, String password, IPresence initialPresence) throws Exception { + public SessionManager(String account, String password, + IPresence initialPresence) throws Exception { this(account, password); - if(accountManager != null) { + if (accountManager != null) { accountManager.sendPresence(initialPresence); } } @@ -170,6 +182,9 @@ public class SessionManager { try { container.connect(targetID, ConnectContextFactory .createPasswordConnectContext(password)); + + presenceAdapter = Tools.getPresenceContainerAdapter(container, + IPresenceContainerAdapter.class); } catch (ContainerConnectException e) { System.out.println("Error attempting to connect"); e.printStackTrace(); @@ -182,13 +197,8 @@ public class SessionManager { */ private void setupAccountManager() { if (accountManager == null) { - if (isConnected()) { - IPresenceContainerAdapter presenceAdapter = Tools - .getPresenceContainerAdapter(container, - IPresenceContainerAdapter.class); - if (presenceAdapter != null) { - accountManager = new AccountManager(presenceAdapter); - } + if (isConnected() && (presenceAdapter != null)) { + accountManager = new AccountManager(presenceAdapter); } } } @@ -210,8 +220,9 @@ public class SessionManager { */ private void setupRosterManager() { IRoster roster = null; - IPresenceContainerAdapter presenceAdapter = Tools.getPresenceContainerAdapter( - container, IPresenceContainerAdapter.class); + IPresenceContainerAdapter presenceAdapter = Tools + .getPresenceContainerAdapter(container, + IPresenceContainerAdapter.class); if (presenceAdapter != null) { roster = presenceAdapter.getRosterManager().getRoster(); if (roster != null) { @@ -245,7 +256,6 @@ public class SessionManager { */ public void closeManager() { if (container != null) { - removeVenueInvitationListener(); // Close any created sessions. for (ISession session : sessions.values()) { @@ -260,11 +270,13 @@ public class SessionManager { /** * Get the PeerToPeerChat session instance. + * * @return */ public ISession getPeerToPeerSession() throws CollaborationException { - if(chatInstance == null) { + if (chatInstance == null) { chatInstance = new PeerToPeerChat(container, eventBus, this); + sessions.put(chatInstance.getSessionId(), chatInstance); } return chatInstance; } @@ -282,6 +294,7 @@ public class SessionManager { session = new VenueSession(container, eventBus, this); if (session != null) { session.joinVenue(venueName); + sessions.put(session.getSessionId(), session); } } catch (Exception e) { @@ -303,14 +316,14 @@ public class SessionManager { session = new VenueSession(container, eventBus, this); if (session != null) { session.createVenue(venueName, subject); - + IPresence presence = new Presence(); presence.setMode(IPresence.Mode.AVAILABLE); presence.setType(IPresence.Type.AVAILABLE); presence.setProperty("DATA_PROVIDER", ""); presence.setProperty("SESSION_LEADER", ""); - - + + sessions.put(session.getSessionId(), session); } } catch (Exception e) { } @@ -330,6 +343,7 @@ public class SessionManager { session = new VenueSession(container, eventBus, this); if (session != null) { session.joinVenue(venueName); + sessions.put(session.getSessionId(), session); } } catch (Exception e) { @@ -351,6 +365,7 @@ public class SessionManager { session = new VenueSession(container, eventBus, this); if (session != null) { session.createVenue(venueName, subject); + sessions.put(session.getSessionId(), session); } } catch (Exception e) { @@ -358,7 +373,7 @@ public class SessionManager { } return session; } - + /** * * @param session @@ -378,7 +393,8 @@ public class SessionManager { IPresenceContainerAdapter presenceAdapter = Tools .getPresenceContainerAdapter(container, IPresenceContainerAdapter.class); - IChatRoomManager venueManager = presenceAdapter.getChatRoomManager(); + IChatRoomManager venueManager = presenceAdapter + .getChatRoomManager(); if (venueManager != null) { IChatRoomInfo[] roomInfo = venueManager.getChatRoomInfos(); for (IChatRoomInfo rInfo : roomInfo) { @@ -398,22 +414,41 @@ public class SessionManager { } // *************************** - // Venue invitation listener management + // Connection listener // *************************** private void setupInternalConnectionListeners() { - - if(container != null) { + + if (container != null) { container.addListener(new IContainerListener() { @Override public void handleEvent(IContainerEvent event) { - + } }); } } - + + // *************************** + // Peer to Peer communications + // *************************** + + /** + * + */ + ISession getSession(String sessionId) { + return sessions.get(sessionId); + } + + private void setupP2PComm(IPresenceContainerAdapter presenceAdapter) { + if (isConnected() && (presenceAdapter != null)) { + PeerToPeerCommHelper helper = new PeerToPeerCommHelper(this, + presenceAdapter); + presenceAdapter.getChatManager().addMessageListener(helper); + } + } + // *************************** // Venue invitation listener management // *************************** @@ -422,51 +457,57 @@ public class SessionManager { * */ private void setupInternalVenueInvitationListener() { - if (isConnected()) { - IPresenceContainerAdapter presenceAdapter = Tools - .getPresenceContainerAdapter(container, - IPresenceContainerAdapter.class); - if (presenceAdapter != null) { - IChatRoomManager venueManager = presenceAdapter.getChatRoomManager(); - if (venueManager != null) { - intInvitationListener = new IChatRoomInvitationListener() { - @Override - public void handleInvitationReceived(ID roomID, - ID from, String subject, String body) { - if (invitationListener != null) { - invitationListener.handleInvitation(null, null, - subject, body); - } - - -// IVenueInvitationEvent invite = new VenueInvitationEvent(roomID, from, subject, body); - - - - - } - }; - venueManager.addInvitationListener(intInvitationListener); - } + if (isConnected() && (presenceAdapter != null)) { + IChatRoomManager venueManager = presenceAdapter + .getChatRoomManager(); + if (venueManager != null) { + intInvitationListener = new IChatRoomInvitationListener() { + @Override + public void handleInvitationReceived(ID roomID, ID from, + String subject, String body) { + + IQualifiedID venueId = IDConverter.convertFrom(roomID); + IQualifiedID id = IDConverter.convertFrom(from); + + IChatID invitor = new VenueUserId(id.getName(), + id.getHost(), id.getResource()); + + IVenueInvitationEvent invite = new VenueInvitationEvent( + venueId, invitor, subject, body); + System.out.println("Posting invitation using eventBus:" + + eventBus.hashCode()); + eventBus.post(invite); + } + }; + venueManager.addInvitationListener(intInvitationListener); } } } /** + * Register an event handler with this * - * @param listener - * @return + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#registerEventHandler(java.lang.Object) */ - public IVenueInvitationListener setVenueInvitationListener( - IVenueInvitationListener listener) { - invitationListener = listener; - return listener; + @Override + public void registerEventHandler(Object handler) { + eventBus.register(handler); } /** - * + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unRegisterEventHandler(java.lang.Object) */ - public void removeVenueInvitationListener() { - invitationListener = null; + @Override + public void unRegisterEventHandler(Object handler) { + eventBus.unregister(handler); } + + /** + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#getEventPublisher() + */ + @Override + public EventBus getEventPublisher() { + return eventBus; + } + } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestJAXBObject.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestJAXBObject.java index db551b9d3c..cd0f35334c 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestJAXBObject.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestJAXBObject.java @@ -48,7 +48,8 @@ public class TestJAXBObject implements IRenderable, ISerializableObject { } /** - * @param item_1 the item_1 to set + * @param item_1 + * the item_1 to set */ public void setItem_1(String item_1) { this.item_1 = item_1; @@ -62,7 +63,8 @@ public class TestJAXBObject implements IRenderable, ISerializableObject { } /** - * @param value the value to set + * @param value + * the value to set */ public void setValue(Integer value) { this.value = value; diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestObject.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestObject.java index a5699b8990..2c8a60cc80 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestObject.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/TestObject.java @@ -27,30 +27,30 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 23, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ @DynamicSerialize public class TestObject implements IRenderable { @DynamicSerializeElement private String name; - + @DynamicSerializeElement private int value = 0; - + public TestObject() { } - + public TestObject(String name) { this.name = name; } @@ -63,7 +63,8 @@ public class TestObject implements IRenderable { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; @@ -77,7 +78,8 @@ public class TestObject implements IRenderable { } /** - * @param value the value to set + * @param value + * the value to set */ public void setValue(int value) { this.value = value; 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 0982d74b37..7ec5b2ddac 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 @@ -19,8 +19,6 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.session; -import java.util.ArrayList; -import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.List; @@ -44,7 +42,7 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener; import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID; import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; +// import com.google.common.eventbus.Subscribe; 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; @@ -57,9 +55,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEv import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IInvitation; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener; -import com.raytheon.uf.viz.collaboration.comm.identity.listener.IPresenceListener; import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; @@ -110,79 +105,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId; public class VenueSession extends BaseSession implements IVenueSession, ISharedDisplaySession { - /** - * - * TODO Add Description - * - *
-     * 
-     * SOFTWARE HISTORY
-     * 
-     * Date         Ticket#    Engineer    Description
-     * ------------ ---------- ----------- --------------------------
-     * Feb 27, 2012            jkorman     Initial creation
-     * 
-     * 
- * - * @author jkorman - * @version 1.0 - */ - private static class InternalListener { - - private IMessageListener messageListener; - - private IPresenceListener presenceListener; - - private IMessageFilter filter; - - /** - * - * @param listener - * @param filter - */ - public InternalListener(IMessageListener listener, IMessageFilter filter) { - messageListener = listener; - this.filter = filter; - - } - - /** - * - * @param listener - * @param filter - */ - public InternalListener(IPresenceListener listener, - IMessageFilter filter) { - presenceListener = listener; - this.filter = filter; - } - - /** - * - * @param message - */ - public void processMessage(IMessage message) { - messageListener.processMessage(message); - } - - /** - * - * @param presence - */ - public void processPresence(IPresence presence) { - presenceListener.notifyPresence(presence); - } - - /** - * - * @param message - * @return - */ - public boolean filter(IMessage message) { - return filter.filter(message); - } - } - private static final String SEND_CMD = "[[COMMAND"; private static final String SEND_TXT = "[[TEXT]]"; @@ -193,10 +115,6 @@ public class VenueSession extends BaseSession implements IVenueSession, private IChatRoomContainer venueContainer = null; - private List collaborationListeners = null; - - private List presenceListeners = null; - private IIMMessageListener intListener = null; private IChatRoomParticipantListener participantListener = null; @@ -218,84 +136,79 @@ public class VenueSession extends BaseSession implements IVenueSession, * @param eventBus */ VenueSession(IContainer container, EventBus externalBus, - SessionManager manager) { + SessionManager manager) throws CollaborationException { super(container, externalBus, manager); - try { - setup(); - } catch (ECFException e) { - } finally { - initListeners(); - } - -// Runnable r = new Runnable() { -// @Override -// public void run() { -// try { -// Thread.sleep(20000); -// -// TestJAXBObject j = new TestJAXBObject(); -// j.setItem_1("This is an object"); -// j.setValue(5); -// sendRenderableObject(j); -// -// VenueParticipant id = new VenueParticipant("jkorman", "paul", "awipscm.omaha.us.ray.com"); -// id.setResource("cave"); -// IInitData d = new InitData(); -// ((InitData) d).setName("This is a test init data object"); -// -// IDisplayEvent e = new DisplayEvent(); -// ((DisplayEvent) e).setName("This is a test display event"); -// -// sendInitData(id, d); -// sendEvent(id,e); -// } catch (Exception e) { -// System.out.println("Error sending RenderableObject"); -// } -// } -// }; -// Thread t = new Thread(r); -// t.start(); -// registerEventHandler(this); -// try { -// DataHandler h = new DataHandler(); -// subscribeToInitData(h); -// } catch (CollaborationException ce) { -// ce.printStackTrace(); -// } + // Runnable r = new Runnable() { + // @Override + // public void run() { + // try { + // Thread.sleep(30000); + // + // TestJAXBObject j = new TestJAXBObject(); + // j.setItem_1("This is an object"); + // j.setValue(5); + // sendRenderableObject(j); + // + // VenueParticipant id = new VenueParticipant("jkorman", + // "paul", "awipscm.omaha.us.ray.com"); + // id.setResource("cave"); + // IInitData d = new InitData(); + // ((InitData) d).setName("This is a test init data object"); + // + // IDisplayEvent e = new DisplayEvent(); + // ((DisplayEvent) e).setName("This is a test display event"); + // + // sendInitData(id, d); + // sendEvent(id, e); + // + // Thread.sleep(10000); + // System.out.println("Sending invitation"); + // + // sendInvitation("tester5@conference.awipscm.omaha.us.ray.com", + // "jkorman", "Test Room", "Join the test"); + // + // } catch (Exception e) { + // System.out.println("Error sending RenderableObject"); + // } + // + // } + // }; + // Thread t = new Thread(r); + // t.start(); + // registerEventHandler(this); + // try { + // DataHandler h = new DataHandler(); + // subscribeToInitData(h); + // } catch (CollaborationException ce) { + // ce.printStackTrace(); + // } } -// @Subscribe -// public void handle(IRenderable renderable) { -// System.out.println("Renderable found"); -// if (renderable instanceof TestJAXBObject) { -// TestJAXBObject j = (TestJAXBObject) renderable; -// if (j.getValue() < 100) { -// System.out.println(String.format("%s %d Renderable", -// j.getItem_1(), j.getValue())); -// j.setValue(j.getValue() + 200); -// j.setItem_1("Now for the return trip"); -// try { -// sendRenderableObject(j); -// } catch (CollaborationException ce) { -// System.out.println("Error sending RenderableObject"); -// } -// } else { -// System.out.println(String.format("%s %d Renderable", -// j.getItem_1(), j.getValue())); -// } -// } -// } - - /** - * - * @throws ECFException - */ - void setup() throws ECFException { - super.setup(); - } + // @Subscribe + // public void handle(IRenderable renderable) { + // System.out.println("Renderable found"); + // if (renderable instanceof TestJAXBObject) { + // TestJAXBObject j = (TestJAXBObject) renderable; + // if (j.getValue() < 100) { + // System.out.println(String.format("%s %d Renderable", + // j.getItem_1(), j.getValue())); + // j.setValue(j.getValue() + 200); + // j.setItem_1("Now for the return trip"); + // try { + // sendRenderableObject(j); + // } catch (CollaborationException ce) { + // System.out.println("Error sending RenderableObject"); + // } + // } else { + // System.out.println(String.format("%s %d Renderable", + // j.getItem_1(), j.getValue())); + // } + // } + // } /** + * Get the identification of the owner of this session. * * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID() */ @@ -310,6 +223,7 @@ public class VenueSession extends BaseSession implements IVenueSession, * * @return */ + @Override public ISharedDisplaySession spawnSharedDisplaySession() { return this; } @@ -325,20 +239,17 @@ public class VenueSession extends BaseSession implements IVenueSession, if (intListener != null) { venueContainer.removeMessageListener(intListener); + intListener = null; } if (participantListener != null) { venueContainer .removeChatRoomParticipantListener(participantListener); + participantListener = null; + } + if (venueContainer != null) { + venueContainer.disconnect(); + venueContainer = null; } - - collaborationListeners.clear(); - collaborationListeners = null; - - presenceListeners.clear(); - presenceListeners = null; - - venueContainer.disconnect(); - venueContainer = null; venueManager = null; venueInfo = null; @@ -346,11 +257,335 @@ public class VenueSession extends BaseSession implements IVenueSession, super.close(); } + /** + * Get information about this venue. + * + * @return The information about this venue. May return a null reference if + * the venue is not connected. + */ + @Override + public IVenue getVenue() { + IVenue venue = null; + if (isConnected() && (venueContainer != null)) { + venue = new Venue(); + ID[] ids = venueContainer.getChatRoomParticipants(); + for (ID id : ids) { + + IVenueParticipant vp = new VenueParticipant(); + String fullName = id.getName(); + vp.setName(Tools.parseName(fullName)); + vp.setHost(Tools.parseHost(fullName)); + vp.setResource(Tools.parseResource(fullName)); + venue.addParticipant(vp); + } + venue.setInfo(InfoAdapter.createVenueInfo(venueInfo)); + } else { + + } + return venue; + } + + /** + * Send an invitation from this venue to another user. + * + * @param invitation + * An invitation + * @return + */ + @Override + public int sendInvitation(IInvitation invitation) { + int status = Errors.NO_ERROR; + IChatRoomInvitationSender sender = getConnectionPresenceAdapter() + .getChatRoomManager().getInvitationSender(); + if (sender != null) { + ID roomId = getConnectionPresenceAdapter().getChatRoomManager() + .getChatRoomInfo(invitation.getRoomId()).getConnectedID(); + + // ******************* + // ** TODO : The host part of this need to defined + ID userId = IDFactory.getDefault().createID( + getConnectionNamespace(), + invitation.getFrom() + "@awipscm.omaha.us.ray.com"); + // ******************* + + try { + String body = insertSessionId(invitation.getBody()); + + sender.sendInvitation(roomId, userId, invitation.getSubject(), + body); + } catch (ECFException e) { + e.printStackTrace(); + } + } + return status; + } + + /** + * Send an invitation from this venue to another user. + * + * @param room + * The target venue for this invitation. + * @param id + * 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 + * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public int sendInvitation(String room, String id, String subject, + String body) { + // Assume success + int status = Errors.NO_ERROR; + IChatRoomInvitationSender sender = getConnectionPresenceAdapter() + .getChatRoomManager().getInvitationSender(); + if (sender != null) { + body = insertSessionId(body); + + ID roomId = getConnectionPresenceAdapter().getChatRoomManager() + .getChatRoomInfo(room).getConnectedID(); + ID userId = IDFactory.getDefault().createID( + getConnectionNamespace(), id + "@awipscm.omaha.us.ray.com"); + + try { + sender.sendInvitation(roomId, userId, subject, body); + } catch (ECFException e) { + e.printStackTrace(); + } + } + return status; + } + + /** + * Send an invitation from this venue to another user. + * + * @param room + * The target venue for this invitation. + * @param id + * 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 + * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public int sendInvitation(String room, List ids, String subject, + String body) { + // Assume success + int status = Errors.NO_ERROR; + if (ids != null) { + for (String id : ids) { + sendInvitation(room, id, subject, body); + } + } else { + status = -1; + } + return status; + } + + /** + * + * @param body + * @return + */ + private String insertSessionId(String body) { + return String.format(Tools.TAG_INVITE_ID, sessionId, + (body != null) ? body : ""); + } + + /** + * + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getSessionId() + */ + @Override + public String getSessionId() { + return sessionId; + } + + // *************************** + // ISharedDisplaySession + // *************************** + + /** + * + * @param participant + * @param initData + * @throws CollaborationException + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendInitData(com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID, + * com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData) + */ + @Override + public void sendInitData( + com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, + IInitData initData) throws CollaborationException { + + PeerToPeerChat session = null; + session = getP2PSession(); + if (session != null) { + String message = Tools.marshallData(initData); + if (message != null) { + session.sendPeerToPeer(participant.getFQName(), message); + } + } + } + + /** + * Subscribe to peer to peer data events. + * + * @param An + * object that subscribes to peer to peer events. + */ + @Override + public void subscribeToInitData(Object subscriber) + throws CollaborationException { + if (!initSubscribers.containsKey(subscriber)) { + initSubscribers.put(subscriber, subscriber); + } + EventBus bus = getP2PSession().getEventPublisher(); + System.out.println("Subscribe EventBus instance :" + bus.hashCode()); + bus.register(subscriber); + } + + /** + * UnSubscribe to peer to peer data events. + * + * @param An + * object that will be unsubscribed for peer to peer events. + */ + @Override + public void unSubscribeToInitData(Object subscriber) + throws CollaborationException { + if (initSubscribers.containsKey(subscriber)) { + initSubscribers.remove(subscriber); + getP2PSession().getEventPublisher().unregister(subscriber); + } + } + + /** + * + * @param participant + * @param event + * @throws CollaborationException + */ + @Override + public void sendEvent( + com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, + IDisplayEvent event) throws CollaborationException { + + PeerToPeerChat session = null; + session = getP2PSession(); + if (session != null) { + String message = Tools.marshallData(event); + if (message != null) { + session.sendPeerToPeer(participant.getFQName(), message); + } + } + } + + /** + * + * @param event + * @throws CollaborationException + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendEvent(com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent) + */ + @Override + public void sendEvent(IDisplayEvent event) throws CollaborationException { + if (event != null) { + String message = Tools.marshallData(event); + if (message != null) { + sendTextMessage(message); + } + } + } + + /** + * @param renderable + * @throws CollaborationException + * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendRenderableObject(com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable) + */ + @Override + public void sendRenderableObject(IRenderable renderable) + throws CollaborationException { + if (renderable != null) { + String message = Tools.marshallData(renderable); + if (message != null) { + sendTextMessage(message); + } + } + } + + /** + * 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 IChatID getCurrentDataProvider() { + return sessionDataProvider; + } + + /** + * 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 IChatID 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) { + return roles.contains(role); + } + + // *************************** + // ISharedDisplaySession + // *************************** + + /** + * @param message + * A message to send. + * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendTextMessage(java.lang.String) + */ + @Override + public void sendTextMessage(String message) throws CollaborationException { + // Assume success + if ((venueContainer != null) && (message != null)) { + IChatRoomMessageSender sender = venueContainer + .getChatRoomMessageSender(); + try { + if (message.startsWith(SEND_CMD)) { + sender.sendMessage(message); + } else { + sender.sendMessage(SEND_TXT + message); + } + } catch (ECFException e) { + throw new CollaborationException("Error sending text messge"); + } + } + } + + // *************************** + // Internal methods + // *************************** + /** * * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#joinVenue(java.lang.String) */ - public int joinVenue(String venueName) { + int joinVenue(String venueName) { int errorStatus = -1; try { // Create chat room container from manager @@ -382,7 +617,7 @@ public class VenueSession extends BaseSession implements IVenueSession, * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String, * java.lang.String) */ - public int createVenue(String venueName, String subject) { + int createVenue(String venueName, String subject) { int errorStatus = -1; try { // Create chat room container from manager @@ -517,317 +752,6 @@ public class VenueSession extends BaseSession implements IVenueSession, return errorStatus; } - /** - * - * @return The information about this venue. May return a null reference if - * the venue is not connected. - */ - public IVenue getVenue() { - IVenue venue = null; - if (isConnected() && (venueContainer != null)) { - venue = new Venue(); - ID[] ids = venueContainer.getChatRoomParticipants(); - for (ID id : ids) { - IVenueParticipant participant = new VenueParticipant(); - participant.setName(id.getName()); - venue.addParticipant(participant); - } - venue.setInfo(InfoAdapter.createVenueInfo(venueInfo)); - } else { - - } - return venue; - } - - /** - * Send an invitation from this venue to another user. - * - * @param invitation - * An invitation - * @return - */ - public int sendInvitation(IInvitation invitation) { - int status = Errors.NO_ERROR; - IChatRoomInvitationSender sender = getConnectionPresenceAdapter() - .getChatRoomManager().getInvitationSender(); - if (sender != null) { - ID roomId = getConnectionPresenceAdapter().getChatRoomManager() - .getChatRoomInfo(invitation.getRoomId()).getConnectedID(); - - // ******************* - // ** TODO : The host part of this need to defined - ID userId = IDFactory.getDefault().createID( - getConnectionNamespace(), - invitation.getFrom() + "@awipscm.omaha.us.ray.com"); - // ******************* - - try { - sender.sendInvitation(roomId, userId, invitation.getSubject(), - invitation.getBody()); - } catch (ECFException e) { - e.printStackTrace(); - } - } - return status; - } - - /** - * Send an invitation from this venue to another user. - * - * @param room - * The target venue for this invitation. - * @param id - * 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 - * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public int sendInvitation(String room, String id, String subject, - String body) { - // Assume success - int status = Errors.NO_ERROR; - IChatRoomInvitationSender sender = getConnectionPresenceAdapter() - .getChatRoomManager().getInvitationSender(); - if (sender != null) { - - ID roomId = getConnectionPresenceAdapter().getChatRoomManager() - .getChatRoomInfo(room).getConnectedID(); - ID userId = IDFactory.getDefault().createID( - getConnectionNamespace(), id + "@awipscm.omaha.us.ray.com"); - - try { - sender.sendInvitation(roomId, userId, subject, body); - } catch (ECFException e) { - e.printStackTrace(); - } - } - return status; - } - - /** - * Send an invitation from this venue to another user. - * - * @param room - * The target venue for this invitation. - * @param id - * 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 - * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public int sendInvitation(String room, List ids, String subject, - String body) { - // Assume success - int status = Errors.NO_ERROR; - if (ids != null) { - for (String id : ids) { - sendInvitation(room, id, subject, body); - } - } else { - status = -1; - } - return status; - } - - /** - * - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getSessionId() - */ - @Override - public String getSessionId() { - return sessionId; - } - - // *************************** - // ISharedDisplaySession - // *************************** - - /** - * - * @param participant - * @param initData - * @throws CollaborationException - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendInitData(com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID, - * com.raytheon.uf.viz.collaboration.comm.identity.event.IInitData) - */ - @Override - public void sendInitData( - com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, - IInitData initData) throws CollaborationException { - - PeerToPeerChat session = null; - session = getP2PSession(); - if (session != null) { - String message = Tools.marshallData(initData); - if (message != null) { - session.sendPeerToPeer(participant.getFQName(), message); - } - } - } - - /** - * Subscribe to peer to peer data events. - * - * @param An - * object that subscribes to peer to peer events. - */ - @Override - public void subscribeToInitData(Object subscriber) - throws CollaborationException { - if (!initSubscribers.containsKey(subscriber)) { - initSubscribers.put(subscriber, subscriber); - } - PeerToPeerChat session = getP2PSession(); - session.getEventPublisher().register(subscriber); - } - - /** - * UnSubscribe to peer to peer data events. - * - * @param An - * object that will be unsubscribed for peer to peer events. - */ - @Override - public void unSubscribeToInitData(Object subscriber) - throws CollaborationException { - if (initSubscribers.containsKey(subscriber)) { - initSubscribers.remove(subscriber); - PeerToPeerChat session = getP2PSession(); - session.getEventPublisher().unregister(subscriber); - } - } - - /** - * - * @param participant - * @param event - * @throws CollaborationException - */ - @Override - public void sendEvent( - com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID participant, - IDisplayEvent event) throws CollaborationException { - - PeerToPeerChat session = null; - session = getP2PSession(); - if (session != null) { - String message = Tools.marshallData(event); - if (message != null) { - session.sendPeerToPeer(participant.getFQName(), message); - } - } - } - - /** - * - * @param event - * @throws CollaborationException - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendEvent(com.raytheon.uf.viz.collaboration.comm.identity.event.IDisplayEvent) - */ - @Override - public void sendEvent(IDisplayEvent event) throws CollaborationException { - if (event != null) { - String message = Tools.marshallData(event); - if (message != null) { - sendTextMessage(message); - } - } - } - - /** - * @param renderable - * @throws CollaborationException - * @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#sendRenderableObject(com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable) - */ - @Override - public void sendRenderableObject(IRenderable renderable) - throws CollaborationException { - if (renderable != null) { - String message = Tools.marshallData(renderable); - if (message != null) { - sendTextMessage(message); - } - } - } - - /** - * 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 IChatID getCurrentDataProvider() { - return sessionDataProvider; - } - - /** - * 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 IChatID 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) { - return roles.contains(role); - } - - // *************************** - // ISharedDisplaySession - // *************************** - - /** - * @param message - * A message to send. - * @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendTextMessage(java.lang.String) - */ - @Override - public void sendTextMessage(String message) throws CollaborationException { - // Assume success - if ((venueContainer != null) && (message != null)) { - IChatRoomMessageSender sender = venueContainer - .getChatRoomMessageSender(); - try { - if (message.startsWith(SEND_CMD)) { - sender.sendMessage(message); - } else { - sender.sendMessage(SEND_TXT + message); - } - } catch (ECFException e) { - throw new CollaborationException("Error sending text messge"); - } - } - } - - /** - * Set up the various message listener lists. Ensures that all listener - * collections are not null prior to use. - */ - private void initListeners() { - presenceListeners = Collections - .synchronizedList(new ArrayList()); - collaborationListeners = Collections - .synchronizedList(new ArrayList()); - } - /** * * @param message @@ -862,23 +786,6 @@ public class VenueSession extends BaseSession implements IVenueSession, } } - /** - * - * @param message - */ - private void firePresenceListeners(IMessage message) { - synchronized (presenceListeners) { - if (message instanceof IPresence) { - IPresence presence = (IPresence) message; - for (InternalListener listener : presenceListeners) { - if (listener.filter(message)) { - listener.processPresence(presence); - } - } - } - } - } - /** * Convert from an ECF chat room message to an IMessage instance. * diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java new file mode 100644 index 0000000000..aea8bf766c --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java @@ -0,0 +1,68 @@ +/** + * 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.user; + +import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; +import com.raytheon.uf.viz.collaboration.comm.provider.Tools; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 28, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class IDConverter { + + /** + * + * @param user + * @return + */ + public static IQualifiedID convertFrom(org.eclipse.ecf.core.identity.ID id) { + String name = Tools.parseName(id.getName()); + String host = Tools.parseHost(id.getName()); + String rsc = Tools.parseResource(id.getName()); + return new UserId(name, host, rsc); + } + + /** + * + * @param user + * @return + */ + public static IChatID convertFrom(org.eclipse.ecf.core.user.IUser user) { + String name = Tools.parseName(user.getID().getName()); + String host = Tools.parseHost(user.getID().getName()); + return new VenueUserId(name, user.getNickname(), host); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/RosterId.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/RosterId.java index 9012fc91b9..e2a2fe0eaa 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/RosterId.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/RosterId.java @@ -26,17 +26,17 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 21, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class RosterId extends UserId implements IChatID { @@ -50,11 +50,12 @@ public class RosterId extends UserId implements IChatID { * @param nickName * @param resource */ - public RosterId(String userName, String hostName, String resource, String nickName) { + public RosterId(String userName, String hostName, String resource, + String nickName) { super(userName, hostName, resource); nickname = nickName; } - + /** * @see com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID#setNickname(java.lang.String) */ @@ -71,7 +72,9 @@ public class RosterId extends UserId implements IChatID { return nickname; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override @@ -83,7 +86,9 @@ public class RosterId extends UserId implements IChatID { return result; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -102,15 +107,15 @@ public class RosterId extends UserId implements IChatID { return false; return true; } - + /** * * @param user * @return */ public static IChatID convertFrom(org.eclipse.ecf.core.user.IUser user) { - String name = Tools.parseName(user.getName()); - String host = Tools.parseHost(user.getName()); + String name = Tools.parseName(user.getID().getName()); + String host = Tools.parseHost(user.getID().getName()); return new RosterId(name, host, user.getNickname(), null); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java index 87344d2f7b..f3771d7431 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java @@ -25,24 +25,24 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 24, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class UserId implements IQualifiedID { private String name; - + private String host; - + private String resource; /** @@ -55,7 +55,7 @@ public class UserId implements IQualifiedID { this.host = hostName; resource = null; } - + /** * * @param userName @@ -108,7 +108,8 @@ public class UserId implements IQualifiedID { /** * - * @param resourceName The resource associated with this id. + * @param resourceName + * The resource associated with this id. * @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setResourceName(java.lang.String) */ @Override @@ -135,14 +136,16 @@ public class UserId implements IQualifiedID { StringBuilder sb = new StringBuilder(name); sb.append("@"); sb.append(host); - if(resource != null) { + if (resource != null) { sb.append("/"); sb.append(resource); } return sb.toString(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override @@ -156,7 +159,9 @@ public class UserId implements IQualifiedID { return result; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java index 97309599d8..27be20c5d3 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueParticipant.java @@ -29,21 +29,21 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 1, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class VenueParticipant implements IVenueParticipant { - + private Map properties; private String name; @@ -53,7 +53,7 @@ public class VenueParticipant implements IVenueParticipant { private String host; private String resource; - + /** * */ @@ -79,7 +79,8 @@ public class VenueParticipant implements IVenueParticipant { } /** - * @see com.raytheon.uf.viz.collaboration.comm.identity.IPropertied#setProperty(java.lang.String, java.lang.String) + * @see com.raytheon.uf.viz.collaboration.comm.identity.IPropertied#setProperty(java.lang.String, + * java.lang.String) */ @Override public void setProperty(String key, String value) { @@ -87,12 +88,13 @@ public class VenueParticipant implements IVenueParticipant { } /** - * @see com.raytheon.uf.viz.collaboration.comm.identity.IPropertied#getProperty(java.lang.String, java.lang.String) + * @see com.raytheon.uf.viz.collaboration.comm.identity.IPropertied#getProperty(java.lang.String, + * java.lang.String) */ @Override public String getProperty(String key, String defaultValue) { String value = properties.get(key); - if(value == null) { + if (value == null) { value = defaultValue; } return value; @@ -178,7 +180,7 @@ public class VenueParticipant implements IVenueParticipant { StringBuilder sb = new StringBuilder(name); sb.append("@"); sb.append(host); - if(resource != null) { + if (resource != null) { sb.append("/"); sb.append(resource); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java index 702999fb75..2be415e4b2 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueUserId.java @@ -20,29 +20,28 @@ package com.raytheon.uf.viz.collaboration.comm.provider.user; import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID; -import com.raytheon.uf.viz.collaboration.comm.provider.Tools; /** * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 5, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class VenueUserId extends UserId implements IChatID { private String nickName; - + /** * * @param userName @@ -110,15 +109,4 @@ public class VenueUserId extends UserId implements IChatID { return false; return true; } - - /** - * - * @param user - * @return - */ - public static IChatID convertFrom(org.eclipse.ecf.core.user.IUser user) { - String name = Tools.parseName(user.getName()); - String host = Tools.parseHost(user.getName()); - return new VenueUserId(name, user.getNickname(), host); - } }