3232from wlsdeploy .logging .platform_logger import PlatformLogger
3333from wlsdeploy .tool .create .domain_creator import DomainCreator
3434from wlsdeploy .tool .create .domain_typedef import DomainTypedef
35+ from wlsdeploy .tool .util import filter_helper
3536from wlsdeploy .tool .validate .validator import Validator
3637from wlsdeploy .util import getcreds
3738from wlsdeploy .util import variables
6667 CommandLineArgUtil .PASSPHRASE_SWITCH
6768]
6869
70+
6971def __process_args (args ):
7072 """
7173 Process the command-line arguments and prompt the user for any missing information
@@ -95,6 +97,7 @@ def __process_args(args):
9597 domain_typedef .set_model_context (model_context )
9698 return model_context
9799
100+
98101def __verify_required_args_present (required_arg_map ):
99102 """
100103 Verify that the required args are present.
@@ -111,6 +114,7 @@ def __verify_required_args_present(required_arg_map):
111114 raise ex
112115 return
113116
117+
114118def __process_java_home_arg (optional_arg_map ):
115119 """
116120 Verify that java_home is set. If not, set it.
@@ -132,6 +136,7 @@ def __process_java_home_arg(optional_arg_map):
132136 optional_arg_map [CommandLineArgUtil .JAVA_HOME_SWITCH ] = java_home .getAbsolutePath ()
133137 return
134138
139+
135140def __process_model_args (optional_arg_map ):
136141 """
137142 Verify that either the model_file or archive_file was provided and exists.
@@ -176,6 +181,7 @@ def __process_model_args(optional_arg_map):
176181 raise ex
177182 return
178183
184+
179185def __process_rcu_args (optional_arg_map , domain_type , domain_typedef ):
180186 """
181187 Determine if the RCU is needed and validate/prompt for any missing information
@@ -234,6 +240,7 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
234240 raise ex
235241 return
236242
243+
237244def __process_encryption_args (optional_arg_map ):
238245 """
239246 Determine if the user is using our encryption and if so, get the passphrase.
@@ -255,6 +262,7 @@ def __process_encryption_args(optional_arg_map):
255262 optional_arg_map [CommandLineArgUtil .PASSPHRASE_SWITCH ] = String (passphrase )
256263 return
257264
265+
258266def __clean_up_temp_files ():
259267 """
260268 If a temporary directory was created to extract the model from the archive, delete the directory and its contents.
@@ -265,6 +273,28 @@ def __clean_up_temp_files():
265273 FileUtils .deleteDirectory (__tmp_model_dir )
266274 __tmp_model_dir = None
267275
276+
277+ def validate_model (model_dictionary , model_context , aliases ):
278+ _method_name = 'validate_model'
279+
280+ try :
281+ validator = Validator (model_context , aliases , wlst_mode = __wlst_mode )
282+
283+ # no need to pass the variable file for processing, substitution has already been performed
284+ return_code = validator .validate_in_tool_mode (model_dictionary , variables_file_name = None ,
285+ archive_file_name = model_context .get_archive_file_name ())
286+ except ValidateException , ex :
287+ __logger .severe ('WLSDPLY-20000' , _program_name , ex .getLocalizedMessage (), error = ex ,
288+ class_name = _class_name , method_name = _method_name )
289+ __clean_up_temp_files ()
290+ sys .exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
291+
292+ if return_code == Validator .ReturnCode .STOP :
293+ __logger .severe ('WLSDPLY-20001' , _program_name , class_name = _class_name , method_name = _method_name )
294+ __clean_up_temp_files ()
295+ sys .exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
296+
297+
268298def main ():
269299 """
270300 The entry point for the create domain tool.
@@ -306,26 +336,12 @@ def main():
306336 __clean_up_temp_files ()
307337 sys .exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
308338
309- try :
310- aliases = Aliases (model_context , wlst_mode = __wlst_mode )
311- validator = Validator (model_context , aliases , wlst_mode = __wlst_mode )
339+ aliases = Aliases (model_context , wlst_mode = __wlst_mode )
340+ validate_model (model , model_context , aliases )
312341
313- # Since the have already performed all variable substitution,
314- # no need to pass the variable file for processing.
315- #
316- return_code = validator .validate_in_tool_mode (model ,
317- variables_file_name = None ,
318- archive_file_name = model_context .get_archive_file_name ())
319- except ValidateException , ex :
320- __logger .severe ('WLSDPLY-20000' , _program_name , ex .getLocalizedMessage (), error = ex ,
321- class_name = _class_name , method_name = _method_name )
322- __clean_up_temp_files ()
323- sys .exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
324-
325- if return_code == Validator .ReturnCode .STOP :
326- __logger .severe ('WLSDPLY-20001' , _program_name , class_name = _class_name , method_name = _method_name )
327- __clean_up_temp_files ()
328- sys .exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
342+ if filter_helper .apply_filters (model , "create" ):
343+ # if any filters were applied, re-validate the model
344+ validate_model (model , model_context , aliases )
329345
330346 try :
331347 creator = DomainCreator (model , model_context , aliases )
0 commit comments