1 package org.simantics.db.server;
4 import java.nio.file.Path;
6 import org.simantics.db.Database;
7 import org.simantics.db.exception.SDBException;
8 import org.simantics.db.server.internal.DatabaseI;
9 import org.simantics.db.server.internal.DatabaseManager;
11 public class Auxiliary {
12 public static void ignoreExit(File dbFolder)
13 throws ProCoreException {
14 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
16 throw new ProCoreException("Ignoring exit status did not help.");
18 public static void ignoreProtocol(File dbFolder)
19 throws ProCoreException {
20 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
21 if (!db.ignoreProtocol())
22 throw new ProCoreException("Ignoring protocol version did not help.");
24 public static void copyDatabase(File dbFolder, File dbTo)
25 throws ProCoreException {
26 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
29 public static boolean purgeDatabaseDone(File dbFolder)
30 throws ProCoreException {
31 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
32 return !db.canPurge();
34 public static void purgeDatabase(File dbFolder)
36 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
39 public static void deleteDatabase(File dbFolder)
40 throws ProCoreException {
41 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
42 db.deleteDatabaseFiles();
44 public static void deleteDatabaseFiles(File dbFolder)
45 throws ProCoreException {
46 DatabaseI.deleteDatabaseFiles(dbFolder.toPath());
48 public static boolean canReadJournal(File dbFolder)
49 throws ProCoreException {
50 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
51 Database.Journal j = db.getJournal();
54 public static Path replaceFromJournal(File dbFolder)
56 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
57 db.replaceFromJournal();
58 return dbFolder.toPath();
60 public static Path saveDatabase(File dbFolder)
61 throws ProCoreException {
62 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
63 return db.saveDatabase();
65 public static Path saveDatabase(File dbFolder, Path parent)
66 throws ProCoreException {
67 DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
68 return db.saveDatabase(parent);