@@ -134,17 +134,18 @@ def get_variable_names(text):
134134 return names
135135
136136
137- def substitute (dictionary , variables , model_context ):
137+ def substitute (dictionary , variables , model_context , validation_result = None ):
138138 """
139139 Substitute fields in the specified dictionary with variable values.
140140 :param dictionary: the dictionary in which to substitute variables
141141 :param variables: a dictionary of variables for substitution
142142 :param model_context: used to resolve variables in file paths
143143 """
144- _process_node (dictionary , variables , model_context )
144+ _process_node (dictionary , variables , model_context , validation_result )
145+ return validation_result
145146
146147
147- def _process_node (nodes , variables , model_context ):
148+ def _process_node (nodes , variables , model_context , validation_result ):
148149 """
149150 Process variables in the node.
150151 :param nodes: the dictionary to process
@@ -160,18 +161,18 @@ def _process_node(nodes, variables, model_context):
160161 value = nodes [key ]
161162
162163 # if the key changes with substitution, remove old key and map value to new key
163- new_key = _substitute (key , variables , model_context )
164+ new_key = _substitute (key , variables , model_context , validation_result )
164165 if new_key is not key :
165166 nodes .pop (key )
166167 nodes [new_key ] = value
167168
168169 if isinstance (value , dict ):
169- _process_node (value , variables , model_context )
170+ _process_node (value , variables , model_context , validation_result )
170171 elif type (value ) is str :
171- nodes [key ] = _substitute (value , variables , model_context )
172+ nodes [key ] = _substitute (value , variables , model_context , validation_result )
172173
173174
174- def _substitute (text , variables , model_context ):
175+ def _substitute (text , variables , model_context , validation_result ):
175176 """
176177 Substitute the variable placeholders with the variable value.
177178 :param text: the text to process for variable placeholders
@@ -204,17 +205,25 @@ def _substitute(text, variables, model_context):
204205 key = token [7 :- 2 ]
205206 # for @@PROP:key@@ variables, throw an exception if key is not found.
206207 if key not in variables :
207- ex = exception_helper .create_variable_exception ('WLSDPLY-01732' , key )
208- _logger .throwing (ex , class_name = _class_name , method_name = method_name )
209- raise ex
208+ if model_context .get_validation_method () == 'strict' :
209+ if validation_result :
210+ validation_result .add_error ('WLSDPLY-01732' , key )
211+ ex = exception_helper .create_variable_exception ('WLSDPLY-01732' , key )
212+ _logger .throwing (ex , class_name = _class_name , method_name = method_name )
213+ raise ex
214+ else :
215+ if validation_result :
216+ validation_result .add_info ('WLSDPLY-01732' , key )
217+ continue
218+
210219 value = variables [key ]
211220 text = text .replace (token , value )
212221
213222 tokens = _file_variable_pattern .findall (text )
214223 if tokens :
215224 for token in tokens :
216225 path = token [7 :- 2 ]
217- value = _read_value_from_file (path )
226+ value = _read_value_from_file (path , model_context , validation_result )
218227 text = text .replace (token , value )
219228
220229 # special case for @@FILE:@@ORACLE_HOME@@/dir/name.txt@@
@@ -223,13 +232,13 @@ def _substitute(text, variables, model_context):
223232 for token in tokens :
224233 path = token [7 :- 2 ]
225234 path = model_context .replace_token_string (path )
226- value = _read_value_from_file (path )
235+ value = _read_value_from_file (path , model_context , validation_result )
227236 text = text .replace (token , value )
228237
229238 return text
230239
231240
232- def _read_value_from_file (file_path ):
241+ def _read_value_from_file (file_path , model_context , validation_result ):
233242 """
234243 Read a single text value from the first line in the specified file.
235244 :param file_path: the file from which to read the value
@@ -243,9 +252,18 @@ def _read_value_from_file(file_path):
243252 line = file_reader .readLine ()
244253 file_reader .close ()
245254 except IOException , e :
246- ex = exception_helper .create_variable_exception ('WLSDPLY-01733' , file_path , e .getLocalizedMessage (), error = e )
247- _logger .throwing (ex , class_name = _class_name , method_name = method_name )
248- raise ex
255+ if model_context .get_validation_method () == 'strict' :
256+ if validation_result :
257+ validation_result .add_error ('WLSDPLY-01733' , file_path , e .getLocalizedMessage ())
258+ ex = exception_helper .create_variable_exception ('WLSDPLY-01733' , file_path , e .getLocalizedMessage (), error = e )
259+ _logger .throwing (ex , class_name = _class_name , method_name = method_name )
260+ raise ex
261+ else :
262+ if validation_result :
263+ validation_result .add_info ('WLSDPLY-01733' , file_path , e .getLocalizedMessage ())
264+ _logger .info ('WLSDPLY-01733' , file_path , e .getLocalizedMessage (), error = e ,
265+ class_name = _class_name , method_name = method_name )
266+ line = ''
249267
250268 if line is None :
251269 ex = exception_helper .create_variable_exception ('WLSDPLY-01734' , file_path )
0 commit comments