def _validate_domain_home_arg_for_create(self, value): method_name = '_validate_domain_home_arg_for_create' try: parent_dir = os.path.dirname(value) JFileUtils.validateWritableDirectory(parent_dir) except JIllegalArgumentException, iae: ex = exception_helper.create_cla_exception('WLSDPLY-01606', value, iae.getLocalizedMessage(), error=iae) ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE) self._logger.throwing(ex, class_name=self._class_name, method_name=method_name) raise ex
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)