Skip to content

Commit a482d0b

Browse files
Merge pull request #125 from oracle/issue#123-aliases-should-handle-typeerror
Issue#123 - Convert TypeError to AliasException when thrown
2 parents f4e16ce + 987b9b3 commit a482d0b

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

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

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def is_attribute_server_start_arguments(location, model_attribute_name):
555555
:return: True if so, False otherwise
556556
"""
557557
return location.get_folder_path() == _server_start_location_folder_path and \
558-
model_attribute_name == _server_start_argument_attribute_name
558+
model_attribute_name == _server_start_argument_attribute_name
559559

560560

561561
def compute_delimiter_from_data_type(data_type, value):
@@ -631,6 +631,8 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
631631
Convert the value to the specified type.
632632
:param data_type: the type
633633
:param value: the value
634+
:param subtype: optional subtype for jarray type
635+
:param delimiter: optional delimiter to use for parsing
634636
:return: the value converted to the specified type
635637
"""
636638
_method_name = 'convert_to_type'
@@ -653,28 +655,33 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
653655
raise ex
654656

655657
if new_value is not None:
656-
if data_type == LONG:
657-
new_value = Long(new_value)
658-
elif data_type == JAVA_LANG_BOOLEAN:
659-
new_value = Boolean(new_value)
660-
elif data_type == JARRAY:
661-
if subtype is None or subtype == 'java.lang.String':
662-
new_value = _create_string_array(new_value)
663-
else:
664-
new_value = _create_mbean_array(new_value, subtype)
665-
elif data_type == LIST:
666-
new_value = list(new_value)
667-
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
668-
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
669-
#
670-
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
671-
# This is required to handle the special case where the value we read from WLST might have a
672-
# different delimiter than the model value. In this use case, the value passed into the method
673-
# is the WLST value delimiter and the data_type is the preferred_model_type, so we compute the
674-
# model delimiter from the data_type directly.
675-
#
676-
delimiter = compute_delimiter_from_data_type(data_type, new_value)
677-
new_value = delimiter.join(new_value)
658+
try:
659+
if data_type == LONG:
660+
new_value = Long(new_value)
661+
elif data_type == JAVA_LANG_BOOLEAN:
662+
new_value = Boolean(new_value)
663+
elif data_type == JARRAY:
664+
if subtype is None or subtype == 'java.lang.String':
665+
new_value = _create_string_array(new_value)
666+
else:
667+
new_value = _create_mbean_array(new_value, subtype)
668+
elif data_type == LIST:
669+
new_value = list(new_value)
670+
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
671+
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
672+
#
673+
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
674+
# This is required to handle the special case where the value we read from WLST might have a
675+
# different delimiter than the model value. In this use case, the value passed into the method
676+
# is the WLST value delimiter and the data_type is the preferred_model_type, so we compute the
677+
# model delimiter from the data_type directly.
678+
#
679+
delimiter = compute_delimiter_from_data_type(data_type, new_value)
680+
new_value = delimiter.join(new_value)
681+
except TypeError, te:
682+
ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, te)
683+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
684+
raise ex
678685

679686
return new_value
680687

0 commit comments

Comments
 (0)