@@ -169,11 +169,20 @@ def __process_archive_filename_arg(argument_map):
169
169
else :
170
170
archive_file_name = argument_map [CommandLineArgUtil .ARCHIVE_FILE_SWITCH ]
171
171
archive_dir_name = path_utils .get_parent_directory (archive_file_name )
172
- if os .path .exists (archive_dir_name ) is False :
172
+ if not os .path .exists (archive_dir_name ):
173
173
ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,
174
174
'WLSDPLY-06026' , archive_file_name )
175
175
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
176
176
raise ex
177
+
178
+ # Delete any existing archive file for discoverDomain so that we always start with a fresh zip file.
179
+ archive_file_obj = FileUtils .getCanonicalFile (archive_file_name )
180
+ if archive_file_obj .exists () and not archive_file_obj .delete ():
181
+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,'WLSDPLY-06047' ,
182
+ _program_name , archive_file_name )
183
+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
184
+ raise ex
185
+
177
186
try :
178
187
archive_file = WLSDeployArchive (archive_file_name )
179
188
except (IllegalArgumentException , IllegalStateException ), ie :
@@ -187,23 +196,27 @@ def __process_archive_filename_arg(argument_map):
187
196
188
197
def __process_variable_filename_arg (optional_arg_map ):
189
198
"""
190
- If the variable filename argument is present, the required model variable injector json file must exist in
191
- the WLSDEPLOY lib directory.
199
+ Validate the variable filename argument if present.
192
200
:param optional_arg_map: containing the variable file name
193
- :raises: CLAException: if this argument is present but the model variable injector json does not exist
201
+ :raises: CLAException: if this argument is present but fails validation
194
202
"""
195
203
_method_name = '__process_variable_filename_arg'
196
204
197
205
if CommandLineArgUtil .VARIABLE_FILE_SWITCH in optional_arg_map :
198
- variable_injector_file_name = optional_arg_map [CommandLineArgUtil .VARIABLE_FILE_SWITCH ]
199
- try :
200
- FileUtils . validateWritableFile ( variable_injector_file_name )
201
- except IllegalArgumentException , ie :
206
+ variable_file_name = optional_arg_map [CommandLineArgUtil .VARIABLE_FILE_SWITCH ]
207
+ variable_dir_name = path_utils . get_parent_directory ( variable_file_name )
208
+
209
+ if not os . path . exists ( variable_dir_name ) :
202
210
ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,
203
- 'WLSDPLY-06021' ,
204
- optional_arg_map [CommandLineArgUtil .VARIABLE_FILE_SWITCH ],
205
- variable_injector_file_name ,
206
- ie .getLocalizedMessage (), error = ie )
211
+ 'WLSDPLY-06048' , variable_file_name )
212
+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
213
+ raise ex
214
+
215
+ # Delete any existing variable file for discoverDomain so that we always start with a fresh file.
216
+ variable_file_obj = FileUtils .getCanonicalFile (variable_file_name )
217
+ if variable_file_obj .exists () and not variable_file_obj .delete ():
218
+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,'WLSDPLY-06049' ,
219
+ _program_name , variable_file_name )
207
220
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
208
221
raise ex
209
222
0 commit comments