@@ -47,6 +47,8 @@ class docstring
47
47
_SPEC_INDEX = 1
48
48
_IMPL_INDEX = 2
49
49
50
+ _APP_VERSION_MANIFEST_KEY = 'Weblogic-Application-Version'
51
+
50
52
def __init__ (self , model , model_context , aliases , wlst_mode = WlstModes .OFFLINE , base_location = LocationContext ()):
51
53
Deployer .__init__ (self , model , model_context , aliases , wlst_mode )
52
54
self ._class_name = 'ApplicationDeployer'
@@ -172,7 +174,7 @@ def __add_applications(self):
172
174
full_source_path = File (self .model_context .replace_token_string (app_source_path )).getAbsolutePath ()
173
175
174
176
application_name = \
175
- self .__get_deployable_library_versioned_name (full_source_path , application_name )
177
+ self .__get_deployable_application_versioned_name (full_source_path , application_name )
176
178
177
179
quoted_application_name = self .wlst_helper .get_quoted_name_for_wlst (application_name )
178
180
application_location .add_name_token (application_token , quoted_application_name )
@@ -783,7 +785,7 @@ def __deploy_app_online(self, application_name, source_path, targets, plan=None,
783
785
raise ex
784
786
785
787
# if options is not None and 'libraryModule' in options and string_utils.to_boolean(options['libraryModule']):
786
- computed_name = self .__get_deployable_library_versioned_name (source_path , application_name )
788
+ computed_name = self .__get_deployable_application_versioned_name (source_path , application_name )
787
789
application_name = computed_name
788
790
789
791
# build the dictionary of named arguments to pass to the deploy_application method
@@ -845,13 +847,6 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
845
847
manifest = bao .toString ('UTF-8' )
846
848
tokens = manifest .split ()
847
849
848
- # this is specific to application not shared library, so just returns it
849
-
850
- if 'Weblogic-Application-Version:' in tokens :
851
- weblogic_appname_index = tokens .index ('Weblogic-Application-Version:' )
852
- versioned_name = old_name_tuple [self ._EXTENSION_INDEX ] + '#' + tokens [weblogic_appname_index + 1 ]
853
- return versioned_name
854
-
855
850
if 'Extension-Name:' in tokens :
856
851
extension_index = tokens .index ('Extension-Name:' )
857
852
if len (tokens ) > extension_index :
@@ -883,8 +878,6 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
883
878
self .logger .throwing (ex , class_name = self ._class_name , method_name = _method_name )
884
879
raise ex
885
880
886
-
887
-
888
881
self .logger .info ('WLSDPLY-09324' , model_name , versioned_name ,
889
882
class_name = self ._class_name , method_name = _method_name )
890
883
except (IOException , FileNotFoundException , ZipException , IllegalStateException ), e :
@@ -895,6 +888,45 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
895
888
self .logger .exiting (class_name = self ._class_name , method_name = _method_name , result = versioned_name )
896
889
return versioned_name
897
890
891
+ def __get_deployable_application_versioned_name (self , source_path , model_name ):
892
+ """
893
+ Get the proper name of the deployable application that WLST requires in the target domain.
894
+ This method is needed for the case where the application is explicitly versioned in its ear/war manifest.
895
+ Rather than requiring the modeller to have to know/adjust the application name, we extract
896
+ the information from the application's archive file (e.g., war file) and compute the correct name.
897
+ :param source_path: the SourcePath value of the application
898
+ :param model_name: the model name of the application
899
+ :return: the updated application name for the target environment
900
+ :raises: DeployException: if an error occurs
901
+ """
902
+ _method_name = '__get_deployable_application_versioned_name'
903
+
904
+ self .logger .entering (source_path , model_name , class_name = self ._class_name , method_name = _method_name )
905
+
906
+ # discard any version information in the model name
907
+ model_name_tuple = deployer_utils .get_library_name_components (model_name , self .wlst_mode )
908
+ versioned_name = model_name_tuple [self ._EXTENSION_INDEX ]
909
+
910
+ try :
911
+ source_path = self .model_context .replace_token_string (source_path )
912
+ archive = JarFile (source_path )
913
+ manifest = archive .getManifest ()
914
+ if manifest is not None :
915
+ attributes = manifest .getMainAttributes ()
916
+ application_version = attributes .getValue (self ._APP_VERSION_MANIFEST_KEY )
917
+ if application_version is not None :
918
+ versioned_name = model_name + '#' + application_version
919
+ self .logger .info ('WLSDPLY-09328' , model_name , versioned_name , class_name = self ._class_name ,
920
+ method_name = _method_name )
921
+
922
+ except (IOException , FileNotFoundException , ZipException , IllegalStateException ), e :
923
+ ex = exception_helper .create_deploy_exception ('WLSDPLY-09329' , model_name , source_path , str (e ), error = e )
924
+ self .logger .throwing (ex , class_name = self ._class_name , method_name = _method_name )
925
+ raise ex
926
+
927
+ self .logger .exiting (class_name = self ._class_name , method_name = _method_name , result = versioned_name )
928
+ return versioned_name
929
+
898
930
def __get_deployment_ordering (self , apps ):
899
931
_method_name = '__get_deployment_ordering'
900
932
name_sorted_keys = apps .keys ()
0 commit comments