|
1 | 1 | """
|
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. |
3 | 3 | The Universal Permissive License (UPL), Version 1.0
|
4 | 4 | """
|
5 | 5 | import copy
|
|
26 | 26 | from wlsdeploy.aliases.alias_constants import CONTAINS
|
27 | 27 | from wlsdeploy.aliases.alias_constants import DEFAULT_NAME_VALUE
|
28 | 28 | from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
|
| 29 | +from wlsdeploy.aliases.alias_constants import FOLDER_PARAMS |
29 | 30 | from wlsdeploy.aliases.alias_constants import FOLDERS
|
30 | 31 | from wlsdeploy.aliases.alias_constants import GET_MBEAN_TYPE
|
31 | 32 | from wlsdeploy.aliases.alias_constants import GET_METHOD
|
@@ -590,7 +591,7 @@ def get_name_token_for_location(self, location):
|
590 | 591 | path = location.get_folder_path()
|
591 | 592 |
|
592 | 593 | err_location = LocationContext(location)
|
593 |
| - if not err_location.is_empty(): |
| 594 | + if not err_location.is_empty(): |
594 | 595 | folder_name = err_location.pop_location()
|
595 | 596 | code, message = self.is_valid_model_folder_name_for_location(err_location, folder_name)
|
596 | 597 | if code == ValidationCodes.VERSION_INVALID:
|
@@ -790,7 +791,7 @@ def is_valid_model_folder_name_for_location(self, location, model_folder_name):
|
790 | 791 | folder_dict = self.__get_dictionary_for_location(sub_location, False)
|
791 | 792 | if folder_dict is None:
|
792 | 793 | 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]: |
794 | 795 | result = ValidationCodes.VERSION_INVALID
|
795 | 796 | valid_version_range = self._category_dict[UNRESOLVED_FOLDERS_MAP][model_folder_name]
|
796 | 797 | else:
|
@@ -1091,42 +1092,8 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
|
1091 | 1092 | #
|
1092 | 1093 | # First, determine if this dictionary is even relevant to the current WLS version.
|
1093 | 1094 | #
|
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 |
1130 | 1097 |
|
1131 | 1098 | result = dict()
|
1132 | 1099 | if FOLDERS in alias_dict:
|
@@ -1227,6 +1194,94 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
|
1227 | 1194 |
|
1228 | 1195 | return result
|
1229 | 1196 |
|
| 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 | + The folder params has a two-fold purpose. To identify valid version / wlst mode |
| 1258 | + combinations (all version / wlst mode combinations must be represented). And to |
| 1259 | + contain folder parameters that are different depending on the combination. Once |
| 1260 | + a folder parameter version has been selected, then all the folder parameters in the |
| 1261 | + valid entry are added to the alias_dict dictionary parameters. |
| 1262 | + :param alias_dict: |
| 1263 | + :return: |
| 1264 | + """ |
| 1265 | + _method_name = '__resolve_folder_params' |
| 1266 | + if FOLDER_PARAMS in alias_dict: |
| 1267 | + folder_params = alias_dict[FOLDER_PARAMS] |
| 1268 | + |
| 1269 | + if not isinstance(folder_params, list): |
| 1270 | + ex = exception_helper.create_alias_exception('WLSDPLY-08134', path_name, class_name=_class_name, |
| 1271 | + method_name=_method_name) |
| 1272 | + _logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 1273 | + raise ex |
| 1274 | + |
| 1275 | + if folder_params: |
| 1276 | + add_entry = folder_params[0] |
| 1277 | + for folder_set in folder_params: |
| 1278 | + if self.__test_dictionary(path_name, folder_set): |
| 1279 | + _logger.finer('WLSDPLY-08135', path_name, class_name=_class_name, method_name=_method_name) |
| 1280 | + add_entry = folder_set |
| 1281 | + break |
| 1282 | + for key, value in add_entry.iteritems(): |
| 1283 | + alias_dict[key] = value |
| 1284 | + |
1230 | 1285 | def __resolve_attribute_by_wlst_context(self, path_name, attr_name, attrs_dict):
|
1231 | 1286 | """
|
1232 | 1287 | Find the attribute list element that applies to the current WLS version and WLST mode.
|
@@ -1436,3 +1491,10 @@ def __get_path_for_location(self, location, path_type=WLST_ATTRIBUTES_PATH):
|
1436 | 1491 |
|
1437 | 1492 | _logger.exiting(class_name=_class_name, method_name=_method_name, result=tokenized_path)
|
1438 | 1493 | return tokenized_path
|
| 1494 | + |
| 1495 | + |
| 1496 | +def _add_to_unresolved_folders(path_name, parent_dict, unresolved): |
| 1497 | + if UNRESOLVED_FOLDERS_MAP not in parent_dict: |
| 1498 | + parent_dict[UNRESOLVED_FOLDERS_MAP] = dict() |
| 1499 | + alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name) |
| 1500 | + parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = unresolved |
0 commit comments