Skip to content

Commit 9f46384

Browse files
BUG:WDT-57 Arrays on folders
1 parent 5e1d86e commit 9f46384

File tree

4 files changed

+132
-43
lines changed

4 files changed

+132
-43
lines changed

core/src/main/python/wlsdeploy/aliases/alias_constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
55
These constants are internal to the aliases module and should not be used, as they are not part of the public API.
@@ -14,6 +14,7 @@
1414
DEFAULT_NAME_VALUE = 'default_name_value'
1515
FLATTENED_FOLDER_DATA = 'flattened_folder_data'
1616
FOLDERS = 'folders'
17+
FOLDER_PARAMS = 'folder_params'
1718
GET_MBEAN_TYPE = 'get_mbean_type'
1819
GET_METHOD = 'get_method'
1920
MERGE = 'merge'

core/src/main/python/wlsdeploy/aliases/alias_entries.py

Lines changed: 96 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import copy
@@ -26,6 +26,7 @@
2626
from wlsdeploy.aliases.alias_constants import CONTAINS
2727
from wlsdeploy.aliases.alias_constants import DEFAULT_NAME_VALUE
2828
from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
29+
from wlsdeploy.aliases.alias_constants import FOLDER_PARAMS
2930
from wlsdeploy.aliases.alias_constants import FOLDERS
3031
from wlsdeploy.aliases.alias_constants import GET_MBEAN_TYPE
3132
from wlsdeploy.aliases.alias_constants import GET_METHOD
@@ -590,7 +591,7 @@ def get_name_token_for_location(self, location):
590591
path = location.get_folder_path()
591592

592593
err_location = LocationContext(location)
593-
if not err_location.is_empty():
594+
if not err_location.is_empty():
594595
folder_name = err_location.pop_location()
595596
code, message = self.is_valid_model_folder_name_for_location(err_location, folder_name)
596597
if code == ValidationCodes.VERSION_INVALID:
@@ -790,7 +791,7 @@ def is_valid_model_folder_name_for_location(self, location, model_folder_name):
790791
folder_dict = self.__get_dictionary_for_location(sub_location, False)
791792
if folder_dict is None:
792793
if UNRESOLVED_FOLDERS_MAP in self._category_dict and \
793-
model_folder_name in self._category_dict[UNRESOLVED_FOLDERS_MAP]:
794+
model_folder_name in self._category_dict[UNRESOLVED_FOLDERS_MAP]:
794795
result = ValidationCodes.VERSION_INVALID
795796
valid_version_range = self._category_dict[UNRESOLVED_FOLDERS_MAP][model_folder_name]
796797
else:
@@ -1091,42 +1092,8 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
10911092
#
10921093
# First, determine if this dictionary is even relevant to the current WLS version.
10931094
#
1094-
if VERSION in alias_dict:
1095-
dict_version_range = alias_dict[VERSION]
1096-
try:
1097-
_logger.finer('WLSDPLY-08123', path_name, dict_version_range,
1098-
self._wls_helper.get_actual_weblogic_version(),
1099-
class_name=_class_name, method_name=_method_name)
1100-
if not self.__version_in_range(dict_version_range):
1101-
_logger.finer('WLSDPLY-08124', path_name, dict_version_range,
1102-
self._wls_helper.get_actual_weblogic_version(),
1103-
class_name=_class_name, method_name=_method_name)
1104-
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1105-
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1106-
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1107-
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = dict_version_range
1108-
return None
1109-
else:
1110-
_logger.finer('WLSDPLY-08125', path_name, dict_version_range,
1111-
self._wls_helper.get_actual_weblogic_version(),
1112-
class_name=_class_name, method_name=_method_name)
1113-
except VersionException, ve:
1114-
ex = exception_helper.create_alias_exception('WLSDPLY-08126', path_name, dict_version_range,
1115-
ve.getLocalizedMessage(), error=ve)
1116-
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1117-
raise ex
1118-
1119-
if WLST_MODE in alias_dict:
1120-
dict_wlst_mode = alias_dict[WLST_MODE]
1121-
mode = WlstModes.from_value(self._wlst_mode)
1122-
if not self.__wlst_mode_matches(dict_wlst_mode):
1123-
_logger.finer('WLSDPLY-08132', path_name, dict_wlst_mode, mode, class_name=_class_name,
1124-
method_name=_method_name)
1125-
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1126-
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1127-
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1128-
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = mode
1129-
return None
1095+
if not self.__use_alias_dict(path_name, alias_dict, parent_dict):
1096+
return None
11301097

11311098
result = dict()
11321099
if FOLDERS in alias_dict:
@@ -1227,6 +1194,89 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
12271194

12281195
return result
12291196

1197+
def __is_version(self, path_name, alias_dict):
1198+
_method_name = '__is_version'
1199+
is_version = True
1200+
dict_version_range = alias_utils.get_dictionary_version(alias_dict)
1201+
if dict_version_range:
1202+
try:
1203+
_logger.finer('WLSDPLY-08123', path_name, dict_version_range,
1204+
self._wls_helper.get_actual_weblogic_version(),
1205+
class_name=_class_name, method_name=_method_name)
1206+
is_version = self.__version_in_range(dict_version_range)
1207+
1208+
except VersionException, ve:
1209+
ex = exception_helper.create_alias_exception('WLSDPLY-08126', path_name, dict_version_range,
1210+
ve.getLocalizedMessage(), error=ve)
1211+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1212+
raise ex
1213+
else:
1214+
dict_version_range = 'All'
1215+
1216+
if is_version:
1217+
_logger.finer('WLSDPLY-08125', path_name, dict_version_range,
1218+
self._wls_helper.get_actual_weblogic_version(),
1219+
class_name=_class_name, method_name=_method_name)
1220+
1221+
return is_version
1222+
1223+
def __is_wlst_mode(self, path_name, alias_dict):
1224+
_method_name = '__is_wlst_mode'
1225+
is_mode = True
1226+
mode = WlstModes.from_value(self._wlst_mode)
1227+
dict_wlst_mode = alias_utils.get_dictionary_mode(alias_dict)
1228+
if dict_wlst_mode:
1229+
if not self.__wlst_mode_matches(dict_wlst_mode):
1230+
_logger.finer('WLSDPLY-08132', path_name, dict_wlst_mode, mode, class_name=_class_name,
1231+
method_name=_method_name)
1232+
is_mode = False
1233+
else:
1234+
dict_wlst_mode = 'Both'
1235+
1236+
if is_mode:
1237+
_logger.finer('WLSDPLY-08133', path_name, dict_wlst_mode, class_name=_class_name,
1238+
method_name=_method_name)
1239+
return is_mode
1240+
1241+
def __test_dictionary(self, path_name, alias_dict):
1242+
return self.__is_version(path_name, alias_dict) and self.__is_wlst_mode(path_name, alias_dict)
1243+
1244+
def __use_alias_dict(self, path_name, alias_dict, parent_dict):
1245+
self.__resolve_folder_params(path_name, alias_dict)
1246+
if not self.__is_version(path_name, alias_dict):
1247+
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
1248+
return False
1249+
if not self.__is_wlst_mode(path_name, alias_dict):
1250+
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
1251+
return False
1252+
1253+
return True
1254+
1255+
def __resolve_folder_params(self, path_name, alias_dict):
1256+
"""
1257+
This is a folder that has different parameters based on version / offline.
1258+
Search through the folder params and find the correct set of parameters. Add
1259+
this set of parameters to the alias_dict directly and remove the folder_params array.
1260+
:param alias_dict:
1261+
:return:
1262+
"""
1263+
_method_name = '__resolve_folder_params'
1264+
if FOLDER_PARAMS in alias_dict:
1265+
folder_params = alias_dict[FOLDER_PARAMS]
1266+
1267+
if not isinstance(folder_params, list):
1268+
ex = exception_helper.create_alias_exception('WLSDPLY-08134', path_name, class_name=_class_name,
1269+
method_name=_method_name)
1270+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1271+
raise ex
1272+
1273+
for folder_set in folder_params:
1274+
if self.__test_dictionary(path_name, folder_set):
1275+
_logger.finer('WLSDPLY-08135', path_name, class_name=_class_name, method_name=_method_name)
1276+
for key, value in folder_set.iteritems():
1277+
alias_dict[key] = value
1278+
break
1279+
12301280
def __resolve_attribute_by_wlst_context(self, path_name, attr_name, attrs_dict):
12311281
"""
12321282
Find the attribute list element that applies to the current WLS version and WLST mode.
@@ -1436,3 +1486,10 @@ def __get_path_for_location(self, location, path_type=WLST_ATTRIBUTES_PATH):
14361486

14371487
_logger.exiting(class_name=_class_name, method_name=_method_name, result=tokenized_path)
14381488
return tokenized_path
1489+
1490+
1491+
def _add_to_unresolved_folders(path_name, parent_dict, unresolved):
1492+
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1493+
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1494+
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1495+
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = unresolved

core/src/main/python/wlsdeploy/aliases/alias_utils.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import copy
@@ -31,21 +31,21 @@
3131
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
3232
from wlsdeploy.aliases.alias_constants import COMMA_DELIMITED_STRING
3333
from wlsdeploy.aliases.alias_constants import DELIMITED_STRING
34-
from wlsdeploy.aliases.alias_constants import DICTIONARY
3534
from wlsdeploy.aliases.alias_constants import JARRAY
3635
from wlsdeploy.aliases.alias_constants import JAVA_LANG_BOOLEAN
3736
from wlsdeploy.aliases.alias_constants import LIST
3837
from wlsdeploy.aliases.alias_constants import LONG
3938
from wlsdeploy.aliases.alias_constants import PATH_SEPARATOR_DELIMITED_STRING
40-
from wlsdeploy.aliases.alias_constants import PROPERTIES
4139
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
4240
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_FOLDER_PATHS
4341
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_MBEAN_NAME_MAP
4442
from wlsdeploy.aliases.alias_constants import SEMI_COLON_DELIMITED_STRING
4543
from wlsdeploy.aliases.alias_constants import SPACE_DELIMITED_STRING
44+
from wlsdeploy.aliases.alias_constants import VERSION
4645
from wlsdeploy.aliases.alias_constants import WLST_ATTRIBUTES_PATH
4746
from wlsdeploy.aliases.alias_constants import WLST_CREATE_PATH
4847
from wlsdeploy.aliases.alias_constants import WLST_LIST_PATH
48+
from wlsdeploy.aliases.alias_constants import WLST_MODE
4949
from wlsdeploy.aliases.alias_constants import WLST_PATH
5050
from wlsdeploy.aliases.alias_constants import WLST_PATHS
5151
from wlsdeploy.aliases.alias_constants import WLST_READ_TYPE
@@ -806,6 +806,29 @@ def get_security_provider_model_folder_name(mbean_name):
806806
return result
807807

808808

809+
def get_dictionary_version(alias_dict):
810+
"""
811+
Return the version in the alias dictionary, if present. Not present
812+
means all versions. The alias dictionary can represent a folder or an attribute.
813+
:param alias_dict: in which to find the version
814+
:return: alias_dict VERSION or None if not present
815+
"""
816+
if VERSION in alias_dict:
817+
return alias_dict[VERSION]
818+
return None
819+
820+
821+
def get_dictionary_mode(alias_dict):
822+
"""
823+
Return the wlst mode in the alias dictionary, if present. Not present means both offline
824+
and online. The alias dictionary can represent a folder or an attribute.
825+
:param alias_dict: in which to find the wlst mode
826+
:return: alias_dict mode or None if not present
827+
"""
828+
if WLST_MODE in alias_dict:
829+
return alias_dict[WLST_MODE]
830+
return None
831+
809832
###############################################################################
810833
# Private functions #
811834
###############################################################################

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ WLSDPLY-06142=The online attribute {0} is in the lsa() list but is a folder not
464464
WLSDPLY-06143=Attribute {0} at location {1} is not writable and is deprecated
465465
WLSDPLY-06144=Folder {0} at location {1} is not an online folder. Removing from online subfolder list
466466
WLSDPLY-06145=Subfolder list {0} at location {1} does not match the mbi containment folder list {2}
467+
WLSDPLY-06146=Discovered WLST MBean names {0} at location {1}
468+
WLSDPLY-06147=Call method {0} to get the value for wlst attribute {1} at wlst path {2}
467469

468470
# resources_discoverer.py
469471
WLSDPLY-06300=Discovering domain model resources
@@ -707,6 +709,10 @@ WLSDPLY-08130=Unable to compute the name token for folder {0} because the folder
707709
WLSDPLY-08131=Unable to compute the name token for folder {0} because the folder is not valid in \
708710
WebLogic Server version {1}
709711
WLSDPLY-08132=Folder {0} present only for {1} mode is not relevant for WLST in {2} mode
712+
WLSDPLY-08133=Folder {0} present for {1} mode is relevant in WebLogic Server version {2}
713+
WLSDPLY-08134=Folder parameters for Folder {0} are invalid and cannot be processed
714+
WLSDPLY-08135=Found a valid parameters for Folder {0} in the array of folder parameters
715+
710716
#
711717
# Empty slots to fill up...
712718
#
@@ -1079,6 +1085,8 @@ WLSDPLY-19030=Failed to get the model attribute list that use path tokens for mo
10791085
WLSDPLY-19031=Failed to determine if the model attribute name {0} at location ({1}) is valid: {2}
10801086
WLSDPLY-19032=Failed to get the default value for model attribute {0} at location ({1}): {2}
10811087
WLSDPLY-19033=Failed to determine if location ({0}) is version valid, or not
1088+
WLSDPLY-19034=Failed to get the model attribute list that require a special processing via a method for model \
1089+
folder ({0}) at location ({1}): {2}
10821090

10831091
# wlsdeploy/tool/util/wlst_helper.py
10841092
WLSDPLY-19100=Failed to change to the WLST directory {0}: {1}

0 commit comments

Comments
 (0)