Skip to content

Commit 31e2394

Browse files
CarolynRountreeddsharpe
authored andcommitted
Change Tokenize to look at canonical strings (#501)
1 parent 0796ab9 commit 31e2394

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from wlsdeploy.aliases.alias_constants import RESTART_REQUIRED
4444
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
4545
from wlsdeploy.aliases.alias_constants import SET_METHOD
46+
from wlsdeploy.aliases.alias_constants import STRING
4647
from wlsdeploy.aliases.alias_constants import USES_PATH_TOKENS
4748
from wlsdeploy.aliases.alias_constants import VALUE
4849
from wlsdeploy.aliases.alias_constants import WLST_NAME
@@ -969,13 +970,18 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
969970
if default_value == '[]' or default_value == 'None':
970971
model_attribute_value = None
971972

973+
elif self._model_context is not None and USES_PATH_TOKENS in attribute_info:
974+
if attribute_info[WLST_TYPE] == STRING:
975+
model_attribute_value = self._model_context.tokenize_path(converted_value)
976+
else:
977+
model_attribute_value = self._model_context.tokenize_classpath(converted_value)
978+
if model_attribute_value == default_value:
979+
model_attribute_value = None
972980
elif str(converted_value) != str(default_value):
973981
if _strings_are_empty(converted_value, default_value):
974982
model_attribute_value = None
975983
else:
976984
model_attribute_value = converted_value
977-
if self._model_context and USES_PATH_TOKENS in attribute_info:
978-
model_attribute_value = self._model_context.tokenize_path(model_attribute_value)
979985

980986
self._logger.exiting(class_name=self._class_name, method_name=_method_name,
981987
result={model_attribute_name: model_attribute_value})
@@ -1245,22 +1251,23 @@ def __is_model_attribute_read_only(self, location, attribute_info):
12451251
return rtnval
12461252

12471253

1254+
def _convert_to_string(value):
1255+
if type(value) in [str, unicode]:
1256+
str_converted_value = value
1257+
else:
1258+
str_converted_value = str(value)
1259+
return str_converted_value
1260+
1261+
12481262
def _strings_are_empty(converted_value, default_value):
12491263
"""
12501264
Test converted and default values to see if they are both either None or an empty string
12511265
:param converted_value: the converted value
12521266
:param default_value: the default value
12531267
:return:
12541268
"""
1255-
if type(converted_value) is str:
1256-
str_converted_value = converted_value
1257-
else:
1258-
str_converted_value = str(converted_value)
1259-
1260-
if type(default_value) is str:
1261-
str_default_value = default_value
1262-
else:
1263-
str_default_value = str(default_value)
1269+
str_converted_value = _convert_to_string(converted_value)
1270+
str_default_value = _convert_to_string(default_value)
12641271

12651272
if str_default_value == 'None':
12661273
str_default_value = None

core/src/main/python/wlsdeploy/util/model_context.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from wlsdeploy.logging import platform_logger
1010
from wlsdeploy.util.cla_utils import CommandLineArgUtil
1111
from wlsdeploy.util import path_utils
12+
from wlsdeploy.util import string_utils
1213
from wlsdeploy.util.weblogic_helper import WebLogicHelper
1314

1415

@@ -578,18 +579,21 @@ def tokenize_path(self, path):
578579
:return: tokenized path or original path
579580
"""
580581
my_path = path_utils.fixup_path(path)
582+
wl_home = path_utils.fixup_path(self.get_wl_home())
583+
domain_home = path_utils.fixup_path(self.get_domain_home())
584+
oracle_home = path_utils.fixup_path(self.get_oracle_home())
581585
tmp_dir = path_utils.fixup_path(tempfile.gettempdir())
582586
cwd = path_utils.fixup_path(os.path.dirname(os.path.abspath(__file__)))
583587

584588
# decide later what is required to be in context home for appropriate exception prevention
585589
result = my_path
586-
if my_path:
587-
if self.get_wl_home() and my_path.startswith(self.get_wl_home()):
588-
result = my_path.replace(self.get_wl_home(), self.__WL_HOME_TOKEN)
589-
elif self.get_domain_home() and my_path.startswith(self.get_domain_home()):
590-
result = my_path.replace(self.get_domain_home(), self.__DOMAIN_HOME_TOKEN)
591-
elif self.get_oracle_home() and my_path.startswith(self.get_oracle_home()):
592-
result = my_path.replace(self.get_oracle_home(), self.__ORACLE_HOME_TOKEN)
590+
if not string_utils.is_empty(my_path):
591+
if wl_home is not None and my_path.startswith(wl_home):
592+
result = my_path.replace(wl_home, self.__WL_HOME_TOKEN)
593+
elif domain_home is not None and my_path.startswith(domain_home):
594+
result = my_path.replace(domain_home, self.__DOMAIN_HOME_TOKEN)
595+
elif oracle_home is not None and my_path.startswith(oracle_home):
596+
result = my_path.replace(oracle_home, self.__ORACLE_HOME_TOKEN)
593597
elif my_path.startswith(cwd):
594598
result = my_path.replace(cwd, self.__CURRENT_DIRECTORY_TOKEN)
595599
elif my_path.startswith(tmp_dir):

core/src/main/python/wlsdeploy/util/path_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def fixup_path(path):
4141
"""
4242
result = path
4343
if path is not None:
44-
result = path.replace('\\', '/')
44+
if is_relative_path(path):
45+
result = path.replace('\\', '/')
46+
else:
47+
result = get_canonical_path(path)
4548
if result.endswith('/'):
4649
result = result[:-1]
4750
return result

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
"PersistenceDefaultMode": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "PersistenceDefaultMode", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "access": "RO" } ],
267267
"PersistenceSnapshotDirectory": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "PersistenceSnapshotDirectory", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "access": "RO" } ],
268268
"PersistenceTrashDirectory": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "PersistenceTrashDirectory", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "access": "RO" } ],
269-
"ReportGroupFile": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ReportGroupFile", "wlst_path": "WP001", "value": {"default": "em/coherence/report-group.xml" }, "wlst_type": "string"} ],
269+
"ReportGroupFile": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ReportGroupFile", "wlst_path": "WP001", "value": {"default": "em/metadata/reports/coherence/report-group.xml" }, "wlst_type": "string", "uses_path_tokens": "true" } ],
270270
"SourcePath": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "SourcePath", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
271271
"Target": [ {"version": "[12.1.2,)", "wlst_mode": "offline", "wlst_name": "Target", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "delimited_string" },
272272
{"version": "[12.1.2,)", "wlst_mode": "online", "wlst_name": "Targets", "wlst_path": "WP002", "value": {"default": "None" }, "wlst_type": "jarray", "preferred_model_type": "delimited_string", "get_method": "GET", "set_method": "MBEAN.set_target_mbeans", "set_mbean_type": "weblogic.management.configuration.TargetMBean"} ],

0 commit comments

Comments
 (0)