def ensure_no_uncommitted_changes_or_edit_sessions(ignoreEditSessionCheck=False): """ Ensure that the domain does not contain any uncommitted changes and there is no existing edit session. :raises: DeployException: if there are any uncommitted changes, existing edit sessions, or a WLST error occurs """ _method_name = 'ensure_no_uncommitted_changes_or_edit_sessions' _logger.entering(class_name=_class_name, method_name=_method_name) try: cmgr = _wlst_helper.get_config_manager() tasks = _wlst_helper.get_active_activation_tasks(cmgr) current_editor = _wlst_helper.get_current_editor(cmgr) unactivated_changes = _wlst_helper.have_unactivated_changes(cmgr) if len(tasks) > 0: ex = exception_helper.create_deploy_exception('WLSDPLY-09102', len(tasks)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex if unactivated_changes and not ignoreEditSessionCheck: ex = exception_helper.create_deploy_exception('WLSDPLY-09103') _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex if current_editor is not None and not ignoreEditSessionCheck: ex = exception_helper.create_deploy_exception('WLSDPLY-09104', str(current_editor)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex except PyWLSTException, e: ex = exception_helper.create_deploy_exception('WLSDPLY-09105', e.getLocalizedMessage(), error=e) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def get_library_name_components(name, wlst_mode=WlstModes.OFFLINE): """ Helper method for application deployer to decompose a shared library name into its components. :param name: the name :param wlst_mode: the WLST mode :return: a tuple of the name components """ _method_name = '__get_library_name_components' _logger.entering(name, class_name=_class_name, method_name=_method_name) items = name.split('#') name_tuple = [items[0]] if len(items) == 2: ver_items = items[1].split('@') name_tuple.append(ver_items[0]) if len(ver_items) == 2: name_tuple.append(ver_items[1]) elif len(ver_items) == 1: # no implementation version specified... pass else: ex = exception_helper.create_deploy_exception('WLSDPLY-09106', name, len(ver_items) - 1) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif len(items) == 1: pass else: ex = exception_helper.create_deploy_exception('WLSDPLY-09107', name, len(items) - 1) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex _logger.exiting(class_name=_class_name, method_name=_method_name, result=name_tuple) return name_tuple
def merge_model_and_existing_properties(model_props, existing_props, string_props_separator_char=','): """ Merge the two properties objects so that the resulting properties contains all of the elements in both properties. :param model_props: the model properties :param existing_props: the existing properties :param string_props_separator_char: the property delimiter :return: the merged properties object as a java.util.Properties or a string, depending on the type of the model_props :raises: DeployException: if either properties is not either a string or a java.util.Properties object """ _method_name = 'merge_model_and_existing_lists' _logger.entering(model_props, existing_props, string_props_separator_char, class_name=_class_name, method_name=_method_name) if existing_props is None or len(existing_props) == 0: result = model_props elif model_props is None or len(model_props) == 0: result = existing_props if isinstance(model_props, basestring) and isinstance(existing_props, basestring): result = _properties_to_string(existing_props, string_props_separator_char) else: model_props_is_string = False if type(model_props) is str: model_props_is_string = True model_properties = _string_to_properties(model_props, string_props_separator_char) elif TypeUtils.isInstanceOfClass(Properties().getClass(), model_props): model_properties = model_props else: ex = exception_helper.create_deploy_exception('WLSDPLY-08002', str(type(model_props))) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex if type(existing_props) is str: existing_properties = _string_to_properties(existing_props, string_props_separator_char) elif TypeUtils.isInstanceOfClass(Properties().getClass(), existing_props): existing_properties = existing_props else: ex = exception_helper.create_deploy_exception('WLSDPLY-08003', str(type(existing_props))) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex for entry_set in model_properties.entrySet(): key = entry_set.getKey() value = entry_set.getValue() existing_properties.setProperty(key, value) if model_props_is_string: result = _properties_to_string(existing_properties, string_props_separator_char) else: result = existing_properties _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) return result
def get_library_name_components(name, wlst_mode=WlstModes.OFFLINE): """ Helper method for application deployer to decompose a shared library name into its components. :param name: the name :param wlst_mode: the WLST mode :return: a tuple of the name components """ _method_name = '__get_library_name_components' _logger.entering(name, class_name=_class_name, method_name=_method_name) items = name.split('#') name_tuple = [items[0]] if len(items) == 2: ver_items = items[1].split('@') name_tuple.append(ver_items[0]) if len(ver_items) == 2: name_tuple.append(ver_items[1]) elif len(ver_items) == 1: # no implementation version specified... pass else: ex = exception_helper.create_deploy_exception( 'WLSDPLY-09106', name, len(ver_items) - 1) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif len(items) == 1: # # In WLST online mode, WLST will go figure out the right name for us so we can just use the existing name. # if wlst_mode == WlstModes.ONLINE: _logger.exiting(class_name=_class_name, method_name=_method_name, result=name) return name else: # Otherwise, no spec version specified so nothing to add to name_tuple pass else: ex = exception_helper.create_deploy_exception('WLSDPLY-09107', name, len(items) - 1) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex _logger.exiting(class_name=_class_name, method_name=_method_name, result=name_tuple) return name_tuple
def _get_existing_wlst_value(self, location, key, lsa_required_attribute_names): """ Returns the existing value for the specified attribute key in the specified location. :param location: the location to be checked :param key: the attribute key :return: The value of the attribute in WLST """ _method_name = '_get_existing_wlst_value' wlst_key = self.alias_helper.get_wlst_attribute_name(location, key) if wlst_key is None: return None if key in lsa_required_attribute_names: attribute_map = self.wlst_helper.lsa() if wlst_key in attribute_map: wlst_value = attribute_map[wlst_key] else: path = self.alias_helper.get_model_folder_path(location) ex = exception_helper.create_deploy_exception('WLSDPLY-09201', key, path, wlst_key) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex else: wlst_value = self.wlst_helper.get(wlst_key) wlst_value = self._convert_if_mbean_list(wlst_value) return wlst_value
def extract(self): """ Deploy resource model elements at the domain level, including multi-tenant elements. """ _method_name = 'extract' resource_file = self._model_context.get_domain_resource_file() self._logger.info("WLSDPLY-10000", resource_file, method_name=_method_name, class_name=self._class_name) # create the target file directory, if needed resource_dir = File(resource_file).getParentFile() if (not resource_dir.isDirectory()) and (not resource_dir.mkdirs()): mkdir_ex = exception_helper.create_deploy_exception( 'WLSDPLY-10001', resource_dir) raise mkdir_ex # build the resource file structure from the kubernetes section of the model resource_dict = self._create_domain_resource_dictionary() # revise the resource file structure with values from command line, and elsewhere in model self._update_resource_dictionary(resource_dict) # write the resource file structure to the output file writer = PythonToFile(resource_dict) writer.write_to_file(resource_file) return
def __process_archive_entry(self, location, key, value): """ Extract the archive entry, if needed. Note that this method assumes the path has already been tested to verify that it points into the archive. :param location: the location :param key: the attribute name :param value: the attribute value :return: True if the artifact was extracted, False otherwise """ _method_name = '__process_archive_entry' self.logger.entering(str(location), key, value, class_name=self._class_name, method_name=_method_name) result = False fullpath = os.path.join(self.model_context.get_domain_home(), value) if self.archive_helper.contains_file(value): if self.wlst_mode == WlstModes.OFFLINE: if value.endswith('/'): result = self.__process_directory_entry(fullpath) else: # In offline mode, just overwrite any existing file. self.archive_helper.extract_file(value) result = True else: if value.endswith('/'): result = self.__process_directory_entry(fullpath) else: if os.path.isfile(fullpath): # If the file already exists in the file system, # compare the hash values to determine if it needs # to be extracted. archive_hash = self.archive_helper.get_file_hash(value) file_hash = deployer_utils.get_file_hash(fullpath) if archive_hash != file_hash: self.archive_helper.extract_file(value) result = True else: # The file does not exist so extract it from the archive. self.archive_helper.extract_file(value) result = True elif value.endswith('/'): # If the path is a directory in the wlsdeploy directory tree # but not in the archive, just create it to help the user. result = self.__process_directory_entry(fullpath) else: path = self.alias_helper.get_model_folder_path(location) ex = exception_helper.create_deploy_exception( 'WLSDPLY-09204', key, path, value, self.model_context.get_archive_file_name()) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=result) return result
def _extract_from_archive_if_needed(self, location, key, value): """ Extract the file from the archive, if needed. :param location: the location :param key: the attribute name :param value: the attribute value :return: True if the file/directory was extracted, False otherwise :raise: DeployException: if an error occurs """ _method_name = '_extract_from_archive_if_needed' self.logger.entering(str(location), key, value, class_name=self._class_name, method_name=_method_name) result = False if deployer_utils.is_path_into_archive(value): if self.archive_helper is not None: result = self.__process_archive_entry(location, key, value) else: path = self.alias_helper.get_model_folder_path(location) ex = exception_helper.create_deploy_exception( 'WLSDPLY-09110', key, path, value) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=result) return result
def deploy_resources(model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): """ Deploy the resources in specific order. Applications are not included, since they are processed after save/activate for online deployment. :param model: the model :param model_context: the model context :param aliases: the aliases object :param wlst_mode: the WLST mode to use :raises DeployException: if an error occurs """ _method_name = 'deploy_resources' try: location = LocationContext() resources_deployer = ResourcesDeployer(model, model_context, aliases, wlst_mode=wlst_mode) resources_deployer.deploy(location) except PyWLSTException, pwe: ex = exception_helper.create_deploy_exception( 'WLSDPLY-09111', pwe.getLocalizedMessage(), error=pwe) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def _string_to_properties(string, string_props_separator_char): """ Convert a delimited string into a java.util.Properties object :param string: the delimited string :param string_props_separator_char:, the delimiter used to separate properties :return: the java.util.Properties object :raises: DeployException: if the string is not formatted as expected (i.e., name=value pairs separated by the specified separator) """ _method_name = '_string_to_properties' _logger.entering(string, string_props_separator_char, class_name=_class_name, method_name=_method_name) result = Properties() if string is not None and len(string) > 0: elements = string.split(string_props_separator_char) for element in elements: stripped_element = element.strip() prop_key_value = stripped_element.split('=') if len(prop_key_value) == 2: key = prop_key_value[0].strip() value = prop_key_value[1].strip() result.setProperty(key, value) else: ex = exception_helper.create_deploy_exception('WLSDPLY-08018', string) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) return result
def raiseDeployException(self): map = { 'name':'Derek', 'address':'1234' } try: print map['bad key'] except KeyError, key_error: self.logger.fine('WLSDPLY-01760', str(key_error), error=key_error, class_name=self.name, method_name='testPythonException') raise exception_helper.create_deploy_exception('WLSDPLY-01760', str(key_error), error=key_error)
def set_attributes(self, location, model_nodes, excludes=None): """ Set all the attributes in the model_nodes list. Exclude items that are sub-folders. :param location: the location of the attributes to be set :param model_nodes: a map of model nodes with attributes to be set :param excludes: a list of items that should not be set :raise: DeployException: if an error condition is encountered """ _method_name = 'set_attributes' attribute_names = self.aliases.get_model_attribute_names(location) uses_path_tokens_attribute_names = self.aliases.get_model_uses_path_tokens_attribute_names( location) restart_attribute_names = self.aliases.get_model_restart_required_attribute_names( location) merge_attribute_names = self.aliases.get_model_merge_required_attribute_names( location) lsa_required_attribute_names = self.aliases.get_model_lsa_required_attribute_names( location) set_method_map = self.aliases.get_model_mbean_set_method_attribute_names_and_types( location) for key in model_nodes: key_excluded = (excludes is not None) and (key in excludes) if key in attribute_names and not key_excluded: value = model_nodes[key] if key in uses_path_tokens_attribute_names: value = deployer_utils.extract_from_uri( self.model_context, value) self._extract_from_archive_if_needed(location, key, value) wlst_merge_value = None if key in merge_attribute_names: wlst_merge_value = self._get_existing_wlst_value( location, key, lsa_required_attribute_names) if not self._skip_setting_attribute(key, value, wlst_merge_value, restart_attribute_names) and \ (not self.set_special_attribute(location, key, value, wlst_merge_value, set_method_map)): try: self.attribute_setter.set_attribute( location, key, value, wlst_merge_value) except PyWLSTException, pwe: loc_type, loc_name = self.get_location_type_and_name( location) ex = exception_helper.create_deploy_exception( 'WLSDPLY-09200', key, loc_type, loc_name, pwe.getLocalizedMessage(), error=pwe) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex
def get_delete_item_name(name): """ Returns the WLST name of the item to be deleted. Removes the "!" prefix from the name. An exception is thrown if the name is not prefixed. :param name: the prefixed model name of the item to be deleted :return: the model name of the item to be deleted """ _method_name = 'get_delete_item_name' if is_delete_name(name): return name[1:] ex = exception_helper.create_deploy_exception('WLSDPLY-09111', name) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def set_special_attribute(self, location, key, value, wlst_merge_value, set_method_map): method_name = 'set_special_attribute' set_method_info = dictionary_utils.get_dictionary_element(set_method_map, key) set_method_name = dictionary_utils.get_element(set_method_info, 'set_method') if set_method_name is not None: try: set_method = getattr(self.attribute_setter, set_method_name) set_method(location, key, value, wlst_merge_value) return True except AttributeError, e: location_text = '/'.join(location.get_model_folders()) ex = exception_helper.create_deploy_exception('WLSDPLY-09202', set_method_name, key, location_text, error=e) self.logger.throwing(ex, class_name=self._class_name, method_name=method_name) raise ex
def get_file_hash(file_name): """ Compute the Base64-encoded hash value for the specified file. :param file_name: the file name :return: the Base64-encoded hash value :raise: DeployException: if an error occurs """ _method_name = 'get_file_hash' _logger.entering(file_name, class_name=_class_name, method_name=_method_name) try: result = FileUtils.computeHash(file_name) except (IOException, NoSuchAlgorithmException), e: ex = exception_helper.create_deploy_exception('WLSDPLY-09108', file_name, e.getLocalizedMessage(), error=e) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def get_library_versioned_name(self, source_path, model_name, from_archive=False): """ Get the proper name of the deployable library that WLST requires in the target domain. This method is primarily needed for shared libraries in the Oracle Home where the implementation version may have changed. Rather than requiring the modeller to have to know/adjust the shared library name, we extract the information from the target domain's archive file (e.g., war file) and compute the correct name. :param source_path: the SourcePath value of the shared library :param model_name: the model name of the library :param from_archive: if True, use the manifest from the archive, otherwise from the file system :return: the updated shared library name for the target environment :raises: DeployException: if an error occurs """ _method_name = 'get_library_versioned_name' self.logger.entering(source_path, model_name, class_name=self._class_name, method_name=_method_name) old_name_tuple = deployer_utils.get_library_name_components(model_name) try: versioned_name = old_name_tuple[self._EXTENSION_INDEX] manifest = self.__get_manifest(source_path, from_archive) if manifest is not None: attributes = manifest.getMainAttributes() extension_name = attributes.getValue(EXTENSION_NAME) if not string_utils.is_empty(extension_name): versioned_name = extension_name specification_version = attributes.getValue(SPECIFICATION_VERSION) if not string_utils.is_empty(specification_version): versioned_name += '#' + specification_version # Cannot specify an impl version without a spec version implementation_version = attributes.getValue(IMPLEMENTATION_VERSION) if not string_utils.is_empty(implementation_version): versioned_name += '@' + implementation_version self.logger.info('WLSDPLY-09324', model_name, versioned_name, class_name=self._class_name, method_name=_method_name) except (IOException, FileNotFoundException, ZipException, IllegalStateException), e: ex = exception_helper.create_deploy_exception('WLSDPLY-09325', model_name, source_path, str(e), error=e) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex
def deploy_model_offline(model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): """ Deploy the topology, resources and applications, in specific order. This order is correct for offline. For online deployment, applications should be processed after save/activate. :param model: the model :param model_context: the model context :param aliases: the aliases object :param wlst_mode: the WLST mode to use :raises DeployException: if an error occurs """ _method_name = 'deploy_model_offline' try: deploy_resources(model, model_context, aliases, wlst_mode=wlst_mode) deploy_applications(model, model_context, aliases, wlst_mode=wlst_mode) except PyWLSTException, pwe: ex = exception_helper.create_deploy_exception('WLSDPLY-09650', pwe.getLocalizedMessage(), error=pwe) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def deploy_model_after_update(model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): """ Deploy the resources that must be done after WLST updateDomain. :param model: the model :param model_context: the model context :param aliases: the aliases object :param wlst_mode: the WLST mode to use :raises DeployException: if an error occurs """ _method_name = 'deploy_model_offline_after_update' try: location = LocationContext() resources_deployer = ResourcesDeployer(model, model_context, aliases, wlst_mode=wlst_mode) resources_deployer.deploy_after_update(location) except PyWLSTException, pwe: ex = exception_helper.create_deploy_exception('WLSDPLY-09650', pwe.getLocalizedMessage(), error=pwe) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def discard_current_edit(): """ Undo any current edit that may have left. :raises: DeployException: if there are any wlst errors """ _method_name = 'discard_current_edit' _logger.entering(class_name=_class_name, method_name=_method_name) try: cmgr = _wlst_helper.get_config_manager() unactivated_changes = _wlst_helper.have_unactivated_changes(cmgr) if unactivated_changes: _logger.info("WLSDPLY-09016") cmgr.undoUnactivatedChanges() except PyWLSTException, e: ex = exception_helper.create_deploy_exception('WLSDPLY-09112', e.getLocalizedMessage(), error=e) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def _create_set(list_item, string_list_separator_char, message_key): """ Create a set object from the specified list item. :param list_item: the item to be examined, should be a string, list, or array :param string_list_separator_char: the character separator to use to split the lists if either list is a string :param message_key: the key of the message to display if list item type is invalid :return: a set containing the list item's elements :raises: DeployException: if either list is not either a string or a list """ _method_name = '_create_set' item_type = type(list_item) if item_type is str: item_set = Set([x.strip() for x in list_item.split(string_list_separator_char)]) elif item_type is list or item_type is array: item_set = Set(list_item) else: ex = exception_helper.create_deploy_exception(message_key, str(item_type)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex return item_set
def create_list(list_value, message_key): """ Create a list from the specified list value. :param list_value: the model value to be examined, should be a string, list, or array :param message_key: the key of the message to display if list item type is invalid :return: a list containing the list value's elements :raises: DeployException: if either list is not either a string or a list """ _method_name = '_create_list' item_type = type(list_value) if (list_value is None) or (len(list_value) == 0): item_list = [] elif isinstance(list_value, basestring): item_list = [x.strip() for x in list_value.split(MODEL_LIST_DELIMITER)] elif item_type is list or item_type is array: item_list = list(list_value) else: ex = exception_helper.create_deploy_exception(message_key, str(item_type)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex return item_list
def get_application_versioned_name(self, source_path, model_name, from_archive=False): """ Get the proper name of the deployable application that WLST requires in the target domain. This method is needed for the case where the application is explicitly versioned in its ear/war manifest. Rather than requiring the modeller to have to know/adjust the application name, we extract the information from the application's archive file (e.g., war file) and compute the correct name. :param source_path: the SourcePath value of the application :param model_name: the model name of the application :param from_archive: if True, use the manifest from the archive, otherwise from the file system :return: the updated application name for the target environment :raises: DeployException: if an error occurs """ _method_name = 'get_application_versioned_name' self.logger.entering(source_path, model_name, class_name=self._class_name, method_name=_method_name) # if no manifest version is found, leave the original name unchanged versioned_name = model_name try: manifest = self.__get_manifest(source_path, from_archive) if manifest is not None: attributes = manifest.getMainAttributes() application_version = attributes.getValue(self._APP_VERSION_MANIFEST_KEY) if application_version is not None: # replace any version information in the model name model_name_tuple = deployer_utils.get_library_name_components(model_name) versioned_name = model_name_tuple[self._EXTENSION_INDEX] versioned_name = versioned_name + '#' + application_version self.logger.info('WLSDPLY-09328', model_name, versioned_name, class_name=self._class_name, method_name=_method_name) except (IOException, FileNotFoundException, ZipException, IllegalStateException), e: ex = exception_helper.create_deploy_exception('WLSDPLY-09329', model_name, source_path, str(e), error=e) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex
def _get_existing_wlst_value(self, location, key, lsa_required_attribute_names): """ Returns the existing value for the specified attribute key in the specified location. :param location: the location to be checked :param key: the attribute key :return: The value of the attribute in WLST """ _method_name = '_get_existing_wlst_value' wlst_key = self.aliases.get_wlst_attribute_name(location, key) if wlst_key is None: return None # online WLST may return a default value, even if the attribute was not set. # don't merge with a value that was not set (example: JDBCDataSourceParams: JNDINames). if not self.wlst_helper.is_set(wlst_key): return None if key in lsa_required_attribute_names: attribute_map = self.wlst_helper.lsa() if wlst_key in attribute_map: wlst_value = attribute_map[wlst_key] else: path = self.aliases.get_model_folder_path(location) ex = exception_helper.create_deploy_exception( 'WLSDPLY-09201', key, path, wlst_key) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex else: wlst_value = self.wlst_helper.get(wlst_key) wlst_value = self._convert_if_mbean_list(wlst_value) return wlst_value
def _update_server(self, name, dictionary, config_location): _method_name = '_update_server' # these imports are local, since they are only present in JRF environments. # this method is only called after that check has been made. from oracle.core.ojdl.weblogic.ODLConfiguration import CONFIG_DIR from oracle.core.ojdl.weblogic.ODLConfiguration import CONFIG_FILE from oracle.core.ojdl.logging.config import LoggingConfigurationDocument config_dir = File(self.model_context.get_domain_home(), CONFIG_DIR) server_dir = File(config_dir, name) config_file = File(server_dir, CONFIG_FILE) log_template_dir = config_dir.getParentFile() try: if config_file.exists(): source_file = config_file FileUtils.validateWritableFile(config_file.getPath()) else: # for dynamic servers, the logging config does not exist until the server is started. # read the from template file, verify that the server directory is present and writable. source_file = File(log_template_dir, LOGGING_TEMPLATE_FILE) FileUtils.validateExistingFile(source_file) if not server_dir.exists() and not server_dir.mkdirs(): ex = exception_helper.create_deploy_exception( 'WLSDPLY-19710', server_dir) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex FileUtils.validateWritableDirectory(server_dir.getPath()) document = LoggingConfigurationDocument( FileInputStream(source_file)) # configure AddJvmNumber add_jvm_number = dictionary_utils.get_element( dictionary, _ADD_JVM_NUMBER) if add_jvm_number is not None: document.setAddJvmNumber( alias_utils.convert_boolean(add_jvm_number)) # configure HandlerDefaults handler_defaults = dictionary_utils.get_dictionary_element( dictionary, _HANDLER_DEFAULTS) if handler_defaults is not None: for key in handler_defaults: value = handler_defaults[key] document.setHandlerDefault(key, _get_property_text(value)) # configure Handlers # do these before loggers, in case new handlers are assigned to loggers existing_handler_names = document.getHandlerNames() handlers = dictionary_utils.get_dictionary_element( dictionary, _HANDLER) if handlers is not None: for handler_name in handlers: handler = handlers[handler_name] self._configure_handler(handler_name, handler, document, existing_handler_names, config_location) # configure Loggers existing_logger_names = document.getLoggerNames() loggers = dictionary_utils.get_dictionary_element( dictionary, _LOGGER) if loggers is not None: for logger_name in loggers: logger = loggers[logger_name] self._configure_logger(logger_name, logger, document, existing_logger_names, config_location) document.writeDocument(FileOutputStream(config_file)) except (ParserConfigurationException, SAXException, IOException, IllegalArgumentException), ex: self.logger.severe('WLSDPLY-19707', name, ex.getLocalizedMessage(), class_name=self.__class_name, method_name=_method_name)