26
26
from wlsdeploy .aliases .model_constants import SOURCE_PATH
27
27
from wlsdeploy .aliases .wlst_modes import WlstModes
28
28
from wlsdeploy .exception import exception_helper
29
+ from wlsdeploy .exception .exception_types import ExceptionType
29
30
from wlsdeploy .logging .platform_logger import PlatformLogger
30
31
from wlsdeploy .tool .discover import discoverer
31
32
from wlsdeploy .tool .discover .discoverer import Discoverer
33
+ from wlsdeploy .tool .util import structured_apps_helper
32
34
from wlsdeploy .util import dictionary_utils
33
35
from wlsdeploy .util import path_helper
36
+ from wlsdeploy .util import string_utils
34
37
35
38
_class_name = 'DeploymentsDiscoverer'
36
39
_logger = PlatformLogger (discoverer .get_discover_logger_name ())
@@ -442,45 +445,17 @@ def _is_structured_app(self, application_name, application_dict):
442
445
_logger .finer ('WLSDPLY-06405' , application_name , source_path , plan_dir , plan_path ,
443
446
class_name = _class_name , method_name = _method_name )
444
447
445
- if source_path is None :
448
+ if string_utils . is_empty ( source_path ) :
446
449
de = exception_helper .create_discover_exception ('WLSDPLY-06404' , application_name )
447
450
_logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
448
451
raise de
449
- if plan_path is None :
452
+ if string_utils . is_empty ( plan_path ) :
450
453
_logger .exiting (class_name = _class_name , method_name = _method_name , result = [False , None ])
451
454
return False , None
452
455
453
- if self .path_helper .is_relative_path (source_path ):
454
- source_path = self .path_helper .join (self ._model_context .get_domain_home (), source_path )
455
- source_path = self .path_helper .get_canonical_path (source_path )
456
-
457
- source_path_parent = self .path_helper .get_parent_directory (source_path )
458
- _logger .finer ('WLSDPLY-06406' , application_name , source_path_parent ,
459
- class_name = _class_name , method_name = _method_name )
460
- if source_path_parent is None or \
461
- self .path_helper .basename (source_path_parent ) != 'app' or \
462
- self .path_helper .get_parent_directory (source_path_parent ) == source_path_parent :
463
- _logger .exiting (class_name = _class_name , method_name = _method_name , result = [False , None ])
464
- return False , None
465
-
466
- # _get_app_install_root() only needs a path to either the PlanDir or the PlanPath to determine
467
- # if this application is a structured app.
468
- #
469
- if plan_dir is None :
470
- if self .path_helper .is_relative_path (plan_path ):
471
- plan_path = self .path_helper .join (self ._model_context .get_domain_home (), plan_path )
472
- plan_path = self .path_helper .get_canonical_path (plan_path )
473
- effective_plan = plan_path
474
- else :
475
- if self .path_helper .is_relative_path (plan_dir ):
476
- plan_dir = self .path_helper .join (self ._model_context .get_domain_home (), plan_dir )
477
- plan_dir = self .path_helper .get_canonical_path (plan_dir )
478
- effective_plan = plan_dir
479
-
480
- install_root_dir = self ._get_app_install_root (source_path_parent , effective_plan )
456
+ install_root_dir = self ._get_structured_app_install_root (application_name , source_path , plan_dir , plan_path )
481
457
if install_root_dir is not None :
482
- _logger .exiting (class_name = _class_name , method_name = _method_name ,
483
- result = [True , install_root_dir ])
458
+ _logger .exiting (class_name = _class_name , method_name = _method_name , result = [True , install_root_dir ])
484
459
return True , install_root_dir
485
460
486
461
_logger .exiting (class_name = _class_name , method_name = _method_name , result = [False , None ])
@@ -671,15 +646,39 @@ def _resolve_deployment_plan_path(self, plan_dir, plan_path):
671
646
return self .path_helper .get_canonical_path (plan_path , relative_to = relative_to )
672
647
return plan_path
673
648
674
- def _get_app_install_root (self , app_dir , plan_dir ):
675
- _method_name = '_get_app_install_root'
676
- _logger .entering (app_dir , plan_dir , class_name = _class_name , method_name = _method_name )
649
+ def _get_structured_app_install_root (self , app_name , source_path , plan_dir , plan_path ):
650
+ """
651
+ This method tries to determine if this is a structured application and if so, returns the
652
+ install root directory.
653
+
654
+ :param app_name: The application name
655
+ :param source_path: The application source path (already validated as not None)
656
+ :param plan_dir: The application plan directory, if set
657
+ :param plan_path: The application plan path (already validated as not None)
658
+ :return: The structured application install root directory or None, if it is not a structured application
659
+ """
660
+ _method_name = '_get_structured_app_install_root'
661
+ _logger .entering (app_name , source_path , plan_dir , plan_path ,
662
+ class_name = _class_name , method_name = _method_name )
663
+
664
+ full_source_path = source_path
665
+ if self .path_helper .is_relative_path (source_path ):
666
+ full_source_path = self .path_helper .join (self ._model_context .get_domain_home (), source_path )
667
+ full_source_path = self .path_helper .get_canonical_path (full_source_path )
677
668
678
- app_install_root = self .path_helper .get_parent_directory (app_dir )
679
- if plan_dir .startswith (app_install_root ):
680
- install_root = app_install_root
669
+ full_plan_path = plan_path
670
+ if string_utils .is_empty (plan_dir ):
671
+ if self .path_helper .is_relative_path (plan_path ):
672
+ full_plan_path = self .path_helper .join (self ._model_context .get_domain_home (), plan_path )
673
+ full_plan_path = self .path_helper .get_canonical_path (full_plan_path )
681
674
else :
682
- install_root = None
675
+ full_plan_path = self .path_helper .join (plan_dir , plan_path )
676
+ if self .path_helper .is_relative_path (full_plan_path ):
677
+ full_plan_path = self .path_helper .join (self ._model_context .get_domain_home (), full_plan_path )
678
+ full_plan_path = self .path_helper .get_canonical_path (full_plan_path )
679
+
680
+ install_root = structured_apps_helper .get_structured_app_install_root (app_name , full_source_path ,
681
+ full_plan_path , ExceptionType .DISCOVER )
683
682
684
683
_logger .exiting (class_name = _class_name , method_name = _method_name , result = install_root )
685
684
return install_root
@@ -695,6 +694,7 @@ def _get_dictionary_attribute_with_path_tokens_replaced(self, model_dict, attrib
695
694
_logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
696
695
return result
697
696
697
+
698
698
def _generate_new_plan_name (binary_path , plan_path ):
699
699
"""
700
700
Generate a new plan name from the plan path and binary path.
0 commit comments