1
1
"""
2
- Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2
+ Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
"""
5
5
from java .lang import String
40
40
from wlsdeploy .aliases .alias_constants import USES_PATH_TOKENS
41
41
from wlsdeploy .aliases .alias_constants import VALUE
42
42
from wlsdeploy .aliases .alias_constants import WLST_NAME
43
+ from wlsdeploy .aliases .alias_constants import WLST_READ_TYPE
43
44
from wlsdeploy .aliases .alias_constants import WLST_TYPE
44
45
from wlsdeploy .aliases .alias_entries import AliasEntries
45
46
from wlsdeploy .aliases .model_constants import MODEL_LIST_DELIMITER
@@ -503,8 +504,8 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
503
504
delimiter = MODEL_LIST_DELIMITER )
504
505
505
506
_read_type , read_delimiter = \
506
- alias_utils .compute_read_data_type_and_delimiter_from_attribute_info (attribute_info ,
507
- existing_wlst_value )
507
+ alias_utils .compute_read_data_type_and_delimiter_from_attribute_info (
508
+ attribute_info , existing_wlst_value )
508
509
existing_val = alias_utils .convert_to_type (LIST , existing_wlst_value ,
509
510
delimiter = read_delimiter )
510
511
merged_value = alias_utils .merge_model_and_existing_lists (model_val , existing_val )
@@ -1112,6 +1113,25 @@ def is_valid_model_attribute_name(self, location, model_attribute_name):
1112
1113
self ._raise_exception (ae , _method_name , 'WLSDPLY-19031' , model_attribute_name , location .get_folder_path (),
1113
1114
ae .getLocalizedMessage ())
1114
1115
1116
+ def get_model_attribute_type (self , location , model_attribute_name ):
1117
+ """
1118
+ Get the wlst_type for the model attribute name at the specified location
1119
+ :param location:
1120
+ :param model_attribute_name:
1121
+ :return: WLST attribute type
1122
+ """
1123
+ _method_name = 'get_model_attribute_type'
1124
+ wlst_type = None
1125
+ try :
1126
+ attribute_info = self ._alias_entries .get_alias_attribute_entry_by_model_name (location , model_attribute_name )
1127
+ if attribute_info is not None :
1128
+ wlst_type = attribute_info [WLST_TYPE ]
1129
+ except AliasException , ae :
1130
+ self ._raise_exception (ae , _method_name , 'WLSDPLY-19015' , model_attribute_name , location .get_folder_path (),
1131
+ ae .getLocalizedMessage ())
1132
+
1133
+ return wlst_type
1134
+
1115
1135
def get_model_attribute_default_value (self , location , model_attribute_name ):
1116
1136
"""
1117
1137
Get the default value for the specified attribute
@@ -1132,7 +1152,8 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
1132
1152
default_value = None
1133
1153
else :
1134
1154
data_type , delimiter = \
1135
- alias_utils .compute_read_data_type_and_delimiter_from_attribute_info (attribute_info , default_value )
1155
+ alias_utils .compute_read_data_type_and_delimiter_from_attribute_info (
1156
+ attribute_info , default_value )
1136
1157
1137
1158
default_value = alias_utils .convert_to_type (data_type , default_value , delimiter = delimiter )
1138
1159
self ._logger .exiting (class_name = self ._class_name , method_name = _method_name , result = default_value )
@@ -1152,6 +1173,50 @@ def get_ignore_attribute_names(self):
1152
1173
self ._logger .finest ('WLSDPLY-19038' , names , class_name = self ._class_name , method_name = _method_name )
1153
1174
return names
1154
1175
1176
+ def get_preferred_model_type (self , location , model_attribute_name ):
1177
+ """
1178
+ Return the preferred model type, if present, for the alias attribute definition.
1179
+ :param location: current location context
1180
+ :param model_attribute_name: name of the attribute to look up in model representation
1181
+ :return: alias attribute preferred model type or None if not present or attribute not found
1182
+ :raises: Tool Exception if an AliasException encountered
1183
+ """
1184
+ _method_name = 'get_preferred_model_type'
1185
+ self ._logger .entering (str (location ), model_attribute_name ,
1186
+ class_name = self ._class_name , method_name = _method_name )
1187
+ result = None
1188
+ try :
1189
+ attribute_info = self ._alias_entries .get_alias_attribute_entry_by_model_name (location , model_attribute_name )
1190
+ if attribute_info is not None and PREFERRED_MODEL_TYPE in attribute_info :
1191
+ result = attribute_info [PREFERRED_MODEL_TYPE ]
1192
+ except AliasException , ae :
1193
+ self ._raise_exception (ae , _method_name , 'WLSDPLY-19042' , model_attribute_name , location .get_folder_path (),
1194
+ ae .getLocalizedMessage ())
1195
+ self ._logger .exiting (class_name = self ._class_name , method_name = _method_name , result = result )
1196
+ return result
1197
+
1198
+ def get_wlst_read_type (self , location , model_attribute_name ):
1199
+ """
1200
+ Return the aliases attribute WLST_READ_TYPE, which overrides the WLST_TYPE when retrieving the attribute value.
1201
+ :param location: The context for the current location in WLST
1202
+ :param model_attribute_name: the model name for the WLST attribute
1203
+ :return: WLST_READ_TYPE or None if not defined for the attribute in the alias definitions
1204
+ :raises: Tool Exception when AliasException occurs retrieving read type
1205
+ """
1206
+ _method_name = 'get_wlst_read_type'
1207
+ self ._logger .entering (str (location ), model_attribute_name ,
1208
+ class_name = self ._class_name , method_name = _method_name )
1209
+ result = None
1210
+ try :
1211
+ attribute_info = self ._alias_entries .get_alias_attribute_entry_by_model_name (location , model_attribute_name )
1212
+ if attribute_info is not None and WLST_READ_TYPE in attribute_info :
1213
+ result = attribute_info [WLST_READ_TYPE ]
1214
+ except AliasException , ae :
1215
+ self ._raise_exception (ae , _method_name , 'WLSDPLY-19043' , model_attribute_name , location .get_folder_path (),
1216
+ ae .getLocalizedMessage ())
1217
+ self ._logger .exiting (class_name = self ._class_name , method_name = _method_name , result = result )
1218
+ return result
1219
+
1155
1220
def decrypt_password (self , text ):
1156
1221
"""
1157
1222
Decrypt the specified password if model encryption is used and the password is encrypted.
0 commit comments