Skip to content

Commit 9690fdd

Browse files
Merge pull request #1047 from oracle/JIRA-WT-464-alias-none
Jira WDT-464 avoid using "None" for null in alias files
2 parents 6900072 + bc42fea commit 9690fdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5592
-5594
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
These constants are internal to the aliases module and should not be used, as they are not part of the public API.
@@ -10,8 +10,8 @@
1010
ATTRIBUTES = 'attributes'
1111
CHILD_FOLDERS_TYPE = 'child_folders_type'
1212
CONTAINS = 'contains'
13-
DEFAULT = 'default'
1413
DEFAULT_NAME_VALUE = 'default_name_value'
14+
DEFAULT_VALUE = 'default_value'
1515
FLATTENED_FOLDER_DATA = 'flattened_folder_data'
1616
FOLDERS = 'folders'
1717
FOLDER_ORDER = 'folder_order'
@@ -31,7 +31,6 @@
3131
UNRESOLVED_ATTRIBUTES_MAP = '__unresolved_attributes__'
3232
UNRESOLVED_FOLDERS_MAP = '__unresolved_folders__'
3333
USES_PATH_TOKENS = 'uses_path_tokens'
34-
VALUE = 'value'
3534
# VERSION is used for folder versioning
3635
VERSION = 'version'
3736
# VERSION_RAGE is used for attribute versioning
@@ -70,6 +69,9 @@
7069
ROD = 'ROD' # Read only but discover
7170
RW = 'RW' # Default Read WRITE
7271

72+
# used when DEFAULT_VALUE has curly-brace value that resolves to null
73+
NULL_VALUE_KEY = '__NULL__'
74+
7375
# attribute wlst_type values
7476
BOOLEAN = 'boolean'
7577
COMMA_DELIMITED_STRING = 'delimited_string[comma]'

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import copy
@@ -17,6 +17,7 @@
1717
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
1818
from wlsdeploy.aliases.alias_constants import CONTAINS
1919
from wlsdeploy.aliases.alias_constants import DEFAULT_NAME_VALUE
20+
from wlsdeploy.aliases.alias_constants import DEFAULT_VALUE
2021
from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
2122
from wlsdeploy.aliases.alias_constants import FOLDER_ORDER
2223
from wlsdeploy.aliases.alias_constants import FOLDER_PARAMS
@@ -26,6 +27,7 @@
2627
from wlsdeploy.aliases.alias_constants import MODEL_NAME
2728
from wlsdeploy.aliases.alias_constants import NAME_VALUE
2829
from wlsdeploy.aliases.alias_constants import NONE_CHILD_FOLDERS_TYPE
30+
from wlsdeploy.aliases.alias_constants import NULL_VALUE_KEY
2931
from wlsdeploy.aliases.alias_constants import PATH_TOKEN
3032
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
3133
from wlsdeploy.aliases.alias_constants import SET_METHOD
@@ -890,7 +892,7 @@ def is_model_location_valid(self, location):
890892
def get_folders_in_order_for_location(self, location):
891893
"""
892894
Find the folders that are ordered (greater than zero) at the specified location and
893-
return the list in order of the
895+
return the list in ascending order
894896
:param location:
895897
:return:
896898
"""
@@ -1467,6 +1469,9 @@ def __resolve_attribute(self, attr_dict):
14671469
result[key] = self.__resolve_attribute(attr)
14681470
else:
14691471
result[key] = self._resolve_curly_braces(attr)
1472+
# resolve null key in curly brace values, such as "${__NULL__,Online}"
1473+
if key == DEFAULT_VALUE and result[key] == NULL_VALUE_KEY:
1474+
result[key] = None
14701475

14711476
for key in [GET_METHOD, SET_METHOD, GET_MBEAN_TYPE, SET_MBEAN_TYPE]:
14721477
if key in result and len(result[key]) == 0:

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from wlsdeploy.aliases.alias_constants import ALIAS_MAP_TYPES
1717
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
1818
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
19-
from wlsdeploy.aliases.alias_constants import DEFAULT
19+
from wlsdeploy.aliases.alias_constants import DEFAULT_VALUE
2020
from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
2121
from wlsdeploy.aliases.alias_constants import FOLDERS
2222
from wlsdeploy.aliases.alias_constants import GET
@@ -38,7 +38,6 @@
3838
from wlsdeploy.aliases.alias_constants import SET_METHOD
3939
from wlsdeploy.aliases.alias_constants import STRING
4040
from wlsdeploy.aliases.alias_constants import USES_PATH_TOKENS
41-
from wlsdeploy.aliases.alias_constants import VALUE
4241
from wlsdeploy.aliases.alias_constants import WLST_NAME
4342
from wlsdeploy.aliases.alias_constants import WLST_READ_TYPE
4443
from wlsdeploy.aliases.alias_constants import WLST_TYPE
@@ -990,20 +989,21 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
990989
delimiter=delimiter)
991990

992991
model_attribute_name = attribute_info[MODEL_NAME]
993-
default_value = attribute_info[VALUE][DEFAULT]
992+
default_value = attribute_info[DEFAULT_VALUE]
994993

995994
#
996995
# The logic below to compare the str() representation of the converted value and the default value
997996
# only works for lists/maps if both the converted value and the default value are the same data type...
998997
#
999998
if (model_type in ALIAS_LIST_TYPES or model_type in ALIAS_MAP_TYPES) \
1000-
and not (default_value == '[]' or default_value == 'None'):
999+
and not (default_value == '[]' or default_value is None):
10011000
# always the model delimiter
10021001
default_value = alias_utils.convert_to_type(model_type, default_value,
10031002
delimiter=MODEL_LIST_DELIMITER)
10041003

10051004
if attribute_info[WLST_TYPE] == STRING:
1006-
default_value = alias_utils.replace_tokens_in_path(location, default_value)
1005+
if default_value:
1006+
default_value = alias_utils.replace_tokens_in_path(location, default_value)
10071007

10081008
if model_type == 'password':
10091009
if string_utils.is_empty(wlst_attribute_value) or converted_value == default_value:
@@ -1021,7 +1021,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
10211021

10221022
elif (model_type in ALIAS_LIST_TYPES or data_type in ALIAS_MAP_TYPES) and \
10231023
(converted_value is None or len(converted_value) == 0):
1024-
if default_value == '[]' or default_value == 'None':
1024+
if default_value == '[]' or default_value is None:
10251025
model_attribute_value = None
10261026

10271027
elif self._model_context is not None and USES_PATH_TOKENS in attribute_info:
@@ -1031,6 +1031,10 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
10311031
model_attribute_value = self._model_context.tokenize_classpath(converted_value)
10321032
if model_attribute_value == default_value:
10331033
model_attribute_value = None
1034+
1035+
elif default_value is None:
1036+
model_attribute_value = converted_value
1037+
10341038
elif str(converted_value) != str(default_value):
10351039
if _strings_are_empty(converted_value, default_value):
10361040
model_attribute_value = None
@@ -1199,15 +1203,12 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
11991203
default_value = None
12001204
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name)
12011205
if attribute_info is not None:
1202-
default_value = attribute_info[VALUE][DEFAULT]
1203-
if default_value == 'None':
1204-
default_value = None
1205-
else:
1206-
data_type, delimiter = \
1207-
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(
1208-
attribute_info, default_value)
1206+
default_value = attribute_info[DEFAULT_VALUE]
1207+
data_type, delimiter = \
1208+
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(
1209+
attribute_info, default_value)
12091210

1210-
default_value = alias_utils.convert_to_type(data_type, default_value, delimiter=delimiter)
1211+
default_value = alias_utils.convert_to_type(data_type, default_value, delimiter=delimiter)
12111212
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=default_value)
12121213
return default_value
12131214
except AliasException, ae:

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"copyright": "Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.",
2+
"copyright": "Copyright (c) 2019, 2022, Oracle Corporation and/or its affiliates.",
33
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
44
"wlst_type": "AdminConsole",
55
"default_name_value": "${NO_NAME_0:%DOMAIN%}",
66
"short_name": "Console",
77
"folders": {},
88
"attributes": {
9-
"CookieName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CookieName", "wlst_path": "WP001", "value": {"default": "ADMINCONSOLESESSION" }, "wlst_type": "string" } ],
10-
"MinThreads": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "MinThreads", "wlst_path": "WP001", "value": {"default": 101 }, "wlst_type": "integer" } ],
11-
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
12-
"ProtectedCookieEnabled": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "ProtectedCookieEnabled", "wlst_path": "WP001", "value": {"default": true }, "wlst_type": "boolean" } ],
13-
"SsoLogoutUrl": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "${Sso:SSO}Logout${Url:URL}", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
14-
"SessionTimeout": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SessionTimeout", "wlst_path": "WP001", "value": {"default": 3600 }, "wlst_type": "integer" } ]
9+
"CookieName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CookieName", "wlst_path": "WP001", "default_value": "ADMINCONSOLESESSION", "wlst_type": "string" } ],
10+
"MinThreads": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "MinThreads", "wlst_path": "WP001", "default_value": 101, "wlst_type": "integer" } ],
11+
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
12+
"ProtectedCookieEnabled": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "ProtectedCookieEnabled", "wlst_path": "WP001", "default_value": true, "wlst_type": "boolean" } ],
13+
"SsoLogoutUrl": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "${Sso:SSO}Logout${Url:URL}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
14+
"SessionTimeout": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SessionTimeout", "wlst_path": "WP001", "default_value": 3600, "wlst_type": "integer" } ]
1515
},
1616
"wlst_attributes_path": "WP001",
1717
"wlst_paths": {

0 commit comments

Comments
 (0)