Skip to content

Commit 9f20909

Browse files
committed
CLI folder fix.
1 parent 923065d commit 9f20909

File tree

1 file changed

+12
-4
lines changed
  • jsonvalidator-jar/src/main/java/eu/europa/ec/itb/json/standalone

1 file changed

+12
-4
lines changed

jsonvalidator-jar/src/main/java/eu/europa/ec/itb/json/standalone/Application.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,27 @@ public static void main(String[] args) throws IOException {
2424
System.out.print("Starting validator ...");
2525
File tempFolder = Files.createTempDirectory("jsonvalidator").toFile();
2626
Runtime.getRuntime().addShutdownHook(new Thread(() -> FileUtils.deleteQuietly(tempFolder)));
27+
// Setup folders - start
28+
File resourceFolder = new File(tempFolder, "resources");
29+
File logFolder = new File(tempFolder, "logs");
30+
File workFolder = new File(tempFolder, "work");
31+
if (!resourceFolder.mkdirs() || !logFolder.mkdirs() || !workFolder.mkdirs()) {
32+
throw new IllegalStateException("Unable to create work directories under ["+tempFolder.getAbsolutePath()+"]");
33+
}
2734
// Set the resource root so that it can be used. This is done before app startup to avoid PostConstruct issues.
28-
String resourceRoot = tempFolder.getAbsolutePath();
35+
String resourceRoot = resourceFolder.getAbsolutePath();
2936
if (!resourceRoot.endsWith(File.separator)) {
3037
resourceRoot += File.separator;
3138
}
39+
System.setProperty("LOG_PATH", logFolder.getAbsolutePath());
40+
System.setProperty("validator.tmpFolder", workFolder.getAbsolutePath());
3241
System.setProperty("validator.resourceRoot", resourceRoot);
33-
prepareConfigForStandalone(tempFolder);
42+
// Setup folders - end
43+
prepareConfigForStandalone(resourceFolder);
3444
// Start the application.
3545
ApplicationContext ctx = SpringApplication.run(Application.class, args);
3646
// Post process config.
3747
ApplicationConfig config = ctx.getBean(ApplicationConfig.class);
38-
// Set report folder for use as a temp file generation target.
39-
config.setTmpFolder(tempFolder.getAbsolutePath());
4048
System.out.println(" Done.");
4149
try {
4250
ValidationRunner runner = ctx.getBean(ValidationRunner.class);

0 commit comments

Comments
 (0)