Better error handling if both schemas/ and searchdefintions/ exist
If something fails when having both directories, throw an
InvalidApplicationException with an explanation about what to do
@@ -841,6 +841,7 @@ public class SessionRepository {
File schemasDir = applicationDir.resolve(ApplicationPackage.SCHEMAS_DIR.getRelative()).toFile();
File sdDir = applicationDir.resolve(ApplicationPackage.SEARCH_DEFINITIONS_DIR.getRelative()).toFile();
if (sdDir.exists() && sdDir.isDirectory()) {
+ try {
File[] sdFiles = sdDir.listFiles();
if (sdFiles != null) {
Files.createDirectories(schemasDir.toPath());
@@ -850,6 +851,14 @@ public class SessionRepository {
StandardCopyOption.REPLACE_EXISTING)));
}
Files.delete(sdDir.toPath());
+ } catch (IOException | UncheckedIOException e) {
+ if (schemasDir.exists() && schemasDir.isDirectory())
+ throw new InvalidApplicationException(
+ "Both " + ApplicationPackage.SCHEMAS_DIR.getRelative() + " and " + ApplicationPackage.SEARCH_DEFINITIONS_DIR +
+ " exists in application package, please remove " + ApplicationPackage.SEARCH_DEFINITIONS_DIR, e);
+ else
+ throw e;
+ }
}
}
