+ private static Path tryGetInstallLocation() {
+ Location l = Platform.getInstallLocation();
+ return l == null ? null : new File(l.getURL().getPath()).toPath();
+ }
+
+ private Path resolveBaselineFile() throws PlatformException {
+ String dbBaselineArchive = System.getProperty("org.simantics.db.baseline", null);
+ if (dbBaselineArchive == null)
+ return null;
+
+ Path baseline = Paths.get(dbBaselineArchive);
+ if (baseline.isAbsolute()) {
+ if (!Files.isRegularFile(baseline))
+ throw new PlatformException("Specified database baseline archive " + baseline
+ + " does not exist. Cannot initialize workspace database from baseline.");
+ return baseline;
+ }
+
+ // Relative path resolution order:
+ // 1. from the platform "install location"
+ // 2. from working directory
+ Path installLocation = tryGetInstallLocation();
+ if (installLocation != null) {
+ Path installedBaseline = installLocation.resolve(dbBaselineArchive);
+ if (Files.isRegularFile(installedBaseline))
+ return installedBaseline;
+ }
+ if (!Files.isRegularFile(baseline))
+ throw new PlatformException("Specified database baseline archive " + baseline
+ + " does not exist in either the install location (" + installLocation
+ + ") or the working directory (" + Paths.get(".").toAbsolutePath()
+ + "). Cannot initialize workspace database.");
+ return null;
+ }
+
+ private boolean handleBaselineDatabase() throws PlatformException {