| ... |
... |
@@ -356,7 +356,7 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
356
|
356
|
// 1 - user data directory
|
|
357
|
357
|
|
|
358
|
358
|
File dataDirectory = createDirectory(ClientConfigOption.DATA_DIRECTORY);
|
|
359
|
|
- log.debug("user data directory : " + dataDirectory);
|
|
|
359
|
+ log.debug("user data directory : {}", dataDirectory);
|
|
360
|
360
|
createParentDirectory(ClientConfigOption.DB_DIRECTORY);
|
|
361
|
361
|
createParentDirectory(ClientConfigOption.INITIAL_DB_DUMP);
|
|
362
|
362
|
|
| ... |
... |
@@ -370,14 +370,19 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
370
|
370
|
|
|
371
|
371
|
createDirectory(ClientConfigOption.TEMPORARY_DIRECTORY);
|
|
372
|
372
|
|
|
373
|
|
- // 3 - backup directory
|
|
|
373
|
+ // 3 - backup / import / avdth directory
|
|
374
|
374
|
|
|
375
|
|
- createDirectory(ClientConfigOption.BACKUP_DIRECTORY);
|
|
|
375
|
+ boolean saveConfiguration = initBackupDirectory();
|
|
|
376
|
+ saveConfiguration |= initImportDirectory() ;
|
|
|
377
|
+ saveConfiguration |= initAvdthDirectory() ;
|
|
|
378
|
+ if (saveConfiguration) {
|
|
|
379
|
+ saveForUser();
|
|
|
380
|
+ }
|
|
376
|
381
|
|
|
377
|
382
|
// 4 - resources directory
|
|
378
|
383
|
|
|
379
|
384
|
File resourcesDirectory = createDirectory(ClientConfigOption.RESOURCES_DIRECTORY);
|
|
380
|
|
- log.debug("user resource data directory : " + resourcesDirectory);
|
|
|
385
|
+ log.debug("user resource data directory : {}", resourcesDirectory);
|
|
381
|
386
|
createParentDirectory(ClientConfigOption.SWING_PREFERENCES_FILE);
|
|
382
|
387
|
|
|
383
|
388
|
// 5 - resources report
|
| ... |
... |
@@ -486,6 +491,44 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
486
|
491
|
return gsonSupplier == null ? gsonSupplier = new DtoGsonSupplier(true) : gsonSupplier;
|
|
487
|
492
|
}
|
|
488
|
493
|
|
|
|
494
|
+ private boolean initBackupDirectory() {
|
|
|
495
|
+ String defaultDirectory = get().replaceRecursiveOptions(ClientConfigOption.BACKUP_DIRECTORY.getDefaultValue());
|
|
|
496
|
+ String currentDirectory = getBackupDirectory().getAbsolutePath();
|
|
|
497
|
+ if (defaultDirectory.equals(currentDirectory)) {
|
|
|
498
|
+ createDirectory(ClientConfigOption.BACKUP_DIRECTORY);
|
|
|
499
|
+ } else {
|
|
|
500
|
+ if (Files.notExists(getBackupDirectory().toPath())) {
|
|
|
501
|
+ log.warn("Setting back backup directory to {} (since previous location does not exist any longer ({}).", defaultDirectory, currentDirectory);
|
|
|
502
|
+ setBackupDirectory(new File(defaultDirectory));
|
|
|
503
|
+ createDirectory(ClientConfigOption.BACKUP_DIRECTORY);
|
|
|
504
|
+ return true;
|
|
|
505
|
+ }
|
|
|
506
|
+ }
|
|
|
507
|
+ return false;
|
|
|
508
|
+ }
|
|
|
509
|
+
|
|
|
510
|
+ private boolean initImportDirectory() {
|
|
|
511
|
+ String defaultDirectory = get().replaceRecursiveOptions(ClientConfigOption.IMPORT_DIRECTORY.getDefaultValue());
|
|
|
512
|
+ String currentDirectory = getImportDirectory().getAbsolutePath();
|
|
|
513
|
+ if (!defaultDirectory.equals(currentDirectory) && Files.notExists(getImportDirectory().toPath())) {
|
|
|
514
|
+ log.warn("Setting back import directory to {} (since previous location does not exist any longer ({}).", defaultDirectory, currentDirectory);
|
|
|
515
|
+ setImportDirectory(new File(defaultDirectory));
|
|
|
516
|
+ return true;
|
|
|
517
|
+ }
|
|
|
518
|
+ return false;
|
|
|
519
|
+ }
|
|
|
520
|
+
|
|
|
521
|
+ private boolean initAvdthDirectory() {
|
|
|
522
|
+ String defaultDirectory = get().replaceRecursiveOptions(ClientConfigOption.AVDTH_DIRECTORY.getDefaultValue());
|
|
|
523
|
+ String currentDirectory = getAvdthDirectory().getAbsolutePath();
|
|
|
524
|
+ if (!defaultDirectory.equals(currentDirectory) && Files.notExists(getImportDirectory().toPath())) {
|
|
|
525
|
+ log.warn("Setting back avdth directory to {} (since previous location does not exist any longer ({}).", defaultDirectory, currentDirectory);
|
|
|
526
|
+ setAvdthDirectory(new File(defaultDirectory));
|
|
|
527
|
+ return true;
|
|
|
528
|
+ }
|
|
|
529
|
+ return false;
|
|
|
530
|
+ }
|
|
|
531
|
+
|
|
489
|
532
|
private void removeSnapshotFromVersion() {
|
|
490
|
533
|
Version version = Objects.requireNonNull(getBuildVersion());
|
|
491
|
534
|
if (version.isSnapshot()) {
|
| ... |
... |
@@ -510,7 +553,7 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
510
|
553
|
{
|
|
511
|
554
|
String content = old.getProperty("serverDataSourceConfigurations");
|
|
512
|
555
|
if (content != null && Files.notExists(getServerDataSourceConfigurationsFile().toPath())) {
|
|
513
|
|
- log.info("Migrates serverDataSourceConfigurations to: " + getServerDataSourceConfigurationsFile().toPath());
|
|
|
556
|
+ log.info("Migrates serverDataSourceConfigurations to: {}", getServerDataSourceConfigurationsFile().toPath());
|
|
514
|
557
|
ServerDataSourceConfiguration[] data = getGsonSupplier().get().fromJson(content, ServerDataSourceConfiguration[].class);
|
|
515
|
558
|
setServerDataSourceConfigurations(Arrays.asList(data));
|
|
516
|
559
|
}
|
| ... |
... |
@@ -518,7 +561,7 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
518
|
561
|
{
|
|
519
|
562
|
String content = old.getProperty("remoteDataSourceConfigurations");
|
|
520
|
563
|
if (content != null && Files.notExists(getRemoteDataSourceConfigurationsFile().toPath())) {
|
|
521
|
|
- log.info("Migrates remoteDataSourceConfigurations to: " + getRemoteDataSourceConfigurationsFile().toPath());
|
|
|
564
|
+ log.info("Migrates remoteDataSourceConfigurations to: {}", getRemoteDataSourceConfigurationsFile().toPath());
|
|
522
|
565
|
RemoteDataSourceConfiguration[] data = getGsonSupplier().get().fromJson(content, RemoteDataSourceConfiguration[].class);
|
|
523
|
566
|
setRemoteDataSourceConfigurations(Arrays.asList(data));
|
|
524
|
567
|
}
|
| ... |
... |
@@ -701,7 +744,7 @@ public class ClientConfig extends GeneratedClientConfig implements TripMapConfig |
|
701
|
744
|
Date now = new Date();
|
|
702
|
745
|
String day = String.format("%1$tF", now);
|
|
703
|
746
|
feedBackDirectoryFile = getFeedBackDirectory().toPath().resolve(day).toFile();
|
|
704
|
|
- log.info("Create Feedback directory: " + feedBackDirectoryFile);
|
|
|
747
|
+ log.info("Create Feedback directory: {}", feedBackDirectoryFile);
|
|
705
|
748
|
}
|
|
706
|
749
|
return feedBackDirectoryFile;
|
|
707
|
750
|
}
|