Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions core/src/main/python/wlsdeploy/aliases/alias_entries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
import copy
Expand Down Expand Up @@ -68,7 +68,7 @@
from wlsdeploy.exception import exception_helper
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.util import dictionary_utils
from wlsdeploy.util.weblogic_helper import WebLogicHelper
from wlsdeploy.util import string_utils

_class_name = 'AliasEntries'
_logger = PlatformLogger('wlsdeploy.aliases')
Expand Down Expand Up @@ -196,10 +196,10 @@ def __init__(self, wlst_mode=WlstModes.OFFLINE, wls_version=None):
self._category_dict = {}
self._wlst_mode = wlst_mode
if wls_version is None:
from wlsdeploy.util.weblogic_helper import WebLogicHelper
self._wls_helper = WebLogicHelper(_logger)
self._wls_version = self._wls_helper.get_actual_weblogic_version()
else:
self._wls_helper = WebLogicHelper(_logger, wls_version)
self._wls_version = wls_version

return
Expand Down Expand Up @@ -242,9 +242,9 @@ def get_model_topology_subfolder_names(self):
:return: a list of the folder names
"""
result = list(self.__topology_top_level_folders)
if not self._wls_helper.is_weblogic_version_or_above('12.2.1'):
if not string_utils.is_weblogic_version_or_above(self._wls_version, '12.2.1'):
result.remove('VirtualTarget')
if not self._wls_helper.is_weblogic_version_or_above('12.1.2'):
if not string_utils.is_weblogic_version_or_above(self._wls_version, '12.1.2'):
result.remove('RestfulManagementServices')
result.remove('ServerTemplate')
return result
Expand All @@ -255,13 +255,13 @@ def get_model_resources_subfolder_names(self):
:return: a list of the folder names
"""
result = list(self.__resources_top_level_folders)
if not self._wls_helper.is_weblogic_version_or_above('12.2.1'):
if not string_utils.is_weblogic_version_or_above(self._wls_version, '12.2.1'):
result.remove('Partition')
result.remove('PartitionWorkManager')
result.remove('ResourceGroup')
result.remove('ResourceGroupTemplate')
result.remove('ResourceManagement')
if not self._wls_helper.is_weblogic_version_or_above('12.1.2'):
if not string_utils.is_weblogic_version_or_above(self._wls_version, '12.1.2'):
result.remove('CoherenceClusterSystemResource')
return result

Expand Down Expand Up @@ -356,7 +356,7 @@ def get_model_folder_path_for_location(self, location):
my_loc.add_name_token(name_token, name)
# dont include token in path for single-unpredictable
if not self.is_location_child_folder_type(my_loc, ChildFoldersTypes.SINGLE):
model_folder_path += '%s/' % name
model_folder_path += '%s/' % name
elif location_folder != location_folders[-1]:
# Throw AliasException if name_token is missing
# from any location folder, except the last one
Expand Down Expand Up @@ -581,12 +581,11 @@ def get_name_token_for_location(self, location):
code, message = self.is_valid_model_folder_name_for_location(err_location, folder_name)
if code == ValidationCodes.VERSION_INVALID:
ex = exception_helper.create_alias_exception('WLSDPLY-08130', path,
self._wls_helper.get_actual_weblogic_version(),
self._wls_version,
message)
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex
ex = exception_helper.create_alias_exception('WLSDPLY-08131', path,
self._wls_helper.get_actual_weblogic_version())
ex = exception_helper.create_alias_exception('WLSDPLY-08131', path, self._wls_version)
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex

Expand Down Expand Up @@ -833,7 +832,7 @@ def is_version_valid_location(self, location):
if self.get_wlst_mbean_type_for_location(location) is None:
model_folder_path = self.get_model_folder_path_for_location(location)
message = exception_helper.get_message('WLSDPLY-08138', model_folder_path,
self._wls_helper.get_weblogic_version())
self._wls_version)
code = ValidationCodes.VERSION_INVALID

_logger.exiting(class_name=_class_name, method_name=_method_name, result=[code, message])
Expand Down Expand Up @@ -1281,7 +1280,7 @@ def __is_version(self, path_name, alias_dict):
if dict_version_range:
try:
_logger.finer('WLSDPLY-08123', path_name, dict_version_range,
self._wls_helper.get_actual_weblogic_version(),
self._wls_version,
class_name=_class_name, method_name=_method_name)
is_version = self.__version_in_range(dict_version_range)

Expand All @@ -1295,7 +1294,7 @@ def __is_version(self, path_name, alias_dict):

if is_version:
_logger.finer('WLSDPLY-08125', path_name, dict_version_range,
self._wls_helper.get_actual_weblogic_version(),
self._wls_version,
class_name=_class_name, method_name=_method_name)

return is_version
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/python/wlsdeploy/aliases/aliases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
from java.lang import String
Expand Down Expand Up @@ -50,7 +50,6 @@
from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.util import string_utils
from wlsdeploy.util.weblogic_helper import WebLogicHelper


class Aliases(object):
Expand All @@ -74,8 +73,9 @@ def __init__(self, model_context, wlst_mode=WlstModes.OFFLINE, wls_version=None,
self._exception_type = exception_type
self._logger = PlatformLogger('wlsdeploy.aliases')

self._wls_helper = WebLogicHelper(self._logger)
if wls_version is None:
from wlsdeploy.util.weblogic_helper import WebLogicHelper
self._wls_helper = WebLogicHelper(self._logger)
self._wls_version = self._wls_helper.wl_version_actual
else:
self._wls_version = wls_version
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/python/wlsdeploy/util/cla_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
from wlsdeploy.util.target_configuration import CREDENTIALS_METHOD
from wlsdeploy.util.target_configuration import CREDENTIALS_METHODS
from wlsdeploy.util.target_configuration import TargetConfiguration
from wlsdeploy.util.weblogic_helper import WebLogicHelper

# tool type may indicate variations in argument processing
TOOL_TYPE_CREATE = "create"
TOOL_TYPE_DEFAULT = "default"
TOOL_TYPE_EXTRACT = "extract"



class CommandLineArgUtil(object):
"""
Class that handles command-line argument parsing and common validation.
Expand Down Expand Up @@ -422,6 +422,7 @@ def is_oracle_home_key(self, key):
return self.ORACLE_HOME_SWITCH == key

def _validate_oracle_home_arg(self, value):
from wlsdeploy.util.weblogic_helper import WebLogicHelper
method_name = '_validate_oracle_home_arg'

try:
Expand Down Expand Up @@ -923,6 +924,7 @@ def is_target_version_switch(self, key):
return self.TARGET_VERSION_SWITCH == key

def _validate_target_version_arg(self, value):
from wlsdeploy.util.weblogic_helper import WebLogicHelper
method_name = '_validate_target_version_arg'

# Try our best to determine if this is a legitimate WLS version number.
Expand Down
58 changes: 57 additions & 1 deletion core/src/main/python/wlsdeploy/util/string_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates. All rights reserved.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

This module provides string manipulation helper methods that are not found in the WLST version of Jython
"""
import java.lang.String as JString
import java.util.Properties as Properties
import java.io.FileInputStream as FileInputStream
import java.io.IOException as IOException
Expand All @@ -15,6 +16,8 @@
__logger = PlatformLogger('wlsdeploy.util')
_class_name = 'string_utils'

STANDARD_VERSION_NUMBER_PLACES = 5


def is_empty(text):
"""
Expand Down Expand Up @@ -104,3 +107,56 @@ def load_properties(property_file, exception_type=None):
prop_dict[key] = value

return prop_dict


def is_weblogic_version_or_above(wls_version, str_version):
"""
Is the provided version number equal to or greater than the version encapsualted by this version instance
:param wls_version: the string representation of the current weblogic version
:param str_version: the string representation of the version to be compared to the weblogic version
:return: True if the provided version is equal or greater than the version represented by the wls_version argument
"""
result = False
array_version = str_version.split('.')
array_wl_version = _get_wl_version_array(wls_version)

len_compare = len(array_wl_version)
if len(array_version) < len_compare:
len_compare = len(array_version)

idx = 0
while idx < len_compare:
compare_value = JString(array_version[idx]).compareTo(JString(array_wl_version[idx]))
if compare_value < 0:
result = True
break
elif compare_value > 0:
result = False
break
elif idx + 1 == len_compare:
result = True

idx += 1

return result


# We need to pad the actual version number for comparison purposes so
# that is is never shorter than the specified version. Otherwise,
# actual version 12.2.1 will be considered to be equal to 12.2.1.1
#
def _get_wl_version_array(wl_version):
"""
Get the WebLogic version number padded to the standard number of digits.
:param wl_version: WebLogic version number
:return: the padded WebLogic version number
"""
result = wl_version.split('.')

if len(result) < STANDARD_VERSION_NUMBER_PLACES:
index = len(result)
while index < STANDARD_VERSION_NUMBER_PLACES:
result.append('0')
index += 1

return result
55 changes: 8 additions & 47 deletions core/src/main/python/wlsdeploy/util/weblogic_helper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
import java.lang.Exception as JException
import java.lang.String as JString

import weblogic.management.provider.ManagementServiceClient as ManagementServiceClient
import weblogic.security.internal.SerializedSystemIni as SerializedSystemIni
Expand All @@ -16,11 +15,12 @@
import os
import re


class WebLogicHelper(object):
"""
Helper functions for version-specific WebLogic operations.
"""
STANDARD_VERSION_NUMBER_PLACES = 5

MINIMUM_WEBLOGIC_VERSION = '10.3.6'
_class_name = 'WebLogicHelper'

Expand Down Expand Up @@ -228,27 +228,11 @@ def is_weblogic_version_or_above(self, str_version, use_actual_version=False):
False (default), use version places up to the number represented by STANDARD_VERSION_NUMBER_PLACES
:return: True if the provided version is equal or greater than the version represented by this helper instance
"""
result = False
array_version = str_version.split('.')
array_wl_version = self._get_wl_version_array(use_actual_version=use_actual_version)

len_compare = len(array_wl_version)
if len(array_version) < len_compare:
len_compare = len(array_version)

idx = 0
while idx < len_compare:
compare_value = JString(array_version[idx]).compareTo(JString(array_wl_version[idx]))
if compare_value < 0:
result = True
break
elif compare_value > 0:
result = False
break
elif idx + 1 == len_compare:
result = True

idx += 1
if use_actual_version:
wl_version = self.wl_version_actual
else:
wl_version = self.wl_version
result = string_utils.is_weblogic_version_or_above(wl_version, str_version)

return result

Expand All @@ -261,29 +245,6 @@ def get_bean_info_for_interface(self, interface_name):
bean_access = ManagementServiceClient.getBeanInfoAccess()
return bean_access.getBeanInfoForInterface(interface_name, False, '9.0.0.0')

# We need to pad the actual version number for comparison purposes so
# that is is never shorter than the specified version. Otherwise,
# actual version 12.2.1 will be considered to be equal to 12.2.1.1
#
def _get_wl_version_array(self, use_actual_version=False):
"""
Get the WebLogic version number padded to the standard number of digits.
:param use_actual_version: whether to use the actual or supplied version of WebLogic
:return: the padded WebLogic version number
"""
if use_actual_version:
result = self.wl_version_actual.split('.')
else:
result = self.wl_version.split('.')

if len(result) < self.STANDARD_VERSION_NUMBER_PLACES:
index = len(result)
while index < self.STANDARD_VERSION_NUMBER_PLACES:
result.append('0')
index += 1

return result

def get_next_higher_order_version_number(self, version_number):
"""
Get the next higher order version number. For example, passing in '12.2.1.2' will return '12.2.1'.
Expand Down