Skip to content

Commit 757aecd

Browse files
rakillenddsharpe
authored andcommitted
Issue #434 - Use separate rules for application version naming (#439)
1 parent 47bfd07 commit 757aecd

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class docstring
4747
_SPEC_INDEX = 1
4848
_IMPL_INDEX = 2
4949

50+
_APP_VERSION_MANIFEST_KEY = 'Weblogic-Application-Version'
51+
5052
def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE, base_location=LocationContext()):
5153
Deployer.__init__(self, model, model_context, aliases, wlst_mode)
5254
self._class_name = 'ApplicationDeployer'
@@ -172,7 +174,7 @@ def __add_applications(self):
172174
full_source_path = File(self.model_context.replace_token_string(app_source_path)).getAbsolutePath()
173175

174176
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)
176178

177179
quoted_application_name = self.wlst_helper.get_quoted_name_for_wlst(application_name)
178180
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,
783785
raise ex
784786

785787
# 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)
787789
application_name = computed_name
788790

789791
# 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):
845847
manifest = bao.toString('UTF-8')
846848
tokens = manifest.split()
847849

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-
855850
if 'Extension-Name:' in tokens:
856851
extension_index = tokens.index('Extension-Name:')
857852
if len(tokens) > extension_index:
@@ -883,8 +878,6 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
883878
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
884879
raise ex
885880

886-
887-
888881
self.logger.info('WLSDPLY-09324', model_name, versioned_name,
889882
class_name=self._class_name, method_name=_method_name)
890883
except (IOException, FileNotFoundException, ZipException, IllegalStateException), e:
@@ -895,6 +888,45 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
895888
self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=versioned_name)
896889
return versioned_name
897890

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+
898930
def __get_deployment_ordering(self, apps):
899931
_method_name = '__get_deployment_ordering'
900932
name_sorted_keys = apps.keys()

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,9 @@ WLSDPLY-09324=Shared library {0} name has been updated to {1} to match the \
987987
implementation version in the MANIFEST.MF file
988988
WLSDPLY-09325=Failed to compute name for shared library {0} from archive at {1}: {2}
989989
WLSDPLY-09326=Deployment order is {0}
990-
WLSDPLY-09327=Failed to stop application (0): {1}
990+
WLSDPLY-09327=Failed to stop application {0}: {1}
991+
WLSDPLY-09328=Application {0} name has been updated to {1} to match the application version in the MANIFEST.MF file
992+
WLSDPLY-09329=Failed to compute name for application {0} from archive at {1}: {2}
991993

992994

993995
# wlsdeploy/tool/deploy/common_resources_deployer.py

0 commit comments

Comments
 (0)