|
|
@ -95,12 +95,15 @@ class LocationResourceLoader {
|
|
|
|
validatePattern(location, type);
|
|
|
|
validatePattern(location, type);
|
|
|
|
String directoryPath = location.substring(0, location.indexOf("*/"));
|
|
|
|
String directoryPath = location.substring(0, location.indexOf("*/"));
|
|
|
|
String fileName = location.substring(location.lastIndexOf("/") + 1);
|
|
|
|
String fileName = location.substring(location.lastIndexOf("/") + 1);
|
|
|
|
Resource directoryResource = getResource(directoryPath);
|
|
|
|
Resource resource = getResource(directoryPath);
|
|
|
|
if (!directoryResource.exists()) {
|
|
|
|
if (!resource.exists()) {
|
|
|
|
return new Resource[] { directoryResource };
|
|
|
|
return EMPTY_RESOURCES;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
File file = getFile(location, resource);
|
|
|
|
|
|
|
|
if (!file.isDirectory()) {
|
|
|
|
|
|
|
|
return EMPTY_RESOURCES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
File directory = getDirectory(location, directoryResource);
|
|
|
|
File[] subDirectories = file.listFiles(this::isVisibleDirectory);
|
|
|
|
File[] subDirectories = directory.listFiles(this::isVisibleDirectory);
|
|
|
|
|
|
|
|
if (subDirectories == null) {
|
|
|
|
if (subDirectories == null) {
|
|
|
|
return EMPTY_RESOURCES;
|
|
|
|
return EMPTY_RESOURCES;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -131,11 +134,9 @@ class LocationResourceLoader {
|
|
|
|
Assert.state(directoryPath.endsWith("*/"), () -> String.format("Location '%s' must end with '*/'", location));
|
|
|
|
Assert.state(directoryPath.endsWith("*/"), () -> String.format("Location '%s' must end with '*/'", location));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private File getDirectory(String patternLocation, Resource resource) {
|
|
|
|
private File getFile(String patternLocation, Resource resource) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
File directory = resource.getFile();
|
|
|
|
return resource.getFile();
|
|
|
|
Assert.state(directory.isDirectory(), () -> "'" + directory + "' is not a directory");
|
|
|
|
|
|
|
|
return directory;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
catch (Exception ex) {
|
|
|
|
throw new IllegalStateException(
|
|
|
|
throw new IllegalStateException(
|
|
|
|