21
21
from wlsdeploy .aliases .alias_constants import PASSWORD_TOKEN
22
22
from wlsdeploy .aliases import model_constants
23
23
from wlsdeploy .aliases .location_context import LocationContext
24
+ from wlsdeploy .aliases .model_constants import PLAN_DIR
25
+ from wlsdeploy .aliases .model_constants import PLAN_PATH
26
+ from wlsdeploy .aliases .model_constants import SOURCE_PATH
24
27
from wlsdeploy .aliases .wlst_modes import WlstModes
25
28
from wlsdeploy .exception import exception_helper
26
29
from wlsdeploy .logging .platform_logger import PlatformLogger
@@ -299,49 +302,48 @@ def _add_application_to_archive(self, application_name, application_dict):
299
302
_logger .entering (application_name , class_name = _class_name , method_name = _method_name )
300
303
301
304
archive_file = self ._model_context .get_archive_file ()
302
- if model_constants .SOURCE_PATH in application_dict :
303
- file_name = application_dict [model_constants .SOURCE_PATH ]
304
- if file_name :
305
- file_name_path = file_name
306
- if not self ._model_context .is_remote ():
307
- file_name_path = self ._convert_path (file_name )
308
- if self ._is_file_to_exclude_from_archive (file_name_path ):
309
- _logger .info ('WLSDPLY-06393' , application_name ,
305
+ file_name = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , SOURCE_PATH )
306
+ if file_name is not None :
307
+ file_name_path = file_name
308
+ if not self ._model_context .is_remote ():
309
+ file_name_path = self ._convert_path (file_name )
310
+ if self ._is_file_to_exclude_from_archive (file_name_path ):
311
+ _logger .info ('WLSDPLY-06393' , application_name ,
312
+ class_name = _class_name , method_name = _method_name )
313
+ else :
314
+ new_source_name = None
315
+ if self ._model_context .is_remote ():
316
+ new_source_name = WLSDeployArchive .getApplicationArchivePath (file_name_path )
317
+ self .add_to_remote_map (file_name_path , new_source_name ,
318
+ WLSDeployArchive .ArchiveEntryType .APPLICATION .name ())
319
+ elif not self ._model_context .is_skip_archive ():
320
+ _logger .info ('WLSDPLY-06394' , application_name , file_name_path ,
310
321
class_name = _class_name , method_name = _method_name )
311
- else :
312
- new_source_name = None
313
- if self ._model_context .is_remote ():
314
- new_source_name = WLSDeployArchive .getApplicationArchivePath (file_name_path )
315
- self .add_to_remote_map (file_name_path , new_source_name ,
316
- WLSDeployArchive .ArchiveEntryType .APPLICATION .name ())
317
- elif not self ._model_context .is_skip_archive ():
318
- _logger .info ('WLSDPLY-06394' , application_name , file_name_path ,
319
- class_name = _class_name , method_name = _method_name )
320
- try :
321
- if self ._model_context .is_ssh ():
322
- file_name_path = \
323
- self .download_deployment_from_remote_server (file_name_path ,
324
- self .download_temporary_dir ,
325
- "applications" )
326
-
327
- new_source_name = archive_file .addApplication (file_name_path )
328
- module_type = dictionary_utils .get_dictionary_element (application_dict ,
329
- model_constants .MODULE_TYPE )
330
- if module_type == 'jdbc' :
331
- self ._jdbc_password_fix (new_source_name )
332
-
333
- except IllegalArgumentException , iae :
334
- self ._disconnect_target (application_name , application_dict , iae .getLocalizedMessage ())
335
- except WLSDeployArchiveIOException , wioe :
336
- de = exception_helper .create_discover_exception ('WLSDPLY-06397' , application_name ,
337
- file_name_path , wioe .getLocalizedMessage ())
338
- _logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
339
- raise de
340
- if new_source_name is not None :
341
- _logger .finer ('WLSDPLY-06398' , application_name , new_source_name , class_name = _class_name ,
342
- method_name = _method_name )
343
- application_dict [model_constants .SOURCE_PATH ] = new_source_name
344
- self .add_application_plan_to_archive (application_name , application_dict )
322
+ try :
323
+ if self ._model_context .is_ssh ():
324
+ file_name_path = \
325
+ self .download_deployment_from_remote_server (file_name_path ,
326
+ self .download_temporary_dir ,
327
+ "applications" )
328
+
329
+ new_source_name = archive_file .addApplication (file_name_path )
330
+ module_type = dictionary_utils .get_dictionary_element (application_dict ,
331
+ model_constants .MODULE_TYPE )
332
+ if module_type == 'jdbc' :
333
+ self ._jdbc_password_fix (new_source_name )
334
+
335
+ except IllegalArgumentException , iae :
336
+ self ._disconnect_target (application_name , application_dict , iae .getLocalizedMessage ())
337
+ except WLSDeployArchiveIOException , wioe :
338
+ de = exception_helper .create_discover_exception ('WLSDPLY-06397' , application_name ,
339
+ file_name_path , wioe .getLocalizedMessage ())
340
+ _logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
341
+ raise de
342
+ if new_source_name is not None :
343
+ _logger .finer ('WLSDPLY-06398' , application_name , new_source_name , class_name = _class_name ,
344
+ method_name = _method_name )
345
+ application_dict [model_constants .SOURCE_PATH ] = new_source_name
346
+ self .add_application_plan_to_archive (application_name , application_dict )
345
347
346
348
_logger .exiting (class_name = _class_name , method_name = _method_name )
347
349
@@ -357,9 +359,17 @@ def add_application_plan_to_archive(self, application_name, application_dict):
357
359
_method_name = 'add_application_plan_to_archive'
358
360
_logger .entering (application_name , class_name = _class_name , method_name = _method_name )
359
361
archive_file = self ._model_context .get_archive_file ()
360
- if model_constants .PLAN_PATH in application_dict :
361
- app_source_name = application_dict [model_constants .SOURCE_PATH ]
362
- plan_path = application_dict [model_constants .PLAN_PATH ]
362
+
363
+ model_plan_path = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , PLAN_PATH )
364
+ if model_plan_path is not None :
365
+ app_source_name = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , SOURCE_PATH )
366
+ model_plan_dir = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , PLAN_DIR )
367
+
368
+ if model_plan_dir is not None and self .path_helper .is_relative_path (model_plan_path ):
369
+ plan_path = self .path_helper .join (model_plan_dir , model_plan_path )
370
+ else :
371
+ plan_path = model_plan_path
372
+
363
373
if plan_path :
364
374
if not self ._model_context .is_remote ():
365
375
plan_path = self ._convert_path (plan_path )
@@ -425,16 +435,9 @@ def _is_structured_app(self, application_name, application_dict):
425
435
_method_name = '_is_structured_app'
426
436
_logger .entering (application_dict , class_name = _class_name , method_name = _method_name )
427
437
428
- source_path = None
429
- plan_dir = None
430
- plan_path = None
431
-
432
- if 'SourcePath' in application_dict :
433
- source_path = application_dict ['SourcePath' ]
434
- if 'PlanDir' in application_dict :
435
- plan_dir = application_dict ['PlanDir' ]
436
- if 'PlanPath' in application_dict :
437
- plan_path = application_dict ['PlanPath' ]
438
+ source_path = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , SOURCE_PATH )
439
+ plan_dir = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , PLAN_DIR )
440
+ plan_path = self ._get_dictionary_attribute_with_path_tokens_replaced (application_dict , PLAN_PATH )
438
441
439
442
_logger .finer ('WLSDPLY-06405' , application_name , source_path , plan_dir , plan_path ,
440
443
class_name = _class_name , method_name = _method_name )
@@ -681,6 +684,16 @@ def _get_app_install_root(self, app_dir, plan_dir):
681
684
_logger .exiting (class_name = _class_name , method_name = _method_name , result = install_root )
682
685
return install_root
683
686
687
+ def _get_dictionary_attribute_with_path_tokens_replaced (self , model_dict , attribute_name ):
688
+ _method_name = '_get_dictionary_attribute_with_path_tokens_replaced'
689
+ _logger .entering (model_dict , attribute_name , class_name = _class_name , method_name = _method_name )
690
+
691
+ result = dictionary_utils .get_element (model_dict , attribute_name )
692
+ if result is not None :
693
+ result = self ._model_context .replace_token_string (result )
694
+
695
+ _logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
696
+ return result
684
697
685
698
def _generate_new_plan_name (binary_path , plan_path ):
686
699
"""
0 commit comments