X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics%2Fsrc%2Forg%2Fsimantics%2FDatabaseBaselines.java;h=fe3393a2c0afd6f7abb7eb522eb22086b9ed4d51;hb=48bb50bb6640506d1f150ca8e4fa5a6e878464be;hp=96db5ed72f46339fb869cbaa25c9bc1f26b8ec5c;hpb=b913419ca9037bf9734c56a5f079024c3a1cd177;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics/src/org/simantics/DatabaseBaselines.java b/bundles/org.simantics/src/org/simantics/DatabaseBaselines.java index 96db5ed72..fe3393a2c 100644 --- a/bundles/org.simantics/src/org/simantics/DatabaseBaselines.java +++ b/bundles/org.simantics/src/org/simantics/DatabaseBaselines.java @@ -95,7 +95,7 @@ public class DatabaseBaselines { throw new PlatformException("Database location " + db + " already exists. Cannot re-initialize workspace from baseline."); if (REQUIRE_INDEX_IN_BASELINE) { Path index = workspaceLocation.resolve(INDEX_DIRECTORY); - if (!Files.exists(index) || !isEmptyDirectory(index)) + if (Files.exists(index) || !isEmptyDirectory(index)) throw new PlatformException("Index location " + index + " already exists. Cannot re-initialize workspace from baseline."); } } catch (IOException e) { @@ -123,6 +123,17 @@ public class DatabaseBaselines { } } + public static void initializeWorkspaceWithBaseline(Path baseline, Path workspaceLocation, Path indicatorPath) throws PlatformException { + try { + Files.createDirectories(workspaceLocation); + FileUtils.extractZip(baseline.toFile(), workspaceLocation.toFile()); + if (indicatorPath != null) + Files.write(indicatorPath, DatabaseBaselines.baselineIndicatorContents(indicatorPath)); + } catch (IOException e) { + throw new PlatformException(e); + } + } + public static void main(String[] args) throws IOException { packageBaseline(Paths.get("D:/temp/desktop/workspace"), Paths.get("d:/temp/desktop/workspace/baseline.zip")); }