@@ -642,36 +642,36 @@ private Properties loadConfigurationFromClasspath(String fileName) throws Illega
642
642
try {
643
643
// try root
644
644
String currentClasspathSearchLocation = "/ (root)" ;
645
- in = loaders [i ].getResourceAsStream (fileName );
645
+ in = loaders [i ].getResourceAsStream (DefaultSearchPath . ROOT . toString () );
646
646
647
647
// try resourceDirectory folder
648
648
if (in == null ) {
649
649
currentClasspathSearchLocation = resourceDirectory + "/" ;
650
- in = currentLoader .getResourceAsStream (resourceDirectory + "/" + fileName );
650
+ in = currentLoader .getResourceAsStream (DefaultSearchPath . RESOURCE_DIRECTORY + fileName );
651
651
}
652
652
653
653
// try .esapi folder. Look here first for backward compatibility.
654
654
if (in == null ) {
655
655
currentClasspathSearchLocation = ".esapi/" ;
656
- in = currentLoader .getResourceAsStream (".esapi/" + fileName );
656
+ in = currentLoader .getResourceAsStream (DefaultSearchPath . DOT_ESAPI + fileName );
657
657
}
658
658
659
659
// try esapi folder (new directory)
660
660
if (in == null ) {
661
661
currentClasspathSearchLocation = "esapi/" ;
662
- in = currentLoader .getResourceAsStream ("esapi/" + fileName );
662
+ in = currentLoader .getResourceAsStream (DefaultSearchPath . ESAPI + fileName );
663
663
}
664
664
665
665
// try resources folder
666
666
if (in == null ) {
667
667
currentClasspathSearchLocation = "resources/" ;
668
- in = currentLoader .getResourceAsStream ("resources/" + fileName );
668
+ in = currentLoader .getResourceAsStream (DefaultSearchPath . RESOURCES + fileName );
669
669
}
670
670
671
671
// try src/main/resources folder
672
672
if (in == null ) {
673
673
currentClasspathSearchLocation = "src/main/resources/" ;
674
- in = currentLoader .getResourceAsStream ("src/main/resources/" + fileName );
674
+ in = currentLoader .getResourceAsStream (DefaultSearchPath . SRC_MAIN_RESOURCES + fileName );
675
675
}
676
676
677
677
// now load the properties
@@ -1347,4 +1347,26 @@ protected boolean shouldPrintProperties() {
1347
1347
protected Properties getESAPIProperties () {
1348
1348
return properties ;
1349
1349
}
1350
+
1351
+ public enum DefaultSearchPath {
1352
+
1353
+ RESOURCE_DIRECTORY ("resourceDirectory/" ),
1354
+ SRC_MAIN_RESOURCES ("src/main/resources/" ),
1355
+ ROOT ("/" ),
1356
+ DOT_ESAPI (".esapi/" ),
1357
+ ESAPI ("esapi/" ),
1358
+ RESOURCES ("resources/" );
1359
+
1360
+ private final String path ;
1361
+
1362
+
1363
+
1364
+ private DefaultSearchPath (String s ){
1365
+ this .path = s ;
1366
+ }
1367
+
1368
+ public String value (){
1369
+ return path ;
1370
+ }
1371
+ }
1350
1372
}
0 commit comments