Skip to content

Commit 86d687c

Browse files
Merge pull request #166 from oracle/Issue#161-alias-offline-online-folders
Issue#161 alias offline online folders
2 parents 17ffdcc + 3d21d03 commit 86d687c

File tree

7 files changed

+71
-4
lines changed

7 files changed

+71
-4
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ def get_dictionary_for_location(self, location, resolve=True):
210210

211211
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
212212
result = self.__get_dictionary_for_location(location, resolve)
213+
# not one caller checks to see if the dictionary returned is None
214+
if result is None:
215+
result = dict()
213216
_logger.exiting(class_name=_class_name, method_name=_method_name)
214217
return result
215218

@@ -1105,6 +1108,18 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
11051108
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
11061109
raise ex
11071110

1111+
if WLST_MODE in alias_dict:
1112+
dict_wlst_mode = alias_dict[WLST_MODE]
1113+
mode = WlstModes.from_value(self._wlst_mode)
1114+
if not self.__wlst_mode_matches(dict_wlst_mode):
1115+
_logger.finer('WLSDPLY-08132', path_name, dict_wlst_mode, mode, class_name=_class_name,
1116+
method_name=_method_name)
1117+
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1118+
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1119+
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1120+
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = mode
1121+
return None
1122+
11081123
result = dict()
11091124
if FOLDERS in alias_dict:
11101125
result_folders = dict()

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
343343
wlst_attribute_value = None
344344

345345
module_folder = self._alias_entries.get_dictionary_for_location(location)
346+
if not module_folder:
347+
self._logger.fine('WLSDPLY-08410', location.get_current_model_folder(), location.get_parent_folder_path(),
348+
WlstModes.from_value(self._wlst_mode), self._wls_version)
349+
return wlst_attribute_name, wlst_attribute_value
350+
346351
if ATTRIBUTES not in module_folder:
347352
ex = exception_helper.create_alias_exception('WLSDPLY-08400', location.get_folder_path())
348353
self._logger.throwing(ex, class_name=self._class_name, method_name=_method_name)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ def get_current_model_folder(self):
105105
model_folder = model_folder_list[-1]
106106
return model_folder
107107

108+
def get_parent_folder_path(self):
109+
"""
110+
Return the parent folder path for the location. This is the parent of the last folder or None if no parent.
111+
:return: return the parent folder path
112+
"""
113+
result = None
114+
model_folder_list = self.get_model_folders()
115+
if model_folder_list:
116+
result = ''
117+
if len(model_folder_list) > 1:
118+
for folder in model_folder_list[-2]:
119+
result += '/' + folder
120+
if len(result) == 0:
121+
result = '/'
122+
return result
123+
108124
def get_name_tokens(self):
109125
"""
110126
Copy constructor for ``name_tokens`` dictionary of location context.

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/NMProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"copyright": "Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.",
33
"license": "The Universal Permissive License (UPL), Version 1.0",
44
"wlst_type": "NMProperties",
5+
"wlst_mode": "offline",
56
"folders": {},
67
"attributes": {
78
"AuthenticationEnabled": [ {"version": "[12.1.2,)", "wlst_mode": "offline", "wlst_name": "AuthenticationEnabled", "wlst_path": "WP001", "value": {"default": "true" }, "wlst_type": "boolean"} ],

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ WLSDPLY-08130=Unable to compute the name token for folder {0} because the folder
683683
WebLogic Server version {1}: {2}
684684
WLSDPLY-08131=Unable to compute the name token for folder {0} because the folder is not valid in \
685685
WebLogic Server version {1}
686+
WLSDPLY-08132=Folder {0} present only for {1} mode is not relevant for WLST in {2} mode
686687
#
687688
# Empty slots to fill up...
688689
#
@@ -749,6 +750,7 @@ WLSDPLY-08406={0} WLST attribute name is not associated with a model attribute n
749750
WLSDPLY-08407=Attribute {0} in folder {1} is supported in WebLogic version {2}
750751
WLSDPLY-08408=Attribute {0} in folder {1} is not supported in WebLogic version {2}
751752
WLSDPLY-08409=Access for attribute {0} in folder {1} is read-only or validation-only in WLST {2} mode
753+
WLSDPLY-08410={0} model folder at location {1} is not supported for WLST {2} mode WebLogic version {3}
752754

753755
# oracle.weblogic.deploy.aliases.TypeUtils.java
754756
WLSDPLY-08500=Unable to convert type due to an unknown type {0}

core/src/test/python/alias_json_file_test.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ListTestCase(unittest.TestCase):
7070
VERSION,
7171
WLST_CREATE_PATH,
7272
WLST_LIST_PATH,
73+
WLST_MODE,
7374
WLST_SUBFOLDERS_PATH
7475
]
7576

@@ -276,6 +277,7 @@ def _verify_folder_wlst_paths_attribute_type(self, folder_name, attribute_value)
276277
result.append(self._get_invalid_dictionary_type_message(folder_name, WLST_PATHS, attribute_value))
277278
return result
278279

280+
279281
def _verify_folder_wlst_type_attribute_type(self, folder_name, attribute_value):
280282
result = []
281283
if type(attribute_value) is not str:
@@ -341,6 +343,19 @@ def _verify_folder_version_attribute_value(self, folder_name, attribute_value):
341343
result.append(self._get_invalid_string_type_message(folder_name, VERSION, attribute_value))
342344
return result
343345

346+
def _verify_folder_wlst_mode_attribute_value(self, folder_name, attribute_value):
347+
result = []
348+
if type(attribute_value) is not str:
349+
message = self._get_invalid_attribute_string_type_message(folder_name, folder_name,
350+
WLST_MODE, attribute_value)
351+
result.append(message)
352+
else:
353+
# curly braces not allowed in wlst_mode
354+
if attribute_value not in self._known_wlst_mode_attribute_values:
355+
message = self._get_invalid_wlst_mode_message(folder_name, attribute_value)
356+
result.append(message)
357+
return result
358+
344359
def _verify_folder_wlst_create_path_attribute_value(self, folder_name, attribute_value):
345360
result = []
346361
if type(attribute_value) is not str:
@@ -653,6 +668,12 @@ def _get_invalid_attribute_boolean_string_value_message(self, folder_name, attri
653668

654669
return text % (folder_name, attribute_name, alias_attribute_name, alias_attribute_value)
655670

671+
672+
def _get_invalid_wlst_mode_message(self, folder_name, alias_attribute_name):
673+
text = 'Folder at path %s has invalid wlst mode type of %s'
674+
result = text %(folder_name, alias_attribute_name)
675+
return result
676+
656677
def _get_empty_constrained_value_message(self, folder_name, attribute_name, alias_attribute_name, wlst_mode=None):
657678
if wlst_mode is None:
658679
text = 'Folder at path %s has a defined attribute %s with alias attribute %s whose value was empty'
@@ -673,4 +694,4 @@ def _get_invalid_alias_attribute_value_message(self, folder_name, attribute_name
673694
wlst_mode, alias_attribute_value, cause):
674695
text = 'Folder at path %s has a defined attribute %s with alias attribute %s whose ' \
675696
'%s value %s was not valid because %s'
676-
return text % (folder_name, attribute_name, alias_attribute_name, wlst_mode, alias_attribute_value, cause)
697+
return text % (folder_name, attribute_name, alias_attribute_name, wlst_mode, alias_attribute_value, cause)

core/src/test/python/aliases_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from oracle.weblogic.deploy.aliases import TypeUtils
1414

1515
from wlsdeploy.aliases.aliases import Aliases
16+
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
1617
from wlsdeploy.aliases.location_context import LocationContext
1718
import wlsdeploy.aliases.model_constants as FOLDERS
1819
from wlsdeploy.aliases.validation_codes import ValidationCodes
@@ -1234,10 +1235,16 @@ def testIssue91Fix(self):
12341235
wlst_list_path = self.aliases.get_wlst_list_path(location)
12351236
self.assertEqual(wlst_list_path, expected)
12361237

1237-
# All the attributes in FOLDERS.NM_PROPERTIES have 'wlst_mode':'offline", so
1238-
# the default value should be None
1238+
# NMProperties is an offline only folder and the get_model_attribute_default_value will throw and exception
1239+
model_attribute_name = 'weblogic.StartScriptName'
1240+
1241+
self.assertRaises(AliasException, getattr(self.online_aliases, 'get_model_attribute_default_value'),
1242+
location, model_attribute_name)
1243+
1244+
# this method will not return an exception but should return a None
1245+
default_name, default_value = \
1246+
self.online_aliases.get_wlst_attribute_name_and_value(location, model_attribute_name, 'script')
12391247
expected = None
1240-
default_value = self.online_aliases.get_model_attribute_default_value(location, 'weblogic.StartScriptName')
12411248
self.assertEqual(default_value, expected)
12421249

12431250
return

0 commit comments

Comments
 (0)