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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,57 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.provider;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 8, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class Errors {
public static final int NO_ERROR = 0;
public static final int CANNOT_CONNECT = -50;
public static final int ALREADY_CONNECTED = -51;
public static final int BAD_NAME = -52;
// Error - An attempt to use a Venue that has been disposed.
public static final int VENUE_DISPOSED = -100;
// Error - Venue exists when attempting to create a new venue.
public static final int VENUE_EXISTS = -101;
// Error - Venue not found when attempting to join an existing venue.
public static final int VENUE_NOT_FOUND = -102;
}

View file

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

View file

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

View file

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

View file

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

View file

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

Binary file not shown.