From 8022bb6e792eff0e0840092f9625af74edd9303d Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Tue, 15 May 2012 15:59:08 -0500 Subject: [PATCH] Issue #440 username/password logging fixes, synchronize all times collaboratorShapes are manipulated Former-commit-id: f1ea85ea44090e1b17db713861f94fbe73687a0e [formerly f1ea85ea44090e1b17db713861f94fbe73687a0e [formerly 9255532085a1d43955345092d567e04222bbb06d]] Former-commit-id: 096b526e7a85bd2e4916a3110f616744b884b004 Former-commit-id: 9c36b710dc2ad01a0412b62cc4f57ddfd36dc1ee --- .../comm/identity/CollaborationException.java | 20 ++++---- .../identity/UsernamePasswordException.java | 51 +++++++++++++++++++ .../session/CollaborationConnection.java | 27 ++++------ .../collaboration/ui/login/LoginDialog.java | 23 +++++++-- .../CollaborationDrawingLayer.java | 40 ++++++++++++--- 5 files changed, 124 insertions(+), 37 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/UsernamePasswordException.java diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/CollaborationException.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/CollaborationException.java index 7698e645e8..7d92652551 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/CollaborationException.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/CollaborationException.java @@ -23,17 +23,17 @@ package com.raytheon.uf.viz.collaboration.comm.identity; * TODO Add Description * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 8, 2012            jkorman     Initial creation
- *
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class CollaborationException extends Exception { @@ -44,16 +44,16 @@ public class CollaborationException extends Exception { * */ public CollaborationException() { - + } - + /** * @param message */ public CollaborationException(String message) { super(message); } - + /** * * @param message @@ -62,12 +62,12 @@ public class CollaborationException extends Exception { public CollaborationException(String message, Throwable cause) { super(message, cause); } - + /** * @param cause */ public CollaborationException(Throwable cause) { super(cause); } - + } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/UsernamePasswordException.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/UsernamePasswordException.java new file mode 100644 index 0000000000..4bced873f6 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/UsernamePasswordException.java @@ -0,0 +1,51 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.identity; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * May 15, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class UsernamePasswordException extends CollaborationException { + + private static final long serialVersionUID = 3124620509180835631L; + + /** + * @param message + * @param cause + */ + public UsernamePasswordException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java index 65dedcf058..f369a346c9 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java @@ -28,8 +28,6 @@ import org.eclipse.ecf.core.ContainerConnectException; import org.eclipse.ecf.core.ContainerCreateException; import org.eclipse.ecf.core.ContainerFactory; import org.eclipse.ecf.core.IContainer; -import org.eclipse.ecf.core.IContainerListener; -import org.eclipse.ecf.core.events.IContainerEvent; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.identity.IDCreateException; import org.eclipse.ecf.core.identity.IDFactory; @@ -58,6 +56,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.identity.UsernamePasswordException; import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; @@ -167,16 +166,6 @@ public class CollaborationConnection implements IEventPublisher { container = ContainerFactory.getDefault().createContainer(PROVIDER); if (container != null) { - container.addListener(new IContainerListener() { - - @Override - public void handleEvent(IContainerEvent event) { - // TODO? - System.out.println("ContainerEvent.Type = " - + event.getClass().getName()); - } - }); - // add the listeners before we connect so we don't potentially // miss something presenceAdapter = Tools.getPresenceContainerAdapter(container, @@ -195,7 +184,7 @@ public class CollaborationConnection implements IEventPublisher { connectToContainer(); } catch (ContainerConnectException e) { closeInternals(); - throw new CollaborationException( + throw new UsernamePasswordException( "Login failed. Invalid username or password", e); } ID id = container.getConnectedID(); @@ -204,6 +193,7 @@ public class CollaborationConnection implements IEventPublisher { String host = Tools.parseHost(id.getName()); String resource = Tools.parseResource(id.getName()); user = new UserId(name, host, resource); + user.setId(id); } setupAccountManager(); @@ -513,10 +503,13 @@ public class CollaborationConnection implements IEventPublisher { UserId id = IDConverter.convertFrom(fromId); if (rosterManager != null) { - IRosterEntry entry = contactsMgr.getUsersMap().get( - id); - ((RosterEntry) entry).setPresence(presence); - eventBus.post(entry); + if (contactsMgr != null + && contactsMgr.getUsersMap() != null) { + IRosterEntry entry = contactsMgr.getUsersMap() + .get(id); + ((RosterEntry) entry).setPresence(presence); + eventBus.post(entry); + } } } }); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java index fff9c5c959..09e31cfd39 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java @@ -49,6 +49,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.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.identity.UsernamePasswordException; 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; @@ -373,9 +374,25 @@ public class LoginDialog extends CaveSWTDialog { }; }); } catch (CollaborationException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to create connection", - e); + if (e instanceof UsernamePasswordException) { + VizApp.runAsync(new Runnable() { + public void run() { + MessageBox messageBox = new MessageBox( + getShell(), + SWT.ERROR); + messageBox + .setText("Login Error"); + messageBox + .setMessage("Wrong username/password entered"); + messageBox.open(); + }; + }); + } else { + statusHandler + .handle(Priority.PROBLEM, + "Unable to create connection", + e); + } } return Status.OK_STATUS; }; diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java index b334647019..bdeff1ec96 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Iterator; import org.eclipse.swt.graphics.RGB; +import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.google.common.collect.HashMultimap; import com.google.common.collect.LinkedHashMultimap; @@ -220,8 +221,12 @@ public class CollaborationDrawingLayer extends DrawingLayer { while (itr.hasNext()) { lastElement = itr.next(); } - deletedCollaboratorShapes.put(userName, lastElement); - collaboratorShapes.get(userName).remove(lastElement); + synchronized (deletedCollaboratorShapes) { + deletedCollaboratorShapes.put(userName, lastElement); + } + synchronized (collaboratorShapes) { + collaboratorShapes.get(userName).remove(lastElement); + } break; case REDO: userName = event.getUserName(); @@ -234,8 +239,12 @@ public class CollaborationDrawingLayer extends DrawingLayer { while (itr.hasNext()) { lastElement = itr.next(); } - collaboratorShapes.put(userName, lastElement); - deletedCollaboratorShapes.get(userName).remove(lastElement); + synchronized (collaboratorShapes) { + collaboratorShapes.put(userName, lastElement); + } + synchronized (deletedCollaboratorShapes) { + deletedCollaboratorShapes.get(userName).remove(lastElement); + } break; case CLEAR: resetTemp(); @@ -300,8 +309,9 @@ public class CollaborationDrawingLayer extends DrawingLayer { containers.put(userName, cont); } } + collaboratorShapes.clear(); + collaboratorShapes.putAll(containers); } - collaboratorShapes = containers; break; } issueRefresh(); @@ -320,7 +330,9 @@ public class CollaborationDrawingLayer extends DrawingLayer { for (ShapeContainer shape : map.get(cont)) { shape.getShape().dispose(); } - collaboratorShapes.removeAll(cont); + synchronized (collaboratorShapes) { + collaboratorShapes.removeAll(cont); + } } } @@ -328,7 +340,9 @@ public class CollaborationDrawingLayer extends DrawingLayer { // for (ShapeContainer cont : collaboratorShapes.get(userName)) { // cont.getShape().dispose(); // } - collaboratorShapes.removeAll(userName); + synchronized (collaboratorShapes) { + collaboratorShapes.removeAll(userName); + } } /* @@ -529,4 +543,16 @@ public class CollaborationDrawingLayer extends DrawingLayer { // deletedCollaboratorShapes.clear(); // } } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.drawing.DrawingLayer#project(org.opengis.referencing + * .crs.CoordinateReferenceSystem) + */ + @Override + public void project(CoordinateReferenceSystem crs) throws VizException { + super.project(crs); + } }