Merge branch 'ss_builds' (12.11.1-4) into development

Conflicts:
	cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/procedures/IAlterBundleContributor.java
	cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/AlterBundleDlg.java
	cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/CoordinateInputPanel.java
	cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointEditDialog.java
	cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/dialog/PointsMgrDialog.java
	cave/com.raytheon.uf.viz.points/src/com/raytheon/uf/viz/points/ui/layer/PointsToolLayer.java
	cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/products/ui/BaseRadarProductUI.java
	cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/ToolsAlterBundleContributor.java
	cave/com.raytheon.viz.gfe/help/EXAMPLElocalMaps.py
	cave/com.raytheon.viz.gfe/help/EXAMPLElocalMapsAdd.py
	cave/com.raytheon.viz.gfe/help/localMapsConfig.html
	cave/com.raytheon.viz.gfe/help/mapConfig.html
	cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
	cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java
	edexOsgi/build.edex/esb/data/utility/edex_static/base/config/gfe/Maps.py
	edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java
	edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/MapManager.java
	edexOsgi/com.raytheon.edex.plugin.gfe/utility/edex_static/base/gfe/ShapeTable.py
	edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/util/WorldWrapCorrector.java
	ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java
	rpms/common/yum/arch.x86/comps.xml

Former-commit-id: c19835d4be [formerly da7a11fe97] [formerly 4610ecc513] [formerly 751563e331 [formerly 4610ecc513 [formerly 07beab271f793ae79fcf9233f9d384702ead22a9]]]
Former-commit-id: 751563e331
Former-commit-id: 4390735c107d9ebc5c839213d322a92aad724790 [formerly 0c0c1144c6]
Former-commit-id: d0e91329b4
This commit is contained in:
Steve Harris 2012-10-16 15:48:14 -05:00
commit d88afce365
656 changed files with 71520 additions and 2531 deletions

View file

@ -276,6 +276,14 @@
<param name="feature"
value="com.raytheon.uf.viz.kml.export.feature" />
</antcall>
<antcall target="p2.build.repo">
<param name="feature"
value="com.raytheon.uf.viz.npp.feature" />
</antcall>
<antcall target="p2.build.repo">
<param name="feature"
value="com.raytheon.uf.viz.collaboration.feature" />
</antcall>
<antcall target="cleanup.features" />
</target>
@ -407,6 +415,20 @@
</delete>
</then>
</if>
<!-- Remove 'com.raytheon.uf.viz.collaboration.product.feature' -->
<if>
<available
file="${basedir}/cave/p2/features/com.raytheon.uf.viz.collaboration.product.feature"
type="dir" />
<then>
<delete includeemptydirs="true">
<fileset
dir="${basedir}/cave/p2/features/com.raytheon.uf.viz.collaboration.product.feature"
/>
</delete>
</then>
</if>
</target>
<taskdef resource="net/sf/antcontrib/antlib.xml"

View file

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

View file

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

View file

@ -0,0 +1,8 @@
#Fri Jul 20 17:19:32 CDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xmpp
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.comm.xmpp;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.comm.xmpp.Activator
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf;bundle-version="3.1.300",
org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0",
org.eclipse.ecf.provider;bundle-version="4.2.100",
org.eclipse.ecf.presence;bundle-version="2.0.0",
org.eclipse.ecf.sharedobject;bundle-version="2.2.100",
org.jivesoftware.smack;bundle-version="3.1.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.collaboration.comm.xmpp

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ecf.containerFactory">
<containerFactory
class="com.raytheon.uf.viz.collaboration.comm.xmpp.internal.XMPPContainerInstantiator"
description="AWIPS XMPP (Jabber)"
name="com.raytheon.uf.viz.collaboration.comm.xmpp">
</containerFactory>
</extension>
</plugin>

View file

@ -0,0 +1,30 @@
package com.raytheon.uf.viz.collaboration.comm.xmpp;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext 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;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
}

View file

@ -0,0 +1,356 @@
/**
* 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.xmpp;
import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.events.ContainerConnectedEvent;
import org.eclipse.ecf.core.events.ContainerConnectingEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.sharedobject.SharedObjectAddException;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.internal.provider.xmpp.Messages;
import org.eclipse.ecf.internal.provider.xmpp.XmppPlugin;
import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnectionObjectPacketEvent;
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
import org.eclipse.ecf.presence.im.IChatManager;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.provider.comm.AsynchEvent;
import org.eclipse.ecf.provider.comm.ConnectionCreateException;
import org.eclipse.ecf.provider.comm.ISynchAsynchConnection;
import org.eclipse.ecf.provider.generic.ContainerMessage;
import org.eclipse.osgi.util.NLS;
import org.jivesoftware.smack.XMPPException;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.XMPPChatRoomContainer;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.XMPPChatRoomManager;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.XMPPContainerPresenceHelper;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.smack.ECFConnection;
/**
* Extends the ECF XMPPContainer but overrides any methods which use the
* chatRoomManager or containerPresenceHelper to use viz specific instances.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPContainer extends org.eclipse.ecf.provider.xmpp.XMPPContainer {
/**
* custom chat room manager.
*/
XMPPChatRoomManager chatRoomManager = null;
XMPPContainerPresenceHelper presenceHelper = null;
public XMPPContainer() throws Exception {
this(DEFAULT_KEEPALIVE);
}
public XMPPContainer(int ka) throws Exception {
super(ka);
chatRoomManager = new XMPPChatRoomManager(getID());
presenceHelper = new XMPPContainerPresenceHelper(this);
}
public XMPPContainer(String userhost, int ka) throws Exception {
super(userhost, ka);
chatRoomManager = new XMPPChatRoomManager(getID());
presenceHelper = new XMPPContainerPresenceHelper(this);
}
/**
* Overridden to return custom chatRoomManager
*/
@Override
public IChatRoomManager getChatRoomManager() {
return chatRoomManager;
}
/**
* Overridden to use rosterManager from custom presenceHelper
*/
@Override
public IRosterManager getRosterManager() {
return presenceHelper.getRosterManager();
}
/**
* Overridden to use chatManager from custom presenceHelper
*/
@Override
public IChatManager getChatManager() {
return presenceHelper.getChatManager();
}
/**
* Overridden to disconnect custom presenceHelper and connect our own
* instead. Also takes the functionality from the connect method in
* ClientSOContainer so that we can complete all the necessary functionality
* of the super's super method in our own method. The super method
* originally called super with a different presence helper id and that
* would break part of our functionality
*/
@Override
public void connect(ID remote, IConnectContext joinContext)
throws ContainerConnectException {
try {
getSharedObjectManager().addSharedObject(presenceHelperID,
presenceHelper, null);
// following taken from
// ClientSOContainer.connect(ID,IConnectContext);
try {
if (isClosing)
throw new IllegalStateException("Container closing"); //$NON-NLS-1$
if (remote == null)
throw new ContainerConnectException(
"targetID cannot be null"); //$NON-NLS-1$
Object response = null;
synchronized (getConnectLock()) {
// Throw if already connected
if (isConnected())
throw new IllegalStateException(
"Container already connected connectedID=" + getConnectedID()); //$NON-NLS-1$
// Throw if connecting
if (isConnecting())
throw new IllegalStateException("Container connecting"); //$NON-NLS-1$
// else we're entering connecting state
// first notify synchonously
final ISynchAsynchConnection aConnection = createConnection(
remote, joinContext);
setStateConnecting(aConnection);
fireContainerEvent(new ContainerConnectingEvent(
this.getID(), remote, joinContext));
final Object connectData = getConnectData(remote,
joinContext);
final int connectTimeout = getConnectTimeout();
synchronized (aConnection) {
try {
// Make connect call
response = aConnection.connect(remote, connectData,
connectTimeout);
} catch (final ECFException e) {
if (getConnection() != aConnection)
disconnect(aConnection);
else
setStateDisconnected(aConnection);
throw e;
}
// If not in correct state, disconnect and return
if (getConnection() != aConnection) {
disconnect(aConnection);
throw new IllegalStateException(
"Container connect failed because not in correct state"); //$NON-NLS-1$
}
ID serverID = null;
try {
serverID = handleConnectResponse(remote, response);
} catch (final Exception e) {
setStateDisconnected(aConnection);
throw e;
}
setStateConnected(serverID, aConnection);
// notify listeners
fireContainerEvent(new ContainerConnectedEvent(
this.getID(), remoteServerID));
aConnection.start();
}
}
} catch (XMPPException e) {
throw new ContainerConnectException(e.getMessage(), e);
} catch (final ECFException e) {
final IStatus s = e.getStatus();
throw new ContainerConnectException(s.getMessage(),
s.getException());
} catch (final Exception e) {
throw new ContainerConnectException(e.getLocalizedMessage(), e);
}
XmppPlugin.getDefault().registerService(this);
} catch (final ContainerConnectException e) {
disconnect();
throw e;
} catch (final SharedObjectAddException e1) {
disconnect();
throw new ContainerConnectException(NLS.bind(
Messages.XMPPContainer_EXCEPTION_ADDING_SHARED_OBJECT,
presenceHelperID), e1);
}
// end ClientSOContainer code
getSharedObjectManager().removeSharedObject(presenceHelperID);
try {
getSharedObjectManager().addSharedObject(presenceHelperID,
presenceHelper, null);
} catch (SharedObjectAddException e) {
disconnect();
throw new ContainerConnectException(NLS.bind(
Messages.XMPPContainer_EXCEPTION_ADDING_SHARED_OBJECT,
presenceHelperID), e);
}
}
/**
* Need to override this method from ClientSOContainer so that our connect
* method can set the connection and the connectionState and the
* remoteServerID
*
* Taken from ECF.
*
* @param serverID
* @param conn
*/
private void setStateConnected(ID serverID, ISynchAsynchConnection conn) {
connectionState = CONNECTED;
connection = conn;
remoteServerID = serverID;
}
/**
* Need to override this method out of ClientSOContainer so that our connect
* method can set the connectionState and disconnect the connection
*
* Taken from ECF
*
*/
private void setStateDisconnected(ISynchAsynchConnection conn) {
disconnect(conn);
connectionState = DISCONNECTED;
connection = null;
remoteServerID = null;
}
/**
* Need to override this method out of ClientSOContainer so that our connect
* method can set the connectionState and the connection
*
* Taken from ECF
*
* @param conn
*/
private void setStateConnecting(ISynchAsynchConnection conn) {
connectionState = CONNECTING;
connection = conn;
}
/**
* Overridden to disconnect custom chatRoomManager and custom presenceHelper
*/
@Override
public void disconnect() {
super.disconnect();
chatRoomManager.setConnection(null, null, null);
presenceHelper.disconnect();
}
/**
* Overridden to return custom chatRoomManager
*/
@Override
public void dispose() {
super.dispose();
chatRoomManager.dispose();
}
/**
* Overriden to set connection in custom chatRoomManager and to set user in
* custom presenceHelper
*/
@Override
protected ID handleConnectResponse(ID originalTarget, Object serverData)
throws Exception {
ID result = super.handleConnectResponse(originalTarget, serverData);
chatRoomManager.setConnection(getConnectNamespace(), originalTarget,
getECFConnection());
presenceHelper.setUser(new User(originalTarget));
return result;
}
/**
* Overriden to cast ECFConnection to viz implementation
*/
public ECFConnection getECFConnection() {
return (ECFConnection) super.getConnection();
}
/**
* Overriden to create viz ECFConnection
*/
@Override
protected ISynchAsynchConnection createConnection(ID remoteSpace,
Object data) throws ConnectionCreateException {
final boolean google = isGoogle(remoteSpace);
return new ECFConnection(google, getConnectNamespace(), receiver);
}
/**
* Adapted from super.processAsynch to use custom chatRoomManager for chat
* events.
*/
@Override
protected void processAsynch(AsynchEvent e) {
try {
if (e instanceof ECFConnectionObjectPacketEvent) {
// It's an ECF object message
final ECFConnectionObjectPacketEvent evt = (ECFConnectionObjectPacketEvent) e;
final Object obj = evt.getObjectValue();
// this should be a ContainerMessage
final Object cm = deserializeContainerMessage((byte[]) obj);
if (cm == null)
super.processAsynch(e);
final ContainerMessage contMessage = (ContainerMessage) cm;
final IChatRoomContainer chat = chatRoomManager
.findReceiverChatRoom(contMessage.getToContainerID());
if (chat != null && chat instanceof XMPPChatRoomContainer) {
final XMPPChatRoomContainer cont = (XMPPChatRoomContainer) chat;
cont.handleContainerMessage(contMessage);
return;
}
super.processAsynch(e);
}
} catch (final IOException except) {
log(NLS.bind(Messages.XMPPContainer_EXCEPTION_HANDLING_ASYCH_EVENT,
e), except);
}
super.processAsynch(e);
}
}

View file

@ -0,0 +1,235 @@
/**
* 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.xmpp.internal;
import java.io.IOException;
import java.util.HashMap;
import org.eclipse.ecf.core.ContainerConnectException;
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.security.IConnectContext;
import org.eclipse.ecf.core.sharedobject.SharedObjectAddException;
import org.eclipse.ecf.internal.provider.xmpp.events.ChatMembershipEvent;
import org.eclipse.ecf.internal.provider.xmpp.events.IQEvent;
import org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent;
import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
import org.eclipse.ecf.provider.generic.SOWrapper;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import com.raytheon.uf.viz.collaboration.comm.xmpp.XMPPContainer;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.smack.ECFConnection;
/**
* Override the ECF XMPPChatRoomContainer but provide a custom viz
* XMPPChatRoomContainerHelper
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPChatRoomContainer extends
org.eclipse.ecf.internal.provider.xmpp.XMPPChatRoomContainer {
private static final String CONTAINER_HELPER_ID = XMPPContainer.class
.getName() + ".xmppgroupchathandler"; //$NON-NLS-1$
private ID containerHelperID;
/**
* Use viz version of chatRoomContainerHelper.
*/
private XMPPChatRoomContainerHelper containerHelper;
public XMPPChatRoomContainer(ECFConnection conn, Namespace usernamespace)
throws IDCreateException {
super(conn, usernamespace);
this.containerHelperID = IDFactory.getDefault().createStringID(
CONTAINER_HELPER_ID);
this.containerHelper = new XMPPChatRoomContainerHelper(usernamespace,
getXMPPConnection());
}
/**
* Overridden to use custom containerHelper.
*/
@Override
public void addChatRoomParticipantListener(
IChatRoomParticipantListener participantListener) {
if (containerHelper != null) {
containerHelper.addChatParticipantListener(participantListener);
}
}
/**
* Overridden to use custom containerHelper.
*/
@Override
public void addMessageListener(IIMMessageListener listener) {
containerHelper.addChatRoomMessageListener(listener);
}
/**
* Overridden to use custom containerHelper.
*/
@Override
protected void addSharedObjectToContainer(ID remote)
throws SharedObjectAddException {
getSharedObjectManager().addSharedObject(containerHelperID,
containerHelper, new HashMap());
}
/**
* Overridden to clean up custom containerHelper.
*/
@Override
protected void cleanUpConnectFail() {
super.cleanUpConnectFail();
if (containerHelper != null) {
getSharedObjectManager().removeSharedObject(containerHelperID);
containerHelper = null;
containerHelperID = null;
}
}
/**
* Overridden to connect custom containerHelper.
*/
@Override
public void connect(ID remote, IConnectContext connectContext)
throws ContainerConnectException {
super.connect(remote, connectContext);
containerHelper.setRoomID(remoteServerID);
}
/**
* Overridden to disconnect custom containerHelper.
*/
@Override
public void disconnect() {
super.disconnect();
if (containerHelper != null)
containerHelper.disconnect();
}
/**
* Overridden to dispose custom containerHelper.
*/
@Override
public void dispose() {
if (containerHelperID != null) {
getSharedObjectManager().removeSharedObject(containerHelperID);
containerHelperID = null;
}
super.dispose();
if (containerHelper != null)
containerHelper.dispose(getID());
containerHelper = null;
}
/**
* Overridden to use custom containerHelper.
*/
@Override
public ID[] getChatRoomParticipants() {
return containerHelper.getChatRoomParticipants();
}
/**
* Overridden to use custom containerHelper.
*/
@Override
public void removeChatRoomParticipantListener(
IChatRoomParticipantListener participantListener) {
if (containerHelper != null) {
containerHelper.removeChatParticipantListener(participantListener);
}
}
/**
* Overridden to use custom containerHelper.
*/
@Override
public void removeMessageListener(IIMMessageListener listener) {
containerHelper.removeChatRoomMessageListener(listener);
}
/**
* Overridden to use custom containerHelperID.
*/
@Override
protected void handleChatMessage(Message mess) throws IOException {
final SOWrapper wrap = getSharedObjectWrapper(containerHelperID);
if (wrap != null) {
wrap.deliverEvent(new MessageEvent(mess));
}
}
/**
* Overridden to use custom containerHelperID.
*/
@Override
protected void handleIQMessage(IQ mess) throws IOException {
final SOWrapper wrap = getSharedObjectWrapper(containerHelperID);
if (wrap != null) {
wrap.deliverEvent(new IQEvent(mess));
}
}
/**
* Overridden to use custom containerHelperID.
*/
@Override
protected void handlePresenceMessage(Presence mess) throws IOException {
final SOWrapper wrap = getSharedObjectWrapper(containerHelperID);
if (wrap != null) {
wrap.deliverEvent(new PresenceEvent(mess));
}
}
/**
* Overridden to use custom containerHelperID.
*/
@Override
protected void handleChatMembershipEvent(String from, boolean add) {
final SOWrapper wrap = getSharedObjectWrapper(containerHelperID);
if (wrap != null) {
wrap.deliverEvent(new ChatMembershipEvent(from, add));
}
}
}

View file

@ -0,0 +1,178 @@
/**
* 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.xmpp.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.internal.provider.xmpp.events.ChatMembershipEvent;
import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent;
import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
/**
* Extend the ECF XMPPChatRoomContainerHelper with three changes (1) add
* properties to presence events in a room. (2) expose methods needed by the Viz
* version of XMPPChatRoomContainer. (3) disable the default chatMembership
* events and instead fire ChatMembershipEvents when the presence changes.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPChatRoomContainerHelper extends
org.eclipse.ecf.internal.provider.xmpp.XMPPChatRoomContainerHelper {
/**
* Need our own list to track who is in the room.
*/
private final List<ID> chatRoomContainerParticipants = Collections
.synchronizedList(new ArrayList<ID>());
public XMPPChatRoomContainerHelper(Namespace usernamespace,
XMPPConnection conn) {
super(usernamespace, conn);
}
/**
* exposed method to this package.
*/
@Override
protected void setRoomID(ID roomID) {
super.setRoomID(roomID);
}
/**
* exposed method to this package.
*/
@Override
protected void disconnect() {
super.disconnect();
}
/**
* exposed method to this package.
*/
@Override
protected void addChatParticipantListener(
IChatRoomParticipantListener listener) {
super.addChatParticipantListener(listener);
}
/**
* exposed method to this package.
*/
@Override
protected void removeChatParticipantListener(
IChatRoomParticipantListener listener) {
super.removeChatParticipantListener(listener);
}
/**
* exposed method to this package.
*/
@Override
protected void addChatRoomMessageListener(IIMMessageListener msgListener) {
super.addChatRoomMessageListener(msgListener);
}
/**
* exposed method to this package.
*/
@Override
protected ID createUserIDFromName(String name) {
return super.createUserIDFromName(name);
}
/**
* adapted from super.createIPresence, but modified to add properties from
* the packet.
*/
@Override
protected IPresence createIPresence(Presence xmppPresence) {
final String status = xmppPresence.getStatus();
final IPresence newPresence = new org.eclipse.ecf.presence.Presence(
createIPresenceType(xmppPresence), status,
createIPresenceMode(xmppPresence),
ECFConnection.getPropertiesFromPacket(xmppPresence));
return newPresence;
}
/**
* Overridden to also fire ChatMembershipEvent, see
* handleChatMembershipEvent for more information on why this is done.
*/
@Override
protected void handlePresenceEvent(PresenceEvent evt) {
super.handlePresenceEvent(evt);
final Presence xmppPresence = evt.getPresence();
final String from = canonicalizeRoomFrom(xmppPresence.getFrom());
final ID fromID = createUserIDFromName(from);
if (xmppPresence.getType().equals(Presence.Type.available)) {
if (!chatRoomContainerParticipants.contains(fromID)) {
chatRoomContainerParticipants.add(fromID);
super.handleChatMembershipEvent(new ChatMembershipEvent(
xmppPresence.getFrom(), true));
}
} else {
chatRoomContainerParticipants.remove(fromID);
super.handleChatMembershipEvent(new ChatMembershipEvent(
xmppPresence.getFrom(), false));
}
}
/**
* The ECF version of this class will not always correctly fire these events
* for the user that created this room. The reason is because
* XMPPChatRoomManager.createChatRoom creates a temporary MultiUserChat to
* create the room but this MultiUserChat registers with the
* RoomListenerMultiplexor and it does not deregister until finalize. When
* we connect to the room it will create a second MultiUserChat and it is
* possible they are both registered. When the temporary chat is garbage
* collected it removes the room from the RoomListenerMultiplexor and events
* for that room are ignored. Most events do not come from the
* RoomListenerMultiplexor so there is no problems but the
* ChatMembershipEvent comes from that and breaks sometimes so we disable it
* and instead fire these events from handlePresenceEvent since that event
* is fired separately from the RoomListenerMultiplexor.
*/
@Override
protected void handleChatMembershipEvent(ChatMembershipEvent evt) {
; // disabled
}
}

View file

@ -0,0 +1,276 @@
/**
* 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.xmpp.internal;
import java.util.Map;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.internal.provider.xmpp.Messages;
import org.eclipse.ecf.presence.chatroom.ChatRoomCreateException;
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.RoomInfo;
import com.raytheon.uf.viz.collaboration.comm.xmpp.internal.smack.ECFConnection;
/**
* Extend the ECF XMPPChatRoomManager but add the ability to use a custom viz
* chat room container.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPChatRoomManager extends
org.eclipse.ecf.internal.provider.xmpp.XMPPChatRoomManager {
private static final String PROP_XMPP_SUBJECT = "subject";
/**
* Super has ecfConnection but it is private and we need it.
*/
private ECFConnection ecfConnection = null;
/**
* Super has connectNamespace but it is private and we need it.
*/
private Namespace connectNamespace = null;
public XMPPChatRoomManager(ID containerID) {
super(containerID);
}
/**
* Overriden to so we can grab the ecfConnection and namespace
*/
public void setConnection(Namespace connectNamespace, ID connectedID,
ECFConnection connection) {
super.setConnection(connectNamespace, connectedID, connection);
this.connectNamespace = connectNamespace;
this.ecfConnection = connection;
}
/**
* Overriden to wrap the roomInfo in a custom roomInfo.
*/
@Override
protected IChatRoomInfo getChatRoomInfo(ID roomID) {
IChatRoomInfo result = super.getChatRoomInfo(roomID);
if (result != null) {
result = new ECFRoomInfo(result);
}
return result;
}
/**
* Overriden to wrap the roomInfo in a custom roomInfo.
*/
@Override
public IChatRoomInfo getChatRoomInfo(String roomname) {
IChatRoomInfo result = super.getChatRoomInfo(roomname);
if (result != null) {
result = new ECFRoomInfo(result);
} else if (ecfConnection != null) {
// If the result is null then it is possible that ecf silently
// disgarded an exception from xmpp, we would like some way to be
// able to capture that exception so this code will
// attempt to find the room itself and log errors.
Exception exception = null;
String mucName = null;
try {
XMPPConnection conn = ecfConnection.getXMPPConnection();
XMPPRoomID roomID = new XMPPRoomID(connectNamespace, conn,
roomname);
mucName = roomID.getMucString();
RoomInfo info = MultiUserChat.getRoomInfo(conn, mucName);
if (info != null) {
// Theoretically this will never hit but if it does there is
// no way of getting a super.ECFRoomInfo even
// though we know the room exists, so just log it.
System.err
.println("XMPPChatRoomManager cannot find info for room "
+ roomname + " but it exists.");
}
} catch (XMPPException e) {
if (e.getXMPPError().getCode() != 404) {
// 404 is considered normal, everything else is bad
exception = e;
}
} catch (final Exception e) {
exception = e;
}
if (exception != null) {
System.err
.println("XMPPChatRoomManager cannot find info for room "
+ roomname
+ " when looking for "
+ String.valueOf(mucName));
exception.printStackTrace();
}
}
return result;
}
/**
* Overriden to use the same nickname that is used when joining.
*/
@Override
public IChatRoomInfo createChatRoom(String roomname, Map properties)
throws ChatRoomCreateException {
if (roomname == null)
throw new ChatRoomCreateException(roomname,
Messages.XMPPChatRoomManager_EXCEPTION_ROOM_CANNOT_BE_NULL);
try {
String nickname = ecfConnection.getXMPPConnection().getUser();
final String server = ecfConnection.getXMPPConnection().getHost();
final String domain = (properties == null) ? XMPPRoomID.DOMAIN_DEFAULT
: (String) properties.get(PROP_XMPP_CONFERENCE);
final String conference = XMPPRoomID.fixConferenceDomain(domain,
server);
final String roomID = roomname + XMPPRoomID.AT_SIGN + conference;
// create proxy to the room
final MultiUserChat muc = new MultiUserChat(
ecfConnection.getXMPPConnection(), roomID);
if (!checkRoom(conference, roomID)) {
// otherwise create a new one
/**
* This is the reason we override super.createChatRoom, when we
* join it only uses the username, not then host so we must do
* the same here or a user departed event is triggered for
* user@host when user arrives.
*/
if (nickname.contains("@")) {
nickname = nickname.split("@")[0];
}
muc.create(nickname);
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
final String subject = (properties == null) ? null
: (String) properties.get(PROP_XMPP_SUBJECT);
if (subject != null)
muc.changeSubject(subject);
}
} catch (final XMPPException e) {
throw new ChatRoomCreateException(roomname, e.getMessage(), e);
}
return getChatRoomInfo(roomname);
}
/**
* Custom roomInfo that wraps another roomInfo and overrides
* createChatRoomContainer to return viz container.
*/
class ECFRoomInfo implements IChatRoomInfo {
IChatRoomInfo realInfo;
public ECFRoomInfo(IChatRoomInfo realInfo) {
this.realInfo = realInfo;
}
public String getDescription() {
return realInfo.getDescription();
}
public String getSubject() {
return realInfo.getSubject();
}
public ID getRoomID() {
return realInfo.getRoomID();
}
public int getParticipantsCount() {
return realInfo.getParticipantsCount();
}
public String getName() {
return realInfo.getName();
}
public boolean isPersistent() {
return realInfo.isPersistent();
}
public boolean requiresPassword() {
return realInfo.requiresPassword();
}
public boolean isModerated() {
return realInfo.isModerated();
}
public ID getConnectedID() {
return realInfo.getConnectedID();
}
public Object getAdapter(Class adapter) {
return realInfo.getAdapter(adapter);
}
/**
* Adapted from the ECF version of ECFRoomInfo but changed to return our
* custom container.
*/
public IChatRoomContainer createChatRoomContainer()
throws ContainerCreateException {
XMPPChatRoomContainer chatContainer = null;
if (ecfConnection == null)
throw new ContainerCreateException(
Messages.XMPPChatRoomManager_EXCEPTION_CONTAINER_DISCONNECTED);
try {
chatContainer = new XMPPChatRoomContainer(ecfConnection,
connectNamespace);
addChat(chatContainer);
return chatContainer;
} catch (final IDCreateException e) {
throw new ContainerCreateException(
Messages.XMPPChatRoomManager_EXCEPTION_CREATING_CHAT_CONTAINER,
e);
}
}
public String toString() {
return realInfo.toString();
}
}
}

View file

@ -0,0 +1,85 @@
/**
* 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.xmpp.internal;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerTypeDescription;
import com.raytheon.uf.viz.collaboration.comm.xmpp.XMPPContainer;
/**
*
* Extends the ECF XMPPContainerInstantiator to create a Viz specific container
* with fixes needed for Viz.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPContainerInstantiator extends
org.eclipse.ecf.internal.provider.xmpp.XMPPContainerInstantiator {
/**
* Adapted from super.createInstance, only change is that it returns the Viz
* XMPPContainer instead of the ECF XMPPContainer
*/
@Override
public XMPPContainer createInstance(ContainerTypeDescription description,
Object[] args) throws ContainerCreateException {
try {
Integer ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
String name = null;
if (args != null) {
if (args.length > 0) {
name = (String) args[0];
if (args.length > 1) {
ka = getIntegerFromArg(args[1]);
}
}
}
if (name == null) {
if (ka == null) {
return new XMPPContainer();
} else {
return new XMPPContainer(ka.intValue());
}
} else {
if (ka == null) {
ka = new Integer(XMPPContainer.DEFAULT_KEEPALIVE);
}
return new XMPPContainer(name, ka.intValue());
}
} catch (Exception e) {
throw new ContainerCreateException(
"Exception creating generic container", e);
}
}
}

View file

@ -0,0 +1,494 @@
/**
* 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.xmpp.internal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.internal.provider.xmpp.events.IQEvent;
import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresenceListener;
import org.eclipse.ecf.presence.IPresenceSender;
import org.eclipse.ecf.presence.roster.IRoster;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.IRosterGroup;
import org.eclipse.ecf.presence.roster.IRosterItem;
import org.eclipse.ecf.presence.roster.IRosterListener;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
import org.eclipse.ecf.provider.xmpp.XMPPContainer;
import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.RosterPacket;
/**
* Viz specific implementation of the XMPPContainerPresenceHelper which fixes a
* bug that causes users to disappear from rosters when they log out when they
* are in multiple groups. This class no handles all presence events when a user
* becomes unavaialble, all other events are handled by the ECF version.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class XMPPContainerPresenceHelper extends
org.eclipse.ecf.internal.provider.xmpp.XMPPContainerPresenceHelper {
/**
* Have our own roster manager to track listeners.
*/
private VizRosterManager rosterManager;
public XMPPContainerPresenceHelper(XMPPContainer container) {
super(container);
rosterManager = new VizRosterManager();
}
/**
* This is overriden because when a roster packet is delivered with a new
* name then the ecf implementation does not change the name, this will
* change it before letting the ecf connection handle the event normally.
*/
@Override
protected void handleIQEvent(IQEvent evt) {
final IQ iq = evt.getIQ();
if (iq instanceof RosterPacket) {
final RosterPacket rosterPacket = (RosterPacket) iq;
if (rosterPacket.getType() == IQ.Type.SET) {
for (RosterPacket.Item item : rosterPacket.getRosterItems()) {
final RosterPacket.ItemType itemType = item.getItemType();
if (itemType == RosterPacket.ItemType.to
|| itemType == RosterPacket.ItemType.both) {
XMPPID newID = createIDFromName(item.getUser());
@SuppressWarnings("unchecked")
Collection<Object> items = roster.getItems();
synchronized (items) {
updateRosterName(items, newID, item.getName());
}
}
}
}
}
super.handleIQEvent(evt);
}
/**
* Method to recursively find roster entries that match the user id provided
* and change the name of the user in the roster entry.
*
* @param rosterItems
* @param id
* @param name
*/
private void updateRosterName(Collection<Object> rosterItems, XMPPID id,
String name) {
if (name == null || name.isEmpty()) {
return;
}
for (Object obj : rosterItems) {
if (obj instanceof IRosterGroup) {
@SuppressWarnings("unchecked")
Collection<Object> items = ((IRosterGroup) obj).getEntries();
synchronized (items) {
updateRosterName(items, id, name);
}
} else if (obj instanceof IRosterEntry) {
IRosterEntry entry = (IRosterEntry) obj;
if (entry.getUser().getID().equals(id)) {
((User) entry.getUser()).setName(name);
}
}
}
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it can call a custom version of updatePresence when the presence
* type is unavaialble.
*/
@Override
protected void handlePresenceEvent(PresenceEvent evt) {
if (evt.getPresence().getType() == Presence.Type.unavailable) {
final Presence xmppPresence = evt.getPresence();
final String from = xmppPresence.getFrom();
final IPresence newPresence = createIPresence(xmppPresence);
final XMPPID fromID = createIDFromName(from);
updatePresence(fromID, newPresence);
rosterManager.notifyPresenceListeners(fromID, newPresence);
} else {
super.handlePresenceEvent(evt);
}
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it can call a custom version of updatePresenceInGroup and
* updatePresenceForMatchingEntry, it also only handles cases of removal.
*/
private void updatePresence(XMPPID fromID, IPresence newPresence) {
@SuppressWarnings("unchecked")
final Collection<Object> rosterItems = roster.getItems();
List<IRosterEntry> newEntrys = new ArrayList<IRosterEntry>();
synchronized (rosterItems) {
for (final Iterator<Object> i = rosterItems.iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof IRosterGroup) {
IRosterEntry[] es = updatePresenceInGroup(
(IRosterGroup) item, fromID, newPresence);
for (int j = 0; j < es.length; j++) {
newEntrys.add(es[j]);
}
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
IRosterEntry entry = updatePresenceForMatchingEntry(
(org.eclipse.ecf.presence.roster.RosterEntry) item,
fromID, newPresence);
if (entry != null)
newEntrys.add(entry);
}
}
}
IRosterEntry[] entrys = newEntrys.toArray(new IRosterEntry[] {});
if (entrys.length > 0) {
for (int i = 0; i < entrys.length; i++) {
removeItemFromRoster(rosterItems, fromID);
}
}
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it can call a custom version of updatePresenceForMatchingEntry
*/
private IRosterEntry[] updatePresenceInGroup(IRosterGroup group,
XMPPID fromID, IPresence newPresence) {
List<IRosterEntry> results = new ArrayList<IRosterEntry>();
@SuppressWarnings("unchecked")
final Collection<Object> groupEntries = group.getEntries();
synchronized (groupEntries) {
for (final Iterator<Object> i = groupEntries.iterator(); i
.hasNext();) {
IRosterEntry newEntry = updatePresenceForMatchingEntry(
(org.eclipse.ecf.presence.roster.RosterEntry) i.next(),
fromID, newPresence);
if (newEntry != null)
results.add(newEntry);
}
}
return results.toArray(new IRosterEntry[] {});
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it can call a custom version of removeEntryFromRoster, it has also
* been simplified to handle only cases of removal when the presence type is
* unavaialble.
*/
private IRosterEntry updatePresenceForMatchingEntry(
org.eclipse.ecf.presence.roster.RosterEntry entry, XMPPID fromID,
IPresence newPresence) {
final IUser user = entry.getUser();
XMPPID oldID = (XMPPID) user.getID();
// If the username/host part matches that means we either have to update
// the resource, or create a new client
if (oldID.equals(fromID)) {
return removeEntryFromRoster(oldID, entry, newPresence, user);
} else if (oldID.getUsernameAtHost().equals(fromID.getUsernameAtHost())) {
return entry;
}
return null;
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it can call a custom version of countClientsInRoster, it also uses
* the results of this method differently
*/
private IRosterEntry removeEntryFromRoster(XMPPID oldID,
org.eclipse.ecf.presence.roster.RosterEntry entry,
IPresence newPresence, IUser user) {
if (countClientsInRoster(oldID) > 0) {
// remove this client from roster
return entry;
} else {
// Last one, so we set resource to null and set presence to
// unavailable
oldID.setResourceName(null);
entry.setPresence(newPresence);
rosterManager.notifyRosterUpdate(entry);
return null;
}
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it will return the number of entries that have the same name/hose
* but a different resource. Returning the number of users with same
* name/host even if they have the same resource is what causes the ECF
* version to delete users that are in multiple groups. For a user that is
* not logged in more than once this will always return 0.
*/
private int countClientsInRosterGroup(
org.eclipse.ecf.presence.roster.RosterGroup group, XMPPID oldID) {
@SuppressWarnings("unchecked")
Collection<Object> groupItems = group.getEntries();
int count = 0;
for (final Iterator<Object> i = groupItems.iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
XMPPID entryID = (XMPPID) entry.getUser().getID();
if (!entryID.equals(oldID)
&& entryID.getUsernameAtHost().equals(
oldID.getUsernameAtHost()))
count++;
}
}
return count;
}
/**
* This method has been adapted from the ECF XMPPContainerPresenceHelper so
* that it will return the number of entries that have the same name/hose
* but a different resource. Returning the number of users with same
* name/host even if they have the same resource is what causes the ECF
* version to delete users that are in multiple groups. For a user that is
* not logged in more than once this will always return 0.
*/
private int countClientsInRoster(XMPPID oldID) {
@SuppressWarnings("unchecked")
Collection<Object> rosterItems = roster.getItems();
int count = 0;
synchronized (rosterItems) {
for (final Iterator<Object> i = rosterItems.iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
count += countClientsInRosterGroup(group, oldID);
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) item;
XMPPID entryID = (XMPPID) entry.getUser().getID();
if (!entryID.equals(oldID)
&& entryID.getUsernameAtHost().equals(
oldID.getUsernameAtHost())) {
count++;
}
}
}
}
return count;
}
private void removeItemFromRoster(Collection<Object> rosterItems,
XMPPID itemIDToRemove) {
boolean removed = false;
synchronized (rosterItems) {
for (final Iterator<Object> i = rosterItems.iterator(); i.hasNext();) {
final IRosterItem item = (IRosterItem) i.next();
if (item instanceof org.eclipse.ecf.presence.roster.RosterGroup) {
final org.eclipse.ecf.presence.roster.RosterGroup group = (org.eclipse.ecf.presence.roster.RosterGroup) item;
removed = removeItemFromRosterGroup(group, itemIDToRemove);
// If group is empty, remove it too
if (group.getEntries().size() == 0)
i.remove();
} else if (item instanceof org.eclipse.ecf.presence.roster.RosterEntry) {
if (((org.eclipse.ecf.presence.roster.RosterEntry) item)
.getUser().getID().equals(itemIDToRemove)) {
i.remove();
removed = true;
}
}
}
}
if (removed)
rosterManager.notifyRosterUpdate(roster);
}
private boolean removeItemFromRosterGroup(
org.eclipse.ecf.presence.roster.RosterGroup group,
XMPPID itemIDToRemove) {
@SuppressWarnings("unchecked")
final Collection<Object> groupEntries = group.getEntries();
synchronized (groupEntries) {
for (final Iterator<Object> i = groupEntries.iterator(); i
.hasNext();) {
final org.eclipse.ecf.presence.roster.RosterEntry entry = (org.eclipse.ecf.presence.roster.RosterEntry) i
.next();
if (entry.getUser().getID().equals(itemIDToRemove)) {
i.remove();
return true;
}
}
}
return false;
}
/**
* provide the VizRosterManager access to the super rosterManager
*
* @return
*/
protected IRosterManager getSuperRosterManager() {
return super.getRosterManager();
}
/**
* Use the viz roster manager instead of super, most calls are just
* forwarded through.
*/
@Override
public IRosterManager getRosterManager() {
return rosterManager;
}
/**
* The entire purpose of this class is to intercept the various listeners so
* that they can be notified when presence changes in the viz
* XMPPCOntainerPresenceHelper since it does not have access to the super
* class roster manager listeners.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 26, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
private class VizRosterManager implements IRosterManager {
private final List<IRosterListener> rosterUpdateListeners = new ArrayList<IRosterListener>();
private final List<IPresenceListener> presenceListeners = new ArrayList<IPresenceListener>();
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {
return getSuperRosterManager().getAdapter(adapter);
}
public void notifyRosterUpdate(IRosterItem entry) {
List<IRosterListener> toNotify = null;
synchronized (rosterUpdateListeners) {
toNotify = new ArrayList<IRosterListener>(rosterUpdateListeners);
}
for (IRosterListener l : toNotify) {
l.handleRosterUpdate(entry.getRoster(), entry);
}
}
public void notifyPresenceListeners(ID fromID, IPresence presence) {
List<IPresenceListener> toNotify = null;
synchronized (presenceListeners) {
toNotify = new ArrayList<IPresenceListener>(presenceListeners);
}
for (IPresenceListener l : toNotify) {
l.handlePresence(fromID, presence);
}
}
@Override
public IRoster getRoster() {
return getSuperRosterManager().getRoster();
}
@Override
public void addRosterListener(IRosterListener listener) {
getSuperRosterManager().addRosterListener(listener);
synchronized (rosterUpdateListeners) {
rosterUpdateListeners.add(listener);
}
}
@Override
public void removeRosterListener(IRosterListener listener) {
getSuperRosterManager().removeRosterListener(listener);
synchronized (rosterUpdateListeners) {
rosterUpdateListeners.remove(listener);
}
}
@Override
public void addRosterSubscriptionListener(
IRosterSubscriptionListener listener) {
getSuperRosterManager().addRosterSubscriptionListener(listener);
}
@Override
public void removeRosterSubscriptionListener(
IRosterSubscriptionListener listener) {
getSuperRosterManager().removeRosterSubscriptionListener(listener);
}
@Override
public IRosterSubscriptionSender getRosterSubscriptionSender() {
return getSuperRosterManager().getRosterSubscriptionSender();
}
@Override
public IPresenceSender getPresenceSender() {
return getSuperRosterManager().getPresenceSender();
}
@Override
public void addPresenceListener(IPresenceListener listener) {
getSuperRosterManager().addPresenceListener(listener);
synchronized (presenceListeners) {
presenceListeners.add(listener);
}
}
@Override
public void removePresenceListener(IPresenceListener listener) {
getSuperRosterManager().removePresenceListener(listener);
synchronized (presenceListeners) {
presenceListeners.remove(listener);
}
}
}
}

View file

@ -0,0 +1,71 @@
/**
* 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.xmpp.internal.smack;
import java.io.IOException;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.provider.comm.IAsynchEventHandler;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import org.jivesoftware.smack.packet.Presence;
/**
* Extends ECFConnection from xmpp provider, adds ability to send presence to a
* room using the roomId.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 20, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@SuppressWarnings("restriction")
public class ECFConnection extends
org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection {
public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h) {
super(google, ns, h);
}
@Override
public void sendPresenceUpdate(ID target, Presence presence)
throws IOException {
if (target instanceof XMPPRoomID) {
// sendPresenceUpdate uses target.getName to determine where to send
// the presence to, this does not work for roomId because getName
// will return the room name without the host, so instead of using
// the super version directly we will setTo on the presence here and
// then send no target to super.
presence.setTo(((XMPPRoomID) target).getMucString());
super.sendPresenceUpdate(null, presence);
} else {
super.sendPresenceUpdate(target, presence);
}
}
}

View file

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

View file

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

View file

@ -0,0 +1,8 @@
#Fri Feb 24 08:50:10 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,35 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Collaboratioin
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.comm
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.comm.Activator
Bundle-Vendor: RAYTHEON
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf;bundle-version="3.1.300";visibility:=reexport,
org.eclipse.ecf.presence;bundle-version="2.0.0",
org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0",
org.apache.commons.lang;bundle-version="2.3.0",
com.google.guava;bundle-version="1.0.0";visibility:=reexport,
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.jivesoftware.smack;bundle-version="3.1.100",
org.eclipse.swt;bundle-version="3.6.1",
com.raytheon.uf.common.comm,
com.raytheon.uf.common.localization
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.collaboration.comm,
com.raytheon.uf.viz.collaboration.comm.compression,
com.raytheon.uf.viz.collaboration.comm.identity,
com.raytheon.uf.viz.collaboration.comm.identity.event,
com.raytheon.uf.viz.collaboration.comm.identity.info,
com.raytheon.uf.viz.collaboration.comm.identity.invite,
com.raytheon.uf.viz.collaboration.comm.identity.roster,
com.raytheon.uf.viz.collaboration.comm.identity.user,
com.raytheon.uf.viz.collaboration.comm.provider,
com.raytheon.uf.viz.collaboration.comm.provider.event,
com.raytheon.uf.viz.collaboration.comm.provider.info,
com.raytheon.uf.viz.collaboration.comm.provider.session,
com.raytheon.uf.viz.collaboration.comm.provider.user

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,83 @@
/**
* 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;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import com.raytheon.uf.common.comm.NetworkStatistics;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class Activator implements BundleActivator {
public static final String PEER_TO_PEER = "PeerToPeerMsg";
public static final String VENUE = "VenueMsg";
private static Activator plugin;
private BundleContext context;
private NetworkStatistics networkStats = new NetworkStatistics();
public BundleContext getContext() {
return context;
}
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
this.context = bundleContext;
plugin = this;
}
/**
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
plugin = null;
context = null;
}
public NetworkStatistics getNetworkStats() {
return networkStats;
}
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,175 @@
/**
* 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.compression;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.InflaterInputStream;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
/**
* Utilities for compressing or decompressing data.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 11, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class CompressionUtil {
public static CompressionType COMPRESSION_TYPE = CompressionType.ZLIB;
private static boolean log_compression = false;
private enum CompressionType {
ZLIB, GZIP;
public byte toByte() {
return (byte) ordinal();
}
public static CompressionType fromByte(byte b) {
if (b < 0 || b > CompressionType.values().length) {
throw new IndexOutOfBoundsException(
"Unable to determine CompressionType for " + b);
}
return CompressionType.values()[b];
}
};
public static byte[] compress(byte[] bytes) throws CollaborationException {
ByteArrayOutputStream out = new ByteArrayOutputStream(bytes.length);
CompressionType cType = COMPRESSION_TYPE;
out.write(cType.toByte());
OutputStream compressionStrm = null;
try {
compressionStrm = createCompressionOutputStream(out);
long start = System.currentTimeMillis();
compressionStrm.write(bytes);
compressionStrm.flush();
compressionStrm.close();
byte[] result = out.toByteArray();
if (log_compression) {
System.out.println(cType + " Compression time(milliseconds) "
+ (System.currentTimeMillis() - start) / 1000F
+ " to compress " + bytes.length + " bytes to "
+ result.length + " bytes.");
}
return result;
} catch (IOException e) {
throw new CollaborationException("Unable to compress data.", e);
}
}
private static OutputStream createCompressionOutputStream(OutputStream out)
throws IOException {
OutputStream stream = null;
switch (COMPRESSION_TYPE) {
case GZIP:
stream = new GZIPOutputStream(out);
break;
case ZLIB:
default:
Deflater defl = new Deflater(Deflater.BEST_COMPRESSION);
stream = new DeflaterOutputStream(out, defl);
break;
}
return stream;
}
public static byte[] uncompress(byte[] bytes) throws CollaborationException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
ByteArrayOutputStream out = new ByteArrayOutputStream();
CompressionType cType = CompressionType.fromByte((byte) in.read());
long start = System.currentTimeMillis();
try {
ReadableByteChannel src = Channels
.newChannel(createCompressionInputStream(cType, in));
WritableByteChannel dest = Channels.newChannel(out);
final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024);
while (src.read(buffer) != -1) {
buffer.flip();
dest.write(buffer);
buffer.compact();
}
// EOF will leave buffer in fill state
buffer.flip();
// make sure the buffer is fully drained.
while (buffer.hasRemaining()) {
dest.write(buffer);
}
dest.close();
byte[] resultBuffer = out.toByteArray();
if (log_compression) {
System.out.println(cType
+ " Uncompression time(milliseconds): "
+ ((System.currentTimeMillis() - start) / 1000F)
+ " to uncompress " + bytes.length + " bytes to "
+ resultBuffer.length + " bytes.");
}
return resultBuffer;
} catch (IOException e) {
throw new CollaborationException("Unable to uncompress data.", e);
}
}
private static InputStream createCompressionInputStream(
CompressionType cType, InputStream in) throws IOException {
InputStream stream = null;
switch (cType) {
case GZIP:
stream = new GZIPInputStream(in);
break;
case ZLIB:
default:
stream = new InflaterInputStream(in);
break;
}
return stream;
}
}

View file

@ -0,0 +1,73 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 8, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class CollaborationException extends Exception {
private static final long serialVersionUID = 2897604473798379699L;
/**
*
*/
public CollaborationException() {
}
/**
* @param message
*/
public CollaborationException(String message) {
super(message);
}
/**
*
* @param message
* @param cause
*/
public CollaborationException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param cause
*/
public CollaborationException(Throwable cause) {
super(cause);
}
}

View file

@ -0,0 +1,130 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import java.util.Map;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
/**
* TODO Add Description
*
*
*
*
* <ul>
* EventBus subscription events.
* <li>ISubscriptionResponseEvent : This event is posted when a subscription
* request has been responded to.</li>
* </ul>
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 16, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IAccountManager {
/**
* Set whether the account manager will auto subscribe to subscription
* requests.
*
* @param mode
* The auto subscription mode.
*/
void setAutoSubscriptionMode(boolean mode);
/**
* Get the account manager auto subscription mode.
*
* @return The auto subscription mode.
*/
boolean getAutoSubscriptionMode();
/**
*
* @param responder
*/
void setSubscriptionRequestResponder(ISubscriptionResponder responder);
/**
* Removes the current subscription request responder.
*/
void removeSubscriptionRequestResponder();
/**
*
* @param name
* @param password
* @param attributes
* @throws CollaborationException
*/
void createAccount(String name, char[] password,
Map<String, String> attributes) throws CollaborationException;
/**
* Allows the user to change their account password. If the server does not
* allow this operation an exception will be thrown.
*
* @param password
* @throws CollaborationException
*/
void changePassword(char[] password) throws CollaborationException;
/**
* Allows the user to delete this account on the server. An exception will
* be thrown if the account deletion fails. If the account is currently
* connected, it and any associated objects will be closed followed by the
* account deletion.
*
* @throws CollaborationException
*/
void deleteAccount() throws CollaborationException;
/**
* Can an account be created on the server.
*
* @return Can an account be created on the server?
* @throws CollaborationException
* The query failed.
*/
boolean canCreateAccount() throws CollaborationException;
/**
* Allow the user to send presence information to the transport provider.
*
* @param presence
* @return Return status information.
* @throws CollaborationException
*/
public void sendPresence(IPresence presence) throws CollaborationException;
}

View file

@ -0,0 +1,41 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 19, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ICollaborationMessage extends IMessage {
}

View file

@ -0,0 +1,136 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IMessage extends IPropertied {
public enum MessageType { CHAT, COLLABORATION };
static final String MESSAGE_TYPE = "type";
static final String TIMESTAMP = "timestamp";
/**
* @return the to
*/
IQualifiedID getTo();
/**
* @param to
* the to to set
*/
void setTo(IQualifiedID to);
/**
* @return the from
*/
IQualifiedID getFrom();
/**
* @param from
* the from to set
*/
void setFrom(IQualifiedID from);
/**
* Get the subject of this message.
* @return The subject of this message. The subject may be null.
*/
String getSubject();
/**
* Set the subject of this message. If not set the
* subject is set to null.
* @param subject The subject of this message.
*/
void setSubject(String subject);
/**
*
* @return
*/
MessageType getMessageType();
/**
* Get the body of this message.
* @return The body of this message. The body may be null.
*/
String getBody();
/**
* Set the data to be transmitted in the message. If not set the
* body is set to null.
* @param body The data to be transmitted in the message.
*/
void setBody(String body);
/**
* Returns the body of the message as a byte array.
* @return The body of the message as binary data.
*/
byte [] getBodyAsBinary();
/**
* Set the body of the message as a byte array.
* @param body The binary data to be transmitted in the message.
*/
void getBodyAsBinary(byte [] body);
/**
* Get the status of this message.
* @return The message status.
*/
String getStatus();
/**
* Set the status of this message.
* @param The message status.
*/
void setStatus(String status);
/**
* Get the receipt time for this message in milliseconds from
* Jan 1, 1970.
* @return The receipt time stamp.
*/
long getTimeStamp();
}

View file

@ -0,0 +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.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IPeerToPeer extends ISession, IEventPublisher {
/**
* Send a Text message. Note that the recipient of the message is included
* as an attribute of the message.
*
* @param message
*/
void sendPeerToPeer(IMessage message) throws CollaborationException;
/**
* Send a Text message to a specific receiver.
*
* @param to
* The intended receiver.
* @param message
* The message to send.
*/
void sendPeerToPeer(IQualifiedID to, String message)
throws CollaborationException;
}

View file

@ -0,0 +1,153 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import java.util.Collection;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IPropertied {
public static class Property {
private String value;
private String key;
/**
*
* @param key
* @param value
*/
public Property(String key, String value) {
this.key = key;
this.value = value;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key the key to set
*/
public void setKey(String key) {
this.key = key;
}
@Override
public String toString() {
return String.format("[%s{%s}]", key, value);
}
/**
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Property other = (Property) obj;
if (key == null) {
if (other.key != null)
return false;
} else if (!key.equals(other.key))
return false;
if (value == null) {
if (other.value != null)
return false;
} else if (!value.equals(other.value))
return false;
return true;
}
}
/**
*
* @param key
* @param defaultValue
* @return
*/
void setProperty(String key, String value);
/**
*
* @param key
* @param defaultValue
* @return
*/
String getProperty(String key, String defaultValue);
/**
* Gets the message properties as a collection of key, value
* pairs. Always returns a not-null value.
* @return
*/
Collection<Property> getProperties();
}

View file

@ -0,0 +1,96 @@
/**
* 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.
**/
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
*
* Implementations of ISession do not support polling for messages but instead
* make exclusive use of listener based callbacks to make incoming data
* available.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ISession extends IEventPublisher {
/**
* Close and clean up this session. After a close, isConnected must return
* false.
*/
public void close();
/**
*
* @return
*/
public UserId getUserID();
/**
* Gets the connection status of the session.
*
* @return The connection status.
*/
public boolean isConnected();
/**
* Get the session identifier.
*
* @return The session identifier.
*/
public String getSessionId();
public CollaborationConnection getConnection();
}

View file

@ -0,0 +1,133 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
*
*
* <ul>
* <li>EventBus subscription events. Implementors may to post the following
* events.</li>
* <ul>
* <li><strong>IVenueParticipantEvent</strong> : This event is posted when a
* venue participant enters, leaves a venue, or updates their status in the
* venue.</li>
* <li><strong>TextMessage</strong> : Text messages send between users. Meant to
* be displayed as conversation.</li>
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE events</li>
* <li><strong>IRenderable</strong> : These messages are CAVE to CAVE
* display......</li>
* <li><strong>IInitData</strong> : These messages are CAVE to CAVE
* initialization data......</li>
* <li><strong>IDisplayEvent</strong> : These messages are CAVE to CAVE
* display......</li>
*
* </ul>
* </ul>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ISharedDisplaySession extends IVenueSession {
/**
* Sends the object to the other collaborators on the session. The object
* must be serializable and once received by the others, will be posted to
* the session's event bus.
*
* @param obj
* the serializable object to send
* @throws CollaborationException
*/
public void sendObjectToVenue(Object obj) throws CollaborationException;
/**
* Sends the object to a specific collaborator on the session. The object
* must be serializable and once received by the other, will be posted to
* the session's event bus.
*
* @param id
* the id of the collaborator to send to
* @param obj
* the serializable object to send
* @throws CollaborationException
*/
public void sendObjectToPeer(IQualifiedID id, Object obj)
throws CollaborationException;
/**
* Returns the current Data Provider for the session
*
* @return
*/
public UserId getCurrentDataProvider();
/**
* Returns the current Session Leader for the session
*
* @return
*/
public UserId getCurrentSessionLeader();
/**
* Sets the current Data Provider for the session
*
* @param participant
*/
public void setCurrentDataProvider(UserId participant);
/**
* Sets the current Session Leader for the session
*
* @param participant
*/
public void setCurrentSessionLeader(UserId participant);
/**
* Checks if the currently logged in user has the role on this session
*
* @param role
* @return
*/
public boolean hasRole(SharedDisplayRole role);
/**
* Gets the connection status of the session.
*
* @return The connection status.
*/
public boolean isConnected();
}

View file

@ -0,0 +1,41 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 19, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueMessage extends IMessage {
}

View file

@ -0,0 +1,109 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
import java.util.List;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue;
import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
*
*
* <ul>
* <li>EventBus subscription events. Implementors are required to post the
* following events.</li>
* <ul>
* <li><strong>IVenueParticipantEvent</strong> : This event is posted when a
* venue participant enters, leaves a venue, or updates their status in the
* venue.</li>
* <li><strong>TextMessage</strong> : Text messages send between users. Meant to
* be displayed as conversation.</li>
* <li><strong>CollaborationMessage</strong> : These messages are CAVE to CAVE
* command messages.</li>
* </ul>
* </ul>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueSession extends ISession {
/**
* Returns information about a venue.
*
* @return Information about a venue
*/
public IVenue getVenue();
/**
* Send a chat message.
*
* @param message
* The message to send.
*/
public void sendChatMessage(String message) throws CollaborationException;
/**
* Send an invitation from this venue to another user.
*
* @param id
* The target user for this invitation.
* @param subject
* The intended subject of the venue conversation.
* @return
*/
public void sendInvitation(UserId id, VenueInvite invite)
throws CollaborationException;
/**
* Send an invitation from this venue to a list of users.
*
* @param ids
* A list of target users for this invitation.
* @param body
* Any text that the user may wish to include.
* @return
*/
public void sendInvitation(List<UserId> ids, VenueInvite invite)
throws CollaborationException;
/**
* Send presence to a venue.
*
* @param presence
*/
public void sendPresence(IPresence presence) throws CollaborationException;
}

View file

@ -0,0 +1,51 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* If a user is logged in one CAVE and tries to login from another this
* exception gets thrown as that is not supported.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 9, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class MultipleLoginException extends CollaborationException {
private static final long serialVersionUID = 3124620509180835631L;
/**
* @param message
* @param cause
*/
public MultipleLoginException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,51 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 15, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class UsernamePasswordException extends CollaborationException {
private static final long serialVersionUID = 3124620509180835631L;
/**
* @param message
* @param cause
*/
public UsernamePasswordException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,47 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Jun 12, 2012 njensen Improved
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IEventPublisher {
public void registerEventHandler(Object handler);
public void unregisterEventHandler(Object handler);
public void postEvent(Object event);
}

View file

@ -0,0 +1,47 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 11, 2012 bkowal Initial creation
*
* </pre>
*
* @author bkowal
* @version 1.0
*/
public interface IHttpdCollaborationConfigurationEvent {
/**
*
* @return the url used to connect to the collaboration
* httpd server.
*/
String getHttpdCollaborationURL();
}

View file

@ -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.identity.event;
import java.util.regex.Pattern;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
/**
* Used to store constants that are used to validate, analyze, and parse status
* and configuration messages associated with the AWIPS II httpd collaboration
* server.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 7, 2012 bkowal Initial creation
*
* </pre>
*
* @author bkowal
* @version 1.0
*/
public interface IHttpdXmppMessage {
// Constant Strings
public static final String URL_PARAMETER_NAME = "sessionDataHttpURL";
public static final String ERROR_PARAMETER_NAME = "error";
// Regex
static final String PREABMLE_REGEX = Tools.CONFIG_PREAMBLE.replace("[",
"\\[");
static final String SUFFIX_REGEX = " : .+" + Tools.DIRECTIVE_SUFFIX;
static final String COLLABORATION_URL_REGEX = "http://.+:[1-9][0-9]*/session_data/";
// Regex Patterns
public static final Pattern configErrorPattern = Pattern
.compile(PREABMLE_REGEX + ERROR_PARAMETER_NAME + SUFFIX_REGEX);
public static final Pattern configURLPattern = Pattern
.compile(PREABMLE_REGEX + URL_PARAMETER_NAME + SUFFIX_REGEX);
public static final Pattern urlPattern = Pattern
.compile(COLLABORATION_URL_REGEX);
}

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import org.eclipse.ecf.presence.roster.IRosterItem;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 6, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IRosterChangeEvent {
/**
* Get the event type.
*
* @return The event type.
*/
RosterChangeType getType();
/**
* Get the changed entry
*
* @return The changed entry.
*/
IRosterItem getItem();
}

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import org.eclipse.ecf.presence.IPresence;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 16, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ISubscriptionResponseEvent {
/**
* How was the subscription responded to.
*
* @return The response type.
*/
IPresence.Type getResponse();
/**
* Was this response due to an auto responder.
*
* @return Was this response due to an auto responder.
*/
boolean isAutoResponder();
}

View file

@ -0,0 +1,49 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ITextMessageEvent {
/**
*
* @return
*
*/
TextMessage getMessage();
}

View file

@ -0,0 +1,62 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* Encapsulates a venue invitation to the user.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueInvitationEvent {
/**
*
* @return
*/
IQualifiedID getRoomId();
/**
*
* @return
*/
IQualifiedID getInviter();
/**
*
*/
String getSubject();
public VenueInvite getInvite();
}

View file

@ -0,0 +1,62 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 20, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueParticipantEvent {
/**
*
* @return
*/
ParticipantEventType getEventType();
/**
*
* @return
*/
UserId getParticipant();
/**
*
* @return
*/
IPresence getPresence();
}

View file

@ -0,0 +1,41 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 20, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public enum ParticipantEventType {
ARRIVED, DEPARTED, UPDATED, PRESENCE_UPDATED;
}

View file

@ -0,0 +1,41 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.event;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 11, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public enum RosterChangeType {
ADD, DELETE, MODIFY, PRESENCE
}

View file

@ -0,0 +1,69 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.info;
import java.util.Collection;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* Provides information about a venue. In addition implementations will act as a
* target for participant updates such as
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenue {
/**
*
* @return
*/
public IVenueInfo getInfo();
/**
*
* @return
*/
public Collection<UserId> getParticipants();
/**
* Get the presence for a user in the session.
*
* @param user
* @return
*/
public IPresence getPresence(IUser user);
}

View file

@ -0,0 +1,91 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.info;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueInfo {
/**
*
* @return
*/
String getVenueDescription();
/**
* Get a long name for venue
*
* @return
*/
String getVenueName();
/**
*
* @return
*/
String getVenueSubject();
/**
*
* @return
*/
String getVenueID();
/**
* Get a count of the current number of room participants
*
* @return Count of the current number of room participants
*/
int getParticipantCount();
/**
*
* @return
*/
boolean isModerated();
/**
*
* @return
*/
boolean isPersistent();
/**
*
* @return
*/
boolean requiresPassword();
}

View file

@ -0,0 +1,187 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.info;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 12, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class SiteConfigInformation {
public static final String ROLE_NAME = "Role";
public static final String SITE_NAME = "Site";
@XmlElement
private List<HostConfig> server;
@XmlElement
private List<SiteConfig> config;
/**
* @return the hosts
*/
public List<HostConfig> getServer() {
return server;
}
/**
* @param hosts
* the hosts to set
*/
public void setServer(List<HostConfig> server) {
this.server = server;
}
/**
* @return the infos
*/
public List<SiteConfig> getConfig() {
return config;
}
/**
* @param infos
* the infos to set
*/
public void setConfig(List<SiteConfig> config) {
this.config = config;
}
@XmlAccessorType(XmlAccessType.NONE)
public static class HostConfig {
@XmlAttribute
private String hostname;
@XmlAttribute
private String prettyName;
/**
* @return the hostname
*/
public String getHostname() {
return hostname;
}
/**
* @param hostname
* the hostname to set
*/
public void setHostname(String hostname) {
this.hostname = hostname;
}
/**
* @return the prettyName
*/
public String getPrettyName() {
return prettyName;
}
/**
* @param prettyName
* the prettyName to set
*/
public void setPrettyName(String prettyName) {
this.prettyName = prettyName;
}
}
@XmlAccessorType(XmlAccessType.NONE)
public static class SiteConfig {
@XmlAttribute
private String site;
@XmlElement
private String[] subscribedSites;
@XmlElement
private String[] roles;
/**
* @return the site
*/
public String getSite() {
return site;
}
/**
* @param site
* the site to set
*/
public void setSite(String site) {
this.site = site;
}
/**
* @return the subscribedSites
*/
public String[] getSubscribedSites() {
return subscribedSites;
}
/**
* @param subscribedSites
* the subscribedSites to set
*/
public void setSubscribedSites(String[] subscribedSites) {
this.subscribedSites = subscribedSites;
}
/**
* @return the role
*/
public String[] getRoles() {
return roles;
}
/**
* @param role
* the role to set
*/
public void setRoles(String[] roles) {
this.roles = roles;
}
}
}

View file

@ -0,0 +1,148 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.invite;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 19, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class ColorPopulator {
@DynamicSerializeElement
private List<UserId> userName;
@DynamicSerializeElement
private List<Integer> red;
@DynamicSerializeElement
private List<Integer> green;
@DynamicSerializeElement
private List<Integer> blue;
public ColorPopulator() {
}
public ColorPopulator(Map<UserId, RGB> rgbs) {
userName = new ArrayList<UserId>();
red = new ArrayList<Integer>();
green = new ArrayList<Integer>();
blue = new ArrayList<Integer>();
for (UserId key : rgbs.keySet()) {
userName.add(key);
red.add(rgbs.get(key).red);
green.add(rgbs.get(key).green);
blue.add(rgbs.get(key).blue);
}
}
public Map<UserId, RGB> getColors() {
Map<UserId, RGB> colors = new HashMap<UserId, RGB>();
for (int i = 0; i < userName.size(); i++) {
colors.put(userName.get(i),
new RGB(red.get(i), green.get(i), blue.get(i)));
}
return colors;
}
/**
* @return the userName
*/
public List<UserId> getUserName() {
return userName;
}
/**
* @param userName
* the userName to set
*/
public void setUserName(List<UserId> userName) {
this.userName = userName;
}
/**
* @return the red
*/
public List<Integer> getRed() {
return red;
}
/**
* @param red
* the red to set
*/
public void setRed(List<Integer> red) {
this.red = red;
}
/**
* @return the green
*/
public List<Integer> getGreen() {
return green;
}
/**
* @param green
* the green to set
*/
public void setGreen(List<Integer> green) {
this.green = green;
}
/**
* @return the blue
*/
public List<Integer> getBlue() {
return blue;
}
/**
* @param blue
* the blue to set
*/
public void setBlue(List<Integer> blue) {
this.blue = blue;
}
}

View file

@ -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.identity.invite;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 19, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class SharedDisplayVenueInvite extends VenueInvite {
@DynamicSerializeElement
private UserId sessionLeader;
@DynamicSerializeElement
private UserId dataProvider;
public UserId getSessionLeader() {
return sessionLeader;
}
public void setSessionLeader(UserId sessionLeader) {
this.sessionLeader = sessionLeader;
}
public UserId getDataProvider() {
return dataProvider;
}
public void setDataProvider(UserId dataProvider) {
this.dataProvider = dataProvider;
}
}

View file

@ -0,0 +1,77 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.invite;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* An invite message for inviting another user to a venue.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 10, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
@DynamicSerialize
public class VenueInvite {
@DynamicSerializeElement
private String subject;
@DynamicSerializeElement
private String message;
@DynamicSerializeElement
private String sessionId;
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
}

View file

@ -0,0 +1,64 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.roster;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 16, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ISubscriptionResponder {
/**
*
* @param fromID
* @return The response that should be returned to the subscriber.
*/
IPresence.Type handleSubscribeRequest(IQualifiedID fromID);
/**
*
* @param fromID
*/
void handleSubscribed(IQualifiedID fromID);
/**
*
* @param fromID
*/
void handleUnsubscribed(IQualifiedID fromID);
}

View file

@ -0,0 +1,58 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface ID {
/**
*
* @param userName
*/
void setName(String userName);
/**
*
*/
String getName();
/**
*
* @return
*/
String getFQName();
}

View file

@ -0,0 +1,65 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IQualifiedID extends ID {
/**
*
* @param hostName
*/
void setHost(String hostName);
/**
*
* @return
*/
String getHost();
/**
*
* @param resource
*/
void setResource(String resource);
/**
*
* @return
*/
String getResource();
}

View file

@ -0,0 +1,43 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface IVenueId extends IQualifiedID {
String getVenueName();
}

View file

@ -0,0 +1,41 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 22, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public enum SharedDisplayRole {
DATA_PROVIDER, SESSION_LEADER, PARTICIPANT;
}

View file

@ -0,0 +1,251 @@
/**
* 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;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class BaseMessage implements Serializable, IMessage {
private static final long serialVersionUID = 1L;
private Map<String, String> properties = null;
private String body;
private IQualifiedID to;
private IQualifiedID from;
private String subject;
private String status;
private long timeStamp;
/**
*
* @param to
* @param body
*/
protected BaseMessage(IQualifiedID to, String body) {
this.body = body;
this.to = to;
initProperties();
timeStamp = setCurrentTimeStamp();
}
/**
* @return the to
*/
@Override
public IQualifiedID getTo() {
return to;
}
/**
* @param to
* the to to set
*/
@Override
public void setTo(IQualifiedID to) {
this.to = to;
}
/**
* @return the from
*/
@Override
public IQualifiedID getFrom() {
return from;
}
/**
* @param from
* the from to set
*/
@Override
public void setFrom(IQualifiedID from) {
this.from = from;
}
/**
* @param body
* the body to set
*/
@Override
public void setBody(String body) {
this.body = body;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getBody()
*/
@Override
public String getBody() {
return body;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getBodyAsBinary()
*/
@Override
public byte[] getBodyAsBinary() {
return null;
}
/**
*
*/
private void initProperties() {
if (properties == null) {
properties = new HashMap<String, 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) {
properties.put(key, value);
}
/**
*
* @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.containsKey(key)) {
retValue = properties.get(key);
}
}
return retValue;
}
/**
* 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<Property> getProperties() {
Collection<Property> p = new ArrayList<Property>();
for (String s : properties.keySet()) {
p.add(new Property(s, properties.get(s)));
}
return p;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getSubject()
*/
@Override
public String getSubject() {
return subject;
}
/**
*
* @param subject
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#setSubject(java.lang.String)
*/
@Override
public void setSubject(String subject) {
this.subject = subject;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getStatus()
*/
@Override
public String getStatus() {
return status;
}
/**
*
* @param status
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#setStatus(java.lang.String)
*/
@Override
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.
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getTimeStamp()
*/
@Override
public long getTimeStamp() {
return timeStamp;
}
/**
*
* @return
*/
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
private long setCurrentTimeStamp() {
long timestamp = System.currentTimeMillis();
properties.put(TIMESTAMP, Long.toHexString(timestamp));
return timestamp;
}
}

View file

@ -0,0 +1,71 @@
/**
* 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;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class CollaborationMessage extends BaseMessage {
private static final long serialVersionUID = 1L;
/**
*
* @param to
* @param body
*/
public CollaborationMessage(IQualifiedID to, String body) {
super(to, body);
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getMessageType()
*/
@Override
public MessageType getMessageType() {
return MessageType.COLLABORATION;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IMessage#getBodyAsBinary(byte[])
*/
@Override
public void getBodyAsBinary(byte[] body) {
}
}

View file

@ -0,0 +1,74 @@
/**
* 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;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 23, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @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) {
mode = STRING;
} else if (object instanceof Serializable) {
mode = JAVA;
} else {
// We may override the serialization type
Class<?> clazz = object.getClass();
Annotation a = clazz.getAnnotation(DynamicSerialize.class);
if (a != null) {
mode = THRIFT;
} else {
a = clazz.getAnnotation(XmlRootElement.class);
if (a != null) {
mode = JAXB;
} else {
mode = NONE;
}
}
}
}
return mode;
}
}

View file

@ -0,0 +1,66 @@
/**
* 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;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @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);
}
/**
*
*/
@Override
public MessageType getMessageType() {
return MessageType.CHAT;
}
@Override
public void getBodyAsBinary(byte[] body) {
}
}

View file

@ -0,0 +1,389 @@
/**
* 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;
import javax.xml.bind.JAXBException;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.util.Base64;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.viz.collaboration.comm.compression.CompressionUtil;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class Tools {
public static final String TAG_INVITE = "[[INVITEID#";
public static final String TAG_INVITE_ID = TAG_INVITE + "%s]]%s";
public static final String PROP_SESSION_ID = "sessionId";
public static final String CMD_PREAMBLE = "[[COMMAND#";
public static final String CONFIG_PREAMBLE = "[[CONFIG#";
public static final String DIRECTIVE_SUFFIX = "]]";
private static final String ENV_THRIFT = CMD_PREAMBLE
+ SerializationMode.THRIFT.name() + "]]";
private static final String ENV_THRIFT_COMPRESSED = CMD_PREAMBLE
+ SerializationMode.THRIFT.name() + "-COMPRESSED]]";
private static final String ENV_JAXB = CMD_PREAMBLE
+ SerializationMode.JAXB.name() + "]]";
private static final String ENV_JAXB_COMPRESSED = CMD_PREAMBLE
+ SerializationMode.JAXB.name() + "-COMPRESSED]]";
private static final String ENV_STRING = CMD_PREAMBLE
+ SerializationMode.STRING.name() + "]]";
private static final String ENV_JAVA = CMD_PREAMBLE
+ SerializationMode.JAVA.name() + "]]";
private static final String ENV_NONE = CMD_PREAMBLE
+ SerializationMode.NONE.name() + "]]";
public static final String VENUE_SUBJECT_PROP = "subject";
public static final String NAME_DELIM = "@";
public static final String PORT_DELIM = ":";
public static final String RESOURCE_DELIM = "/";
public static boolean COMPRESSION_OFF = false;
static {
try {
COMPRESSION_OFF = Boolean
.getBoolean("collaboration.compressionOff");
} catch (Exception e) {
// must not have permission to access system properties. ignore and
// use default.
}
}
/**
*
* @param <T>
* @param container
* @param c
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T getPresenceContainerAdapter(IContainer container,
Class<T> c) {
return (T) container.getAdapter(c);
}
/**
*
* @param id
* @return
*/
public static String parseName(String id) {
String name = null;
if (id != null) {
int delimPos = id.indexOf(NAME_DELIM);
if (delimPos >= 0) {
name = id.substring(0, delimPos);
}
}
return name;
}
/**
*
* @param id
* @return
*/
public static String parseHost(String id) {
String host = null;
if (id != null) {
int delimPos = id.indexOf(NAME_DELIM);
if (delimPos >= 0) {
// Ok we have the start of the host name
int start = delimPos + 1;
int stop = start;
delimPos = id.indexOf(PORT_DELIM);
if (delimPos > stop) {
// ok we have a port so grab anything in between
stop = delimPos;
} else {
// no port delimiter, so check for the resource
delimPos = id.indexOf(RESOURCE_DELIM);
if (delimPos > stop) {
// we have the resource delimiter
stop = delimPos;
} else {
stop = id.length();
}
}
host = id.substring(start, stop);
}
}
return host;
}
/**
*
* @param id
* @return
*/
public static String parsePort(String id) {
String host = null;
if (id != null) {
int delimPos = id.indexOf(NAME_DELIM);
if (delimPos >= 0) {
// Ok we have the start of the host name
int start = delimPos + 1;
int stop = start;
delimPos = id.indexOf(PORT_DELIM);
if (delimPos > stop) {
// ok we have a port so grab anything in between
start = delimPos + 1;
delimPos = id.indexOf(RESOURCE_DELIM);
if (delimPos > start) {
stop = delimPos;
} else {
stop = id.length();
}
host = id.substring(start, stop);
}
}
}
return host;
}
/**
*
* @param id
* @return
*/
public static String parseResource(String id) {
String resource = null;
if (id != null) {
int delimPos = id.indexOf(NAME_DELIM);
// Ensure that the name delimiter is there first.
if (delimPos >= 0) {
int start = delimPos + 1;
delimPos = id.indexOf(RESOURCE_DELIM);
if (delimPos > start) {
delimPos++;
if (delimPos < id.length()) {
resource = id.substring(delimPos);
}
}
}
}
return resource;
}
/**
* Decode Base64 encoded String data into a byte array.
*
* @param message
* @return The decoded byte array data.
*/
public static byte[] decodeFromBase64(String message) {
return Base64.decode(message);
}
/**
* Encode byte array data into a Base64 String for transmission.
*
* @param message
* The message to encode.
* @return The encoded data as a String.
*/
public static String encodeToBase64(byte[] message) {
return Base64.encode(message);
}
/**
*
* @param data
* @return
*/
public static String marshallData(Object data)
throws CollaborationException {
String marshalledData = null;
if (data != null) {
StringBuilder sb = new StringBuilder();
byte[] marshalledBinary = null;
SerializationMode mode = SerializationMode.getMode(data);
switch (mode) {
case THRIFT: {
try {
if (COMPRESSION_OFF) {
marshalledBinary = SerializationUtil
.transformToThrift(data);
sb.append(ENV_THRIFT);
} else {
/*
* compress(thrift(data))
*/
byte[] marshalledThrift = SerializationUtil
.transformToThrift(data);
marshalledBinary = CompressionUtil
.compress(marshalledThrift);
sb.append(ENV_THRIFT_COMPRESSED);
}
} catch (Exception e) {
throw new CollaborationException(
"[THRIFT] Could not serialize object", e);
}
break;
}
case JAXB: {
try {
if (COMPRESSION_OFF) {
String s = SerializationUtil.marshalToXml(data);
if (s != null) {
sb.append(ENV_JAXB);
sb.append(s);
}
} else {
String rawString = SerializationUtil.marshalToXml(data);
marshalledBinary = CompressionUtil.compress(rawString
.getBytes());
sb.append(ENV_JAXB_COMPRESSED);
}
} catch (Exception je) {
throw new CollaborationException(
"[JAXB] Could not serialize object", je);
}
break;
}
case JAVA: {
break;
}
case STRING: {
sb.append(ENV_STRING);
sb.append(data);
break;
}
case NONE: {
throw new CollaborationException("Serialization of "
+ data.getClass().getName() + " not supported");
}
case ISNULL: {
break;
}
}
if (marshalledBinary != null) {
sb.append(encodeToBase64(marshalledBinary));
}
if (sb.length() > 0) {
marshalledData = sb.toString();
}
}
return marshalledData;
}
/**
*
* @param data
* @return
* @throws CollaborationException
*/
public static Object unMarshallData(String data)
throws CollaborationException {
Object unMarshalledData = null;
if (data != null) {
// look for the envelope header first
if (data.startsWith(ENV_THRIFT)) {
String s = data.substring(ENV_THRIFT.length());
try {
byte[] b = decodeFromBase64(s);
unMarshalledData = SerializationUtil.transformFromThrift(b);
} catch (SerializationException e) {
throw new CollaborationException(
"Could not deserialize object", e);
}
} else if (data.startsWith(ENV_THRIFT_COMPRESSED)) {
String s = data.substring(ENV_THRIFT_COMPRESSED.length());
try {
byte[] rawBytes = decodeFromBase64(s);
byte[] uncompressedBytes = CompressionUtil
.uncompress(rawBytes);
unMarshalledData = SerializationUtil
.transformFromThrift(uncompressedBytes);
// unMarshalledData = SerializationUtil
// .transformFromThrift(createCompressionInputStream(rawBytes));
} catch (Exception e) {
throw new CollaborationException(
"Could not deserialize object", e);
}
} else if (data.startsWith(ENV_JAXB)) {
String s = data.substring(ENV_JAXB.length());
try {
unMarshalledData = SerializationUtil.unmarshalFromXml(s);
} catch (JAXBException je) {
throw new CollaborationException(
"[JAXB] Could not deserialize object", je);
}
} else if (data.startsWith(ENV_JAXB_COMPRESSED)) {
String rawString = data.substring(ENV_JAXB_COMPRESSED.length());
try {
byte[] rawBytes = decodeFromBase64(rawString);
unMarshalledData = SerializationUtil
.unmarshalFromXml(new String(CompressionUtil
.uncompress(rawBytes)));
// unMarshalledData = SerializationUtil
// .unmarshalFromXml(createCompressionInputStream(rawBytes));
} catch (Exception je) {
throw new CollaborationException(
"[JAXB] Could not deserialize object", je);
}
} else if (data.startsWith(ENV_STRING)) {
unMarshalledData = data.substring(ENV_STRING.length());
} else if (data.startsWith(ENV_JAVA)) {
throw new CollaborationException("Could not deserialize object");
} else if (data.startsWith(ENV_NONE)) {
throw new CollaborationException("Could not deserialize object");
}
}
return unMarshalledData;
}
}

View file

@ -0,0 +1,69 @@
/**
* 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;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* A command to transfer a role to a different user on the session.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 5, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
@DynamicSerialize
public class TransferRoleCommand {
@DynamicSerializeElement
private SharedDisplayRole role;
@DynamicSerializeElement
private UserId user;
public SharedDisplayRole getRole() {
return role;
}
public void setRole(SharedDisplayRole role) {
this.role = role;
}
public UserId getUser() {
return user;
}
public void setUser(UserId user) {
this.user = user;
}
}

View file

@ -0,0 +1,62 @@
/**
* 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.event;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class ChatMessageEvent implements ITextMessageEvent {
private final TextMessage message;
/**
*
* @param msg
*/
public ChatMessageEvent(TextMessage msg) {
message = msg;
}
/**
*
* @return
*
*/
public TextMessage getMessage() {
return message;
}
}

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.provider.event;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IHttpdCollaborationConfigurationEvent;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 11, 2012 bkowal Initial creation
*
* </pre>
*
* @author bkowal
* @version 1.0
*/
public class HttpdCollaborationConfigurationEvent implements
IHttpdCollaborationConfigurationEvent {
private final String httpdCollaborationURL;
/**
*
*/
public HttpdCollaborationConfigurationEvent(String httpdCollaborationURL) {
this.httpdCollaborationURL = httpdCollaborationURL;
}
@Override
public String getHttpdCollaborationURL() {
return this.httpdCollaborationURL;
}
}

View file

@ -0,0 +1,85 @@
/**
* 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.event;
import org.eclipse.ecf.presence.roster.IRosterItem;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 11, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class RosterChangeEvent implements IRosterChangeEvent {
private final RosterChangeType type;
private final IRosterItem item;
/**
* Create an instance of this event using the given type and entry.
*
* @param type
* The event type.
* @param entry
* The changed entry.
*/
public RosterChangeEvent(RosterChangeType type, IRosterItem item) {
this.type = type;
this.item = item;
}
/**
* Get the event type.
*
* @return The event type.
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent#getType()
*/
@Override
public RosterChangeType getType() {
return type;
}
/**
* Get the changed entry
*
* @return The changed entry.
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent#getEntry()
*/
@Override
public IRosterItem getItem() {
return item;
}
}

View file

@ -0,0 +1,62 @@
/**
* 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.event;
import org.eclipse.ecf.core.user.IUser;
/**
* An event to put on a CollaborationConnection event bus when a users nickname
* has changed to notify all views within this CAVE instance that they need to
* refresh the displays for that user.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class UserNicknameChangedEvent {
public final IUser user;
public final String nickname;
public UserNicknameChangedEvent(IUser user, String nickname) {
this.user = user;
this.nickname = nickname;
}
public IUser getUser() {
return user;
}
public String getNickname() {
return nickname;
}
}

View file

@ -0,0 +1,54 @@
/**
* 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.event;
import org.eclipse.ecf.presence.IPresence;
/**
* Event that is posted when the local uses changes properties of the presence.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 25, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class UserPresenceChangedEvent {
private final IPresence newPresence;
public UserPresenceChangedEvent(IPresence newPresence) {
super();
this.newPresence = newPresence;
}
public IPresence getNewPresence() {
return newPresence;
}
}

View file

@ -0,0 +1,98 @@
/**
* 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.event;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 27, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class VenueInvitationEvent implements IVenueInvitationEvent {
private IQualifiedID venueId;
private IQualifiedID invitor;
private String subject;
private VenueInvite invite;
/**
*
* @param roomId
* @param invitor
* @param subject
* @param body
*/
public VenueInvitationEvent(IQualifiedID venueId, IQualifiedID invitor,
String subject, VenueInvite invite) {
this.venueId = venueId;
this.invitor = invitor;
this.subject = subject;
this.invite = invite;
}
/**
* Get the room identifier
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getRoomId()
*/
@Override
public IQualifiedID getRoomId() {
return venueId;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getInviter()
*/
@Override
public IQualifiedID getInviter() {
return invitor;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getSubject()
*/
@Override
public String getSubject() {
return subject;
}
public VenueInvite getInvite() {
return invite;
}
}

View file

@ -0,0 +1,90 @@
/**
* 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.event;
import org.eclipse.ecf.presence.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 20, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class VenueParticipantEvent implements IVenueParticipantEvent {
private final ParticipantEventType eventType;
private final UserId participant;
private IPresence presence;
public VenueParticipantEvent(UserId participant,
ParticipantEventType eventType) {
this.participant = participant;
this.eventType = eventType;
}
public VenueParticipantEvent(UserId 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()
*/
@Override
public ParticipantEventType getEventType() {
return eventType;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent#getParticipant()
*/
@Override
public UserId getParticipant() {
return participant;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent#getPresence()
*/
@Override
public IPresence getPresence() {
return presence;
}
}

View file

@ -0,0 +1,99 @@
/**
* 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.info;
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.identity.ID;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresence.Type;
import org.eclipse.ecf.presence.Presence;
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class Venue implements IVenue {
private final IChatRoomContainer container;
private final IVenueInfo info;
private Map<String, IPresence> presenceMap = new HashMap<String, IPresence>();;
public Venue(IChatRoomContainer container, IChatRoomInfo info) {
this.container = container;
this.info = new VenueInfo(info);
}
@Override
public IVenueInfo getInfo() {
return info;
}
@Override
public Collection<UserId> getParticipants() {
Set<UserId> participants = new HashSet<UserId>();
ID[] ids = container.getChatRoomParticipants();
for (ID id : ids) {
participants.add(IDConverter.convertFrom(id));
}
return participants;
}
@Override
public IPresence getPresence(IUser user) {
IPresence presence = presenceMap.get(user.getID().getName());
if (presence == null) {
presence = new Presence(Type.UNAVAILABLE);
}
return presence;
}
public void handlePresenceUpdated(ID fromID, IPresence presence) {
presenceMap.put(fromID.getName(), presence);
}
}

View file

@ -0,0 +1,104 @@
/**
* 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.info;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
/**
*
* Wrap a chatroom info in a VenueInfo
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class VenueInfo implements IVenueInfo {
private IChatRoomInfo info;
public VenueInfo(IChatRoomInfo info) {
this.info = info;
}
@Override
public String getVenueDescription() {
return info.getDescription();
}
@Override
public String getVenueName() {
return info.getName();
}
@Override
public String getVenueSubject() {
return info.getSubject();
}
@Override
public String getVenueID() {
return info.getRoomID().toExternalForm();
}
@Override
public int getParticipantCount() {
return info.getParticipantsCount();
}
@Override
public boolean isModerated() {
return info.isModerated();
}
@Override
public boolean isPersistent() {
return info.isPersistent();
}
@Override
public boolean requiresPassword() {
return info.requiresPassword();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("[%s]:", getVenueName()));
sb.append(String.format("[%s]:", getVenueID()));
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("\n subject : %s", getVenueSubject()));
sb.append(String.format("\n description : %s", getVenueDescription()));
return sb.toString();
}
}

View file

@ -0,0 +1,310 @@
/**
* 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.Arrays;
import java.util.Map;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.IPresenceSender;
import org.eclipse.ecf.presence.Presence;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
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.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent;
/**
* TODO Add Description
*
* <ul>
* EventBus subscription events.
* <li>ISubscriptionResponseEvent : This event is posted when a subscription
* request has been responded to.</li>
* </ul>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 16, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class AccountManager implements IAccountManager {
private IRosterSubscriptionListener autoResponder = new IRosterSubscriptionListener() {
@Override
public void handleSubscribeRequest(ID fromID) {
IQualifiedID fromId = null;
IPresence.Type subscribedType = IPresence.Type.UNKNOWN;
if (responder != null) {
subscribedType = responder.handleSubscribeRequest(fromId);
} else {
subscribedType = IPresence.Type.SUBSCRIBED;
}
IPresence presence = new Presence(subscribedType, null,
IPresence.Mode.AVAILABLE);
try {
sendPresence(fromID, presence);
} catch (CollaborationException e) {
e.printStackTrace();
}
}
@Override
public void handleSubscribed(ID fromID) {
System.out.println("AccountManager.handleSubscribed " + fromID);
}
@Override
public void handleUnsubscribed(ID fromID) {
System.out.println("AccountManager.handleUnSubscribed " + fromID);
}
};
private boolean autoRespond = true;
private IPresenceContainerAdapter presenceAdapter;
private ISubscriptionResponder responder;
private CollaborationConnection sessionManager = null;
/**
*
* @param adapter
*/
AccountManager(IPresenceContainerAdapter adapter,
CollaborationConnection manager) {
sessionManager = manager;
presenceAdapter = adapter;
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.
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#setAutoSubscriptionMode(boolean)
*/
@Override
public void setAutoSubscriptionMode(boolean auto) {
autoRespond = auto;
if (!auto) {
responder = null;
}
}
/**
*
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#getAutoSubscriptionMode()
*/
@Override
public boolean getAutoSubscriptionMode() {
return autoRespond;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#setSubscriptionRequestResponder(com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder)
*/
@Override
public void setSubscriptionRequestResponder(ISubscriptionResponder responder) {
this.responder = responder;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#removeSubscriptionRequestResponder()
*/
@Override
public void removeSubscriptionRequestResponder() {
responder = null;
}
/**
*
* @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) {
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");
}
}
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#deleteAccount()
*/
@Override
public void deleteAccount() throws CollaborationException {
org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter
.getAccountManager();
if (manager != null) {
try {
manager.deleteAccount();
} catch (ECFException e) {
throw new CollaborationException("Could not delete account");
}
}
}
/**
* Determines if the server allows new accounts to be created by the user.
*
* @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) {
try {
canCreate = manager.isAccountCreationSupported();
} catch (ECFException e) {
throw new CollaborationException(
"Error attempting to determine if accounts may be created.");
}
}
return canCreate;
}
/**
* 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)
*/
@SuppressWarnings("rawtypes")
@Override
public void createAccount(String name, char[] password,
Map<String, String> attributes) throws CollaborationException {
if (name != null) {
if (password != null) {
// create the account
org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter
.getAccountManager();
if (manager != null) {
Map map = null;
if (attributes != null) {
map = (Map) attributes;
}
try {
manager.createAccount(name, new String(password), map);
} catch (ECFException e) {
throw new CollaborationException(
"Could not create account ");
}
}
// all done so clear the password.
Arrays.fill(password, (char) 0);
}
}
}
/**
*
*
* @param userPresence
* @throws CollaborationException
*/
@Override
public void sendPresence(IPresence userPresence)
throws CollaborationException {
IRosterManager manager = presenceAdapter.getRosterManager();
IPresenceSender sender = manager.getPresenceSender();
try {
sender.sendPresenceUpdate(null, userPresence);
sessionManager.setPresence(userPresence);
for (ISession session : sessionManager.getSessions()) {
if (session instanceof IVenueSession) {
((IVenueSession) session).sendPresence(userPresence);
}
}
sessionManager
.postEvent(new UserPresenceChangedEvent(userPresence));
} catch (ECFException e) {
throw new CollaborationException("Could not send presence");
}
}
/**
*
*
* @param userPresence
* @throws CollaborationException
*/
public void sendPresence(ID toId, IPresence userPresence)
throws CollaborationException {
IRosterManager manager = presenceAdapter.getRosterManager();
IPresenceSender sender = manager.getPresenceSender();
try {
sender.sendPresenceUpdate(toId, userPresence);
sessionManager.setPresence(userPresence);
} catch (ECFException e) {
throw new CollaborationException("Could not send presence");
}
}
}

View file

@ -0,0 +1,272 @@
/**
* 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.HashMap;
import java.util.Map;
import java.util.UUID;
import org.eclipse.ecf.core.IContainer;
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.ECFException;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import com.google.common.eventbus.EventBus;
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.provider.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class BaseSession implements ISession {
protected final String sessionId;
private EventBus managerEventBus;
private EventBus eventBus;
private Map<Object, Object> eventSubscribers;
private IContainer connectionContainer;
private IPresenceContainerAdapter connectionPresence = null;
private Namespace connectionNamespace = null;
private CollaborationConnection connection;
/**
*
* @param container
* @param externalBus
* @param manager
*/
protected BaseSession(IContainer container, EventBus externalBus,
CollaborationConnection manager) throws CollaborationException {
this(container, externalBus, manager, UUID.randomUUID().toString());
}
/**
*
* @param container
* @param externalBus
* @param manager
* @param sessionId
*/
protected BaseSession(IContainer container, EventBus externalBus,
CollaborationConnection manager, String sessionId)
throws CollaborationException {
// Set the session identifier.
this.sessionId = sessionId;
managerEventBus = externalBus;
eventBus = new EventBus();
connectionContainer = container;
connection = manager;
eventSubscribers = new HashMap<Object, Object>();
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);
}
}
/**
* 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) connection.getPeerToPeerSession();
}
/**
*
* @return
*/
IContainer getConnectionContainer() {
return connectionContainer;
}
/**
*
* @return
*/
Namespace getConnectionNamespace() {
return connectionNamespace;
}
/**
*
* @return
*/
IPresenceContainerAdapter getConnectionPresenceAdapter() {
return connectionPresence;
}
/**
*
* @return
*/
EventBus getManagerEventPublisher() {
return managerEventBus;
}
/**
*
* @return
*/
CollaborationConnection getSessionManager() {
return connection;
}
/**
*
* @param name
* @return
*/
public ID createID(String name) throws IDCreateException {
ID id = null;
if (connectionNamespace != null) {
id = IDFactory.getDefault().createID(connectionNamespace, name);
}
return id;
}
// *****************
// Implement IEventPublisher methods
// *****************
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID()
*/
@Override
public UserId getUserID() {
return connection.getUser();
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#isConnected()
*/
@Override
public boolean isConnected() {
boolean connected = false;
if (connectionContainer != null) {
connected = (connectionContainer.getConnectedID() != null);
}
return connected;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#close()
*/
@Override
public void close() {
// Unregister any handlers added using this session
// for(Object o : eventSubscribers.values()) {
// managerEventBus.unregister(o);
// }
connection.removeSession(this);
}
/**
* Get the session identifier.
*
* @return The session id for this session.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getSessionId()
*/
@Override
public String getSessionId() {
return sessionId;
}
// *****************
// Implement IEventPublisher methods
// *****************
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#registerEventHandler(java.lang.Object)
*/
@Override
public void registerEventHandler(Object handler) {
if (!eventSubscribers.containsKey(handler)) {
eventBus.register(handler);
eventSubscribers.put(handler, handler);
}
}
/**
*
* @param handler
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unregisterEventHandler(java.lang.Object)
*/
@Override
public void unregisterEventHandler(Object handler) {
eventSubscribers.remove(handler);
eventBus.unregister(handler);
}
/**
*
*/
@Override
public void postEvent(Object event) {
if (event != null) {
eventBus.post(event);
}
}
@Override
public CollaborationConnection getConnection() {
return connection;
}
}

View file

@ -0,0 +1,736 @@
/**
* 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.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerFactory;
import org.eclipse.ecf.core.IContainer;
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.security.ConnectContextFactory;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresence.Mode;
import org.eclipse.ecf.presence.IPresence.Type;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.presence.IPresenceListener;
import org.eclipse.ecf.presence.Presence;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationListener;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
import org.eclipse.ecf.presence.roster.IRoster;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.IRosterItem;
import org.eclipse.ecf.presence.roster.IRosterListener;
import org.eclipse.ecf.presence.roster.IRosterManager;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
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.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.MultipleLoginException;
import com.raytheon.uf.viz.collaboration.comm.identity.UsernamePasswordException;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenueInvite;
import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
import com.raytheon.uf.viz.collaboration.comm.provider.event.RosterChangeEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.info.VenueInfo;
import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
/**
*
* <ul>
* <li>EventBus subscription events.</li>
* <ul>
* <li><strong>IVenueInvitationEvent</strong> : This event is posted when the
* SessionManager receives a venue invitation requesting that the user join some
* particular collaboration session.</li>
* <li><strong>IConnectionStatusEvent</strong> : This event is posted when the
* state of the underlying connection changes, reconnecting, connecting,
* disconnected, for example.</li>
* <li><strong>IRosterChangeEvent</strong> : This event is posted when roster
* changes have occurred.</li>
* <li><strong>---------------</strong> : ---------------.</li>
* </ul>
* </ul>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Apr 18, 2012 njensen Major cleanup
*
* </pre>
*
* @author jkorman
* @version 1.0
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent
*/
public class CollaborationConnection implements IEventPublisher {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationConnection.class);
private static final String PROVIDER = "com.raytheon.uf.viz.collaboration.comm.xmpp";// "ecf.xmpp.smack";
private static CollaborationConnection instance = null;
private static Map<CollaborationConnectionData, CollaborationConnection> instanceMap = new HashMap<CollaborationConnectionData, CollaborationConnection>();
private Map<String, ISession> sessions;
private UserId account;
private String password;
private UserId user;
private IPresence userPresence;
private IChatRoomInvitationListener intInvitationListener;
private IPresenceContainerAdapter presenceAdapter;
private Namespace connectionNamespace = null;
private PeerToPeerChat chatInstance = null;
private IAccountManager accountManager = null;
private IRosterManager rosterManager = null;
private IContainer container = null;
private EventBus eventBus;
private ContactsManager contactsMgr;
private CollaborationConnectionData connectionData;
private CollaborationConnection(CollaborationConnectionData connectionData)
throws CollaborationException {
this.connectionData = connectionData;
UserId account = new UserId(connectionData.getUserName(),
connectionData.getServer());
String password = connectionData.getPassword();
IPresence initialPresence = new Presence(Type.AVAILABLE,
connectionData.getMessage(), Mode.fromString(connectionData
.getStatus().toLowerCase()),
connectionData.getAttributes());
eventBus = new EventBus();
sessions = new HashMap<String, ISession>();
try {
container = ContainerFactory.getDefault().createContainer(PROVIDER);
if (container != null) {
// add the listeners before we connect so we don't potentially
// miss something
presenceAdapter = Tools.getPresenceContainerAdapter(container,
IPresenceContainerAdapter.class);
this.setupInternalConnectionListeners();
}
} catch (ContainerCreateException cce) {
closeInternals();
throw new CollaborationException(String.format(
"Could not create container for provider [%s]", PROVIDER));
}
this.account = account;
this.password = password;
try {
connectToContainer();
} catch (ContainerConnectException e) {
closeInternals();
// ECF does a very good job of wrapping up login exceptions so it is
// hard to tell why the login failed. This code will attempt to
// analyze the cause of the failure and in some circumstances
// produce a helpful error. Since this is relying on string
// comparison of exception messages it is very likely that if the
// ECF provider is changed or updated that this will stop producing
// helpful messages. Unfortunately ECF does not provide any other
// mechanism for figuring out why login failed.
for (Throwable t = e; t != null && t != t.getCause(); t = t
.getCause()) {
if (t.getMessage().contains("authentication failed")) {
throw new UsernamePasswordException(
"Login failed. Invalid username or password", e);
} else if (t.getMessage().equals("conflict(409)")) {
throw new MultipleLoginException(
"Login failed. User already logged in elsewhere",
e);
}
}
// In cases where we can't produce anything helpful, at least let
// the user know that it failed and hopeful something in the stack
// trace will be useful in the DR.
throw new CollaborationException("Login failed.", e);
}
ID id = container.getConnectedID();
if (id != null) {
String name = Tools.parseName(id.getName());
String host = Tools.parseHost(id.getName());
String resource = Tools.parseResource(id.getName());
user = new UserId(name, host, resource);
user.setId(id);
}
setupAccountManager();
setupInternalVenueInvitationListener();
setupP2PComm(presenceAdapter);
getPeerToPeerSession();
userPresence = initialPresence;
if (accountManager != null && initialPresence != null) {
accountManager.sendPresence(initialPresence);
}
contactsMgr = new ContactsManager(this);
this.registerEventHandler(contactsMgr);
instanceMap.put(connectionData, this);
if (instance == null) {
instance = this;
}
}
public CollaborationConnectionData getConnectionData() {
return connectionData;
}
/**
* @return
* @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster#getUser()
*/
public UserId getUser() {
return user;
}
/**
*
* @return
*/
public IPresence getPresence() {
return userPresence;
}
/**
*
* @return
*/
public void setPresence(IPresence presence) {
userPresence = presence;
}
/**
* @throws CollaborationException
* @throws ContainerConnectException
*
*/
private void connectToContainer() throws CollaborationException,
ContainerConnectException {
if (container.getConnectedID() == null) {
connectionNamespace = container.getConnectNamespace();
// Now connect
ID targetID = createID(account);
presenceAdapter = Tools.getPresenceContainerAdapter(container,
IPresenceContainerAdapter.class);
container.connect(targetID, ConnectContextFactory
.createPasswordConnectContext(password));
}
}
/**
*
*/
private void setupAccountManager() {
if (accountManager == null) {
if (isConnected() && (presenceAdapter != null)) {
accountManager = new AccountManager(presenceAdapter, this);
}
}
}
/**
* Get the account manager for this connection.
*
* @return The account manager for this connection.
*/
public IAccountManager getAccountManager() {
if (accountManager == null) {
setupAccountManager();
}
return accountManager;
}
/**
*
*/
private void setupRosterManager() {
rosterManager = presenceAdapter.getRosterManager();
}
/**
*
* @return
*/
public IPresenceContainerAdapter getPresenceContainerAdapter() {
return presenceAdapter;
}
/**
*
* @return
*/
public IRosterManager getRosterManager() {
if (rosterManager == null) {
setupRosterManager();
}
return rosterManager;
}
/**
* Is this SessionManager currently connected?
*
* @return Is this SessionManager currently connected?
*/
public boolean isConnected() {
return ((container != null) && (container.getConnectedID() != null));
}
private void closeInternals() {
if (container != null) {
chatInstance = null;
// Get rid of the account and roster managers
container.disconnect();
container.dispose();
container = null;
}
instanceMap.remove(connectionData);
if (this == instance) {
instance = null;
}
}
/**
*
*/
public void close() {
if (container != null) {
// Close any created sessions.
Collection<ISession> toRemove = sessions.values();
sessions.clear();
for (ISession session : toRemove) {
if ((chatInstance != null) && chatInstance.equals(session)) {
chatInstance.close();
chatInstance = null;
} else {
session.close();
}
}
chatInstance = null;
}
closeInternals();
}
/**
* Get the PeerToPeerChat session instance.
*
* @return
*/
public ISession getPeerToPeerSession() throws CollaborationException {
if (chatInstance == null) {
chatInstance = new PeerToPeerChat(container, eventBus, this);
sessions.put(chatInstance.getSessionId(), chatInstance);
postEvent(chatInstance);
}
return chatInstance;
}
public ISharedDisplaySession joinCollaborationVenue(
IVenueInvitationEvent invitation) throws CollaborationException {
SharedDisplaySession session = null;
String venueName = invitation.getRoomId().getName();
String sessionId = invitation.getInvite().getSessionId();
session = new SharedDisplaySession(container, eventBus, this, sessionId);
if (session != null) {
session.joinVenue(venueName);
if (invitation.getInvite() instanceof SharedDisplayVenueInvite) {
SharedDisplayVenueInvite invite = (SharedDisplayVenueInvite) invitation
.getInvite();
session.setCurrentDataProvider(invite.getDataProvider());
session.setCurrentSessionLeader(invite.getSessionLeader());
}
sessions.put(session.getSessionId(), session);
postEvent(session);
}
return session;
}
/**
*
* @param venueName
* @return
* @throws CollaborationException
*/
public ISharedDisplaySession createCollaborationVenue(String venueName,
String subject) throws CollaborationException {
SharedDisplaySession session = null;
try {
session = new SharedDisplaySession(container, eventBus, this);
session.createVenue(venueName, subject);
session.setCurrentSessionLeader(user);
session.setCurrentDataProvider(user);
sessions.put(session.getSessionId(), session);
postEvent(session);
return session;
} catch (Exception e) {
throw new CollaborationException(
"Error creating collaboration venue " + venueName, e);
}
}
/**
*
* @param venueName
* @return
* @throws CollaborationException
*/
public IVenueSession joinTextOnlyVenue(String venueName)
throws CollaborationException {
VenueSession session = null;
try {
session = new VenueSession(container, eventBus, this);
if (session != null) {
session.joinVenue(venueName);
sessions.put(session.getSessionId(), session);
postEvent(session);
}
} catch (Exception e) {
throw new CollaborationException(
"Error joining venue " + venueName, e);
}
return session;
}
/**
*
* @param venueName
* @return
* @throws CollaborationException
*/
public IVenueSession createTextOnlyVenue(String venueName, String subject)
throws CollaborationException {
VenueSession session = null;
try {
session = new VenueSession(container, eventBus, this);
if (session != null) {
session.createVenue(venueName, subject);
sessions.put(session.getSessionId(), session);
postEvent(session);
}
} catch (Exception e) {
throw new CollaborationException("Error creating venue "
+ venueName, e);
}
return session;
}
/**
*
* @param session
*/
protected void removeSession(ISession session) {
sessions.remove(session.getSessionId());
postEvent(session);
}
/**
*
* @return
*/
public Collection<IVenueInfo> getVenueInfo() {
// Check to see if the container has been connected.
Collection<IVenueInfo> info = new ArrayList<IVenueInfo>();
if (isConnected()) {
IPresenceContainerAdapter presenceAdapter = Tools
.getPresenceContainerAdapter(container,
IPresenceContainerAdapter.class);
IChatRoomManager venueManager = presenceAdapter
.getChatRoomManager();
if (venueManager != null) {
IChatRoomInfo[] roomInfo = venueManager.getChatRoomInfos();
for (IChatRoomInfo rInfo : roomInfo) {
IVenueInfo vi = new VenueInfo(rInfo);
info.add(vi);
}
}
}
return info;
}
// ***************************
// Connection listener
// ***************************
/**
*
*/
private void setupInternalConnectionListeners() {
presenceAdapter.getRosterManager().addPresenceListener(
new IPresenceListener() {
@Override
public void handlePresence(ID fromId,
org.eclipse.ecf.presence.IPresence presence) {
if (rosterManager != null) {
if (contactsMgr != null) {
IUser u = contactsMgr.getUser(fromId);
if (u != null) {
IRosterEntry entry = contactsMgr
.getRosterEntry(u);
eventBus.post(entry);
}
}
}
}
});
presenceAdapter.getRosterManager().addRosterListener(
new IRosterListener() {
@Override
public void handleRosterEntryAdd(IRosterEntry entry) {
IRosterChangeEvent event = new RosterChangeEvent(
RosterChangeType.ADD, entry);
eventBus.post(event);
}
@Override
public void handleRosterUpdate(IRoster roster,
IRosterItem item) {
IRosterChangeEvent event = new RosterChangeEvent(
RosterChangeType.MODIFY, item);
eventBus.post(event);
}
@Override
public void handleRosterEntryRemove(IRosterEntry entry) {
IRosterChangeEvent event = new RosterChangeEvent(
RosterChangeType.DELETE, entry);
eventBus.post(event);
}
});
}
public ISession getSession(String sessionId) {
return sessions.get(sessionId);
}
private void setupP2PComm(IPresenceContainerAdapter presenceAdapter) {
if (isConnected() && (presenceAdapter != null)) {
PeerToPeerCommHelper helper = new PeerToPeerCommHelper(this);
presenceAdapter.getChatManager().addMessageListener(helper);
}
}
// ***************************
// Venue invitation listener management
// ***************************
/**
*
*/
private void setupInternalVenueInvitationListener() {
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 = null;
if (roomID instanceof XMPPRoomID) {
XMPPRoomID room = (XMPPRoomID) roomID;
venueId = new VenueId();
venueId.setName(room.getLongName());
}
if (venueId != null) {
IQualifiedID id = IDConverter.convertFrom(from);
UserId invitor = new UserId(id.getName(),
id.getHost(), id.getResource());
VenueInvite received;
try {
received = (VenueInvite) Tools
.unMarshallData(body);
if (subject == null) {
subject = received.getSubject();
if (subject == null) {
subject = presenceAdapter
.getChatRoomManager()
.getChatRoomInfo(
roomID.getName())
.getSubject();
}
}
IVenueInvitationEvent invite = new VenueInvitationEvent(
venueId, invitor, subject, received);
eventBus.post(invite);
} catch (CollaborationException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error handling received invite message",
e);
}
}
}
};
venueManager.addInvitationListener(intInvitationListener);
}
}
}
/**
* Register an event handler with this
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#registerEventHandler(java.lang.Object)
*/
@Override
public void registerEventHandler(Object handler) {
eventBus.register(handler);
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher#unregisterEventHandler(java.lang.Object)
*/
@Override
public void unregisterEventHandler(Object handler) {
eventBus.unregister(handler);
}
@Override
public void postEvent(Object event) {
if (event != null) {
eventBus.post(event);
}
}
public ContactsManager getContactsManager() {
return contactsMgr;
}
/**
*
* @param name
* @return
*/
public ID createID(UserId name) throws CollaborationException {
ID id = null;
try {
if (connectionNamespace != null) {
id = IDFactory.getDefault().createID(connectionNamespace,
name.getFQName());
}
} catch (IDCreateException idce) {
throw new CollaborationException("Could not create id");
}
return id;
}
public Collection<ISession> getSessions() {
return sessions.values();
}
/**
* Returns the currently connected connection or null if it's not connected
*
* @return
*/
public static CollaborationConnection getConnection() {
return instance;
}
/**
* Create a {@link CollaborationConnection} given the
* {@link CollaborationConnectionData}
*
* @param userData
* @return
* @throws CollaborationException
*/
public static CollaborationConnection connect(
CollaborationConnectionData userData) throws CollaborationException {
if (instance != null) {
throw new CollaborationException("Already connected");
} else {
instance = new CollaborationConnection(userData);
return getConnection();
}
}
}

View file

@ -0,0 +1,218 @@
/**
* 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.HashMap;
import java.util.Map;
/**
* Collaboration connection data object used for creating a {@link CollaborationConnection}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 18, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class CollaborationConnectionData {
private String server;
private String userName;
private String password;
private String status;
private String message;
private Map<String, String> attributes;
public CollaborationConnectionData() {
attributes = new HashMap<String, String>();
}
/**
* @return the server
*/
public String getServer() {
return server;
}
/**
* @param server
* the server to set
*/
public void setServer(String server) {
this.server = server;
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName
* the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password
* the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message
* the message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the attributes
*/
public Map<String, String> getAttributes() {
return new HashMap<String, String>(attributes);
}
/**
* @param attributes
* the attributes to set
*/
public void setAttributes(Map<String, String> attributes) {
this.attributes = new HashMap<String, String>(attributes);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((attributes == null) ? 0 : attributes.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result
+ ((password == null) ? 0 : password.hashCode());
result = prime * result + ((server == null) ? 0 : server.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result
+ ((userName == null) ? 0 : userName.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CollaborationConnectionData other = (CollaborationConnectionData) obj;
if (attributes == null) {
if (other.attributes != null)
return false;
} else if (!attributes.equals(other.attributes))
return false;
if (message == null) {
if (other.message != null)
return false;
} else if (!message.equals(other.message))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (server == null) {
if (other.server != null)
return false;
} else if (!server.equals(other.server))
return false;
if (status == null) {
if (other.status != null)
return false;
} else if (!status.equals(other.status))
return false;
if (userName == null) {
if (other.userName != null)
return false;
} else if (!userName.equals(other.userName))
return false;
return true;
}
}

View file

@ -0,0 +1,128 @@
/**
* 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.Collection;
import java.util.HashMap;
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.im.IChatMessage;
import org.eclipse.ecf.presence.im.IChatMessageSender;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.viz.collaboration.comm.Activator;
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.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
/**
*
*
* Only one instance of this class should be created.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Apr 18, 2012 njensen Cleanup
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
private IChatMessageSender chatSender = null;
/**
*
* @param container
* @param externalBus
* @param manager
*/
PeerToPeerChat(IContainer container, EventBus externalBus,
CollaborationConnection manager) throws CollaborationException {
super(container, externalBus, manager);
chatSender = getConnectionPresenceAdapter().getChatManager()
.getChatMessageSender();
}
/**
* @throws CollaborationException
*
*/
@Override
public void sendPeerToPeer(IMessage message) throws CollaborationException {
if (chatSender != null) {
ID toID = createID(message.getTo().getFQName());
String subject = message.getSubject();
String body = message.getBody();
Collection<Property> properties = message.getProperties();
Map<String, String> props = null;
if ((properties != null) && (properties.size() > 0)) {
props = new HashMap<String, String>();
for (Property p : properties) {
props.put(p.getKey(), p.getValue());
}
}
try {
Activator
.getDefault()
.getNetworkStats()
.log(Activator.PEER_TO_PEER,
message.getBody().length(), 0);
chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT,
subject, body, props);
} catch (ECFException e) {
throw new CollaborationException(
"Error sending message to peer "
+ message.getTo().getName(), e);
}
}
}
/**
* Send a message to the named recipient.
*
* @param to
* The recipient of the message.
* @param message
* The body of the message to send.
* @throws CollaborationException
*/
@Override
public void sendPeerToPeer(IQualifiedID to, String message)
throws CollaborationException {
TextMessage msg = new TextMessage(to, message);
this.sendPeerToPeer(msg);
}
}

View file

@ -0,0 +1,259 @@
/**
* 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.im.IChatMessage;
import org.eclipse.ecf.presence.im.IChatMessageEvent;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.Activator;
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.IHttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IHttpdXmppMessage;
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.event.HttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
/**
* Listens for peer to peer messages and routes them appropriately.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class PeerToPeerCommHelper implements IIMMessageListener {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PeerToPeerCommHelper.class);
private static Object httpServerLockObj = new Object();
private static String httpServer;
public static String getCollaborationHttpServer() {
/**
* Wait for initialization of field httpServer.
*/
synchronized (httpServerLockObj) {
try {
while (httpServer == null) {
httpServerLockObj.wait(500);
}
} catch (InterruptedException e) {
statusHandler.handle(Priority.PROBLEM,
"PeerToPeerCommHelper unable to resolve server URL. "
+ e.getLocalizedMessage(), e);
}
}
return httpServer;
}
private CollaborationConnection manager;
/**
*
* @param manager
* @param presenceAdapter
*/
protected PeerToPeerCommHelper(CollaborationConnection manager) {
this.manager = manager;
}
/**
*
*/
@Override
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatMessageEvent) {
IChatMessageEvent event = (IChatMessageEvent) messageEvent;
IChatMessage msg = event.getChatMessage();
String body = msg.getBody();
Activator.getDefault().getNetworkStats()
.log(Activator.PEER_TO_PEER, 0, body.length());
if (body != null) {
if (body.startsWith(Tools.CMD_PREAMBLE)) {
routeData(msg);
} else if (body.startsWith(Tools.CONFIG_PREAMBLE)) {
this.handleConfiguration(body);
} 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) {
statusHandler.handle(Priority.PROBLEM,
"Error unmarshalling PeerToPeer data", e);
}
if (object != null) {
String sessionId = (String) message.getProperties().get(
Tools.PROP_SESSION_ID);
if (sessionId == null) {
manager.postEvent(object);
} else {
// Ok, we have a session id.
ISession session = manager.getSession(sessionId);
if (session != null) {
session.postEvent(object);
} else {
statusHandler.handle(Priority.PROBLEM,
"ERROR: Unknown sessionid [" + sessionId + "]");
}
}
}
}
/**
*
* @param message
*/
private void routeMessage(IChatMessage message) {
IQualifiedID fromId = IDConverter.convertFrom(message.getFromID());
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<Object, Object> 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.postEvent(chatEvent);
} else {
// Ok, we have a session id.
ISession session = manager.getSession(sessionId);
if (session != null) {
session.postEvent(chatEvent);
}
}
}
private void handleConfiguration(String body) {
// Determine if an error has occurred.
if (IHttpdXmppMessage.configErrorPattern.matcher(body).matches()) {
statusHandler.handle(
UFStatus.Priority.ERROR,
this.getCollaborationConfigurationParameterValue(body,
IHttpdXmppMessage.ERROR_PARAMETER_NAME)
+ ". Shared Display Sessions have been disabled.");
this.disableSharedDisplaySession();
// terminate execution
return;
}
// Validate the configuration.
if (IHttpdXmppMessage.configURLPattern.matcher(body).matches() == false) {
statusHandler
.handle(UFStatus.Priority.PROBLEM,
"Received invalid configuration from openfire. Shared Display Sessions have been disabled.");
this.disableSharedDisplaySession();
return;
}
// Remove the parameter name.
String httpdCollaborationURL = this
.getCollaborationConfigurationParameterValue(body,
IHttpdXmppMessage.URL_PARAMETER_NAME);
// validate the url.
if (IHttpdXmppMessage.urlPattern.matcher(httpdCollaborationURL)
.matches() == false) {
statusHandler.handle(UFStatus.Priority.PROBLEM,
"Received an invalid http url from openfire - "
+ httpdCollaborationURL
+ ". Shared Display Sessions have been disabled.");
this.disableSharedDisplaySession();
return;
}
synchronized (httpServerLockObj) {
httpServer = httpdCollaborationURL;
httpServerLockObj.notifyAll();
}
// configuration is valid; publish it.
IHttpdCollaborationConfigurationEvent configurationEvent = new HttpdCollaborationConfigurationEvent(
httpdCollaborationURL);
manager.postEvent(configurationEvent);
}
private String getCollaborationConfigurationParameterValue(String body,
String parameterName) {
// Eliminate the preamble.
String encodedConfiguration = body.replace(Tools.CONFIG_PREAMBLE, "");
// Eliminate the suffix: ]]
encodedConfiguration = encodedConfiguration.substring(0,
encodedConfiguration.length() - 2);
// Remove the parameter name.
return encodedConfiguration.replace(parameterName + " :", "").trim();
}
private void disableSharedDisplaySession() {
// ensure that the shared session displays will be disabled
IHttpdCollaborationConfigurationEvent configurationEvent = new HttpdCollaborationConfigurationEvent(
null);
manager.postEvent(configurationEvent);
}
}

View file

@ -0,0 +1,139 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.provider.session;
import org.eclipse.ecf.core.IContainer;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
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.user.UserId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 18, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class SharedDisplaySession extends VenueSession implements
ISharedDisplaySession {
private UserId sessionLeader = null;
private UserId dataProvider = null;
public SharedDisplaySession(IContainer container, EventBus externalBus,
CollaborationConnection manager) throws CollaborationException {
super(container, externalBus, manager);
}
public SharedDisplaySession(IContainer container, EventBus externalBus,
CollaborationConnection manager, String sessionId)
throws CollaborationException {
super(container, externalBus, manager, sessionId);
}
@Override
public void sendObjectToVenue(Object obj) throws CollaborationException {
if (obj != null) {
String message = Tools.marshallData(obj);
if (message != null) {
sendMessageToVenue(message);
}
}
}
@Override
public void sendObjectToPeer(
com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant,
Object obj) throws CollaborationException {
PeerToPeerChat session = getP2PSession();
if (session != null) {
String message = Tools.marshallData(obj);
if (message != null) {
TextMessage msg = new TextMessage(participant, message);
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
session.sendPeerToPeer(msg);
}
}
}
/**
* Get the identification of the user who is the DataProvider.
*
* @return The DataProvider user identification.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentDataProvider()
*/
@Override
public UserId getCurrentDataProvider() {
return dataProvider;
}
/**
* Get the identification of the user who is the Session Leader.
*
* @return The Session Leader user identification.
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession#getCurrentSessionLeader()
*/
@Override
public UserId 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(SharedDisplayRole role) {
boolean result = true;
if (role.equals(SharedDisplayRole.DATA_PROVIDER)
&& !this.getUserID().equals(this.getCurrentDataProvider())) {
result = false;
} else if (role.equals(SharedDisplayRole.SESSION_LEADER)
&& !this.getUserID().equals(this.getCurrentSessionLeader())) {
result = false;
}
return result;
}
@Override
public void setCurrentSessionLeader(UserId id) {
sessionLeader = id;
}
@Override
public void setCurrentDataProvider(UserId id) {
dataProvider = id;
}
}

View file

@ -0,0 +1,527 @@
/**
* 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.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.presence.IIMMessageEvent;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationSender;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessage;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageEvent;
import org.eclipse.ecf.presence.chatroom.IChatRoomMessageSender;
import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.Activator;
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.IVenueSession;
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.invite.VenueInvite;
import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage;
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.VenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.info.Venue;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
*
* <ul>
* <li>EventBus subscription events.</li>
* <ul>
* <li><strong>IVenueParticipantEvent</strong> : This event is posted when a
* venue participant enters, leaves a venue, or updates their status in the
* venue.</li>
* <li><strong>TextMessage</strong> : Text messages send between users. Meant to
* be displayed as conversation.</li>
* <li><strong>CollaborationMessage</strong> : These messages are CAVE to CAVE
* command messages.</li>
* </ul>
* </ul>
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Apr 17, 2012 njensen Major refactor
*
* </pre>
*
* @author jkorman
* @version 1.0
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent
* @see com.raytheon.uf.viz.collaboration.comm.provider.TextMessage
* @see com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage
*/
public class VenueSession extends BaseSession implements IVenueSession {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(VenueSession.class);
private static final String SEND_CMD = "[[COMMAND";
private static final String SEND_TXT = "[[TEXT]]";
public static final String SEND_HISTORY = "[[HISTORY]]";
private IChatRoomInfo venueInfo = null;
private IChatRoomContainer venueContainer = null;
private IIMMessageListener intListener = null;
private IChatRoomParticipantListener participantListener = null;
private Venue venue;
/**
*
* @param container
* @param eventBus
*/
protected VenueSession(IContainer container, EventBus externalBus,
CollaborationConnection manager, String sessionId)
throws CollaborationException {
super(container, externalBus, manager, sessionId);
}
/**
*
* @param container
* @param eventBus
*/
protected VenueSession(IContainer container, EventBus externalBus,
CollaborationConnection manager) throws CollaborationException {
super(container, externalBus, manager);
}
/**
* Close this session. Closing clears all listeners and disposes of the
* container. No errors for attempting to close an already closed session.
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#close()
*/
@Override
public void close() {
if (intListener != null) {
venueContainer.removeMessageListener(intListener);
intListener = null;
}
if (participantListener != null) {
venueContainer
.removeChatRoomParticipantListener(participantListener);
participantListener = null;
}
if (venueContainer != null) {
venueContainer.disconnect();
venueContainer = null;
}
venueInfo = null;
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() {
return venue;
}
/**
* 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.
* @throws CollaborationException
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String,
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void sendInvitation(UserId id, VenueInvite invite)
throws CollaborationException {
IChatRoomInvitationSender sender = getConnectionPresenceAdapter()
.getChatRoomManager().getInvitationSender();
if (sender != null) {
String msgBody = Tools.marshallData(invite);
ID roomId = venueInfo.getConnectedID();
ID userId = IDFactory.getDefault().createID(
getConnectionNamespace(), id.getFQName());
try {
sender.sendInvitation(roomId, userId, invite.getSubject(),
msgBody);
} catch (ECFException e) {
throw new CollaborationException("Error sending invitation", e);
}
}
}
/**
* 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.
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String,
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void sendInvitation(List<UserId> ids, VenueInvite invite)
throws CollaborationException {
if (ids != null) {
for (UserId id : ids) {
sendInvitation(id, invite);
}
}
}
@Override
public void sendChatMessage(String message) throws CollaborationException {
this.sendMessageToVenue(message);
}
protected void sendMessageToVenue(String message)
throws CollaborationException {
// Assume success
if ((venueContainer != null) && (message != null)) {
Activator.getDefault().getNetworkStats()
.log(Activator.VENUE, message.length(), 0);
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 messge", e);
}
}
}
protected IChatRoomInfo joinVenue(String venueName)
throws CollaborationException {
// Create chat room container from manager
IChatRoomManager venueManager = getConnectionPresenceAdapter()
.getChatRoomManager();
if (venueManager != null) {
venueInfo = venueManager.getChatRoomInfo(venueName);
if (venueInfo == null) {
throw new CollaborationException("Unable to join venue "
+ venueName + ". Venue may have been closed already.");
}
completeVenueConnection(venueInfo);
}
return venueInfo;
}
/**
* This does NOT connect to the room, it only creates the venue and returns
* the info. To connect, connectToRoom must be called.
*
* @param venueName
* @throws CollaborationException
* @throws Exception
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String,
* java.lang.String)
*/
protected IChatRoomInfo createVenue(String venueName, String subject)
throws CollaborationException {
try {
// Create chat room container from manager
IChatRoomManager venueManager = getConnectionPresenceAdapter()
.getChatRoomManager();
if (venueManager != null) {
venueInfo = venueManager.getChatRoomInfo(venueName);
if (venueInfo == null) {
Map<String, String> props = null;
if (subject != null) {
props = new HashMap<String, String>();
props.put(Tools.VENUE_SUBJECT_PROP, subject);
}
venueInfo = venueManager.createChatRoom(venueName, props);
completeVenueConnection(venueInfo);
}
}
} catch (Exception e) {
throw new CollaborationException("Error creating venue "
+ venueName, e);
}
return venueInfo;
}
/**
*
* @return
* @throws CollaborationException
*/
private void completeVenueConnection(IChatRoomInfo venueInfo)
throws CollaborationException {
if (venueInfo != null) {
try {
venueContainer = venueInfo.createChatRoomContainer();
this.venue = new Venue(venueContainer, venueInfo);
} catch (ContainerCreateException e) {
throw new CollaborationException(
"Error completing connection to venue", e);
}
}
}
/**
* Allows users to connect after the fact so that they do not miss any
* messages coming from the room (after the dialog/view has been
* instanstiated)
*/
public void connectToRoom() {
try {
IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() {
@Override
public void handleArrived(IUser participant) {
UserId user = IDConverter.convertFrom(participant);
postEvent(new VenueParticipantEvent(user,
ParticipantEventType.ARRIVED));
}
@Override
public void handleUpdated(IUser participant) {
UserId user = IDConverter.convertFrom(participant);
postEvent(new VenueParticipantEvent(user,
ParticipantEventType.UPDATED));
}
@Override
public void handleDeparted(IUser participant) {
UserId user = IDConverter.convertFrom(participant);
postEvent(new VenueParticipantEvent(user,
ParticipantEventType.DEPARTED));
}
@Override
public void handlePresenceUpdated(ID fromID,
org.eclipse.ecf.presence.IPresence presence) {
venue.handlePresenceUpdated(fromID, presence);
UserId user = IDConverter.convertFrom(fromID);
postEvent(new VenueParticipantEvent(user, presence,
ParticipantEventType.PRESENCE_UPDATED));
}
};
venueContainer.addChatRoomParticipantListener(pListener);
venueContainer.connect(venueInfo.getRoomID(), null);
if (venueContainer.getConnectedID() != null) {
intListener = new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent messageEvent) {
if (messageEvent instanceof IChatRoomMessageEvent) {
IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent)
.getChatRoomMessage();
Activator
.getDefault()
.getNetworkStats()
.log(Activator.VENUE, 0,
m.getMessage().length());
if (accept(m)) {
distributeMessage(convertMessage(m));
}
}
}
};
venueContainer.addMessageListener(intListener);
sendPresence(CollaborationConnection.getConnection()
.getPresence());
}
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} catch (ContainerConnectException e) {
statusHandler.handle(Priority.ERROR,
"Unable to connect to container", e);
}
}
/**
* Examine the incoming message to determine if it should be forwarded. The
* method looks at the from identifier to determine who sent the message.
*
* @param message
* A message to accept.
* @return Should the message be accepted.
*/
private boolean accept(IChatRoomMessage message) {
boolean acceptMessage = true;
String body = message.getMessage();
// Command data only
if (body.startsWith(SEND_CMD)) {
ID from = message.getFromID();
String name = Tools.parseName(from.getName());
UserId account = getSessionManager().getUser();
String aName = account.getFQName();
if (aName.equals(name)) {
acceptMessage = false;
}
}
return acceptMessage;
}
/**
*
* @param message
*/
private void distributeMessage(IMessage message) {
if (message != null) {
String body = message.getBody();
if (body != null) {
if (body.startsWith(SEND_CMD)) {
Object o = null;
try {
o = Tools.unMarshallData(body);
if (o != null) {
this.postEvent(o);
}
} catch (CollaborationException ce) {
statusHandler.error(
"Error deserializing received message on venue "
+ venueInfo.getName(), ce);
}
} else if (body.startsWith(SEND_TXT)) {
body = body.substring(SEND_TXT.length());
message.setBody(body);
TextMessage msg = new TextMessage(message.getTo(),
message.getBody());
msg.setFrom(message.getFrom());
this.postEvent(msg);
} else if (body.startsWith(SEND_HISTORY)) {
String[] vars = body.split("\\|");
String timeString = vars[0]
.substring(SEND_HISTORY.length());
long time = Long.parseLong(timeString);
String username = vars[1];
String site = vars[2];
// add the SEND_HISTORY tag length, and the timestamp
// length, username length, and the site length plus the
// three pipe characters
String moddedBody = body.substring(SEND_HISTORY.length()
+ timeString.length() + username.length()
+ site.length() + SEND_TXT.length() + 3);
message.setBody(moddedBody);
TextMessage msg = new TextMessage(message.getFrom(),
message.getBody());
UserId id = new UserId(username, CollaborationConnection
.getConnection().getConnectionData().getServer());
msg.setFrom(id);
msg.setTimeStamp(time);
msg.setSubject(site);
msg.setStatus(SEND_HISTORY);
this.postEvent(msg);
} else {
// attempt to handle outside clients as text only since the
// SEND_TXT won't be appended to the first portion of the
// body
message.setBody(body);
TextMessage msg = new TextMessage(message.getTo(),
message.getBody());
msg.setFrom(message.getFrom());
this.postEvent(msg);
}
}
}
}
/**
* Convert from an ECF chat room message to an IMessage instance.
*
* @param msg
* The ECF chat room message to convert.
* @return The converted message.
*/
private IMessage convertMessage(IChatRoomMessage msg) {
IMessage message = null;
String body = msg.getMessage();
if (body != null) {
message = new CollaborationMessage(null, msg.getMessage());
message.setFrom(IDConverter.convertFrom(msg.getFromID()));
}
return message;
}
@Override
public void sendPresence(IPresence presence) throws CollaborationException {
try {
CollaborationConnection.getConnection().getRosterManager()
.getPresenceSender()
.sendPresenceUpdate(venueInfo.getRoomID(), presence);
} catch (ECFException e) {
throw new CollaborationException(e);
}
}
}

View file

@ -0,0 +1,585 @@
/**
* 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 java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.JAXB;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.presence.IPresence;
import org.eclipse.ecf.presence.IPresence.Type;
import org.eclipse.ecf.presence.Presence;
import org.eclipse.ecf.presence.roster.IRoster;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.IRosterGroup;
import org.eclipse.ecf.presence.roster.IRosterItem;
import org.eclipse.ecf.presence.roster.IRosterListener;
import org.eclipse.ecf.presence.search.ICriteria;
import org.eclipse.ecf.presence.search.ICriterion;
import org.eclipse.ecf.presence.search.IResult;
import org.eclipse.ecf.presence.search.ISearch;
import org.eclipse.ecf.presence.search.IUserSearchManager;
import org.eclipse.ecf.presence.search.UserSearchException;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserNicknameChangedEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.LocalGroups.LocalGroup;
/**
*
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 29, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class ContactsManager {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ContactsManager.class);
private final Job storeLocalGroupsJob = new Job("Storing Local Groups") {
@Override
protected IStatus run(IProgressMonitor monitor) {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile file = PathManagerFactory.getPathManager()
.getLocalizationFile(
context,
"collaboration" + File.separator
+ "localGroups.xml");
LocalGroups obj;
synchronized (localGroups) {
obj = new LocalGroups(localGroups);
}
JAXB.marshal(obj, file.getFile());
try {
file.save();
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
return org.eclipse.core.runtime.Status.OK_STATUS;
}
};
private final CollaborationConnection connection;
private List<LocalGroup> localGroups;
private Map<String, String> localAliases;
private Set<LocalGroupListener> groupListeners = new HashSet<LocalGroupListener>();
public ContactsManager(CollaborationConnection connection) {
this.connection = connection;
localAliases = UserIdWrapper.readAliasMap();
applyLocalAliases(getRoster());
initLocalGroups();
connection.getRosterManager().addRosterListener(new IRosterListener() {
@Override
public void handleRosterUpdate(IRoster roster,
IRosterItem changedValue) {
}
@Override
public void handleRosterEntryRemove(IRosterEntry entry) {
}
@Override
public void handleRosterEntryAdd(IRosterEntry entry) {
applyLocalAliases(entry);
}
});
}
private void applyLocalAliases(IRosterItem item) {
if (item instanceof IRosterEntry) {
IRosterEntry entry = (IRosterEntry) item;
IUser user = entry.getUser();
String alias = localAliases.get(getUserId(user));
if (alias != null && user instanceof User) {
((User) user).setNickname(alias);
}
} else if (item instanceof IRosterGroup) {
Collection<?> entries = ((IRosterGroup) item).getEntries();
synchronized (entries) {
entries = new ArrayList<Object>(entries);
}
for (Object o : entries) {
applyLocalAliases((IRosterItem) o);
}
} else if (item instanceof IRoster) {
Collection<?> entries = ((IRoster) item).getItems();
synchronized (entries) {
entries = new ArrayList<Object>(entries);
}
for (Object o : entries) {
applyLocalAliases((IRosterItem) o);
}
}
}
private void initLocalGroups() {
storeLocalGroupsJob.setSystem(true);
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile file = PathManagerFactory.getPathManager()
.getLocalizationFile(context,
"collaboration" + File.separator + "localGroups.xml");
if (file.exists()) {
this.localGroups = JAXB
.unmarshal(file.getFile(), LocalGroups.class).getGroups();
}
if (this.localGroups == null) {
this.localGroups = new ArrayList<LocalGroup>();
}
for (LocalGroup group : localGroups) {
group.setManager(this);
}
}
public List<LocalGroup> getLocalGroups() {
synchronized (this.localGroups) {
return new ArrayList<LocalGroup>(this.localGroups);
}
}
public void addToLocalGroup(String groupName, IUser user) {
synchronized (this.localGroups) {
LocalGroup group = createLocalGroup(groupName);
String userId = getUserId(user);
List<String> userNames = group.getUserNames();
if (!userNames.contains(userId)) {
List<IUser> users = group.getUsers();
group.getUserNames().add(userId);
users.add(user);
}
IRosterEntry entry = getRosterEntry(user);
if (entry == null || entry.getGroups().isEmpty()) {
// In order to get presence for a user they must be in the
// roster, we can add them to the roster by either subscribing
// to them using presence or adding them to the roster,
// subscribing to the presence will not set the name coreectly
// so we use the roster add method.
try {
// IPresence presence = new Presence(Type.SUBSCRIBE);
// connection.getRosterManager().getPresenceSender()
// .sendPresenceUpdate(user.getID(), presence);
connection.getRosterManager().getRosterSubscriptionSender()
.sendRosterAdd(userId, user.getName(), null);
} catch (ECFException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.userAdded(group, user);
}
}
storeLocalGroupsJob.schedule();
}
public void deleteFromLocalGroup(String groupName, IUser user) {
synchronized (localGroups) {
Iterator<LocalGroup> it = localGroups.iterator();
while (it.hasNext()) {
LocalGroup group = it.next();
if (group.getName().equals(groupName)) {
group.getUsers().remove(user);
group.getUserNames().remove(getUserId(user));
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.userDeleted(group, user);
}
break;
}
}
if (getLocalGroups(user).isEmpty()) {
// if the user is in no local groups and no roster groups remove
// them from our roster.
IRosterEntry entry = getRosterEntry(user);
if (entry != null && entry.getGroups().isEmpty()) {
IPresence presence = new Presence(Type.UNSUBSCRIBE);
try {
connection.getRosterManager().getPresenceSender()
.sendPresenceUpdate(user.getID(), presence);
} catch (ECFException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
storeLocalGroupsJob.schedule();
}
}
public LocalGroup createLocalGroup(String groupName) {
synchronized (localGroups) {
for (LocalGroup group : this.localGroups) {
if (groupName.equals(group.getName())) {
return group;
}
}
LocalGroup group = new LocalGroup(groupName);
group.setManager(this);
localGroups.add(group);
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.groupCreated(group);
}
storeLocalGroupsJob.schedule();
return group;
}
}
public void deleteLocalGroup(String groupName) {
synchronized (localGroups) {
Iterator<LocalGroup> it = this.localGroups.iterator();
while (it.hasNext()) {
LocalGroup group = it.next();
if (groupName.equals(group.getName())) {
ArrayList<IUser> users = new ArrayList<IUser>(
group.getUsers());
for (IUser user : users) {
deleteFromLocalGroup(groupName, user);
}
it.remove();
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.groupDeleted(group);
}
}
}
}
storeLocalGroupsJob.schedule();
}
public void renameLocalGroup(String oldName, String newName) {
synchronized (localGroups) {
for (LocalGroup group : localGroups) {
if (oldName.equals(group.getName())) {
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.groupDeleted(group);
}
group.setName(newName);
for (LocalGroupListener listener : getSafeGroupListeners()) {
listener.groupCreated(group);
}
}
}
}
storeLocalGroupsJob.schedule();
}
public List<LocalGroup> getLocalGroups(IUser user) {
List<LocalGroup> results = new ArrayList<LocalGroup>();
synchronized (localGroups) {
for (LocalGroup group : localGroups) {
for (String userName : group.getUserNames()) {
if (getUserId(user).equals(userName)) {
results.add(group);
break;
}
}
}
}
return results;
}
public void setNickname(IUser user, String nickname) {
synchronized (localAliases) {
localAliases.put(getUserId(user), nickname);
try {
UserIdWrapper.saveAliasMap(localAliases);
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
applyLocalAliases(getRoster());
connection.postEvent(new UserNicknameChangedEvent(user, nickname));
}
}
/**
* Attempt to find a good displayable name for a user, first it looks in the
* local alias file, then it searches the roster to see if the server has
* provided a name, finally if no name is found it will attempt to use the
* username.
*
* @param user
* @return
*/
public String getDisplayName(IUser user) {
String alias = localAliases.get(getUserId(user));
if (alias == null) {
// at this point try to get the user from roster;
IUser rosterUser = null;
if (user.getID() != null) {
rosterUser = getUser(user.getID());
}
if (rosterUser != null) {
user = rosterUser;
}
alias = user.getNickname();
if (alias == null) {
alias = user.getName();
if (alias == null) {
alias = user.getID().getName();
}
}
if (alias.contains("@")) {
alias = Tools.parseName(alias);
}
}
return alias;
}
public IUser getUser(ID id) {
return getUser(getUserId(id));
}
public IUser getUser(String userId) {
userId = normalizeId(userId);
IRosterEntry entry = searchRoster(getRoster(), userId);
if (entry == null) {
return null;
}
return entry.getUser();
}
public IRosterEntry getRosterEntry(IUser user) {
return searchRoster(user);
}
public IPresence getPresence(IUser user) {
IRosterEntry entry = searchRoster(user);
if (entry == null) {
return new Presence(Type.UNKNOWN);
}
return entry.getPresence();
}
/**
* Used by local groups to make sure all local group items are in the
* roster.
*
* @param name
* @return
*/
protected IUser findAndAddUser(String name) {
name = normalizeId(name);
IUser user = null;
IRosterEntry entry = searchRoster(getRoster(), name);
if (entry != null) {
user = entry.getUser();
}
if (user == null) {
user = findUser(name);
if (user != null) {
try {
connection
.getRosterManager()
.getRosterSubscriptionSender()
.sendRosterAdd(getUserId(user), user.getName(),
null);
} catch (ECFException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
return user;
}
private IUser findUser(String name) {
IUserSearchManager searchManager = connection
.getPresenceContainerAdapter().getUserSearchManager();
ICriterion criterion = searchManager.createRestriction().eq("Username",
Tools.parseName(name));
ICriteria criteria = searchManager.createCriteria();
criteria.add(criterion);
try {
ISearch search = searchManager.search(criteria);
for (Object result : search.getResultList().getResults()) {
if (result instanceof IResult) {
IUser user = ((IResult) result).getUser();
String alias = localAliases.get(getUserId(user));
if (alias != null && user instanceof User) {
((User) user).setNickname(alias);
}
return user;
}
}
} catch (UserSearchException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return null;
}
private IRoster getRoster() {
return connection.getRosterManager().getRoster();
}
/**
* given a user return username@host.
*
* @param user
* @return
*/
private String getUserId(IUser user) {
if (user.getID() == null) {
return normalizeId(user.toString());
}
return getUserId(user.getID());
}
/**
* given a user ID return username@host.
*
* @param id
* @return
*/
private String getUserId(ID id) {
return normalizeId(id.getName());
}
private String normalizeId(String userId) {
String name = Tools.parseName(userId);
String hostname = Tools.parseHost(userId);
hostname = IDConverter.normalizeHostname(hostname);
return name + "@" + hostname;
}
private IRosterEntry searchRoster(IUser user) {
String userId = getUserId(user);
return searchRoster(getRoster(), userId);
}
private IRosterEntry searchRoster(IRosterItem item, String userName) {
if (item instanceof IRosterEntry) {
IRosterEntry entry = (IRosterEntry) item;
if (userName.equals(getUserId(entry.getUser()))) {
return entry;
}
} else if (item instanceof IRosterGroup) {
Collection<?> entries = ((IRosterGroup) item).getEntries();
synchronized (entries) {
entries = new ArrayList<Object>(entries);
}
for (Object o : entries) {
IRosterEntry entry = searchRoster((IRosterItem) o, userName);
if (entry != null) {
return entry;
}
}
} else if (item instanceof IRoster) {
Collection<?> entries = ((IRoster) item).getItems();
synchronized (entries) {
entries = new ArrayList<Object>(entries);
}
for (Object o : entries) {
IRosterEntry entry = searchRoster((IRosterItem) o, userName);
if (entry != null) {
return entry;
}
}
} else {
throw new IllegalStateException("Unexpected Roster entry: "
+ item.getClass().getSimpleName());
}
return null;
}
public void addLocalGroupListener(LocalGroupListener listener) {
synchronized (groupListeners) {
groupListeners.add(listener);
}
}
public void removeLocalGroupListener(LocalGroupListener listener) {
synchronized (groupListeners) {
groupListeners.remove(listener);
}
}
protected Set<LocalGroupListener> getSafeGroupListeners() {
Set<LocalGroupListener> safeSet = new HashSet<LocalGroupListener>();
synchronized (groupListeners) {
safeSet.addAll(groupListeners);
}
return safeSet;
}
public static interface LocalGroupListener {
public void groupCreated(LocalGroup group);
public void groupDeleted(LocalGroup group);
public void userAdded(LocalGroup group, IUser user);
public void userDeleted(LocalGroup group, IUser user);
}
}

View file

@ -0,0 +1,90 @@
/**
* 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.provider.Tools;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 28, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class IDConverter {
private static final String CONF_ID = "conference.";
/**
*
* @param user
* @return
*/
public static UserId 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());
UserId uid = new UserId(name, host, rsc);
uid.setId(id);
return uid;
}
/**
*
* @param user
* @return
*/
public static UserId convertFrom(org.eclipse.ecf.core.user.IUser user) {
UserId retVal = null;
if (user instanceof UserId) {
retVal = (UserId) user;
} else {
String name = Tools.parseName(user.getID().getName());
String host = Tools.parseHost(user.getID().getName());
retVal = new UserId(name, host);
retVal.setId(user.getID());
if (user.getNickname() != null) {
retVal.setAlias(user.getNickname());
} else {
retVal.setAlias(user.getName());
}
}
return retVal;
}
public static String normalizeHostname(String hostname) {
if (hostname.startsWith(CONF_ID)) {
return hostname.substring(CONF_ID.length());
}
return hostname;
}
}

View file

@ -0,0 +1,133 @@
/**
* 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 java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.ecf.core.user.IUser;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 2, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "LocalGroups")
public class LocalGroups {
@XmlElement(name = "group")
private List<LocalGroup> groups;
public LocalGroups() {
}
public LocalGroups(List<LocalGroup> groups) {
this.groups = new ArrayList<LocalGroup>(groups);
}
public List<LocalGroup> getGroups() {
return groups;
}
public void setGroups(List<LocalGroup> groups) {
this.groups = groups;
}
@XmlAccessorType(XmlAccessType.NONE)
public static class LocalGroup {
@XmlAttribute
private String name;
@XmlElement(name = "user")
private List<String> userNames;
@XmlTransient
private ContactsManager manager;
@XmlTransient
private List<IUser> users;
public LocalGroup() {
}
public LocalGroup(String name) {
this.name = name;
this.userNames = new ArrayList<String>();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getUserNames() {
if (userNames == null) {
userNames = new ArrayList<String>();
}
return userNames;
}
public void setUserNames(List<String> userNames) {
this.userNames = userNames;
}
public synchronized List<IUser> getUsers() {
if (users == null) {
users = new ArrayList<IUser>();
for (String userName : userNames) {
IUser user = manager.findAndAddUser(userName);
if (user != null) {
users.add(user);
}
}
}
return users;
}
public void setManager(ContactsManager manager) {
this.manager = manager;
}
}
}

View file

@ -0,0 +1,279 @@
/**
* 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 java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.user.IUser;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Apr 18, 2012 njensen Major refactor
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
@DynamicSerialize
@XmlRootElement(name = "userId")
public class UserId implements IQualifiedID, IUser {
@DynamicSerializeElement
protected String name;
@DynamicSerializeElement
protected String host;
@DynamicSerializeElement
protected String resource;
@DynamicSerializeElement
protected String alias;
private ID id;
public UserId() {
}
/**
*
* @param userName
* @param hostName
*/
public UserId(String userName, String hostName) {
this(userName, hostName, null);
}
/**
*
* @param userName
* @param hostName
* @param resourceName
*/
public UserId(String userName, String hostName, String resource) {
this(userName, hostName, resource, null);
}
public UserId(String userName, String hostName, String resource,
String alias) {
this.name = userName;
setHost(hostName);
this.resource = resource;
this.alias = alias;
}
/**
* @param userName
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setUserName(java.lang.String)
*/
@Override
public void setName(String userName) {
name = userName;
}
/**
* @return The user name associated with this id.
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getUserName()
*/
@Override
public String getName() {
return name;
}
/**
*
* @param hostName
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setHostName(java.lang.String)
*/
@Override
public void setHost(String hostname) {
host = IDConverter.normalizeHostname(hostname);
}
/**
*
* @return The host name associated with this id.
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getHostName()
*/
@Override
public String getHost() {
return host;
}
/**
*
* @param resourceName
* The resource associated with this id.
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setResourceName(java.lang.String)
*/
@Override
public void setResource(String resourceName) {
resource = resourceName;
}
/**
*
* @return The resource associated with this id.
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getResource()
*/
@Override
public String getResource() {
return resource;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getFQName()
*/
@Override
public String getFQName() {
StringBuilder sb = new StringBuilder(name);
sb.append("@");
sb.append(host);
sb.append("/");
if (resource != null) {
sb.append(resource);
} else {
// TODO need a better way around this ECF/XMPP flaw that is
// requiring a resource for peerToPeer to go through
sb.append("resource");
}
return sb.toString();
}
public String getAlias() {
if (alias == null || alias.isEmpty()) {
return name;
}
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
@Override
public String toString() {
return this.getFQName();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((host == null) ? 0 : host.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result
+ ((resource == null) ? 0 : resource.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof UserId))
return false;
UserId other = (UserId) obj;
if (host == null) {
if (other.host != null)
return false;
} else if (!host.equals(other.host))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (resource == null) {
if (other.resource != null)
return false;
} else if (!resource.equals(other.resource))
return false;
return true;
}
@Override
public Object getAdapter(Class adapter) {
return null;
}
@Override
public String getNickname() {
return alias;
}
@Override
public Map getProperties() {
return null;
}
@Override
public ID getID() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(ID id) {
this.id = id;
}
/**
* Checks if it is the same user. Does not check the resource.
*
* @param id
* the string id to compare against
* @return if it is the same user
*/
public boolean isSameUser(String id) {
boolean result = false;
String name = Tools.parseName(id);
String host = Tools.parseHost(id);
if (name != null && host != null) {
if (this.name.equals(name) && this.host.equals(host)) {
result = true;
}
}
return result;
}
}

View file

@ -0,0 +1,119 @@
/**
* 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 java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.xml.bind.JAXB;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 30, 2012 mnash Initial creation
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@DynamicSerialize
public class UserIdWrapper {
@DynamicSerializeElement
private UserId[] userIds;
/**
* @param userIds
* the userIds to set
*/
public void setUserIds(UserId[] userIds) {
this.userIds = userIds;
}
/**
* @return the userIds
*/
public UserId[] getUserIds() {
return userIds;
}
public static Map<String, String> readAliasMap() {
Map<String, String> result = new HashMap<String, String>();
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile file = PathManagerFactory.getPathManager()
.getLocalizationFile(
context,
"collaboration" + File.separator
+ "collaborationAliases.xml");
if (file.exists()) {
UserIdWrapper ids = (UserIdWrapper) JAXB.unmarshal(file.getFile(),
UserIdWrapper.class);
if (ids.getUserIds() != null) {
for (UserId id : ids.getUserIds()) {
result.put(id.getName() + "@" + id.getHost(), id.getAlias());
}
}
}
return result;
}
public static void saveAliasMap(Map<String, String> localAliases)
throws LocalizationOpFailedException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile file = pm.getLocalizationFile(context, "collaboration"
+ File.separator + "collaborationAliases.xml");
Set<UserId> ids = new HashSet<UserId>();
for (Entry<String, String> entry : localAliases.entrySet()) {
ids.add(new UserId(Tools.parseName(entry.getKey()), Tools
.parseHost(entry.getKey()), null, entry.getValue()));
}
UserIdWrapper wrapper = new UserIdWrapper();
wrapper.setUserIds(ids.toArray(new UserId[0]));
JAXB.marshal(wrapper, file.getFile());
file.save();
}
}

View file

@ -0,0 +1,116 @@
/**
* 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.IVenueId;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class VenueId implements IVenueId {
private String host;
private String resource;
private String venueName;
private String name;
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setHost(java.lang.String)
*/
@Override
public void setHost(String hostName) {
host = hostName;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getHost()
*/
@Override
public String getHost() {
return host;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setResource(java.lang.String)
*/
@Override
public void setResource(String resource) {
this.resource = resource;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getResource()
*/
@Override
public String getResource() {
return resource;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.ID#setName(java.lang.String)
*/
@Override
public void setName(String userName) {
name = userName;
venueName = name;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.ID#getName()
*/
@Override
public String getName() {
return name;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.ID#getFQName()
*/
@Override
public String getFQName() {
return null;
}
/**
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueId#getVenueName()
*/
@Override
public String getVenueName() {
return venueName;
}
}

View file

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

View file

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

View file

@ -0,0 +1,8 @@
#Tue Jun 26 11:21:58 CDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Collaboration Core UI
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.core.ui
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.core.ui.Activator
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.uf.viz.collaboration.comm;bundle-version="1.0.0",
org.eclipse.ecf.presence;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.collaboration.core.ui

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
icons/

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

View file

@ -0,0 +1,50 @@
package com.raytheon.uf.viz.collaboration.core.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.raytheon.uf.viz.collaboration.core.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,295 @@
/**
* 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.core.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.tree.TreePath;
import org.eclipse.ecf.presence.roster.IRoster;
import org.eclipse.ecf.presence.roster.IRosterEntry;
import org.eclipse.ecf.presence.roster.IRosterGroup;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.core.ui.data.ActiveSessionsTreeData;
import com.raytheon.uf.viz.collaboration.core.ui.data.MyUserTreeData;
import com.raytheon.uf.viz.collaboration.core.ui.data.UserGroupTreeData;
import com.raytheon.uf.viz.collaboration.core.ui.tree.UsersTreeContentProvider;
import com.raytheon.uf.viz.collaboration.core.ui.tree.UsersTreeLabelProvider;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 26, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class CollaborationGroupControl {
private Text filterText;
private TreeViewer usersTreeViewer;
private IMenuManager mainMenu;
private ICollaborationUIManager manager;
private ActiveSessionsTreeData activeSessions;
private MyUserTreeData myUserData;
private List<UserGroupTreeData> groups = new ArrayList<UserGroupTreeData>();
public CollaborationGroupControl(Composite compsite,
ICollaborationUIManager manager) {
this.manager = manager;
initializeGroupControl(compsite);
manager.getConnection().registerEventHandler(this);
}
/**
* @param parent
*/
private void initializeGroupControl(Composite parent) {
parent.setLayout(new GridLayout());
createFilterText(parent);
createUserTree(parent);
createMainMenu();
}
/**
* @param parent
*/
private void createUserTree(Composite parent) {
Composite treeComp = new Composite(parent, SWT.NONE);
treeComp.setLayout(new GridLayout(1, false));
treeComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Tree tree = new Tree(treeComp, SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL | SWT.BORDER);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// any width would work
new TreeColumn(tree, SWT.NONE).setWidth(200);
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
fillContextMenu(mgr);
}
});
Menu menu = menuMgr.createContextMenu(tree);
tree.setMenu(menu);
usersTreeViewer = new TreeViewer(tree);
usersTreeViewer.setContentProvider(new UsersTreeContentProvider());
usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider());
populateTree();
}
private void populateTree() {
if (myUserData == null) {
myUserData = new MyUserTreeData(CollaborationConnection
.getConnection().getUser());
activeSessions = new ActiveSessionsTreeData();
usersTreeViewer.add(new TreePath(new Object[0]), new Object[] {
myUserData, activeSessions });
}
usersTreeViewer.remove(groups.toArray(new Object[groups.size()]));
groups.clear();
populateGroups();
}
/**
*
*/
private void populateGroups() {
Map<String, UserGroupTreeData> dataMap = new HashMap<String, UserGroupTreeData>();
IRoster roster = CollaborationConnection.getConnection()
.getRosterManager().getRoster();
for (Object item : roster.getItems()) {
if (item instanceof IRosterGroup) {
IRosterGroup group = (IRosterGroup) item;
} else if (item instanceof IRosterEntry) {
IRosterEntry entry = (IRosterEntry) item;
}
}
}
private void fillContextMenu(IMenuManager mgr) {
// TODO: Fill context menu based on selected tree items
}
/**
*
*/
private void createFilterText(Composite parent) {
Composite comp = new Composite(parent, SWT.BORDER);
comp.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_BACKGROUND));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
comp.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
comp.setLayoutData(gd);
filterText = new Text(comp, SWT.SINGLE | SWT.NONE);
GridData data = new GridData(SWT.FILL, SWT.NONE, true, false);
filterText.setLayoutData(data);
filterText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
filter();
}
});
// Load icons to be used for label button
final Image inactiveImage = AbstractUIPlugin.imageDescriptorFromPlugin(
PlatformUI.PLUGIN_ID, "$nl$/icons/full/dtool16/clear_co.gif")
.createImage();
final Image activeImage = AbstractUIPlugin.imageDescriptorFromPlugin(
PlatformUI.PLUGIN_ID, "$nl$/icons/full/etool16/clear_co.gif")
.createImage();
final Label clearButton = new Label(comp, SWT.NONE);
clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER,
false, false));
clearButton.setImage(inactiveImage);
clearButton.setBackground(parent.getDisplay().getSystemColor(
SWT.COLOR_LIST_BACKGROUND));
clearButton.setToolTipText("Clear text");
// Add listener for enter/exit changing icon
clearButton.addMouseTrackListener(new MouseTrackAdapter() {
public void mouseEnter(MouseEvent e) {
clearButton.setImage(activeImage);
}
public void mouseExit(MouseEvent e) {
clearButton.setImage(inactiveImage);
}
});
// Add mouse listener for clear pressed
clearButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
filterText.setText("");
filter();
}
});
// Add dispose listener
clearButton.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
inactiveImage.dispose();
activeImage.dispose();
}
});
}
private void createMainMenu() {
// TODO: Populate the main menu
}
/**
* Get the {@link Tree} object that contains user information for the
* control
*
* @return
*/
public Tree getUserTree() {
return usersTreeViewer.getTree();
}
/**
* Gets the contribution items for the group main menu
*
* @return
*/
public IContributionItem[] getMainMenuItems() {
return mainMenu.getItems();
}
/**
* Filters the group view based on the text
*
* @param text
*/
private void filter() {
String currText = filterText.getText();
// TODO: Filter the visible tree objects
}
@Subscribe
public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) {
// TODO: Handle roster events
switch (rosterChangeEvent.getType()) {
case ADD:
break;
case MODIFY:
break;
case DELETE:
break;
case PRESENCE:
break;
}
}
}

Some files were not shown because too many files have changed in this diff Show more