Skip to content

Issue#123 - Convert TypeError to AliasException when thrown #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions core/src/main/python/wlsdeploy/aliases/alias_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def is_attribute_server_start_arguments(location, model_attribute_name):
:return: True if so, False otherwise
"""
return location.get_folder_path() == _server_start_location_folder_path and \
model_attribute_name == _server_start_argument_attribute_name
model_attribute_name == _server_start_argument_attribute_name


def compute_delimiter_from_data_type(data_type, value):
Expand Down Expand Up @@ -631,6 +631,8 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
Convert the value to the specified type.
:param data_type: the type
:param value: the value
:param subtype: optional subtype for jarray type
:param delimiter: optional delimiter to use for parsing
:return: the value converted to the specified type
"""
_method_name = 'convert_to_type'
Expand All @@ -653,28 +655,33 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
raise ex

if new_value is not None:
if data_type == LONG:
new_value = Long(new_value)
elif data_type == JAVA_LANG_BOOLEAN:
new_value = Boolean(new_value)
elif data_type == JARRAY:
if subtype is None or subtype == 'java.lang.String':
new_value = _create_string_array(new_value)
else:
new_value = _create_mbean_array(new_value, subtype)
elif data_type == LIST:
new_value = list(new_value)
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
#
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
# This is required to handle the special case where the value we read from WLST might have a
# different delimiter than the model value. In this use case, the value passed into the method
# is the WLST value delimiter and the data_type is the preferred_model_type, so we compute the
# model delimiter from the data_type directly.
#
delimiter = compute_delimiter_from_data_type(data_type, new_value)
new_value = delimiter.join(new_value)
try:
if data_type == LONG:
new_value = Long(new_value)
elif data_type == JAVA_LANG_BOOLEAN:
new_value = Boolean(new_value)
elif data_type == JARRAY:
if subtype is None or subtype == 'java.lang.String':
new_value = _create_string_array(new_value)
else:
new_value = _create_mbean_array(new_value, subtype)
elif data_type == LIST:
new_value = list(new_value)
elif data_type in (COMMA_DELIMITED_STRING, DELIMITED_STRING, SEMI_COLON_DELIMITED_STRING,
SPACE_DELIMITED_STRING, PATH_SEPARATOR_DELIMITED_STRING):
#
# This code intentionally ignores the delimiter value passed in and computes it from the data type.
# This is required to handle the special case where the value we read from WLST might have a
# different delimiter than the model value. In this use case, the value passed into the method
# is the WLST value delimiter and the data_type is the preferred_model_type, so we compute the
# model delimiter from the data_type directly.
#
delimiter = compute_delimiter_from_data_type(data_type, new_value)
new_value = delimiter.join(new_value)
except TypeError, te:
ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, te)
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex

return new_value

Expand Down