import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.InvalidResourceReferenceException;
import org.simantics.db.indexing.IndexedRelationsSearcherBase.State;
+import org.simantics.db.indexing.exception.IndexingException;
import org.simantics.db.layer0.adapter.GenericRelation;
import org.simantics.db.layer0.genericrelation.IndexException;
import org.simantics.db.layer0.genericrelation.IndexedRelations;
// 3. something was wrong, but the index has been successfully cleaned
}
- if(!searcher.checkState(State.NONE))
- throw new IndexException("Illegal searcher state, contact application support.");
-
+ searcher.assertState(State.NONE);
+
// We loop until the index is loaded
while(true) {
searcher.startAccess(null, graph.getSession(), false);
// At this point we have three options:
// 1. we have access
- if(searcher.hasAccess(false)) loaded = true;
+ if(searcher.hasAccess(false))
+ loaded = true;
// 2. something is wrong and the index cannot be cleaned
- if(searcher.checkState(State.PROBLEM)) throw new DatabaseException("Searcher is in problematic state", searcher.getException());
+ if(searcher.checkState(State.PROBLEM))
+ throw new IndexingException("Searcher is in problematic state", searcher.getException());
// 3. something was wrong, but the index has been successfully cleaned
}
if(!loaded) {
if(!searcher.checkState(State.NONE))
- throw new DatabaseException("Illegal searcher state, contact application support.");
+ throw new IndexingException("Illegal searcher state " + searcher.state());
try {
SerialisationSupport ss = graph.getService(SerialisationSupport.class);
searcher.setReady();
} catch (IOException e) {
searcher.setProblem(e);
- throw new DatabaseException(e);
+ throw new IndexingException(e);
}
}
}
if(!success)
- throw new IndexException("Did not manage to load index. Contact application support.");
+ throw new IndexException("Did not manage to load index.");
// Try again
if (searcher.isIndexAvailable()) {
searcher.startAccess(progress.newChild(50), processor.getSession(), false);
if(searcher.hasAccess(false)) return lock;
- throw new IndexException("Illegal searcher state, contact application support.");
+ throw new IndexException("Illegal searcher state " + searcher.state());
}
}
try {
fullRebuild(monitor, graph);
} catch (IOException e) {
- throw new DatabaseException(e);
+ throw new IndexingException(e);
}
}
});
GenericRelation r = graph.adapt(relation, GenericRelation.class);
if (r == null)
- throw new DatabaseException("Given resource " + relation + "could not be adapted to GenericRelation.");
+ throw new IndexingException("Given resource " + relation + "could not be adapted to GenericRelation.");
Object[] bound = new Object[] { ss.getRandomAccessId(indexRoot) };
GenericRelation selection = r.select(IndexedRelationsSearcherBase.getPattern(r, bound.length), bound);