]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcher.java
Replace instantiations of DatabaseException in indexing
[simantics/platform.git] / bundles / org.simantics.db.indexing / src / org / simantics / db / indexing / IndexedRelationsSearcher.java
index 115e54595585bafe2b3b5ca88a9e0c2f2bee4c03..2e714b09a9c1d9cded563c6279011de70175c1c4 100644 (file)
@@ -25,15 +25,20 @@ import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.indexing.exception.IndexingException;
 import org.simantics.db.layer0.adapter.GenericRelation;
 import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author Tuukka Lehtonen
  * @author Antti Villberg
  */
 public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
-    
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsSearcher.class);
+
     IndexedRelationsMemorySearcher cache;
 
     IndexedRelationsSearcher(RequestProcessor session, Resource relation, Resource input, GenericRelation r) throws DatabaseException {
@@ -98,7 +103,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
                     } else if ("String".equals(fieldClass) || "Text".equals(fieldClass)) {
                         data[index++] = "";
                     } else {
-                        throw new DatabaseException("Can only index Long and String fields, encountered class " + fieldClass);
+                        throw new IndexingException("Can only index Long and String fields, encountered class " + fieldClass);
                     }
                 }
             }
@@ -122,11 +127,11 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
     }
     
     List<Map<String, Object>> persistentCachedSearch(IProgressMonitor monitor, RequestProcessor processor, String search,
-            int maxResultCount) throws ParseException, IOException, DatabaseException {
+            int maxResultCount) throws ParseException, IOException, IndexingException {
         
        MemoryIndexing mem = MemoryIndexing.getInstance(session.getSession());
        
-        String key = indexPath.getAbsolutePath();
+        String key = indexPath.toAbsolutePath().toString();
         
         Map<String,List<Map<String, Object>>> cache = mem.persistentCache.get(key);
         if(cache != null) {
@@ -150,11 +155,11 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
     }
 
     List<Resource> persistentCachedSearchResources(IProgressMonitor monitor, RequestProcessor processor, String search,
-            int maxResultCount) throws ParseException, IOException, DatabaseException {
+            int maxResultCount) throws ParseException, IOException, IndexingException {
         
        MemoryIndexing mem = MemoryIndexing.getInstance(session.getSession());
        
-        String key = indexPath.getAbsolutePath();
+        String key = indexPath.toAbsolutePath().toString();
         
         Map<String,List<Resource>> cache = mem.persistentCacheResources.get(key);
         if(cache != null) {
@@ -177,7 +182,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
         
     }
     
-    List<Object> persistentCachedList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, DatabaseException {
+    List<Object> persistentCachedList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, IndexingException {
         
         startAccess(monitor, processor.getSession(), false);
 
@@ -189,7 +194,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
     
     @Override
     List<Map<String, Object>> doSearch(IProgressMonitor monitor, RequestProcessor processor, String search,
-            int maxResultCount) throws ParseException, IOException, DatabaseException {
+            int maxResultCount) throws ParseException, IOException, IndexingException {
         
         List<Map<String,Object>> persistent = persistentCachedSearch(monitor, processor, search, maxResultCount);
         List<Map<String,Object>> cached = cache.doSearch(monitor, processor, search, maxResultCount);
@@ -209,7 +214,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
     
     @Override
     List<Resource> doSearchResources(IProgressMonitor monitor, RequestProcessor processor, String search,
-               int maxResultCount) throws ParseException, IOException, DatabaseException {
+               int maxResultCount) throws ParseException, IOException, IndexingException {
 
         List<Resource> persistent = persistentCachedSearchResources(monitor, processor, search, maxResultCount);
         List<Resource> cached = cache.doSearchResources(monitor, processor, search, maxResultCount);
@@ -225,7 +230,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
        
     }
     
-    List<Object> doList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, DatabaseException {
+    List<Object> doList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, IndexingException {
 
         List<Object> persistent = persistentCachedList(monitor, processor);
         
@@ -280,7 +285,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
         t = cache.bestEffortClear(monitor, session);
         if(t != null) return t;
         
-        String key = indexPath.getAbsolutePath();
+        String key = indexPath.toAbsolutePath().toString();
         MemoryIndexing mem = MemoryIndexing.getInstance(session);
         mem.persistentCache.remove(key);
         mem.persistentCacheResources.remove(key);
@@ -288,5 +293,10 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase {
         return null;
         
     }
+
+    @Override
+    protected Logger getLogger() {
+        return LOGGER;
+    }
     
 }