11"""
2- Copyright (c) 2017, 2024 , Oracle and/or its affiliates.
2+ Copyright (c) 2017, 2025 , Oracle and/or its affiliates.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44"""
55import copy
1818from java .util import Properties
1919from javax .management import ObjectName
2020
21- from oracle .weblogic .deploy .util import PyRealBoolean
2221from oracle .weblogic .deploy .aliases import TypeUtils
2322from oracle .weblogic .deploy .aliases import VersionException
2423from 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
3428from wlsdeploy .aliases .alias_constants import ALIAS_DELIMITED_TYPES
3529from wlsdeploy .aliases .alias_constants import ATTRIBUTES
3630from 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
3733from wlsdeploy .aliases .alias_constants import DELIMITED_STRING
34+ from wlsdeploy .aliases .alias_constants import DICTIONARY
3835from wlsdeploy .aliases .alias_constants import JARRAY
3936from wlsdeploy .aliases .alias_constants import JAVA_LANG_BOOLEAN
4037from wlsdeploy .aliases .alias_constants import LIST
4138from wlsdeploy .aliases .alias_constants import LONG
39+ from wlsdeploy .aliases .alias_constants import NEW_LINE_DELIMITED_MAP
4240from wlsdeploy .aliases .alias_constants import PATH_SEPARATOR_DELIMITED_STRING
4341from wlsdeploy .aliases .alias_constants import PREFERRED_MODEL_TYPE
42+ from wlsdeploy .aliases .alias_constants import PROPERTIES
4443from wlsdeploy .aliases .alias_constants import SECURITY_PROVIDER_FOLDER_PATHS
4544from wlsdeploy .aliases .alias_constants import SECURITY_PROVIDER_MBEAN_NAME_MAP
4645from wlsdeploy .aliases .alias_constants import SEMI_COLON_DELIMITED_STRING
4746from wlsdeploy .aliases .alias_constants import SPACE_DELIMITED_STRING
47+ from wlsdeploy .aliases .alias_constants import STRING
4848from wlsdeploy .aliases .alias_constants import VERSION
4949from wlsdeploy .aliases .alias_constants import WLST_ATTRIBUTES_PATH
5050from wlsdeploy .aliases .alias_constants import WLST_CREATE_PATH
5353from wlsdeploy .aliases .alias_constants import WLST_PATH
5454from wlsdeploy .aliases .alias_constants import WLST_PATHS
5555from wlsdeploy .aliases .alias_constants import WLST_READ_TYPE
56- from wlsdeploy .aliases .alias_constants import WLST_TYPE
5756from 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
5863from wlsdeploy .util import model_helper
5964from 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
0 commit comments