]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/EnvironmentRequest.java
Removed extra modules OntologyModule imported to namespace
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / EnvironmentRequest.java
index 2e37adee82f5fa26c98b68e767e3fe9bb346481c..f1f235a887d867cb85cbd75daec743256900bf94 100644 (file)
@@ -15,11 +15,14 @@ import org.simantics.scl.compiler.module.repository.UpdateListener;
 import org.simantics.scl.osgi.SCLOsgi;
 import org.simantics.scl.runtime.SCLContext;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Finds the environment of a model or other index root.
  */
 public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<EnvironmentSpecification, Environment>> {
+    private static final Logger LOGGER = LoggerFactory.getLogger(EnvironmentRequest.class);
 
     public EnvironmentRequest(Resource parameter) {
         super(parameter);
@@ -78,6 +81,7 @@ public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<Enviro
                         }
                     });
                 } catch (DatabaseException e) {
+                    LOGGER.error("Finding environment failed", e);
                     callback.exception(e);
                     return;
                 }
@@ -86,6 +90,7 @@ public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<Enviro
                         environmentSpecification, listener);
             callback.execute(env);
         } catch (ImportFailureException e) {
+            LOGGER.error("Finding environment failed", e);
             callback.exception(new DatabaseException(e));
         }
 
@@ -107,37 +112,42 @@ public abstract class EnvironmentRequest extends UnaryRead<Resource, Pair<Enviro
         else
             mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI
 
-        return Pair.make(environmentSpecification, graph.syncRequest(new ParametrizedPrimitiveRead<String, Environment>(mainModuleUri) {
-
-            UpdateListenerImpl sclListener;
-
-            @Override
-            public void register(ReadGraph graph, Listener<Environment> procedure) {
-
-                SCLContext context = SCLContext.getCurrent();
-                Object oldGraph = context.put("graph", graph);
-                try {
-
-                    if(procedure.isDisposed()) {
-                        getEnvironment(environmentSpecification, procedure, null);
-                    } else {
-                        sclListener = new UpdateListenerImpl(environmentSpecification, procedure);
-                        sclListener.notifyAboutUpdate();
+        try {
+            return Pair.make(environmentSpecification, graph.syncRequest(new ParametrizedPrimitiveRead<String, Environment>(mainModuleUri) {
+    
+                UpdateListenerImpl sclListener;
+    
+                @Override
+                public void register(ReadGraph graph, Listener<Environment> procedure) {
+    
+                    SCLContext context = SCLContext.getCurrent();
+                    Object oldGraph = context.put("graph", graph);
+                    try {
+    
+                        if(procedure.isDisposed()) {
+                            getEnvironment(environmentSpecification, procedure, null);
+                        } else {
+                            sclListener = new UpdateListenerImpl(environmentSpecification, procedure);
+                            sclListener.notifyAboutUpdate();
+                        }
+    
+                    } finally {
+                        context.put("graph", oldGraph);
                     }
-
-                } finally {
-                    context.put("graph", oldGraph);
+    
                 }
-
-            }
-
-            @Override
-            public void unregistered() {
-                if(sclListener != null)
-                    sclListener.stopListening();
-            }
-
-        }));
+    
+                @Override
+                public void unregistered() {
+                    if(sclListener != null)
+                        sclListener.stopListening();
+                }
+    
+            }));
+        } catch(DatabaseException e) {
+            LOGGER.error("Environment request failed", e);
+            throw e;
+        }
     }
 
     @Override