@@ -190,11 +190,7 @@ public static void main(String[] argv) {
190
190
exitWithHelp ();
191
191
}
192
192
193
- try {
194
- checkConfiguration ();
195
- } catch (ConfigurationException e ) {
196
- die (e .getMessage ());
197
- }
193
+ checkConfiguration ();
198
194
199
195
if (awaitProfiler ) {
200
196
pauseToAwaitProfiler ();
@@ -419,6 +415,22 @@ public static void main(String[] argv) {
419
415
}
420
416
}
421
417
418
+ private static void checkConfiguration () {
419
+ if (bareConfig && (env .getConfigURI () == null || env .getConfigURI ().isEmpty ())) {
420
+ die ("Missing webappURI setting" );
421
+ }
422
+
423
+ if (!repositories .isEmpty () && !cfg .isHistoryEnabled ()) {
424
+ die ("Repositories were specified; history is off however" );
425
+ }
426
+
427
+ try {
428
+ cfg .checkConfiguration ();
429
+ } catch (Configuration .ConfigurationException e ) {
430
+ die (e .getMessage ());
431
+ }
432
+ }
433
+
422
434
/**
423
435
* Parse OpenGrok Indexer options
424
436
* This method was created so that it would be easier to write unit
@@ -887,52 +899,6 @@ public static String[] parseOptions(String[] argv) throws ParseException {
887
899
return argv ;
888
900
}
889
901
890
- static class ConfigurationException extends Exception {
891
- static final long serialVersionUID = -1 ;
892
-
893
- public ConfigurationException (String message ) {
894
- super (message );
895
- }
896
- }
897
-
898
- // TODO: move this Configuration
899
- private static void checkConfiguration () throws ConfigurationException {
900
- env = RuntimeEnvironment .getInstance ();
901
-
902
- if (bareConfig && (env .getConfigURI () == null || env .getConfigURI ().isEmpty ())) {
903
- throw new ConfigurationException ("Missing webappURI setting" );
904
- }
905
-
906
- if (!repositories .isEmpty () && !cfg .isHistoryEnabled ()) {
907
- throw new ConfigurationException ("Repositories were specified; history is off however" );
908
- }
909
-
910
- if (cfg .getSourceRoot () == null ) {
911
- throw new ConfigurationException ("Please specify a SRC_ROOT with option -s !" );
912
- }
913
- if (cfg .getDataRoot () == null ) {
914
- throw new ConfigurationException ("Please specify a DATA ROOT path" );
915
- }
916
-
917
- if (!new File (cfg .getSourceRoot ()).canRead ()) {
918
- throw new ConfigurationException ("Source root '" + cfg .getSourceRoot () + "' must be readable" );
919
- }
920
-
921
- if (!new File (cfg .getDataRoot ()).canWrite ()) {
922
- throw new ConfigurationException ("Data root '" + cfg .getDataRoot () + "' must be writable" );
923
- }
924
-
925
- if (!cfg .isHistoryEnabled () && cfg .isHistoryBasedReindex ()) {
926
- LOGGER .log (Level .INFO , "History based reindex is on, however history is off. " +
927
- "History has to be enabled for history based reindex." );
928
- }
929
-
930
- if (!cfg .isHistoryCache () && cfg .isHistoryBasedReindex ()) {
931
- LOGGER .log (Level .INFO , "History based reindex is on, however history cache is off. " +
932
- "History cache has to be enabled for history based reindex." );
933
- }
934
- }
935
-
936
902
private static void die (String message ) {
937
903
System .err .println ("ERROR: " + message );
938
904
System .exit (1 );
0 commit comments