]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.server/src/org/simantics/db/server/Auxiliary.java
View for used SCL expressions
[simantics/platform.git] / bundles / org.simantics.db.server / src / org / simantics / db / server / Auxiliary.java
1 package org.simantics.db.server;
2
3 import java.io.File;
4 import java.nio.file.Path;
5
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;
10
11 public class Auxiliary {
12     public static void ignoreExit(File dbFolder)
13     throws ProCoreException {
14         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
15         if (!db.ignoreExit())
16             throw new ProCoreException("Ignoring exit status did not help.");
17     }
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.");
23     }
24     public static void copyDatabase(File dbFolder, File dbTo)
25     throws ProCoreException {
26         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
27         db.copy(dbTo);
28     }
29     public static boolean purgeDatabaseDone(File dbFolder)
30     throws ProCoreException {
31         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
32         return !db.canPurge();
33     }
34     public static void purgeDatabase(File dbFolder)
35     throws SDBException {
36         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
37         db.purge();
38     }
39     public static void deleteDatabase(File dbFolder)
40     throws ProCoreException {
41         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
42         db.deleteDatabaseFiles();
43     }
44     public static void deleteDatabaseFiles(File dbFolder)
45     throws ProCoreException {
46         DatabaseI.deleteDatabaseFiles(dbFolder.toPath());
47     }
48     public static boolean canReadJournal(File dbFolder)
49     throws ProCoreException {
50         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
51         Database.Journal j = db.getJournal();
52         return j.canRead();
53     }
54     public static Path replaceFromJournal(File dbFolder)
55     throws SDBException {
56         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
57         db.replaceFromJournal();
58         return dbFolder.toPath();
59     }
60     public static Path saveDatabase(File dbFolder)
61     throws ProCoreException {
62         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
63         return db.saveDatabase();
64     }
65     public static Path saveDatabase(File dbFolder, Path parent)
66     throws ProCoreException {
67         DatabaseI db = DatabaseManager.getDatabase(dbFolder.toPath());
68         return db.saveDatabase(parent);
69     }
70 }