fix #5971: admin menu is visible only if connected and user has role manager
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / store / CdmStore.java
index 8ef10b1e3c67de315fa604a61b26d822016070f5..f8a87dea58c430e3534df40aeb7ed1885a97cb24 100644 (file)
@@ -124,17 +124,30 @@ public class CdmStore {
      *
      * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
      */
-    protected static CdmStore getDefault({
+    protected static CdmStore getDefault(boolean connecting){
         if (instance != null && instance.isConnected) {
             return instance;
         } else{// if (instance == null || !instance.isConnected) {
-
-            MessagingUtils.dataSourceNotAvailableWarningDialog(instance);
+            if (connecting){
+                MessagingUtils.dataSourceNotAvailableWarningDialog(instance);
+            }else{
+                MessagingUtils.noDataSourceWarningDialog(instance);
+            }
 
 
             return null;
         }
     }
+    /**
+     * <p>
+     * getDefault
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
+     */
+    protected static CdmStore getDefault(){
+       return getDefault(false);
+    }
 
     /**
      * Initialize the with the last edited datasource
@@ -200,8 +213,8 @@ public class CdmStore {
         if(isActive()) {
             // before we connect we clear the entity caches and the sessions
             CdmRemoteCacheManager.removeEntityCaches();
-            if(getCurrentSessionManager() != null) {
-                getCurrentSessionManager().disposeAll();
+            if(getCurrentSessionManager(true) != null) {
+                getCurrentSessionManager(true).disposeAll();
             }
         }
         MessagingUtils.info("Connecting to datasource: " + cdmSource);
@@ -342,10 +355,14 @@ public class CdmStore {
             return mockCdmEntitySessionManager;
         }
     }
-
     public static  ICdmEntitySessionManager getCurrentSessionManager() {
-        if (getDefault() != null) {
-            return getDefault().getSessionManager();
+        return getCurrentSessionManager(false);
+    }
+
+
+    public static  ICdmEntitySessionManager getCurrentSessionManager(boolean connecting) {
+        if (getDefault(connecting) != null) {
+            return getDefault(connecting).getSessionManager();
         }
         return null;