X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Finternal%2FAcornDatabase.java;h=1025cc6a5dac0a2e6d5b940b1ad0d17ba971fa00;hp=be505c6039712e322ce80ffa653c1b4c6babac13;hb=c26409b1caf2f1e560d37c5befd11b442399c3fe;hpb=43ddca759254b8e38029c1041d91cbdd7890c9b5 diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java index be505c603..1025cc6a5 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java @@ -19,7 +19,10 @@ import org.simantics.db.Database; import org.simantics.db.DatabaseUserAgent; import org.simantics.db.ServiceLocator; import org.simantics.db.common.utils.Logger; +import org.simantics.db.exception.SDBException; +import org.simantics.db.server.DatabaseStartException; import org.simantics.db.server.ProCoreException; +import org.simantics.db.server.internal.InternalException; /** * @author Tuukka Lehtonen @@ -27,6 +30,8 @@ import org.simantics.db.server.ProCoreException; public class AcornDatabase implements Database { private final Path folder; + + private GraphClientImpl2 currentClient; private DatabaseUserAgent userAgent; @@ -190,22 +195,22 @@ public class AcornDatabase implements Database { @Override public void purgeDatabase() throws ProCoreException { - // TODO: implement - throw new UnsupportedOperationException(); + if(currentClient == null) throw new IllegalStateException("No current session."); + currentClient.purgeDatabase(); } @Override public long serverGetTailChangeSetId() throws ProCoreException { - // "We have it all" - // But after purging we don't so beware. - // TODO: beware for purge - return 1; + if(currentClient == null) throw new IllegalStateException("No current session."); + return currentClient.getTailChangeSetId(); } @Override public Session newSession(ServiceLocator locator) throws ProCoreException { try { - return new GraphClientImpl2(this, folder, locator); + if(currentClient != null) throw new DatabaseStartException(folder.toFile(), "A session is already running. Only one session is supported."); + currentClient = new GraphClientImpl2(this, folder, locator); + return currentClient; } catch (IOException e) { throw new ProCoreException(e); }