Issue #2751 user identity refactor

VenueParticipant no longer a subtype of UserId
New interface for both
refactored base classes to be generic for user types


Former-commit-id: e91ae6eacf4af9e25afc213c3cd0c269c8d465f4
This commit is contained in:
Brian Clements 2014-02-13 13:27:54 -06:00
parent 6093312861
commit ef52908906
34 changed files with 455 additions and 343 deletions

View file

@ -19,7 +19,7 @@
**/
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.IUser;
/**
@ -32,6 +32,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement changed to/from objects to IUser
*
* </pre>
*
@ -50,24 +51,24 @@ public interface IMessage extends IPropertied {
/**
* @return the to
*/
public IQualifiedID getTo();
public IUser getTo();
/**
* @param to
* the to to set
*/
public void setTo(IQualifiedID to);
public void setTo(IUser to);
/**
* @return the from
*/
public IQualifiedID getFrom();
public IUser getFrom();
/**
* @param from
* the from to set
*/
public void setFrom(IQualifiedID from);
public void setFrom(IUser from);
/**
* Get the subject of this message.

View file

@ -20,7 +20,7 @@
package com.raytheon.uf.viz.collaboration.comm.identity;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* Peer to peer chat messaging interface
@ -32,6 +32,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement changed 'to' object to UserId
*
* </pre>
*
@ -57,7 +58,7 @@ public interface IPeerToPeer extends ISession, IEventPublisher {
* @param message
* The message to send.
*/
public void sendPeerToPeer(IQualifiedID to, String message)
public void sendPeerToPeer(UserId to, String message)
throws CollaborationException;
}

View file

@ -39,8 +39,8 @@
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.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* Base interface for sessions in which the client is interacting with others on
@ -58,6 +58,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement changed user object to IUser
*
* </pre>
*
@ -77,7 +78,7 @@ public interface ISession extends IEventPublisher {
*
* @return
*/
public UserId getUserID();
public IUser getUserID();
/**
* Gets the connection status of the session.

View file

@ -19,7 +19,6 @@
**/
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.VenueParticipant;
@ -54,6 +53,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* Feb 13, 2014 2751 bclement changed sendObjectToPeer id to VenueParticipant
*
* </pre>
*
@ -85,7 +85,7 @@ public interface ISharedDisplaySession extends IVenueSession {
* the serializable object to send
* @throws CollaborationException
*/
public void sendObjectToPeer(IQualifiedID id, Object obj)
public void sendObjectToPeer(VenueParticipant id, Object obj)
throws CollaborationException;
/**

View file

@ -20,7 +20,8 @@
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;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
/**
* Encapsulates a venue invitation to the user.
@ -33,6 +34,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* ------------ ---------- ----------- --------------------------
* Mar 21, 2012 jkorman Initial creation
* Dec 18, 2013 2562 bclement removed subject getter (subject in invite)
* Feb 13, 2014 2751 bclement better types for roomid and inviter
*
* </pre>
*
@ -47,13 +49,13 @@ public interface IVenueInvitationEvent {
*
* @return id in {room}@conference.{host} format
*/
public IQualifiedID getRoomId();
public VenueId getRoomId();
/**
*
* @return id of user that sent invitation
*/
public IQualifiedID getInviter();
public IUser getInviter();
/**
* Get detailed invitation which includes subject and message if provided

View file

@ -20,7 +20,8 @@
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
* Top level interface for objects that represent identified items on the server
* (users, rooms, etc)
*
* <pre>
*
@ -29,6 +30,7 @@ package com.raytheon.uf.viz.collaboration.comm.identity.user;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement refactor to remove ID interface
*
* </pre>
*
@ -36,30 +38,24 @@ package com.raytheon.uf.viz.collaboration.comm.identity.user;
* @version 1.0
*/
public interface IQualifiedID extends ID {
public interface IQualifiedID {
/**
*
* @param hostName
* @return server name for item
*/
void setHost(String hostName);
public String getHost();
/**
*
* @return
* @return name of item
*/
String getHost();
public String getName();
/**
*
* @param resource
* @return fully qualified string addressing item
*/
void setResource(String resource);
/**
*
* @return
*/
String getResource();
public String getFQName();
}

View file

@ -20,39 +20,29 @@
package com.raytheon.uf.viz.collaboration.comm.identity.user;
/**
* TODO Add Description
* Interface for users on server. Can represent user accounts or users in a
* chatroom.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 jkorman Initial creation
*
* Feb 13, 2014 2751 bclement Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*
* @author bclement
* @version 1.0
*/
public interface ID {
public interface IUser extends IQualifiedID {
/**
*
* @param userName
* @param other
* @return true if other user represents same person as this user
*/
void setName(String userName);
/**
*
*/
String getName();
/**
*
* @return
*/
String getFQName();
public boolean isSameUser(IUser other);
}

View file

@ -26,10 +26,10 @@ 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;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
/**
* TODO Add Description
* Base concrete implementation for chat message objects
*
* <pre>
*
@ -38,6 +38,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement changed IQualifiedID objects to IUser
*
* </pre>
*
@ -53,9 +54,9 @@ public abstract class BaseMessage implements Serializable, IMessage {
private String body;
private IQualifiedID to;
private IUser to;
private IQualifiedID from;
private IUser from;
private String subject;
@ -68,7 +69,7 @@ public abstract class BaseMessage implements Serializable, IMessage {
* @param to
* @param body
*/
protected BaseMessage(IQualifiedID to, String body) {
protected BaseMessage(IUser to, String body) {
this.body = body;
this.to = to;
initProperties();
@ -79,7 +80,7 @@ public abstract class BaseMessage implements Serializable, IMessage {
* @return the to
*/
@Override
public IQualifiedID getTo() {
public IUser getTo() {
return to;
}
@ -88,7 +89,7 @@ public abstract class BaseMessage implements Serializable, IMessage {
* the to to set
*/
@Override
public void setTo(IQualifiedID to) {
public void setTo(IUser to) {
this.to = to;
}
@ -96,7 +97,7 @@ public abstract class BaseMessage implements Serializable, IMessage {
* @return the from
*/
@Override
public IQualifiedID getFrom() {
public IUser getFrom() {
return from;
}
@ -105,7 +106,7 @@ public abstract class BaseMessage implements Serializable, IMessage {
* the from to set
*/
@Override
public void setFrom(IQualifiedID from) {
public void setFrom(IUser from) {
this.from = from;
}

View file

@ -1,71 +0,0 @@
/**
* 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

@ -19,10 +19,10 @@
**/
package com.raytheon.uf.viz.collaboration.comm.provider;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
/**
* TODO Add Description
* Chat message object
*
* <pre>
*
@ -31,6 +31,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 24, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement changed IQualifiedID objects to IUser
*
* </pre>
*
@ -47,7 +48,7 @@ public class TextMessage extends BaseMessage {
* @param to
* @param body
*/
public TextMessage(IQualifiedID to, String body) {
public TextMessage(IUser to, String body) {
super(to, body);
}

View file

@ -21,7 +21,8 @@ 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;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
/**
* Event that is posted when a venue invitation is sent
@ -34,6 +35,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* ------------ ---------- ----------- --------------------------
* Mar 27, 2012 jkorman Initial creation
* Dec 18, 2013 2562 bclement removed subject (subject in invite)
* Feb 13, 2014 2751 bclement better types for venueid and invitor
*
* </pre>
*
@ -43,9 +45,9 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
public class VenueInvitationEvent implements IVenueInvitationEvent {
private IQualifiedID venueId;
private VenueId venueId;
private IQualifiedID invitor;
private UserId invitor;
private VenueInvite invite;
@ -56,7 +58,7 @@ public class VenueInvitationEvent implements IVenueInvitationEvent {
* @param subject
* @param body
*/
public VenueInvitationEvent(IQualifiedID venueId, IQualifiedID invitor,
public VenueInvitationEvent(VenueId venueId, UserId invitor,
VenueInvite invite) {
this.venueId = venueId;
this.invitor = invitor;
@ -69,7 +71,7 @@ public class VenueInvitationEvent implements IVenueInvitationEvent {
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getRoomId()
*/
@Override
public IQualifiedID getRoomId() {
public VenueId getRoomId() {
return venueId;
}
@ -77,7 +79,7 @@ public class VenueInvitationEvent implements IVenueInvitationEvent {
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent#getInviter()
*/
@Override
public IQualifiedID getInviter() {
public UserId getInviter() {
return invitor;
}

View file

@ -50,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Dec 6, 2013 2561 bclement removed ECF
* Jan 28, 2014 2698 bclement removed getInfo, added methods to replace
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant, getSubject never returns null
* Feb 13, 2014 2751 bclement changed to use VenueParticipant handle instead of alias
*
* </pre>
*
@ -79,7 +80,7 @@ public class Venue implements IVenue {
@Override
public Presence getPresence(VenueParticipant user) {
Presence presence = presenceMap.get(user.getAlias());
Presence presence = presenceMap.get(user.getHandle());
if (presence == null) {
presence = new Presence(Type.unavailable);
presence.setMode(Mode.away);
@ -88,7 +89,7 @@ public class Venue implements IVenue {
}
public void handlePresenceUpdated(VenueParticipant fromID, Presence presence) {
presenceMap.put(fromID.getAlias(), presence);
presenceMap.put(fromID.getHandle(), presence);
}
/*

View file

@ -26,7 +26,7 @@ import java.util.UUID;
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;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
/**
* Base class for chat and collaboration sessions
@ -40,6 +40,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
* Mar 21, 2012 jkorman Initial creation
* Dec 6, 2013 2561 bclement removed ECF
* Jan 28, 2014 2698 bclement removed false throws statements
* Feb 13, 2014 2751 bclement changed UserId object to IUser
*
* </pre>
*
@ -119,7 +120,7 @@ public abstract class BaseSession implements ISession {
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getUserID()
*/
@Override
public UserId getUserID() {
public IUser getUserID() {
return connection.getUser();
}

View file

@ -58,7 +58,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEve
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
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.SessionPayload;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionPayload.PayloadType;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionPayloadProvider;
@ -110,6 +109,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* cleaned up createCollaborationVenue, removed getVenueInfo
* Jan 30, 2014 2698 bclement changed arguments to create sessions, moved room connection from SessionView
* Feb 3, 2014 2699 bclement removed unneeded catch in joinTextOnlyVenue
* Feb 13, 2014 2751 bclement better types for venueid and invitor
*
* </pre>
*
@ -401,7 +401,7 @@ public class CollaborationConnection implements IEventPublisher {
session.createVenue(data);
VenueParticipant leader = session.getUserID();
leader.setAlias(session.getHandle());
leader.setHandle(session.getHandle());
session.setCurrentSessionLeader(leader);
session.setCurrentDataProvider(leader);
@ -616,8 +616,9 @@ public class CollaborationConnection implements IEventPublisher {
String room, String inviter, String reason,
String password, Message message) {
// TODO handle password protected rooms
IQualifiedID venueId = new VenueId();
VenueId venueId = new VenueId();
venueId.setName(Tools.parseName(room));
venueId.setHost(Tools.parseHost(room));
UserId invitor = IDConverter.convertFrom(inviter);
if (message != null) {
@ -641,7 +642,7 @@ public class CollaborationConnection implements IEventPublisher {
}
}
private void handleChatRoomInvite(IQualifiedID venueId, UserId invitor,
private void handleChatRoomInvite(VenueId venueId, UserId invitor,
String reason, Message message) {
VenueInvite invite = new VenueInvite();
if (!StringUtils.isBlank(reason)) {
@ -657,7 +658,7 @@ public class CollaborationConnection implements IEventPublisher {
eventBus.post(event);
}
private void handleCollabInvite(IQualifiedID venueId, UserId invitor,
private void handleCollabInvite(VenueId venueId, UserId invitor,
SessionPayload payload) {
Object obj = payload.getData();
if (obj == null

View file

@ -32,8 +32,9 @@ 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.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
*
@ -49,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
* Mar 21, 2012 jkorman Initial creation
* Apr 18, 2012 njensen Cleanup
* Dec 6, 2013 2561 bclement removed ECF
* Feb 13, 2014 2751 bclement changed IQualifiedID objects to IUser
*
* </pre>
*
@ -77,7 +79,7 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
public void sendPeerToPeer(IMessage message) throws CollaborationException {
CollaborationConnection manager = getConnection();
XMPPConnection conn = manager.getXmppConnection();
IQualifiedID to = message.getTo();
IUser to = message.getTo();
String toId = to.getFQName();
Message xmppMessage = new Message(toId, Type.chat);
xmppMessage.setBody(message.getBody());
@ -116,7 +118,7 @@ public class PeerToPeerChat extends BaseSession implements IPeerToPeer {
* @throws CollaborationException
*/
@Override
public void sendPeerToPeer(IQualifiedID to, String message)
public void sendPeerToPeer(UserId to, String message)
throws CollaborationException {
TextMessage msg = new TextMessage(to, message);
this.sendPeerToPeer(msg);

View file

@ -31,7 +31,7 @@ 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.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionPayload;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
@ -53,6 +53,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
* Dec 18, 2013 2562 bclement added timeout for HTTP config,
* data now in packet extension
* Dec 19, 2013 2563 bclement removed wait for HTTP config, added reset
* Feb 13, 2014 2751 bclement changed IQualifiedID objects to IUser
*
* </pre>
*
@ -168,7 +169,7 @@ public class PeerToPeerCommHelper implements PacketListener {
* @param message
*/
private void routeMessage(Message message) {
IQualifiedID fromId = IDConverter.convertFrom(message.getFrom());
IUser fromId = IDConverter.convertFrom(message.getFrom());
TextMessage textMsg = new TextMessage(fromId, message.getBody());
textMsg.setFrom(fromId);
textMsg.setBody(message.getBody());

View file

@ -76,6 +76,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* changed args to create/configure venue
* Feb 12, 2014 2793 bclement added additional null check to sendObjectToVenue
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -190,15 +191,20 @@ public class SharedDisplaySession extends VenueSession implements
* java.lang.Object)
*/
@Override
public void sendObjectToPeer(
com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID participant,
Object obj) throws CollaborationException {
public void sendObjectToPeer(VenueParticipant participant, Object obj)
throws CollaborationException {
// TODO should only send to CAVE clients
if (obj == null) {
return;
}
// TODO should we use MUC private chat for this?
if (!participant.hasActualUserId()) {
log.warn("Attempted to send object to peer when actual userid is unknown");
return;
}
UserId userid = participant.getUserid();
SessionPayload payload = new SessionPayload(PayloadType.Command, obj);
Message msg = new Message(participant.getFQName(), Type.normal);
Message msg = new Message(userid.getFQName(), Type.normal);
msg.addExtension(payload);
msg.setFrom(conn.getUser());
msg.setProperty(Tools.PROP_SESSION_ID, getSessionId());
@ -299,7 +305,7 @@ public class SharedDisplaySession extends VenueSession implements
topic = pubsubMgr.getNode(getSessionId());
topic.addItemEventListener(this);
topic.addItemDeleteListener(this);
Subscription sub = findSubscription(getUserID());
Subscription sub = findSubscription(getAccount());
if (sub == null) {
sub = topic.subscribe(conn.getUser());
}
@ -435,7 +441,7 @@ public class SharedDisplaySession extends VenueSession implements
return;
}
try {
Subscription sub = findSubscription(getUserID());
Subscription sub = findSubscription(getAccount());
if (sub == null) {
return;
}

View file

@ -48,8 +48,7 @@ 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.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionPayload;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionPayload.PayloadType;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
@ -94,6 +93,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Jan 28, 2014 2698 bclement removed venue info, new rooms are now invite-only
* improved error handling for when room already exists
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant, added handle
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -110,7 +110,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
public static final String SEND_HISTORY = "[[HISTORY]]";
private MultiUserChat muc = null;
protected MultiUserChat muc = null;
private PacketListener intListener = null;
@ -190,7 +190,8 @@ public class VenueSession extends BaseSession implements IVenueSession {
invite);
Message msg = new Message();
msg.setTo(id.getNormalizedId());
msg.setFrom(getUserID().getNormalizedId());
UserId user = getAccount();
msg.setFrom(user.getNormalizedId());
msg.setType(Type.normal);
msg.addExtension(payload);
String reason = "";
@ -268,7 +269,17 @@ public class VenueSession extends BaseSession implements IVenueSession {
* @return
*/
public static String getRoomId(String host, String roomName) {
return roomName + "@conference." + host;
return roomName + "@" + getQualifiedHost(host);
}
/**
* Prepend conference subdomain on host
*
* @param host
* @return
*/
public static String getQualifiedHost(String host) {
return "conference." + host;
}
/**
@ -505,7 +516,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
VenueParticipant user = IDConverter.convertFromRoom(muc,
participant);
VenueParticipantEvent event = new VenueParticipantEvent(user,
ParticipantEventType.ARRIVED);
type);
event.setEventDescription(desciption);
postEvent(event);
}
@ -537,7 +548,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
Activator.getDefault().getNetworkStats()
.log(Activator.VENUE, 0, m.getBody().length());
String fromStr = m.getFrom();
IQualifiedID from;
IUser from;
if (IDConverter.isRoomSystemMessage(fromStr)) {
postEvent(new VenueUserEvent(m.getBody()));
} else {
@ -693,7 +704,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
* user that the message is from
* @return Should the message be accepted.
*/
private boolean accept(Message message, IQualifiedID from) {
private boolean accept(Message message, IUser from) {
if (this.muc == null) {
// we don't seem to be in a room
return false;
@ -767,7 +778,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
* user that the message is from
* @return The converted message.
*/
private IMessage convertMessage(Message msg, IQualifiedID from) {
private IMessage convertMessage(Message msg, IUser from) {
IMessage message = null;
String body = msg.getBody();
@ -775,7 +786,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
if (body.startsWith(SEND_TXT)) {
body = body.substring(SEND_TXT.length());
}
message = new CollaborationMessage(null, body);
message = new TextMessage(null, body);
message.setFrom(from);
}
return message;
@ -802,6 +813,13 @@ public class VenueSession extends BaseSession implements IVenueSession {
return handle;
}
/**
* @return userid of this account
*/
public UserId getAccount() {
return getConnection().getUser();
}
/*
* (non-Javadoc)
*
@ -811,9 +829,9 @@ public class VenueSession extends BaseSession implements IVenueSession {
*/
@Override
public VenueParticipant getUserID() {
UserId account = super.getUserID();
return new VenueParticipant(account.getName(), account.getHost(),
handle);
UserId account = getAccount();
return new VenueParticipant(this.venue.getName(),
getQualifiedHost(account.getHost()), handle, account);
}
}

View file

@ -37,6 +37,7 @@ import org.jivesoftware.smackx.muc.Occupant;
* Dec 6, 2013 2561 bclement removed ECF
* Jan 30, 2014 2698 bclement reworked convertFromRoom for venue participants
* Feb 3, 2014 2699 bclement fixed room id parsing when handle has special characters
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -78,16 +79,16 @@ public class IDConverter {
}
String cleanId = id.substring(0, id.length() - handle.length());
String host = StringUtils.parseServer(cleanId);
String name = null;
String roomName = StringUtils.parseName(id);
VenueParticipant rval = new VenueParticipant(roomName, host, handle);
Occupant occupant;
if (room != null && (occupant = room.getOccupant(id)) != null) {
if (occupant.getJid() != null) {
// get actual user name
name = StringUtils.parseName(occupant.getJid());
rval.setUserid(convertFrom(occupant.getJid()));
}
}
return new VenueParticipant(name, host, handle);
return rval;
}
public static String normalizeHostname(String hostname) {

View file

@ -25,7 +25,7 @@ import org.apache.commons.lang.builder.EqualsBuilder;
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.identity.user.IUser;
/**
* Parsed user id string
@ -41,6 +41,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Dec 6, 2013 2561 bclement removed ECF
* Jan 30, 2014 2698 bclement removed unneeded isSameUser(string, string)
* improved other isSameUser so it won't blow up on nulls
* Feb 13, 2014 2751 bclement changed to implement IUser
*
* </pre>
*
@ -49,7 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
*/
@DynamicSerialize
@XmlRootElement(name = "userId")
public class UserId implements IQualifiedID {
public class UserId implements IUser {
@DynamicSerializeElement
protected String name;
@ -102,7 +103,6 @@ public class UserId implements IQualifiedID {
* @param userName
* @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setUserName(java.lang.String)
*/
@Override
public void setName(String userName) {
name = userName;
}
@ -121,7 +121,6 @@ public class UserId implements IQualifiedID {
* @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);
}
@ -136,23 +135,18 @@ public class UserId implements IQualifiedID {
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()
* @return
*/
@Override
public String getResource() {
return resource;
}
@ -253,7 +247,22 @@ public class UserId implements IQualifiedID {
return isSameUser(IDConverter.convertFrom(id));
}
public boolean isSameUser(UserId other) {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.comm.identity.user.IUser#isSameUser
* (com.raytheon.uf.viz.collaboration.comm.identity.user.IUser)
*/
@Override
public boolean isSameUser(IUser other) {
if (other instanceof VenueParticipant) {
VenueParticipant vp = (VenueParticipant) other;
if (!vp.hasActualUserId()) {
return false;
}
other = vp.getUserid();
}
EqualsBuilder builder = new EqualsBuilder();
builder.append(this.name, other.getName());
builder.append(this.host, other.getHost());

View file

@ -31,6 +31,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 29, 2012 jkorman Initial creation
* Feb 13, 2014 2751 bclement removed resource, fixed getFQN
*
* </pre>
*
@ -42,14 +43,11 @@ public class VenueId implements IQualifiedID {
private String host;
private String resource;
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;
}
@ -62,26 +60,9 @@ public class VenueId implements IQualifiedID {
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 venueName) {
name = venueName;
}
@ -99,8 +80,7 @@ public class VenueId implements IQualifiedID {
*/
@Override
public String getFQName() {
// FIXME
return null;
return name + "@" + host;
}
}

View file

@ -25,6 +25,8 @@ import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
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.IUser;
/**
* Parsed ID string from venue. Not guaranteed to have username, but will always
@ -37,6 +39,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 29, 2014 bclement Initial creation
* Feb 13, 2014 2751 bclement no longer is a subclass of UserId
*
* </pre>
*
@ -45,7 +48,19 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
*/
@DynamicSerialize
@XmlRootElement(name = "participant")
public class VenueParticipant extends UserId {
public class VenueParticipant implements IUser {
@DynamicSerializeElement
private String handle;
@DynamicSerializeElement
private String host;
@DynamicSerializeElement
private UserId userid;
@DynamicSerializeElement
private String room;
/**
*
@ -54,21 +69,33 @@ public class VenueParticipant extends UserId {
}
/**
* @param userName
* @param room
* name of venue
* @param hostName
* qualified name of host including conference subdomain
* @param handle
* public name of user in room
* @param userid
* actual userid of user
*/
public VenueParticipant(String userName, String hostName) {
super(userName, hostName);
public VenueParticipant(String room, String hostName, String handle,
UserId userid) {
this(room, hostName, handle);
this.userid = userid;
}
/**
* @param userName
* @param room
* name of venue
* @param hostName
* @param resource
* qualified name of host including conference subdomain
* @param handle
* public name of user in room
*/
public VenueParticipant(String userName, String hostName, String handle) {
this(userName, hostName);
setAlias(handle);
public VenueParticipant(String room, String hostName, String handle) {
this.room = room;
this.host = hostName;
this.handle = handle;
}
/*
@ -81,7 +108,8 @@ public class VenueParticipant extends UserId {
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(host);
builder.append(alias);
builder.append(handle);
builder.append(room);
return builder.toHashCode();
}
@ -100,29 +128,26 @@ public class VenueParticipant extends UserId {
if (this == obj) {
return true;
}
if (!(obj instanceof UserId)) {
if (!(obj instanceof VenueParticipant)) {
return false;
}
UserId user = (UserId) obj;
VenueParticipant other = (VenueParticipant) obj;
EqualsBuilder builder = new EqualsBuilder();
builder.append(alias, user.alias);
builder.append(host, user.host);
builder.append(handle, other.handle);
builder.append(host, other.host);
builder.append(room, other.room);
return builder.isEquals();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.comm.provider.user.UserId#isSameUser
* (java.lang.String)
/**
* @param id
* @return true if id represents same venue participant as this one
*/
@Override
public boolean isSameUser(String id) {
if (!IDConverter.isFromRoom(id)) {
return false;
return hasActualUserId() && userid.isSameUser(id);
}
UserId other = IDConverter.convertFromRoom(null, id);
VenueParticipant other = IDConverter.convertFromRoom(null, id);
return isSameUser(other);
}
@ -130,12 +155,123 @@ public class VenueParticipant extends UserId {
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.comm.provider.user.UserId#isSameUser
* (com.raytheon.uf.viz.collaboration.comm.provider.user.UserId)
* com.raytheon.uf.viz.collaboration.comm.identity.user.IUser#isSameUser
* (com.raytheon.uf.viz.collaboration.comm.identity.user.IUser)
*/
@Override
public boolean isSameUser(UserId other) {
public boolean isSameUser(IUser other) {
if (other instanceof UserId) {
return hasActualUserId() && userid.isSameUser(other);
}
if (!(other instanceof VenueParticipant)) {
return false;
}
return equals(other);
}
@Override
public String toString() {
return getFQName();
}
/**
* @return id of room that this participant is in (includes hostname)
*/
public String getRoomId() {
return room + "@" + host;
}
/**
* @return true if actually userid of participant is known
*/
public boolean hasActualUserId() {
return this.userid != null;
}
/**
* @return the handle
*/
public String getHandle() {
return handle;
}
/**
* @param handle
* the handle to set
*/
public void setHandle(String handle) {
this.handle = handle;
}
/**
* @return the host
*/
public String getHost() {
return host;
}
/**
* @param host
* the host to set
*/
public void setHost(String host) {
this.host = host;
}
/**
* @return the userid
*/
public UserId getUserid() {
return userid;
}
/**
* @param userid
* the userid to set
*/
public void setUserid(UserId userid) {
this.userid = userid;
}
/**
* name of venue
*
* @return the room
*/
public String getRoom() {
return room;
}
/**
* @param room
* name of venue
*/
public void setRoom(String room) {
this.room = room;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getName
* ()
*/
@Override
public String getName() {
return handle;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#getFQName
* ()
*/
@Override
public String getFQName() {
return getRoomId() + "/" + handle;
}
}

View file

@ -52,6 +52,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 njensen Initial creation
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -72,7 +73,7 @@ public class DataProviderEventController extends
@Subscribe
public void participantChanged(IVenueParticipantEvent event) {
if (event.getEventType().equals(ParticipantEventType.ARRIVED)
&& !event.getParticipant().equals(session.getUserID())) {
&& !event.getParticipant().isSameUser(session.getUserID())) {
try {
AbstractEditor active = container.getActiveSharedEditor();
if (active != null) {

View file

@ -39,7 +39,7 @@ import com.google.common.eventbus.Subscribe;
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.ISharedDisplaySession;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
import com.raytheon.uf.viz.collaboration.display.Activator;
import com.raytheon.uf.viz.collaboration.display.IRemoteDisplayContainer;
import com.raytheon.uf.viz.collaboration.display.editor.ActivateRemoteDisplay;
@ -82,6 +82,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* ------------ ---------- ----------- --------------------------
* Jun 8, 2012 mschenke Initial creation
* Jan 28, 2014 2698 bclement removed venue info
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -95,8 +96,8 @@ public class SharedEditorsManager implements IRemoteDisplayContainer {
@Subscribe
public void remoteDisplayRequested(RemoteDisplayRequested event) {
String userId = event.getUserId();
UserId user = null;
for (UserId uid : session.getVenue().getParticipants()) {
VenueParticipant user = null;
for (VenueParticipant uid : session.getVenue().getParticipants()) {
if (uid.getFQName().equals(userId)) {
user = uid;
break;

View file

@ -29,7 +29,6 @@ import com.google.common.eventbus.Subscribe;
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.event.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
import com.raytheon.uf.viz.collaboration.display.Activator;
import com.raytheon.uf.viz.collaboration.display.data.SessionContainer;
@ -305,7 +304,7 @@ public class CollaborationDrawingResource extends
@Subscribe
public void participantChanged(IVenueParticipantEvent event) {
UserId user = event.getParticipant();
VenueParticipant user = event.getParticipant();
switch (event.getEventType()) {
case DEPARTED:
synchronized (layerMap) {
@ -415,7 +414,7 @@ public class CollaborationDrawingResource extends
}
}
public void sendEventToUser(Object event, UserId user) {
public void sendEventToUser(Object event, VenueParticipant user) {
try {
container.getSession().sendObjectToPeer(user, event);
} catch (CollaborationException e) {

View file

@ -34,9 +34,9 @@ import org.jivesoftware.smack.packet.RosterPacket.ItemStatus;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
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;
/**
@ -50,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
* ------------ ---------- ----------- --------------------------
* Jul 24, 2012 bsteffen Initial creation
* Jan 27, 2014 2700 bclement added roster entry support
* Feb 13, 2014 2751 bclement made generic for IUsers
*
* </pre>
*
@ -57,18 +58,15 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
* @version 1.0
*/
public abstract class AbstractUserLabelProvider extends ColumnLabelProvider {
public abstract class AbstractUserLabelProvider<T extends IUser> extends
ColumnLabelProvider {
protected Map<String, Image> imageMap = new HashMap<String, Image>();
@Override
public String getText(Object element) {
UserId user;
if (element instanceof UserId) {
user = (UserId) element;
} else if ( element instanceof RosterEntry){
user = IDConverter.convertFrom((RosterEntry) element);
} else {
T user = convertObject(element);
if (user == null) {
return null;
}
StringBuilder name = new StringBuilder();
@ -91,14 +89,18 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider {
return name.toString();
}
/**
* Cast object to appropriate type
*
* @param element
* @return null if object cannot be cast
*/
abstract protected T convertObject(Object element);
@Override
public Image getImage(Object element) {
UserId user;
if (element instanceof UserId) {
user = (UserId) element;
} else if (element instanceof RosterEntry) {
user = IDConverter.convertFrom((RosterEntry) element);
} else {
T user = convertObject(element);
if (user == null) {
return null;
}
Presence presence = getPresence(user);
@ -125,12 +127,8 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider {
@Override
public String getToolTipText(Object element) {
UserId user;
if (element instanceof UserId) {
user = (UserId) element;
} else if (element instanceof RosterEntry) {
user = IDConverter.convertFrom((RosterEntry) element);
} else {
T user = convertObject(element);
if (user == null) {
return null;
}
Presence presence = getPresence(user);
@ -187,7 +185,7 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider {
imageMap.clear();
}
protected String getDisplayName(UserId user) {
protected static String getLocalAlias(UserId user) {
CollaborationConnection connection = CollaborationConnection
.getConnection();
if (connection == null) {
@ -201,6 +199,16 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider {
}
}
protected abstract Presence getPresence(UserId user);
/**
* @param user
* @return display text for user name
*/
abstract protected String getDisplayName(T user);
/**
* @param user
* @return last known presence for user
*/
abstract protected Presence getPresence(T user);
}

View file

@ -39,7 +39,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IHttpdCollaborationConfigurationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
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.session.CollaborationConnection;
@ -71,6 +71,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* Jan 14, 2014 2630 bclement added away timeout
* Jan 27, 2014 2700 bclement added auto subscribe property listener
* Jan 30, 2014 2698 bclement moved xmpp join logic to dialog so we can reprompt user on failure
* Feb 13, 2014 2751 bclement messages return IUser instead of IQualifiedID
*
* </pre>
*
@ -226,7 +227,7 @@ public class ConnectionSubscriber {
@Override
public void run() {
IQualifiedID peer = message.getFrom();
IUser peer = message.getFrom();
UserId user = null;
if (peer instanceof UserId) {

View file

@ -40,8 +40,9 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
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.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
@ -59,6 +60,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
* Jan 30, 2014 2698 bclement added logic to join room and reprompt if failed
* Feb 3, 2014 2699 bclement added default handle preference
* Feb 11, 2014 2699 bclement require non-blank handle
* Feb 13, 2014 2751 bclement better types for roomid and inviter
*
* </pre>
*
@ -110,8 +112,8 @@ public class InviteDialog extends CaveSWTDialogBase {
super(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL
| SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL, CAVE.NONE);
setText("Session Invitation");
IQualifiedID inviter = event.getInviter();
IQualifiedID room = event.getRoomId();
IUser inviter = event.getInviter();
VenueId room = event.getRoomId();
StringBuilder sb = new StringBuilder();
VenueInvite invite = event.getInvite();
this.sharedDisplay = invite instanceof SharedDisplayVenueInvite;

View file

@ -39,6 +39,7 @@ import org.jivesoftware.smack.packet.Presence;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
@ -58,6 +59,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
* Jan 24, 2014 2701 bclement removed local groups, added shared groups
* Jan 27, 2014 2700 bclement pass roster entries directly to userLabelProvider
* Jan 28, 2014 2698 bclement removed venue info
* Feb 13, 2014 2751 bclement made AbstractUsersLabelProvider generic
*
* </pre>
*
@ -66,7 +68,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
*/
public class UsersTreeLabelProvider extends ColumnLabelProvider {
private AbstractUserLabelProvider userLabelProvider = new AbstractUserLabelProvider() {
private AbstractUserLabelProvider<UserId> userLabelProvider = new AbstractUserLabelProvider<UserId>() {
@Override
protected Presence getPresence(UserId user) {
@ -77,6 +79,22 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider {
}
return connection.getContactsManager().getPresence(user);
}
protected String getDisplayName(UserId user) {
return getLocalAlias(user);
}
@Override
protected UserId convertObject(Object element) {
if (element instanceof RosterEntry) {
return IDConverter.convertFrom((RosterEntry) element);
} else if (element instanceof UserId) {
return (UserId) element;
} else {
return null;
}
}
};
private List<ILabelProviderListener> listeners;

View file

@ -68,6 +68,7 @@ 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.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.ui.Activator;
@ -94,6 +95,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* Mar 16, 2012 244 rferrel Initial creation
* Dec 19, 2013 2563 bclement moved color lookup into runAsync block
* Jan 30, 2014 2698 bclement get display name from child class
* Feb 13, 2014 2751 bclement made generic
*
* </pre>
*
@ -101,7 +103,8 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* @version 1.0
*/
public abstract class AbstractSessionView extends CaveFloatingView {
public abstract class AbstractSessionView<T extends IUser> extends
CaveFloatingView {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractSessionView.class);
@ -123,8 +126,6 @@ public abstract class AbstractSessionView extends CaveFloatingView {
private StyledText composeText;
private UserId[] userIds = null;
protected SessionMsgArchive msgArchive;
private List<AlertWord> alertWords = null;
@ -149,7 +150,6 @@ public abstract class AbstractSessionView extends CaveFloatingView {
public AbstractSessionView() {
imageMap = new HashMap<String, Image>();
userIds = CollaborationUtils.getIds();
fonts = new HashMap<String, Font>();
colors = new HashMap<RGB, Color>();
dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
@ -311,17 +311,18 @@ public abstract class AbstractSessionView extends CaveFloatingView {
*
* @param message
*/
@SuppressWarnings("unchecked")
public void appendMessage(IMessage message) {
UserId userId = (UserId) message.getFrom();
T userId = (T) message.getFrom();
long timestamp = message.getTimeStamp();
String body = message.getBody();
String subject = message.getSubject();
appendMessage(userId, timestamp, body, subject);
}
protected abstract String getDisplayName(UserId userId);
protected abstract String getDisplayName(T userId);
public void appendMessage(final UserId userId, final long timestamp,
public void appendMessage(final T userId, final long timestamp,
final String body, final String subject) {
VizApp.runAsync(new Runnable() {
@Override
@ -345,7 +346,7 @@ public abstract class AbstractSessionView extends CaveFloatingView {
String name = getDisplayName(userId);
UserId myUser = connection.getUser();
if (!myUser.equals(userId)
if (!myUser.isSameUser(userId)
&& Activator.getDefault().getPreferenceStore()
.getBoolean("notifications")) {
createNotifier(name, time, body);
@ -443,10 +444,10 @@ public abstract class AbstractSessionView extends CaveFloatingView {
}
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, String subject, List<StyleRange> ranges);
String name, T userId, String subject, List<StyleRange> ranges);
protected abstract void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges, Color color);
String name, T userId, List<StyleRange> ranges, Color color);
/**
* Find keys words in body of message starting at offset. /**
@ -567,21 +568,6 @@ public abstract class AbstractSessionView extends CaveFloatingView {
messagesText.setFont(new Font(Display.getCurrent(), data));
}
/**
* @return the userIds
*/
public UserId[] getUserIds() {
return userIds;
}
/**
* @param userIds
* the userIds to set
*/
public void setUserIds(UserId[] userIds) {
this.userIds = userIds;
}
public void setAlertWords(List<AlertWord> words) {
alertWords = words;
}

View file

@ -53,6 +53,7 @@ import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
* Dec 6, 2013 2561 bclement removed ECF
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* added JID and display name if available
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -60,7 +61,8 @@ import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
* @version 1.0
*/
public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
public class ParticipantsLabelProvider extends
AbstractUserLabelProvider<VenueParticipant> {
protected String sessionId = null;
@ -178,9 +180,9 @@ public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
protected boolean isSessionLeader(VenueParticipant user) {
ISession session = getSession();
if (session instanceof SharedDisplaySession) {
UserId leader = ((SharedDisplaySession) session)
VenueParticipant leader = ((SharedDisplaySession) session)
.getCurrentSessionLeader();
return user.getAlias().equals(leader.getAlias());
return user.getHandle().equals(leader.getHandle());
}
return false;
}
@ -188,9 +190,9 @@ public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
protected boolean isDataProvider(VenueParticipant user) {
ISession session = getSession();
if (session instanceof SharedDisplaySession) {
UserId provider = ((SharedDisplaySession) session)
VenueParticipant provider = ((SharedDisplaySession) session)
.getCurrentDataProvider();
return user.getAlias().equals(provider.getAlias());
return user.getHandle().equals(provider.getHandle());
}
return false;
}
@ -231,10 +233,10 @@ public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
// }
}
}
if (user.getName() != null) {
builder.append("\nJID: ").append(user.getNormalizedId());
builder.append("\nDisplay Name: ").append(
super.getDisplayName(user));
if (user.hasActualUserId()) {
UserId actual = user.getUserid();
builder.append("\nJID: ").append(actual.getNormalizedId());
builder.append("\nDisplay Name: ").append(getLocalAlias(actual));
}
return builder.toString();
}
@ -252,9 +254,9 @@ public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
}
@Override
protected Presence getPresence(UserId user) {
protected Presence getPresence(VenueParticipant user) {
IVenueSession session = (IVenueSession) getSession();
return session.getVenue().getPresence((VenueParticipant) user);
return session.getVenue().getPresence(user);
}
/*
@ -265,8 +267,24 @@ public class ParticipantsLabelProvider extends AbstractUserLabelProvider {
* (com.raytheon.uf.viz.collaboration.comm.provider.user.UserId)
*/
@Override
protected String getDisplayName(UserId user) {
return user.getAlias();
protected String getDisplayName(VenueParticipant user) {
return user.getHandle();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider#convertObject
* (java.lang.Object)
*/
@Override
protected VenueParticipant convertObject(Object element) {
if (element instanceof VenueParticipant) {
return (VenueParticipant) element;
} else {
return null;
}
}
}

View file

@ -41,7 +41,6 @@ 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.IPeerToPeer;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterItem;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
@ -58,13 +57,14 @@ import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionIt
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 rferrel Initial creation
* Jan 30, 2014 2698 bclement added getDisplayName
* Feb 13, 2014 2751 bclement made parent generic
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class PeerToPeerView extends AbstractSessionView implements
public class PeerToPeerView extends AbstractSessionView<UserId> implements
IPrintableView {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PeerToPeerView.class);
@ -79,7 +79,7 @@ public class PeerToPeerView extends AbstractSessionView implements
private static Color black = null;
private IQualifiedID peer;
private UserId peer;
private boolean online = true;
@ -238,13 +238,13 @@ public class PeerToPeerView extends AbstractSessionView implements
return new SessionMsgArchive(me.getHost(), me.getName(), peer.getName());
}
public void setPeer(IQualifiedID peer) {
public void setPeer(UserId peer) {
this.peer = peer;
setPartName(getSessionName());
initMessageArchive();
}
public IQualifiedID getPeer() {
public UserId getPeer() {
return peer;
}

View file

@ -40,7 +40,6 @@ import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation;
@ -62,6 +61,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
* Dec 19, 2013 2563 bclement moved participant filter logic to one method
* Jan 08, 2014 2563 bclement changes to match SiteConfigurationManager user sites config
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
@ -272,9 +272,10 @@ public class SessionFeedView extends SessionView {
@Override
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, String subject, List<StyleRange> ranges) {
if (subject != null && userId instanceof VenueParticipant) {
setColorForSite((VenueParticipant) userId, subject);
String name, VenueParticipant userId, String subject,
List<StyleRange> ranges) {
if (subject != null) {
setColorForSite(userId, subject);
}
super.styleAndAppendText(sb, offset, name, userId, subject, ranges);
}

View file

@ -96,13 +96,15 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* Dec 6, 2013 2561 bclement removed ECF
* Dec 19, 2013 2563 bclement reworked participant event logic
* Jan 28, 2014 2698 bclement removed venue info
* Feb 13, 2014 2751 bclement VenueParticipant refactor
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class SessionView extends AbstractSessionView implements IPrintableView {
public class SessionView extends AbstractSessionView<VenueParticipant>
implements IPrintableView {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SessionView.class);
@ -337,10 +339,10 @@ public class SessionView extends AbstractSessionView implements IPrintableView {
usersTable.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
UserId c1 = (UserId) e1;
UserId c2 = (UserId) e1;
VenueParticipant c1 = (VenueParticipant) e1;
VenueParticipant c2 = (VenueParticipant) e1;
return c1.getAlias().compareTo(c2.getAlias());
return c1.getHandle().compareTo(c2.getHandle());
}
});
@ -427,8 +429,8 @@ public class SessionView extends AbstractSessionView implements IPrintableView {
String message = getComposedMessage();
if (message.length() > 0) {
try {
UserId id = CollaborationConnection.getConnection().getUser();
appendMessage(id, System.currentTimeMillis(), message, null);
appendMessage(session.getUserID(), System.currentTimeMillis(),
message, null);
session.sendChatMessage(message);
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
@ -448,17 +450,10 @@ public class SessionView extends AbstractSessionView implements IPrintableView {
*/
@Override
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, String subject, List<StyleRange> ranges) {
RGB rgb = null;
// messages from the venue itself will not be of type VenueParticipant,
// they default to black
if (userId instanceof VenueParticipant) {
rgb = colorManager.getColorFromUser((VenueParticipant) userId);
}
String name, VenueParticipant userId, String subject,
List<StyleRange> ranges) {
RGB rgb = colorManager.getColorFromUser((VenueParticipant) userId);
if (mappedColors.get(rgb) == null) {
if (rgb == null) {
rgb = new RGB(0, 0, 0);
}
Color col = new Color(Display.getCurrent(), rgb);
mappedColors.put(rgb, col);
}
@ -476,7 +471,8 @@ public class SessionView extends AbstractSessionView implements IPrintableView {
*/
@Override
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges, Color color) {
String name, VenueParticipant userId, List<StyleRange> ranges,
Color color) {
StyleRange range = new StyleRange(messagesText.getCharCount(), offset,
color, null, SWT.NORMAL);
ranges.add(range);
@ -774,10 +770,11 @@ public class SessionView extends AbstractSessionView implements IPrintableView {
*
* @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
* getDisplayName
* (com.raytheon.uf.viz.collaboration.comm.provider.user.UserId)
* (com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID)
*/
@Override
protected String getDisplayName(UserId userId) {
return userId.getAlias();
protected String getDisplayName(VenueParticipant userId) {
return userId.getHandle();
}
}