Skip to content

Commit 25a4181

Browse files
rakillenrobertpatrick
authored andcommitted
Support dictionary model types that are string WLST types
1 parent 75f31ca commit 25a4181

File tree

9 files changed

+83
-37
lines changed

9 files changed

+83
-37
lines changed

core/src/main/java/oracle/weblogic/deploy/aliases/TypeUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2025, Oracle 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
package oracle.weblogic.deploy.aliases;
@@ -34,6 +34,7 @@ public final class TypeUtils {
3434
private static final PlatformLogger LOGGER = WLSDeployLogFactory.getLogger("wlsdeploy.util");
3535

3636
public static final String DEFAULT_STRING_LIST_DELIMITER = ",";
37+
public static final String WTC_DELIMITER = "WTC"; // special purpose for Tuxedo / JMS priority maps
3738

3839
private TypeUtils() {
3940
// hide the constructor for this utility class
@@ -128,6 +129,9 @@ public static Object convertToType(String targetTypeName, Object value, String d
128129
targetType = Object[].class;
129130
break;
130131
case "properties":
132+
case "delimited_map":
133+
case "delimited_map[newline]":
134+
case "delimited_map[wtc]":
131135
targetType = Properties.class;
132136
break;
133137
case "OrderedDict":
@@ -429,9 +433,15 @@ static Map<String, String> convertStringToMap(String strValue, String delimiter)
429433
mapString = mapString.substring(0, mapString.length() - 1);
430434
}
431435

436+
String assignOperator = "=";
437+
if(WTC_DELIMITER.equals(delimiter)) {
438+
assignOperator = ":";
439+
delimiter = "\\|";
440+
}
441+
432442
String[] attrPairs = mapString.split(delimiter);
433443
for (String pair : attrPairs) {
434-
String[] keyValue = pair.split("=");
444+
String[] keyValue = pair.split(assignOperator);
435445
if (keyValue.length == 2) {
436446
map.put(keyValue[0].trim(), keyValue[1].trim());
437447
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
BOOLEAN = 'boolean'
8989
COMMA_DELIMITED_STRING = 'delimited_string[comma]'
9090
CREDENTIAL = 'credential'
91+
DELIMITED_MAP = 'delimited_map'
9192
DELIMITED_STRING = 'delimited_string'
9293
DICTIONARY = 'dict'
9394
DOUBLE = 'double'
@@ -96,9 +97,11 @@
9697
JAVA_LANG_BOOLEAN = 'java.lang.Boolean'
9798
LIST = 'list'
9899
LONG = 'long'
100+
NEW_LINE_DELIMITED_MAP = 'delimited_map[newline]'
99101
OBJECT = 'object'
100102
PASSWORD = 'password'
101103
PATH_SEPARATOR_DELIMITED_STRING = 'delimited_string[path_separator]'
104+
WTC_DELIMITED_MAP = 'delimited_map[wtc]'
102105
PROPERTIES = 'properties'
103106
SEMI_COLON_DELIMITED_STRING = 'delimited_string[semicolon]'
104107
SPACE_DELIMITED_STRING = 'delimited_string[space]'
@@ -117,6 +120,12 @@
117120
SPACE_DELIMITED_STRING
118121
]
119122

123+
ALIAS_DELIMITED_MAP_TYPES = [
124+
DELIMITED_MAP,
125+
NEW_LINE_DELIMITED_MAP,
126+
WTC_DELIMITED_MAP
127+
]
128+
120129
ALIAS_LIST_TYPES = [
121130
COMMA_DELIMITED_STRING,
122131
DELIMITED_STRING,
@@ -126,7 +135,14 @@
126135
SEMI_COLON_DELIMITED_STRING,
127136
SPACE_DELIMITED_STRING
128137
]
129-
ALIAS_MAP_TYPES = [PROPERTIES, DICTIONARY]
138+
139+
ALIAS_MAP_TYPES = [
140+
DICTIONARY,
141+
PROPERTIES,
142+
DELIMITED_MAP,
143+
NEW_LINE_DELIMITED_MAP,
144+
WTC_DELIMITED_MAP
145+
]
130146

131147
ALIAS_BOOLEAN_TYPES = [
132148
BOOLEAN,

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

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, Oracle 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
@@ -18,33 +18,33 @@
1818
from java.util import Properties
1919
from javax.management import ObjectName
2020

21-
from oracle.weblogic.deploy.util import PyRealBoolean
2221
from oracle.weblogic.deploy.aliases import TypeUtils
2322
from oracle.weblogic.deploy.aliases import VersionException
2423
from oracle.weblogic.deploy.aliases import VersionUtils
24+
from oracle.weblogic.deploy.util import PyRealBoolean
2525

26-
from wlsdeploy.aliases.alias_constants import BOOLEAN
27-
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
28-
from wlsdeploy.aliases.alias_constants import STRING
29-
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
30-
from wlsdeploy.aliases.wlst_modes import WlstModes
31-
from wlsdeploy.exception import exception_helper
32-
from wlsdeploy.logging.platform_logger import PlatformLogger
33-
26+
from wlsdeploy.aliases.alias_constants import ALIAS_BOOLEAN_TYPES
27+
from wlsdeploy.aliases.alias_constants import ALIAS_DELIMITED_MAP_TYPES
3428
from wlsdeploy.aliases.alias_constants import ALIAS_DELIMITED_TYPES
3529
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
3630
from wlsdeploy.aliases.alias_constants import COMMA_DELIMITED_STRING
31+
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
32+
from wlsdeploy.aliases.alias_constants import DELIMITED_MAP
3733
from wlsdeploy.aliases.alias_constants import DELIMITED_STRING
34+
from wlsdeploy.aliases.alias_constants import DICTIONARY
3835
from wlsdeploy.aliases.alias_constants import JARRAY
3936
from wlsdeploy.aliases.alias_constants import JAVA_LANG_BOOLEAN
4037
from wlsdeploy.aliases.alias_constants import LIST
4138
from wlsdeploy.aliases.alias_constants import LONG
39+
from wlsdeploy.aliases.alias_constants import NEW_LINE_DELIMITED_MAP
4240
from wlsdeploy.aliases.alias_constants import PATH_SEPARATOR_DELIMITED_STRING
4341
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
42+
from wlsdeploy.aliases.alias_constants import PROPERTIES
4443
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_FOLDER_PATHS
4544
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_MBEAN_NAME_MAP
4645
from wlsdeploy.aliases.alias_constants import SEMI_COLON_DELIMITED_STRING
4746
from wlsdeploy.aliases.alias_constants import SPACE_DELIMITED_STRING
47+
from wlsdeploy.aliases.alias_constants import STRING
4848
from wlsdeploy.aliases.alias_constants import VERSION
4949
from wlsdeploy.aliases.alias_constants import WLST_ATTRIBUTES_PATH
5050
from wlsdeploy.aliases.alias_constants import WLST_CREATE_PATH
@@ -53,8 +53,13 @@
5353
from wlsdeploy.aliases.alias_constants import WLST_PATH
5454
from wlsdeploy.aliases.alias_constants import WLST_PATHS
5555
from wlsdeploy.aliases.alias_constants import WLST_READ_TYPE
56-
from wlsdeploy.aliases.alias_constants import WLST_TYPE
5756
from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH
57+
from wlsdeploy.aliases.alias_constants import WLST_TYPE
58+
from wlsdeploy.aliases.alias_constants import WTC_DELIMITED_MAP
59+
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
60+
from wlsdeploy.aliases.wlst_modes import WlstModes
61+
from wlsdeploy.exception import exception_helper
62+
from wlsdeploy.logging.platform_logger import PlatformLogger
5863
from wlsdeploy.util import model_helper
5964
from wlsdeploy.util import unicode_helper as str_helper
6065

@@ -121,7 +126,7 @@ def merge_model_and_existing_properties(model_props, existing_props, string_prop
121126
depending on the type of the model_props
122127
:raises: DeployException: if either properties is not either a string or a java.util.Properties object
123128
"""
124-
_method_name = 'merge_model_and_existing_lists'
129+
_method_name = 'merge_model_and_existing_properties'
125130

126131
_logger.entering(model_props, existing_props, string_props_separator_char,
127132
class_name=_class_name, method_name=_method_name)
@@ -556,12 +561,16 @@ def compute_delimiter_from_data_type(data_type, value):
556561
:return: the delimiter
557562
"""
558563
delimiter = None
559-
if data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING):
564+
if data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, DELIMITED_MAP):
560565
delimiter = ','
561566
elif data_type == SEMI_COLON_DELIMITED_STRING:
562567
delimiter = ';'
563568
elif data_type == SPACE_DELIMITED_STRING:
564569
delimiter = ' '
570+
elif data_type == NEW_LINE_DELIMITED_MAP:
571+
delimiter = '\n'
572+
elif data_type == WTC_DELIMITED_MAP:
573+
delimiter = TypeUtils.WTC_DELIMITER
565574
elif data_type == PATH_SEPARATOR_DELIMITED_STRING:
566575
delimiter = _get_path_separator(value)
567576
else:
@@ -720,6 +729,11 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
720729
#
721730
delimiter = compute_delimiter_from_data_type(data_type, new_value)
722731
new_value = delimiter.join(new_value)
732+
elif data_type in ALIAS_DELIMITED_MAP_TYPES:
733+
# see comment for ALIAS_DELIMITED_TYPES re: delimiter
734+
delimiter = compute_delimiter_from_data_type(data_type, new_value)
735+
new_value = _properties_to_string(new_value, delimiter)
736+
723737
except TypeError, te:
724738
ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, te)
725739
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
@@ -856,15 +870,12 @@ def _convert_value_to_model_type(data_type, value, delimiter):
856870
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
857871
raise ex
858872
try:
859-
if data_type == JAVA_LANG_BOOLEAN:
860-
converted = Boolean(converted)
861-
elif data_type == BOOLEAN:
873+
if data_type in ALIAS_BOOLEAN_TYPES: # TypeUtils returns a string for boolean
862874
converted = PyRealBoolean('true' == converted)
863875
elif data_type == JARRAY:
864876
converted = _create_array(converted, delimiter)
865-
# elif data_type == PROPERTIES:
866-
# if preferred == DICTIONARY:
867-
# new_value = _jconvert_to_type(preferred, new_value, delimiter)
877+
elif data_type == PROPERTIES:
878+
converted = TypeUtils.convertToType(DICTIONARY, converted, delimiter)
868879
elif data_type == LIST:
869880
if converted:
870881
# convert any object elements to str, especially ObjectNames
@@ -882,6 +893,9 @@ def _convert_value_to_model_type(data_type, value, delimiter):
882893
# convert any object elements to str, especially ObjectNames
883894
converted = _create_array(converted, model_delimiter)
884895
converted = model_delimiter.join(converted)
896+
elif data_type in ALIAS_DELIMITED_MAP_TYPES:
897+
converted = TypeUtils.convertToType(DICTIONARY, converted, delimiter)
898+
885899
except TypeError, te:
886900
ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter,
887901
str_helper.to_string(te))
@@ -1031,12 +1045,17 @@ def _properties_to_string(props, string_props_separator_char):
10311045
result = props
10321046
else:
10331047
result = ''
1048+
assign_operator = '='
1049+
if string_props_separator_char == TypeUtils.WTC_DELIMITER:
1050+
string_props_separator_char = ' | '
1051+
assign_operator = ':'
1052+
10341053
for entry_set in props.entrySet():
10351054
key = entry_set.getKey()
10361055
value = entry_set.getValue()
10371056
if len(result) > 0:
10381057
result += string_props_separator_char
1039-
result += str_helper.to_string(key) + '=' + str_helper.to_string(value)
1058+
result += str_helper.to_string(key) + assign_operator + str_helper.to_string(value)
10401059
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
10411060
return result
10421061

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from wlsdeploy.aliases import alias_utils
1515
from wlsdeploy.aliases import password_utils
1616
from wlsdeploy.aliases.alias_constants import ACCESS
17+
from wlsdeploy.aliases.alias_constants import ALIAS_BOOLEAN_TYPES
1718
from wlsdeploy.aliases.alias_constants import ALIAS_LIST_TYPES
1819
from wlsdeploy.aliases.alias_constants import ALIAS_MAP_TYPES
1920
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
@@ -1139,11 +1140,11 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
11391140
if attribute_info is not None and not self.__is_model_attribute_ignored(location, attribute_info):
11401141
model_attribute_name = attribute_info[MODEL_NAME]
11411142

1142-
wlst_type, preferred_type, delimiter = \
1143+
_wlst_read_type, preferred_type, delimiter = \
11431144
alias_utils.compute_read_data_type_for_wlst_and_delimiter_from_attribute_info(
11441145
attribute_info, wlst_attribute_value)
11451146

1146-
model_type = wlst_type
1147+
model_type = attribute_info[WLST_TYPE]
11471148
if preferred_type:
11481149
model_type = preferred_type
11491150

@@ -1212,7 +1213,7 @@ def _get_model_attribute_value(self, wlst_value, default_value, attribute_info,
12121213

12131214
result_model_value = None
12141215

1215-
if model_type == 'boolean':
1216+
if model_type in ALIAS_BOOLEAN_TYPES:
12161217
# some boolean attributes have WLST value of null until they are set
12171218
result_model_value = _get_boolean_or_none(wlst_value) # from unconverted value
12181219
default_boolean = _get_boolean_or_none(default_value)

core/src/main/python/wlsdeploy/tool/validate/validation_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, Oracle 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 re
@@ -144,15 +144,15 @@ def is_compatible_data_type(expected_data_type, actual_data_type):
144144
_type_py_real_boolean, _type_orcl_py_real_boolean])
145145
elif expected_data_type in ['float', 'double']:
146146
retval = (actual_data_type in [_type_float, _type_str, _type_unicode])
147-
elif expected_data_type == 'properties' or expected_data_type == 'dict':
148-
retval = (actual_data_type in [_type_py_ordered_dict, _type_orcl_py_ordered_dict, _type_dict, _type_str])
147+
elif expected_data_type == 'properties' or expected_data_type == 'dict' or 'delimited_map' in expected_data_type:
148+
retval = (actual_data_type in [_type_py_ordered_dict, _type_orcl_py_ordered_dict, _type_dict, _type_str, _type_unicode])
149149
elif 'list' in expected_data_type:
150150
retval = (actual_data_type in [_type_list, _type_str, _type_unicode])
151151
elif expected_data_type in ['password']:
152152
retval = (actual_data_type in [_type_str, _type_unicode, _type_py_array])
153153
elif expected_data_type in ['credential', 'jarray']:
154154
retval = (actual_data_type in [_type_str, _type_unicode])
155-
elif 'delimited_' in expected_data_type:
155+
elif 'delimited_string' in expected_data_type:
156156
retval = (actual_data_type in [_type_str, _type_list, _type_unicode])
157157

158158
return retval

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,15 +1751,15 @@
17511751
"folders" : {},
17521752
"attributes" : {
17531753
"CompatibilityObjectName": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "CompatibilityObjectName", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "access": "IGNORED" } ],
1754-
"ConnectionProperties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ConnectionProperties", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
1754+
"ConnectionProperties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ConnectionProperties", "wlst_path": "WP001", "default_value": null, "wlst_type": "delimited_map" } ],
17551755
"ConnectionURL": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ConnectionURL", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
17561756
"DriverName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DriverName", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
17571757
"JMSExceptionReconnectAttempts": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JMSExceptionReconnectAttempts", "wlst_path": "WP001", "default_value": 0, "wlst_type": "integer" } ],
17581758
"JMSTopic": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JMSTopic", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
17591759
"JMSTopicConnectionFactory": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JMSTopicConnectionFactory", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
17601760
"JNDIPasswordEncrypted": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JNDIPasswordEncrypted", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "get_method": "GET", "secret_suffix": "jndi" } ],
17611761
"JNDIUsername": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JNDIUsername", "wlst_path": "WP001", "default_value": null, "wlst_type": "credential", "secret_suffix": "jndi" } ],
1762-
"NotificationProperties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "NotificationProperties", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
1762+
"NotificationProperties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "NotificationProperties", "wlst_path": "WP001", "default_value": null, "wlst_type": "delimited_map" } ],
17631763
"PasswordEncrypted": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "PasswordEncrypted", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "get_method": "GET" } ],
17641764
"Username": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Username", "wlst_path": "WP001", "default_value": null, "wlst_type": "credential" } ]
17651765
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"Include": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Include${:s}", "wlst_path": "WP001", "default_value": null, "wlst_type": "delimited_string", "get_method": "LSA" } ],
6464
"LocationType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "LocationType", "wlst_path": "WP001", "default_value": "${__NULL__:before}", "wlst_type": "string" } ],
6565
"Pointcut": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Pointcut", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
66-
"Properties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Properties", "wlst_path": "WP001", "default_value": null, "wlst_type": "delimited_string[semicolon]", "preferred_model_type": "delimited_string" } ]
66+
"Properties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Properties", "wlst_path": "WP001", "default_value": null, "wlst_type": "delimited_map[newline]" } ]
6767
},
6868
"wlst_attributes_path": "WP001",
6969
"wlst_paths": {

0 commit comments

Comments
 (0)