@@ -297,54 +297,56 @@ def get_model_folder_path_for_location(self, location):
297297 _method_name = 'get_model_folder_path_for_location'
298298
299299 _logger .entering (str (location ), class_name = _class_name , method_name = _method_name )
300+
301+ # Initialize return variable
302+ model_folder_path = ''
303+
300304 if not location .is_empty ():
301305 location_folders = location .get_model_folders ()
306+
307+ if location_folders [0 ] in self .get_model_topology_subfolder_names ():
308+ model_folder_path += 'topology:/'
309+ elif location_folders [0 ] in self .get_model_resources_subfolder_names ():
310+ model_folder_path += 'resources:/'
311+ elif location_folders [0 ] in self .get_model_app_deployments_subfolder_names ():
312+ model_folder_path += 'appDeployments:/'
313+ elif location_folders [0 ] == 'domainInfo' :
314+ model_folder_path += 'domainInfo:/'
315+
302316 my_loc = LocationContext ()
303317
304- first_folder = True
305- result = ''
306318 for location_folder in location_folders :
307- if first_folder :
308- first_folder = False
309- if location_folder in self .__topology_top_level_folders :
310- result += 'topology:/'
311- elif location_folder in self .__resources_top_level_folders :
312- result += 'resources:/'
313- elif location_folder in self .__app_deployments_top_level_folders :
314- result += 'appDeployments:/'
315- elif location_folder == 'domainInfo' :
316- result += 'domainInfo:/'
317- else :
318- ex = exception_helper .create_alias_exception ('WLSDPLY-08100' , location_folder )
319- _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
320- raise ex
321-
322- result += location_folder + '/'
319+ model_folder_path += '%s/' % location_folder
323320 my_loc .append_location (location_folder )
321+
324322 # Have to check for security provider artificial folders that don't have a trailing name token
325323 if location_folder not in SECURITY_PROVIDER_NAME_MAP :
326324 name_token = self .get_name_token_for_location (my_loc )
327325 if name_token is not None :
328326 name = location .get_name_for_token (name_token )
329327 if name is not None :
330328 my_loc .add_name_token (name_token , name )
331- result += name + '/'
329+ model_folder_path += '%s/' % name
332330 elif location_folder != location_folders [- 1 ]:
333- # Allow the location to be missing a name_token for the last folder only...
331+ # Throw AliasException if name_token is missing
332+ # from any location folder, except the last one
334333 ex = exception_helper .create_alias_exception ('WLSDPLY-08101' , str (location ), name_token )
335334 _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
336335 raise ex
337- # Strip the trailing slash only if the path is not still '<section-name>:/'
338- section_end_index = result .find (':/' )
339- if section_end_index != - 1 and len (result ) > section_end_index + 2 :
340- result = result [:- 1 ]
336+
337+ # Strip off trailing '/' if model_folder_path is not '<section-name>:/'
338+ if model_folder_path [- 2 :] != ':/' :
339+ # Strip off trailing '/'
340+ model_folder_path = model_folder_path [:- 1 ]
341341 else :
342- # Hard to know exactly what to do here but since an empty location is the top-level,
343- # just return the location of top-level Domain attributes.
344- result = 'topology:/'
342+ # Hard to know exactly what to do here but since an empty
343+ # location is the top-level, just return the location of
344+ # top-level Domain attributes.
345+ model_folder_path = 'topology:/'
345346
346- _logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
347- return result
347+ _logger .exiting (class_name = _class_name , method_name = _method_name , result = model_folder_path )
348+
349+ return model_folder_path
348350
349351 def get_wlst_attribute_path_for_location (self , location ):
350352 """
@@ -536,46 +538,58 @@ def get_name_token_for_location(self, location):
536538 _method_name = 'get_name_token_for_location'
537539
538540 _logger .entering (str (location ), class_name = _class_name , method_name = _method_name )
541+
539542 result = None
543+
540544 if len (location .get_model_folders ()) == 0 :
541- result = self .__domain_name_token
542- else :
543- folder_dict = self .__get_dictionary_for_location (location , False )
544- if folder_dict is not None :
545- if WLST_ATTRIBUTES_PATH in folder_dict :
546- paths_index = folder_dict [WLST_ATTRIBUTES_PATH ]
547- tokenized_path = \
548- alias_utils .resolve_path_index (folder_dict , paths_index , WLST_ATTRIBUTES_PATH , location )
549- last_token = tokenized_path .split ('/' )[- 1 ]
550-
551- if last_token != 'NO_NAME_0' and last_token .startswith ('%' ) and last_token .endswith ('%' ):
552- token_occurrences = alias_utils .count_substring_occurrences (last_token , tokenized_path )
553- if token_occurrences == 1 :
554- result = last_token [1 :- 1 ]
555- else :
556- ex = exception_helper .create_alias_exception ('WLSDPLY-08103' , location .get_folder_path (),
557- WLST_ATTRIBUTES_PATH )
558- _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
559- raise ex
545+ # There are no model folders in the location, so
546+ # just return %DOMAIN% for the name token
547+ return self .__domain_name_token
548+
549+ # Use get_wlst_mbean_type_for_location(location) call
550+ # to determine if location is VERSION_INVALID, or not.
551+ if self .get_wlst_mbean_type_for_location (location ) is None :
552+ # This means location is VERSION_INVALID, so just return
553+ # None for the name_token
554+ return result
555+
556+ folder_dict = self .__get_dictionary_for_location (location , False )
557+ if folder_dict is not None :
558+ if WLST_ATTRIBUTES_PATH in folder_dict :
559+ paths_index = folder_dict [WLST_ATTRIBUTES_PATH ]
560+ tokenized_path = \
561+ alias_utils .resolve_path_index (folder_dict , paths_index , WLST_ATTRIBUTES_PATH , location )
562+ last_token = tokenized_path .split ('/' )[- 1 ]
563+
564+ if last_token != 'NO_NAME_0' and last_token .startswith ('%' ) and last_token .endswith ('%' ):
565+ token_occurrences = alias_utils .count_substring_occurrences (last_token , tokenized_path )
566+ if token_occurrences == 1 :
567+ result = last_token [1 :- 1 ]
560568 else :
561- path = location .get_folder_path ()
562-
563- err_location = LocationContext (location )
564- if not err_location .is_empty ():
565- folder_name = err_location .pop_location ()
566- code , message = self .is_valid_model_folder_name_for_location (err_location , folder_name )
567- if code == ValidationCodes .VERSION_INVALID :
568- ex = exception_helper .create_alias_exception ('WLSDPLY-08130' , path ,
569- self ._wls_helper .get_actual_weblogic_version (),
570- message )
571- _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
572- raise ex
573- ex = exception_helper .create_alias_exception ('WLSDPLY-08131' , path ,
574- self ._wls_helper .get_actual_weblogic_version ())
569+ ex = exception_helper .create_alias_exception ('WLSDPLY-08103' , location .get_folder_path (),
570+ WLST_ATTRIBUTES_PATH )
575571 _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
576572 raise ex
573+ else :
574+ path = location .get_folder_path ()
575+
576+ err_location = LocationContext (location )
577+ if not err_location .is_empty ():
578+ folder_name = err_location .pop_location ()
579+ code , message = self .is_valid_model_folder_name_for_location (err_location , folder_name )
580+ if code == ValidationCodes .VERSION_INVALID :
581+ ex = exception_helper .create_alias_exception ('WLSDPLY-08130' , path ,
582+ self ._wls_helper .get_actual_weblogic_version (),
583+ message )
584+ _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
585+ raise ex
586+ ex = exception_helper .create_alias_exception ('WLSDPLY-08131' , path ,
587+ self ._wls_helper .get_actual_weblogic_version ())
588+ _logger .throwing (ex , class_name = _class_name , method_name = _method_name )
589+ raise ex
577590
578591 _logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
592+
579593 return result
580594
581595 def get_wlst_mbean_name_for_location (self , location ):
@@ -789,6 +803,36 @@ def is_valid_model_folder_name_for_location(self, location, model_folder_name):
789803 _logger .exiting (class_name = _class_name , method_name = _method_name , result = [result , valid_version_range ])
790804 return result , valid_version_range
791805
806+ def is_version_valid_location (self , location ):
807+ """
808+ Verify that the specified location is valid for the WLS version
809+ being used.
810+
811+ Caller needs to determine what action (e.g. log, raise exception,
812+ continue processing, record validation item, etc.) to take, when
813+ return code is VERSION_INVALID.
814+
815+ :param location: the location to be checked
816+ :return: A ValidationCodes Enum value of either VERSION_INVALID or VALID
817+ :return: A message saying which WLS version location is valid in, if
818+ return code is VERSION_INVALID
819+ """
820+ _method_name = 'is_version_valid_location'
821+
822+ _logger .entering (str (location ),class_name = _class_name , method_name = _method_name )
823+
824+ code = ValidationCodes .VALID
825+ message = ''
826+ if self .get_wlst_mbean_type_for_location (location ) is None :
827+ model_folder_path = self .get_model_folder_path_for_location (location )
828+ message = exception_helper .get_message ('WLSDPLY-08138' , model_folder_path ,
829+ self ._wls_helper .get_weblogic_version ())
830+ code = ValidationCodes .VERSION_INVALID
831+
832+ _logger .exiting (class_name = _class_name , method_name = _method_name , result = [code , message ])
833+
834+ return code , message
835+
792836 def is_valid_model_attribute_name_for_location (self , location , model_attribute_name ):
793837 """
794838 Is the specified model attribute name valid for the specified location?
0 commit comments