ref #7993: missed to commit some changes to catch 403 Exceptiojn
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / store / ContextManager.java
index 86d1f88a71b69e7a90389d1d8cf74d5b3eba9344..7c84812afc6b9668c9ddb1671cf79f8bacddb6b5 100644 (file)
@@ -24,6 +24,7 @@ import org.eclipse.ui.IWorkbenchListener;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.XMLMemento;
 import org.eclipse.ui.internal.Workbench;
+import org.springframework.remoting.RemoteAccessException;
 
 import eu.etaxonomy.taxeditor.model.IContextListener;
 import eu.etaxonomy.taxeditor.model.MementoHelper;
@@ -81,8 +82,9 @@ public class ContextManager implements IWorkbenchListener{
     }
     /**
      * <p>notifyContextStart</p>
+     * @throws Throwable
      */
-    public void notifyContextStart() {
+    public void notifyContextStart() throws RemoteAccessException {
         MessagingUtils.info("Notifying context listeners, that the context has started.");
         ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell());
 
@@ -107,7 +109,16 @@ public class ContextManager implements IWorkbenchListener{
                 }
             });
         } catch (InvocationTargetException e) {
-            MessagingUtils.error(getClass(), e);
+            if (e.getTargetException().getClass().equals(RemoteAccessException.class)){
+                if (e.getTargetException().getMessage().contains("403")){
+                   // new CdmAuthenticationException("Access Denied", e.getTargetException());
+                    throw new CdmAuthenticationException("You are logged in now but you are not permitted to use the TaxEditor with the selected data source", e.getTargetException());
+                }else{
+                    MessagingUtils.error(getClass(), e.getTargetException());
+                }
+            }else{
+                MessagingUtils.error(getClass(), e);
+            }
         } catch (InterruptedException e) {
             MessagingUtils.error(getClass(), e);
         }
@@ -139,7 +150,15 @@ public class ContextManager implements IWorkbenchListener{
                 }
             });
         } catch (InvocationTargetException e) {
-            MessagingUtils.error(getClass(), e);
+            if (e.getTargetException().getClass().equals(RemoteAccessException.class)){
+                if (e.getTargetException().getMessage().contains("403")){
+                    MessagingUtils.confirmDialog("Access denied", "Access denied");
+                }else{
+                    MessagingUtils.error(getClass(), e.getTargetException());
+                }
+            }else{
+                MessagingUtils.error(getClass(), e);
+            }
         } catch (InterruptedException e) {
             MessagingUtils.error(getClass(), e);
         }