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
public class AcornDatabase implements Database {
private final Path folder;
+
+ private GraphClientImpl2 currentClient;
private DatabaseUserAgent userAgent;
@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);
}