@@ -56,17 +56,30 @@ public static void main(String[] args) {
5656 throw new IllegalStateException ("Model Configs Directory doesn't exists" );
5757 }
5858
59- boolean isVariableConfig = exists (absoluteBasePath + DynamicConfigHelpers .VARIABLE_CONFIG_PATH );
60- boolean isSecurityConfig = exists (absoluteBasePath + DynamicConfigHelpers .SECURITY_CONFIG_PATH );
61- boolean isTableConfig = exists (absoluteBasePath + DynamicConfigHelpers .TABLE_CONFIG_PATH );
59+ readVariableConfig (absoluteBasePath );
60+ if (readSecurityConfig (absoluteBasePath )) {
61+ validateRoleInSecurityConfig (elideSecurityConfig );
62+ }
63+ if (readTableConfig (absoluteBasePath )) {
64+ validateSqlInTableConfig (elideTableConfig );
65+ }
66+
67+ log .info ("Configs Validation Passed!" );
68+ }
6269
70+ private static boolean readVariableConfig (String absoluteBasePath ) {
71+ boolean isVariableConfig = exists (absoluteBasePath + DynamicConfigHelpers .VARIABLE_CONFIG_PATH );
6372 try {
6473 variables = isVariableConfig ? DynamicConfigHelpers .getVaribalesPojo (absoluteBasePath )
6574 : Collections .<String , Object >emptyMap ();
6675 } catch (Exception e ) {
6776 throw new IllegalStateException ("Error while parsing variable config at location: " + absoluteBasePath , e );
6877 }
78+ return isVariableConfig ;
79+ }
6980
81+ private static boolean readSecurityConfig (String absoluteBasePath ) {
82+ boolean isSecurityConfig = exists (absoluteBasePath + DynamicConfigHelpers .SECURITY_CONFIG_PATH );
7083 if (isSecurityConfig ) {
7184 String securityConfigContent = DynamicConfigHelpers
7285 .readConfigFile (new File (absoluteBasePath + DynamicConfigHelpers .SECURITY_CONFIG_PATH ));
@@ -77,10 +90,12 @@ public static void main(String[] args) {
7790 throw new IllegalStateException ("Error while parsing security config at location: " + absoluteBasePath ,
7891 e );
7992 }
80- // Validate Security Config
81- validateRoleInSecurityConfig (elideSecurityConfig );
8293 }
94+ return isSecurityConfig ;
95+ }
8396
97+ private static boolean readTableConfig (String absoluteBasePath ) {
98+ boolean isTableConfig = exists (absoluteBasePath + DynamicConfigHelpers .TABLE_CONFIG_PATH );
8499 if (isTableConfig ) {
85100 Collection <File > tableConfigs = FileUtils .listFiles (
86101 new File (absoluteBasePath + DynamicConfigHelpers .TABLE_CONFIG_PATH ), new String [] { "hjson" },
@@ -99,15 +114,12 @@ public static void main(String[] args) {
99114 } catch (Exception e ) {
100115 throw new IllegalStateException ("Error while parsing table config at location: " + absoluteBasePath , e );
101116 }
102- // Validate Table Config
103- validateSqlInTableConfig (elideTableConfig );
104117 } else {
105118 usage ();
106119 throw new IllegalStateException ("Table Configs Directory doesn't exists at location: " + absoluteBasePath
107120 + DynamicConfigHelpers .TABLE_CONFIG_PATH );
108121 }
109-
110- log .info ("Configs Validation Passed!" );
122+ return isTableConfig ;
111123 }
112124
113125 private static boolean exists (String filePath ) {
@@ -120,8 +132,7 @@ private static void validateConfigForMissingVariables(String config, Map<String,
120132 while (regexMatcher .find ()) {
121133 String str = regexMatcher .group (1 ).trim ();
122134 if (!variables .containsKey (str )) {
123- throw new IllegalStateException (str
124- + " is used as a variable in either table or security config files "
135+ throw new IllegalStateException (str + " is used as a variable in either table or security config files "
125136 + "but is not defined in variables config file." );
126137 }
127138 }
0 commit comments