@@ -685,6 +685,11 @@ def get_wlst_mbean_type_for_location(self, location):
685685 """
686686 _method_name = 'get_wlst_mbean_type_for_location'
687687
688+ # some callers use this method to check for location valid.
689+ # they should call is_model_location_valid(location) directly instead.
690+ if not self .is_model_location_valid (location ):
691+ return None
692+
688693 _logger .entering (str (location ), class_name = _class_name , method_name = _method_name )
689694 folder_dict = self .__get_dictionary_for_location (location , False )
690695 if folder_dict is None :
@@ -907,6 +912,21 @@ def is_valid_model_attribute_name_for_location(self, location, model_attribute_n
907912 _logger .exiting (class_name = _class_name , method_name = _method_name , result = [result , valid_version_range ])
908913 return result , valid_version_range
909914
915+ def is_model_location_valid (self , location ):
916+ """
917+ Determine if the specified location is valid, including version/mode checks.
918+ Returns a boolean answer instead of the (ValidationCode, message) tuple used elsewhere.
919+ :param location: the location to be checked
920+ :return: True if the location is valid, false otherwise
921+ """
922+ if len (location .get_model_folders ()) > 0 :
923+ parent_location = LocationContext (location )
924+ folder = parent_location .pop_location ()
925+ code , message = self .is_valid_model_folder_name_for_location (parent_location , folder )
926+ if code != ValidationCodes .VALID :
927+ return False
928+ return True
929+
910930 def get_folder_short_name_for_location (self , location ):
911931 """
912932 Retrieve the shortened name for the model folder at the provided location.
@@ -1141,10 +1161,10 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
11411161 """
11421162 _method_name = '__apply_wlst_context_changes'
11431163
1144- #
1145- # First, determine if this dictionary is even relevant to the current WLS version.
1146- #
11471164 self .__resolve_folder_params (path_name , alias_dict )
1165+
1166+ # if folder is not valid for this version/mode of WLS,
1167+ # add folder to parent_dict UNRESOLVED_FOLDERS_MAP and return None
11481168 if not self .__use_alias_dict (path_name , alias_dict , parent_dict ):
11491169 return None
11501170
@@ -1153,8 +1173,10 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
11531173 result_folders = dict ()
11541174 folders = alias_dict [FOLDERS ]
11551175 for folder in folders :
1156- folder_dict = self .__apply_wlst_context_changes (path_name + '/' + folder , folders [folder ], alias_dict )
1157- result_folders [folder ] = folder_dict
1176+ folder_dict = self .__apply_wlst_context_changes (path_name + '/' + folder , folders [folder ], result )
1177+ # if folder_dict is None, this folder was invalid for this version/mode of WLS
1178+ if folder_dict is not None :
1179+ result_folders [folder ] = folder_dict
11581180 result [FOLDERS ] = result_folders
11591181
11601182 if FLATTENED_FOLDER_DATA in alias_dict :
0 commit comments