Issue #232 - Modified invitation methods

Former-commit-id: 1c9381e1ba1a8b01084717db7ff3e94b26eb0b89
This commit is contained in:
James Korman 2012-03-30 11:27:09 -05:00
parent 108ac66214
commit 0b6a076129
4 changed files with 118 additions and 187 deletions

View file

@ -257,8 +257,7 @@ public class CollaborationGroupView extends ViewPart {
System.out.println("room: " + info.getVenueName());
System.out.println("subject: "
+ session.getVenue().getInfo().getVenueSubject());
session.sendInvitation(info.getVenueName(), ids, session
.getVenue().getInfo().getVenueSubject(), "body");
session.sendInvitation(ids, "body");
};
};
inviteAction.setImageDescriptor(IconUtil.getImageDescriptor(bundle,

View file

@ -31,30 +31,34 @@ import com.raytheon.uf.viz.collaboration.comm.identity.listener.IVenueParticipan
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
/**
*
*
*
* <ul>
* <li>EventBus subscription events. Implementors are required to post the following events.</li>
* <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>
* <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
* @version 1.0
*/
public interface IVenueSession extends ISession, IEventPublisher {
@ -62,16 +66,18 @@ public interface IVenueSession extends ISession, IEventPublisher {
/**
* Return this session as an ISharedDisplaySession if it is supported. If
* the interface is not supported the method must return a null reference.
* @return
*
* @return
*/
ISharedDisplaySession spawnSharedDisplaySession();
/**
* Returns information about a venue.
* Returns information about a venue.
*
* @return Information about a venue
*/
IVenue getVenue();
/**
*
* @param role
@ -79,37 +85,49 @@ public interface IVenueSession extends ISession, IEventPublisher {
*/
boolean hasRole(ParticipantRole role);
/**
* Set the subject of this collaboration venue conversation.
*
* @param subject
* The subject.
*/
void setSubject(String subject);
/**
* Get the subject of this collaboration venue conversation.
*
* @return The subject.
*/
String getSubject();
/**
* Send a Collaboration message.
* @param message The message to send.
*
* @param message
* The message to send.
*/
void sendTextMessage(String message) throws CollaborationException;
/**
* Send an invitation from this venue to another user.
* @param invitation An invitation
*
* @param id
* The target user for this invitation.
* @param subject
* The intended subject of the venue conversation.
* @return
*/
int sendInvitation(IInvitation invitation);
int sendInvitation(String id, String body);
/**
* 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.
* Send an invitation from this venue to one or more users.
*
* @param ids
* A list of target users for this invitation.
* @param body
* Any text that the user may wish to include.
* @return
*/
int sendInvitation(String room, String id, String subject, String body);
/**
* Send an invitation from this venue to another user.
* @param room The target venue for this invitation.
* @param ids A list of target users for this invitation.
* @param subject The intended subject of the venue conversation.
* @param body Any text that the user may wish to include.
* @return
*/
int sendInvitation(String room, List<String> ids, String subject, String body);
int sendInvitation(List<String> ids, String body);
}

View file

@ -60,6 +60,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEven
import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter;
import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
@ -68,9 +69,12 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
* <ul>
* <li>EventBus subscription events.</li>
* <ul>
* <li><strong>IVenueInvitationEvent</strong> : This event is posted when a
* venue participant enters, leaves a venue, or updates their status in the
* venue.</li>
* <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>---------------</strong> : ---------------.</li>
* </ul>
* </ul>
@ -341,11 +345,23 @@ public class SessionManager implements IEventPublisher {
if (session != null) {
session.createVenue(venueName, subject);
IChatID me = new VenueUserId("jkorman",
"awipscm.omaha.us.ray.com");
session.setSessionLeader(me);
session.setSessionDataProvider(me);
IPresence presence = new Presence();
presence.setMode(IPresence.Mode.AVAILABLE);
presence.setType(IPresence.Type.AVAILABLE);
presence.setProperty("DATA_PROVIDER", "");
presence.setProperty("SESSION_LEADER", "");
presence.setProperty("DATA_PROVIDER", me.getFQName());
presence.setProperty("SESSION_LEADER", me.getFQName());
presenceAdapter
.getRosterManager()
.getPresenceSender()
.sendPresenceUpdate(null,
Presence.convertPresence(presence));
sessions.put(session.getSessionId(), session);
}
@ -441,6 +457,9 @@ public class SessionManager implements IEventPublisher {
// Connection listener
// ***************************
/**
*
*/
private void setupInternalConnectionListeners() {
if (container != null) {
@ -491,13 +510,13 @@ public class SessionManager implements IEventPublisher {
String subject, String body) {
IQualifiedID venueId = null;
if(roomID instanceof XMPPRoomID) {
if (roomID instanceof XMPPRoomID) {
XMPPRoomID room = (XMPPRoomID) roomID;
venueId = new VenueId();
venueId.setName(room.getLongName());
}
if(venueId != null) {
if (venueId != null) {
IQualifiedID id = IDConverter.convertFrom(from);
IChatID invitor = new VenueUserId(id.getName(),
@ -505,8 +524,6 @@ public class SessionManager implements IEventPublisher {
IVenueInvitationEvent invite = new VenueInvitationEvent(
venueId, invitor, subject, body);
System.out.println("Posting invitation using eventBus:"
+ eventBus.hashCode());
eventBus.post(invite);
}
}

View file

@ -42,7 +42,6 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import com.google.common.eventbus.EventBus;
// import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
@ -54,7 +53,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IRenderable;
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.identity.info.IVenue;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IInvitation;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
@ -130,6 +128,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
private Map<Object, Object> initSubscribers = new HashMap<Object, Object>();
private String subject;
/**
*
* @param container
@ -149,75 +149,8 @@ public class VenueSession extends BaseSession implements IVenueSession,
SessionManager manager) throws CollaborationException {
super(container, externalBus, manager);
Runnable r = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(30000);
// TestJAXBObject j = new TestJAXBObject();
// j.setItem_1("This is an object");
// j.setValue(5);
// sendRenderableObject(j);
//
// VenueParticipant id = new VenueParticipant("jkorman",
// "paul", "awipscm.omaha.us.ray.com");
// id.setResource("cave");
// IInitData d = new InitData();
// ((InitData) d).setName("This is a test init data object");
//
// IDisplayEvent e = new DisplayEvent();
// ((DisplayEvent) e).setName("This is a test display event");
//
// sendInitData(id, d);
// sendEvent(id, e);
//
// Thread.sleep(10000);
System.out.println("Sending invitation");
sendInvitation(
"tester5@conference.awipscm.omaha.us.ray.com",
"jkorman", "Test Room", "Join the test");
} catch (Exception e) {
System.out.println("Error sending RenderableObject");
}
}
};
Thread t = new Thread(r);
t.start();
registerEventHandler(this);
try {
DataHandler h = new DataHandler();
subscribeToPeerToPeerData(h);
} catch (CollaborationException ce) {
ce.printStackTrace();
}
}
// @Subscribe
// public void handle(IRenderable renderable) {
// System.out.println("Renderable found");
// if (renderable instanceof TestJAXBObject) {
// TestJAXBObject j = (TestJAXBObject) renderable;
// if (j.getValue() < 100) {
// System.out.println(String.format("%s %d Renderable",
// j.getItem_1(), j.getValue()));
// j.setValue(j.getValue() + 200);
// j.setItem_1("Now for the return trip");
// try {
// sendRenderableObject(j);
// } catch (CollaborationException ce) {
// System.out.println("Error sending RenderableObject");
// }
// } else {
// System.out.println(String.format("%s %d Renderable",
// j.getItem_1(), j.getValue()));
// }
// }
// }
/**
* Get the identification of the owner of this session.
*
@ -295,40 +228,19 @@ public class VenueSession extends BaseSession implements IVenueSession,
}
return venue;
}
/**
* @return the subject
*/
public String getSubject() {
return subject;
}
/**
* Send an invitation from this venue to another user.
*
* @param invitation
* An invitation
* @return
* @param subject the subject to set
*/
@Override
public int sendInvitation(IInvitation invitation) {
int status = Errors.NO_ERROR;
IChatRoomInvitationSender sender = getConnectionPresenceAdapter()
.getChatRoomManager().getInvitationSender();
if (sender != null) {
ID roomId = getConnectionPresenceAdapter().getChatRoomManager()
.getChatRoomInfo(invitation.getRoomId()).getConnectedID();
// *******************
// ** TODO : The host part of this need to defined
ID userId = IDFactory.getDefault().createID(
getConnectionNamespace(),
invitation.getFrom() + "@awipscm.omaha.us.ray.com");
// *******************
try {
String body = insertSessionId(invitation.getBody());
sender.sendInvitation(roomId, userId, invitation.getSubject(),
body);
} catch (ECFException e) {
e.printStackTrace();
}
}
return status;
public void setSubject(String subject) {
this.subject = subject;
}
/**
@ -347,8 +259,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public int sendInvitation(String room, String id, String subject,
String body) {
public int sendInvitation(String id, String body) {
// Assume success
int status = Errors.NO_ERROR;
IChatRoomInvitationSender sender = getConnectionPresenceAdapter()
@ -356,11 +267,11 @@ public class VenueSession extends BaseSession implements IVenueSession,
if (sender != null) {
body = insertSessionId(body);
ID roomId = getConnectionPresenceAdapter().getChatRoomManager()
.getChatRoomInfo(room).getConnectedID();
ID userId = IDFactory.getDefault().createID(
getConnectionNamespace(), id + "@awipscm.omaha.us.ray.com");
ID roomId = venueInfo.getConnectedID();
ID userId = IDFactory.getDefault().createID(
getConnectionNamespace(), id);
try {
sender.sendInvitation(roomId, userId, subject, body);
} catch (ECFException e) {
@ -386,20 +297,19 @@ public class VenueSession extends BaseSession implements IVenueSession,
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public int sendInvitation(String room, List<String> ids, String subject,
String body) {
public int sendInvitation(List<String> ids, String body) {
// Assume success
int status = Errors.NO_ERROR;
if (ids != null) {
for (String id : ids) {
sendInvitation(room, id, subject, body);
sendInvitation(id, body);
}
} else {
status = -1;
}
return status;
}
/**
*
* @param body
@ -596,6 +506,20 @@ public class VenueSession extends BaseSession implements IVenueSession,
// Internal methods
// ***************************
/**
*
*/
void setSessionLeader(IChatID id) {
sessionLeader = id;
}
/**
*
*/
void setSessionDataProvider(IChatID id) {
sessionDataProvider = id;
}
/**
*
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#joinVenue(java.lang.String)
@ -607,13 +531,13 @@ public class VenueSession extends BaseSession implements IVenueSession,
venueManager = getConnectionPresenceAdapter().getChatRoomManager();
if (venueManager != null) {
venueInfo = venueManager.getChatRoomInfo(venueName);
subject = venueInfo.getSubject();
if (venueInfo != null) {
errorStatus = completeVenueConnection(venueInfo);
roles.add(ParticipantRole.PARTICIPANT);
} else {
// Could not join venue.
}
} else {
@ -635,6 +559,7 @@ public class VenueSession extends BaseSession implements IVenueSession,
int createVenue(String venueName, String subject) {
int errorStatus = -1;
try {
this.subject = subject;
// Create chat room container from manager
venueManager = getConnectionPresenceAdapter().getChatRoomManager();
if (venueManager != null) {
@ -677,42 +602,14 @@ public class VenueSession extends BaseSession implements IVenueSession,
IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() {
@Override
public void handleArrived(IUser participant) {
// IVenueParticipant p = new VenueParticipant(
// participant.getName(),
// participant.getNickname());
//
// System.out.println("Arrived");
// IVenueParticipantEvent event = new
// VenueParticipantEvent(
// p, ParticipantEventType.ARRIVED);
//
// getEventPublisher().post(event);
}
@Override
public void handleUpdated(IUser participant) {
// IVenueParticipant p = new VenueParticipant(
// participant.getName(),
// participant.getNickname());
//
// System.out.println("Updated");
// IVenueParticipantEvent event = new
// VenueParticipantEvent(
// p, ParticipantEventType.UPDATED);
// getEventPublisher().post(event);
}
@Override
public void handleDeparted(IUser participant) {
// IVenueParticipant p = new VenueParticipant(
// participant.getName(),
// participant.getNickname());
//
// System.out.println("Departed");
// IVenueParticipantEvent event = new
// VenueParticipantEvent(
// p, ParticipantEventType.DEPARTED);
// getEventPublisher().post(event);
}
@Override