44"""
55
66from oracle .weblogic .deploy .util import WLSDeployArchive
7+ from oracle .weblogic .deploy .exception import BundleAwareException
78
89from wlsdeploy .aliases .location_context import LocationContext
910from wlsdeploy .aliases .validation_codes import ValidationCodes
@@ -179,7 +180,7 @@ def _create_security_provider_mbeans(self, type_name, model_nodes, base_location
179180
180181 self .logger .entering (type_name , str (base_location ), log_created ,
181182 class_name = self .__class_name , method_name = _method_name )
182- if model_nodes is None or len ( model_nodes ) == 0 or not self ._is_type_valid (base_location , type_name ):
183+ if not self ._is_type_valid (base_location , type_name ):
183184 return
184185
185186 location = LocationContext (base_location ).append_location (type_name )
@@ -188,20 +189,19 @@ def _create_security_provider_mbeans(self, type_name, model_nodes, base_location
188189 # For create, delete the existing nodes, and re-add in order found in model in iterative code below
189190 self ._delete_existing_providers (location )
190191
192+ if model_nodes is None or len (model_nodes ) == 0 :
193+ return
194+
191195 token_name = self .alias_helper .get_name_token (location )
192196 create_path = self .alias_helper .get_wlst_create_path (location )
193197 list_path = self .alias_helper .get_wlst_list_path (location )
194198 existing_folder_names = self ._get_existing_folders (list_path )
195199 known_providers = self .alias_helper .get_model_subfolder_names (location )
196200 allow_custom = str (self .alias_helper .is_custom_folder_allowed (location ))
197- self .logger .finer ('create path {0}, list_path {1}, existing folders {2}' , create_path , list_path ,
198- str (existing_folder_names ))
199201
200202 for model_name in model_nodes :
201203 model_node = model_nodes [model_name ]
202204
203- # Need to create the node first ?
204- self .logger .fine ('Adding the provider {0} at location {1}' , model_name , str (location ))
205205 if model_node is None :
206206 # The node is empty so nothing to do... move to the next named node.
207207 continue
@@ -391,23 +391,22 @@ def _create_subfolders(self, location, model_nodes):
391391 """
392392 _method_name = '_create_subfolders'
393393
394- self .logger .entering (str ( location ), class_name = self .__class_name , method_name = _method_name )
394+ self .logger .entering (location . get_folder_path ( ), class_name = self .__class_name , method_name = _method_name )
395395 model_subfolder_names = self .alias_helper .get_model_subfolder_names (location )
396-
397396 for key in model_nodes :
398397 if key in model_subfolder_names :
399-
400398 subfolder_nodes = model_nodes [key ]
401- if len (subfolder_nodes ) != 0 :
402- sub_location = LocationContext (location ).append_location (key )
399+ sub_location = LocationContext (location ).append_location (key )
400+ # both create and update are merge to model so will process a subfolder with an empty node
401+ if self .alias_helper .requires_artificial_type_subfolder_handling (sub_location ):
402+ self .logger .finest ('WLSDPLY-12116' , key , str (sub_location ), subfolder_nodes ,
403+ class_name = self .__class_name , method_name = _method_name )
404+ self ._create_security_provider_mbeans (key , subfolder_nodes , location )
405+ elif len (subfolder_nodes ) != 0 :
403406 if self .alias_helper .supports_multiple_mbean_instances (sub_location ):
404407 self .logger .finest ('WLSDPLY-12109' , key , str (sub_location ), subfolder_nodes ,
405408 class_name = self .__class_name , method_name = _method_name )
406409 self ._create_named_mbeans (key , subfolder_nodes , location )
407- elif self .alias_helper .requires_artificial_type_subfolder_handling (sub_location ):
408- self .logger .finest ('WLSDPLY-12116' , key , str (sub_location ), subfolder_nodes ,
409- class_name = self .__class_name , method_name = _method_name )
410- self ._create_security_provider_mbeans (key , subfolder_nodes , location )
411410 elif self .alias_helper .is_artificial_type_folder (sub_location ):
412411 ex = exception_helper .create_create_exception ('WLSDPLY-12120' , str (sub_location ),
413412 key , str (location ))
@@ -417,6 +416,7 @@ def _create_subfolders(self, location, model_nodes):
417416 self .logger .finest ('WLSDPLY-12110' , key , str (sub_location ), subfolder_nodes ,
418417 class_name = self .__class_name , method_name = _method_name )
419418 self ._create_mbean (key , subfolder_nodes , location )
419+
420420 self .logger .exiting (class_name = self .__class_name , method_name = _method_name )
421421 return
422422
@@ -487,18 +487,27 @@ def _delete_existing_providers(self, location):
487487 self .logger .entering (location .get_folder_path (), class_name = self .__class_name , method_name = _method_name )
488488
489489 list_path = self .alias_helper .get_wlst_list_path (location )
490- self .logger .finer ('Look for providers at location {0}' , list_path )
491490 existing_folder_names = self ._get_existing_folders (list_path )
492491 wlst_base_provider_type = self .alias_helper .get_wlst_mbean_type (location )
493492 if len (existing_folder_names ) == 0 :
494- self .logger .finer ('No default providers installed for {0} at {1}' , wlst_base_provider_type , list_path )
493+ self .logger .finer ('WLSDPLY-12136' , wlst_base_provider_type , list_path , class_name = self .__class_name ,
494+ method_name = _method_name )
495495 else :
496496 create_path = self .alias_helper .get_wlst_create_path (location )
497497 self .wlst_helper .cd (create_path )
498498 for existing_folder_name in existing_folder_names :
499- self .wlst_helper .delete (existing_folder_name , wlst_base_provider_type )
500- self .logger .finer ('Removed default provider {0} from provider {1} at location {2}' ,
501- existing_folder_name , wlst_base_provider_type , create_path )
499+ try :
500+ self .wlst_helper .delete (existing_folder_name , wlst_base_provider_type )
501+ self .logger .finer ('WLSDPLY-12135' , existing_folder_name , wlst_base_provider_type , create_path ,
502+ class_name = self .__class_name , method_name = _method_name )
503+ except BundleAwareException , bae :
504+ ex = exception_helper .create_exception (self ._exception_type , 'WLSDPLY-12134' , existing_folder_name ,
505+ self .wls_helper .get_weblogic_version (),
506+ wlst_base_provider_type , bae .getLocalizedMessage (),
507+ error = bae )
508+ self .logger .throwing (ex , class_name = self .__class_name , method_name = _method_name )
509+ raise ex
510+
502511 self .logger .exiting (class_name = self .__class_name , method_name = _method_name )
503512 return
504513
0 commit comments