Issue #427 exceptions are good
Change-Id: I67bb428804d025d20423b9e2320006c70e9b4c68 Former-commit-id: ec20a1f9d6076c2f72909f9fb9a6c88598201dcf
This commit is contained in:
parent
a54660c377
commit
47639de899
6 changed files with 76 additions and 179 deletions
|
@ -69,7 +69,6 @@ import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
|||
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
|
||||
import com.raytheon.uf.viz.collaboration.ui.role.ParticipantEventController;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
|
||||
|
@ -774,31 +773,6 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
|
|||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String joinCollaborationSession(String venueName, String sessionId) {
|
||||
String result = sessionId;
|
||||
if (sessionsMap.get(sessionId) == null) {
|
||||
|
||||
IVenueSession session = null;
|
||||
try {
|
||||
session = getSessionManager().joinCollaborationVenue(venueName);
|
||||
result = session.getSessionId();
|
||||
ISharedDisplaySession displaySession = (ISharedDisplaySession) session;
|
||||
sessionsMap.put(result, session);
|
||||
ParticipantEventController pec = new ParticipantEventController(
|
||||
displaySession);
|
||||
pec.startup();
|
||||
// TODO this method is broken and should be removed
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void registerEventHandler(Object handler) {
|
||||
eventBus.register(handler);
|
||||
}
|
||||
|
|
|
@ -683,35 +683,37 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void createJoinCollaboration() {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
Object[] nodes = selection.toArray();
|
||||
for (Object node : nodes) {
|
||||
if (node instanceof SessionGroup) {
|
||||
SessionGroup sg = (SessionGroup) node;
|
||||
// System.out.println("Join: " + sg.getId());
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
String sessionId = manager.joinCollaborationSession(
|
||||
sg.getText(), sg.getId());
|
||||
sg.setId(sessionId);
|
||||
try {
|
||||
IViewPart part = PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(CollaborationSessionView.ID, sessionId,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open collaboation sesson", e);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, "Unexpected excepton",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// IStructuredSelection selection = (IStructuredSelection)
|
||||
// usersTreeViewer
|
||||
// .getSelection();
|
||||
// Object[] nodes = selection.toArray();
|
||||
// for (Object node : nodes) {
|
||||
// if (node instanceof SessionGroup) {
|
||||
// SessionGroup sg = (SessionGroup) node;
|
||||
// // System.out.println("Join: " + sg.getId());
|
||||
// CollaborationDataManager manager = CollaborationDataManager
|
||||
// .getInstance();
|
||||
// String sessionId = manager.joinCollaborationSession(
|
||||
// sg.getText(), sg.getId());
|
||||
// sg.setId(sessionId);
|
||||
// try {
|
||||
// IViewPart part = PlatformUI
|
||||
// .getWorkbench()
|
||||
// .getActiveWorkbenchWindow()
|
||||
// .getActivePage()
|
||||
// .showView(CollaborationSessionView.ID, sessionId,
|
||||
// IWorkbenchPage.VIEW_ACTIVATE);
|
||||
// } catch (PartInitException e) {
|
||||
// statusHandler.handle(Priority.PROBLEM,
|
||||
// "Unable to open collaboation sesson", e);
|
||||
// } catch (Exception e) {
|
||||
// statusHandler.handle(Priority.ERROR, "Unexpected excepton",
|
||||
// e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ public interface ISession extends IEventPublisher {
|
|||
* Close and clean up this session. After a close, isConnected must return
|
||||
* false.
|
||||
*/
|
||||
void close();
|
||||
public void close();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -82,12 +82,12 @@ public interface ISession extends IEventPublisher {
|
|||
*
|
||||
* @return The connection status.
|
||||
*/
|
||||
boolean isConnected();
|
||||
public boolean isConnected();
|
||||
|
||||
/**
|
||||
* Get the session identifier.
|
||||
*
|
||||
* @return The session identifier.
|
||||
*/
|
||||
String getSessionId();
|
||||
public String getSessionId();
|
||||
}
|
||||
|
|
|
@ -130,11 +130,4 @@ public interface ISharedDisplaySession extends IVenueSession {
|
|||
*/
|
||||
public boolean isConnected();
|
||||
|
||||
/**
|
||||
* Get the session identifier.
|
||||
*
|
||||
* @return The session identifier.
|
||||
*/
|
||||
public String getSessionId();
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Errors;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.RosterChangeEvent;
|
||||
|
@ -437,32 +436,8 @@ public class SessionManager implements IEventPublisher {
|
|||
sessions.put(session.getSessionId(), session);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO fix
|
||||
e.printStackTrace();
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param venueName
|
||||
* @return
|
||||
* @throws CollaborationException
|
||||
*/
|
||||
@Deprecated
|
||||
public IVenueSession joinCollaborationVenue(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);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO
|
||||
e.printStackTrace();
|
||||
throw new CollaborationException("Error joining venue "
|
||||
+ invitation.getRoomId().getName(), e);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
@ -476,47 +451,25 @@ public class SessionManager implements IEventPublisher {
|
|||
public ISharedDisplaySession createCollaborationVenue(String venueName,
|
||||
String subject) throws CollaborationException {
|
||||
SharedDisplaySession session = null;
|
||||
int errorStatus = -1;
|
||||
try {
|
||||
session = new SharedDisplaySession(container, eventBus, this);
|
||||
if (session != null) {
|
||||
errorStatus = session.createVenue(venueName, subject);
|
||||
if (errorStatus == Errors.NO_ERROR) {
|
||||
String name = Tools.parseName(account);
|
||||
String host = Tools.parseHost(account);
|
||||
|
||||
IVenueParticipant me = new VenueParticipant(name, host);
|
||||
session.createVenue(venueName, subject);
|
||||
String name = Tools.parseName(account);
|
||||
String host = Tools.parseHost(account);
|
||||
|
||||
session.setCurrentSessionLeader(me);
|
||||
session.setCurrentDataProvider(me);
|
||||
session.setUserId(me);
|
||||
IVenueParticipant me = new VenueParticipant(name, host);
|
||||
|
||||
sessions.put(session.getSessionId(), session);
|
||||
}
|
||||
}
|
||||
session.setCurrentSessionLeader(me);
|
||||
session.setCurrentDataProvider(me);
|
||||
session.setUserId(me);
|
||||
|
||||
sessions.put(session.getSessionId(), session);
|
||||
return session;
|
||||
} catch (Exception e) {
|
||||
// TODO
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (errorStatus != Errors.NO_ERROR) {
|
||||
// TODO handle this in a more generic way
|
||||
String message = null;
|
||||
switch (errorStatus) {
|
||||
case Errors.BAD_NAME:
|
||||
message = "Badly formed session name.";
|
||||
break;
|
||||
case Errors.VENUE_EXISTS:
|
||||
message = "Session name already in use.";
|
||||
break;
|
||||
case Errors.CANNOT_CONNECT:
|
||||
message = "Unable to connect.";
|
||||
default:
|
||||
message = "Unknown problem creating session";
|
||||
}
|
||||
throw new CollaborationException(message);
|
||||
}
|
||||
throw new CollaborationException(
|
||||
"Error creating collaboration venue " + venueName, e);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -567,7 +520,7 @@ public class SessionManager implements IEventPublisher {
|
|||
*
|
||||
* @param session
|
||||
*/
|
||||
void removeSession(ISession session) {
|
||||
protected void removeSession(ISession session) {
|
||||
sessions.remove(session);
|
||||
}
|
||||
|
||||
|
@ -688,7 +641,7 @@ public class SessionManager implements IEventPublisher {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
ISession getSession(String sessionId) {
|
||||
protected ISession getSession(String sessionId) {
|
||||
return sessions.get(sessionId);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
|
|||
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.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
|
@ -52,7 +54,6 @@ 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.IVenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Errors;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||
|
@ -96,6 +97,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|||
|
||||
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]]";
|
||||
|
@ -119,7 +123,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
* @param container
|
||||
* @param eventBus
|
||||
*/
|
||||
VenueSession(IContainer container, EventBus externalBus,
|
||||
protected VenueSession(IContainer container, EventBus externalBus,
|
||||
SessionManager manager, String sessionId)
|
||||
throws CollaborationException {
|
||||
super(container, externalBus, manager, sessionId);
|
||||
|
@ -130,7 +134,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
* @param container
|
||||
* @param eventBus
|
||||
*/
|
||||
VenueSession(IContainer container, EventBus externalBus,
|
||||
protected VenueSession(IContainer container, EventBus externalBus,
|
||||
SessionManager manager) throws CollaborationException {
|
||||
super(container, externalBus, manager);
|
||||
}
|
||||
|
@ -239,17 +243,14 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
if (sender != null) {
|
||||
VenueInvite invite = buildInvite(body);
|
||||
String msgBody = Tools.marshallData(invite);
|
||||
|
||||
ID roomId = venueInfo.getConnectedID();
|
||||
|
||||
ID userId = IDFactory.getDefault().createID(
|
||||
getConnectionNamespace(), id);
|
||||
|
||||
try {
|
||||
sender.sendInvitation(roomId, userId, subject, msgBody);
|
||||
} catch (ECFException e) {
|
||||
// TODO fix
|
||||
e.printStackTrace();
|
||||
throw new CollaborationException("Error sending invitation", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,15 +279,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#getSessionId()
|
||||
*/
|
||||
@Override
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void sendChatMessage(String message) throws CollaborationException {
|
||||
this.sendMessageToVenue(message);
|
||||
}
|
||||
|
@ -304,7 +297,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
sender.sendMessage(SEND_TXT + message);
|
||||
}
|
||||
} catch (ECFException e) {
|
||||
throw new CollaborationException("Error sending text messge", e);
|
||||
throw new CollaborationException("Error sending messge", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,12 +306,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
this.userID = id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#joinVenue(java.lang.String)
|
||||
*/
|
||||
int joinVenue(String venueName) {
|
||||
int errorStatus = -1;
|
||||
protected void joinVenue(String venueName) throws CollaborationException {
|
||||
try {
|
||||
// Create chat room container from manager
|
||||
venueManager = getConnectionPresenceAdapter().getChatRoomManager();
|
||||
|
@ -326,30 +314,25 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
venueInfo = venueManager.getChatRoomInfo(venueName);
|
||||
subject = venueInfo.getDescription();
|
||||
if (venueInfo != null) {
|
||||
errorStatus = completeVenueConnection(venueInfo);
|
||||
} else {
|
||||
// Could not join venue.
|
||||
completeVenueConnection(venueInfo);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO fix
|
||||
System.out.println(String.format("joinVenue(%s)", venueName));
|
||||
e.printStackTrace();
|
||||
throw new CollaborationException(
|
||||
"Error joining venue " + venueName, e);
|
||||
}
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param venueName
|
||||
* @throws CollaborationException
|
||||
* @throws Exception
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
int createVenue(String venueName, String subject) {
|
||||
int errorStatus = -1;
|
||||
protected void createVenue(String venueName, String subject)
|
||||
throws CollaborationException {
|
||||
try {
|
||||
this.subject = subject;
|
||||
// Create chat room container from manager
|
||||
|
@ -363,31 +346,22 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
props.put(Tools.VENUE_SUBJECT_PROP, subject);
|
||||
}
|
||||
venueInfo = venueManager.createChatRoom(venueName, props);
|
||||
errorStatus = completeVenueConnection(venueInfo);
|
||||
} else {
|
||||
errorStatus = Errors.VENUE_EXISTS;
|
||||
completeVenueConnection(venueInfo);
|
||||
}
|
||||
} else {
|
||||
errorStatus = Errors.CANNOT_CONNECT; // is this correct?
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO this is bad, we assume it's a bad venue name but it might
|
||||
// not be
|
||||
// and we'd give a poor error message
|
||||
System.out.println(String.format("createVenue(%s)", venueName));
|
||||
e.printStackTrace();
|
||||
errorStatus = Errors.BAD_NAME;
|
||||
throw new CollaborationException("Error creating venue "
|
||||
+ venueName, e);
|
||||
}
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CollaborationException
|
||||
*/
|
||||
private int completeVenueConnection(IChatRoomInfo venueInfo) {
|
||||
int errorStatus = Errors.NO_ERROR;
|
||||
|
||||
private void completeVenueConnection(IChatRoomInfo venueInfo)
|
||||
throws CollaborationException {
|
||||
if (venueInfo != null) {
|
||||
try {
|
||||
venueContainer = venueInfo.createChatRoomContainer();
|
||||
|
@ -453,10 +427,10 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorStatus = -1;
|
||||
throw new CollaborationException(
|
||||
"Error completing connection to venue", e);
|
||||
}
|
||||
}
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,8 +487,9 @@ public class VenueSession extends BaseSession implements IVenueSession {
|
|||
getEventPublisher().post(o);
|
||||
}
|
||||
} catch (CollaborationException ce) {
|
||||
// TODO : more robust!!
|
||||
ce.printStackTrace();
|
||||
statusHandler.error(
|
||||
"Error deserializing received message on venue "
|
||||
+ venueInfo.getName(), ce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue