]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics/src/org/simantics/DatabaseBaselines.java
Removed redundant Files.exists/isDirectory checks
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / DatabaseBaselines.java
index 96db5ed72f46339fb869cbaa25c9bc1f26b8ec5c..fe3393a2c0afd6f7abb7eb522eb22086b9ed4d51 100644 (file)
@@ -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"));
        }