diff --git a/Jenkinsfile b/Jenkinsfile index 4a887a6d2b..0e2302c2ef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,7 @@ pipeline { docker { alwaysPull true reuseNode true - image 'phx.ocir.io/weblogick8s/wdt/jenkinsslave:wls12213' + image 'phx.ocir.io/weblogick8s/wdt/jenkins-slave:122130' args '-u jenkins -v /var/run/docker.sock:/var/run/docker.sock' } } @@ -57,7 +57,7 @@ pipeline { docker { alwaysPull true reuseNode true - image 'phx.ocir.io/weblogick8s/wdt/jenkinsslave:wls12213' + image 'phx.ocir.io/weblogick8s/wdt/jenkins-slave:122130' args '-u jenkins -v /var/run/docker.sock:/var/run/docker.sock' } } diff --git a/core/src/main/java/oracle/weblogic/deploy/json/AbstractJsonTranslator.java b/core/src/main/java/oracle/weblogic/deploy/json/AbstractJsonTranslator.java index 90db192a1b..31c50153a1 100644 --- a/core/src/main/java/oracle/weblogic/deploy/json/AbstractJsonTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/json/AbstractJsonTranslator.java @@ -29,6 +29,7 @@ import org.python.core.PyLong; import org.python.core.PyObject; import org.python.core.PyString; +import org.python.core.PyUnicode; /** * This class does the heavy-lifting of walking the parse tree and performing the conversion into a Python dictionary. @@ -43,6 +44,8 @@ public abstract class AbstractJsonTranslator extends JSONBaseListener { private PyObject currentScalarValue; @SuppressWarnings("WeakerAccess") protected boolean useOrderedDict; + @SuppressWarnings("WeakerAccess") + protected boolean useUnicode; /** * This method triggers parsing of the JSON and conversion into the Python dictionary. @@ -109,7 +112,7 @@ public void exitPair(JSONParser.PairContext ctx) { getLogger().severe("WLSDPLY-18027", name, valueType); value = Py.None; } - container.__setitem__(new PyString(name), value); + container.__setitem__(this.getPythonString(name), value); } /** @@ -135,7 +138,7 @@ public void enterJsonObject(JSONParser.JsonObjectContext ctx) { String name = currentPairName.peek(); PyDictionary nextDict = currentDict.peek(); - if (name != null && nextDict != null && nextDict.has_key(new PyString(name))) { + if (name != null && nextDict != null && nextDict.has_key(this.getPythonString(name))) { String message = ExceptionHelper.getMessage("WLSDPLY-18028", name); ParseCancellationException ex = new ParseCancellationException(message); @@ -184,7 +187,7 @@ public void exitJsonArray(JSONParser.JsonArrayContext ctx) { @Override public void enterJsonString(JSONParser.JsonStringContext ctx) { String cleanString = resolveEscapeSequences(StringUtils.stripQuotes(ctx.STRING().getText())); - currentScalarValue = new PyString(cleanString); + currentScalarValue = this.getPythonString(cleanString); currentValueType.push(ValueType.SCALAR); } @@ -362,6 +365,14 @@ private void addToArrayIfNeeded() { } } + private PyObject getPythonString(String text) { + if (this.useUnicode) { + return new PyUnicode(text); + } else { + return new PyString(text); + } + } + private static String resolveEscapeSequences(String text) { String result = text; if (!StringUtils.isEmpty(text)) { diff --git a/core/src/main/java/oracle/weblogic/deploy/json/JsonStreamTranslator.java b/core/src/main/java/oracle/weblogic/deploy/json/JsonStreamTranslator.java index 754d9a4bbc..6b28d42bd0 100644 --- a/core/src/main/java/oracle/weblogic/deploy/json/JsonStreamTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/json/JsonStreamTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. */ package oracle.weblogic.deploy.json; @@ -43,6 +43,23 @@ public JsonStreamTranslator(String streamFileName, InputStream jsonStream, boole this.streamFileName = streamFileName; this.jsonStream = jsonStream; this.useOrderedDict = useOrderedDict; + this.useUnicode = false; + } + + /** + * The constructor used to specify ordering and unicode usage. + * + * @param streamFileName the name of the file used to create the InputStream (used only for logging purposes) + * @param jsonStream the input stream + * @param useOrderedDict whether or not to use an ordered dictionary for storing translation results + * @param useUnicode whether or not to use PyUnicode instead of PyString + */ + public JsonStreamTranslator(String streamFileName, InputStream jsonStream, + boolean useOrderedDict, boolean useUnicode) { + this.streamFileName = streamFileName; + this.jsonStream = jsonStream; + this.useOrderedDict = useOrderedDict; + this.useUnicode = useUnicode; } /** diff --git a/core/src/main/java/oracle/weblogic/deploy/json/JsonTranslator.java b/core/src/main/java/oracle/weblogic/deploy/json/JsonTranslator.java index 2e9fc3ce81..d099be58d6 100644 --- a/core/src/main/java/oracle/weblogic/deploy/json/JsonTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/json/JsonTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. */ package oracle.weblogic.deploy.json; @@ -44,6 +44,21 @@ public JsonTranslator(String fileName) { public JsonTranslator(String fileName, boolean useOrdering) { this.jsonFile = FileUtils.validateExistingFile(fileName); this.useOrderedDict = useOrdering; + this.useUnicode = false; + } + + /** + * Constructor for parsing JSON file into a Python dictionary and control ordering and unicode usage. + * + * @param fileName - the name of the existing JSON file to parse + * @param useOrdering - whether or not to use an ordered dictionary + * @param useUnicode - whether or not to use PyUnicode instead of PyString + * @throws IllegalArgumentException if the file name is null or does not point to a valid, existing file. + */ + public JsonTranslator(String fileName, boolean useOrdering, boolean useUnicode) { + this.jsonFile = FileUtils.validateExistingFile(fileName); + this.useOrderedDict = useOrdering; + this.useUnicode = useUnicode; } /** diff --git a/core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java b/core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java index b6c978bdb2..443dd3aee2 100644 --- a/core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/yaml/AbstractYamlTranslator.java @@ -24,6 +24,7 @@ import org.python.core.PyLong; import org.python.core.PyObject; import org.python.core.PyString; +import org.python.core.PyUnicode; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.LoaderOptions; @@ -35,6 +36,7 @@ public abstract class AbstractYamlTranslator { private final boolean useOrderedDict; + private final boolean useUnicode; private final String fileName; private final int codePointsLimit; @@ -47,9 +49,10 @@ public abstract class AbstractYamlTranslator { // override to write a list of documents as Python dictionaries to the YAML public abstract void dumpDocuments(List documents) throws YamlException; - protected AbstractYamlTranslator(String fileName, boolean useOrderedDict, int codePointsLimit) { + protected AbstractYamlTranslator(String fileName, boolean useOrderedDict, boolean useUnicode, int codePointsLimit) { this.fileName = fileName; this.useOrderedDict = useOrderedDict; + this.useUnicode = useUnicode; this.codePointsLimit = codePointsLimit; } @@ -268,7 +271,11 @@ private PyObject convertScalarToPythonObject(Object object) throws YamlException String classname = object.getClass().getName(); switch (classname) { case "java.lang.String": - result = new PyString((String) object); + if (this.useUnicode) { + result = new PyUnicode((String) object); + } else { + result = new PyString((String) object); + } break; case "java.lang.Boolean": diff --git a/core/src/main/java/oracle/weblogic/deploy/yaml/YamlStreamTranslator.java b/core/src/main/java/oracle/weblogic/deploy/yaml/YamlStreamTranslator.java index c9dd09f983..19b5a77308 100644 --- a/core/src/main/java/oracle/weblogic/deploy/yaml/YamlStreamTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/yaml/YamlStreamTranslator.java @@ -32,7 +32,7 @@ public class YamlStreamTranslator extends AbstractYamlTranslator { * @param yamlStream the input stream */ public YamlStreamTranslator(String streamFileName, InputStream yamlStream) { - this(streamFileName, yamlStream, false); + this(streamFileName, yamlStream, false, false, 0); } /** @@ -43,7 +43,7 @@ public YamlStreamTranslator(String streamFileName, InputStream yamlStream) { * @param useOrderedDict whether or not to use an ordered dictionary to maintain the order */ public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boolean useOrderedDict) { - super(streamFileName, useOrderedDict, 0); + super(streamFileName, useOrderedDict, false, 0); this.streamFileName = streamFileName; this.yamlStream = yamlStream; this.yamlOutputWriter = null; @@ -57,13 +57,31 @@ public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boole * @param useOrderedDict whether or not to use an ordered dictionary to maintain the order * @param maxCodePoints the maximum number of characters that the parser will accept */ - public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boolean useOrderedDict, int maxCodePoints) { - super(streamFileName, useOrderedDict, maxCodePoints); + public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boolean useOrderedDict, + int maxCodePoints) { + super(streamFileName, useOrderedDict, false, maxCodePoints); this.streamFileName = streamFileName; this.yamlStream = yamlStream; this.yamlOutputWriter = null; } + /** + * The constructor that allows control of everything. + * @param streamFileName the name of the file used to create the InputStream (used only for logging purposes) + * @param yamlStream the input stream + * @param useOrderedDict whether or not to use an ordered dictionary to maintain the order + * @param useUnicode whether or not to use PyUnicode instead of PyString + * @param maxCodePoints the maximum number of characters that the parser will accept + */ + public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boolean useOrderedDict, + boolean useUnicode, int maxCodePoints) { + super(streamFileName, useOrderedDict, useUnicode, maxCodePoints); + this.streamFileName = streamFileName; + this.yamlStream = yamlStream; + this.yamlOutputWriter = null; + } + + /** * The constructor for writing YAML output. * @@ -71,7 +89,7 @@ public YamlStreamTranslator(String streamFileName, InputStream yamlStream, boole * @param yamlOutputWriter the Writer to use for writing the YAML output */ public YamlStreamTranslator(String streamFileName, Writer yamlOutputWriter) { - super(streamFileName, true, 0); + super(streamFileName, true, false, 0); this.streamFileName = streamFileName; this.yamlStream = null; this.yamlOutputWriter = yamlOutputWriter; diff --git a/core/src/main/java/oracle/weblogic/deploy/yaml/YamlTranslator.java b/core/src/main/java/oracle/weblogic/deploy/yaml/YamlTranslator.java index 157d3fc203..866961517d 100644 --- a/core/src/main/java/oracle/weblogic/deploy/yaml/YamlTranslator.java +++ b/core/src/main/java/oracle/weblogic/deploy/yaml/YamlTranslator.java @@ -32,7 +32,7 @@ public class YamlTranslator extends AbstractYamlTranslator { * @throws IllegalArgumentException if the file name is null or does not point to a valid, existing file. */ public YamlTranslator(String fileName) { - this(fileName, false, 0); + this(fileName, false, false, 0); } /** @@ -43,7 +43,7 @@ public YamlTranslator(String fileName) { * @throws IllegalArgumentException if the file name is null or does not point to a valid, existing file. */ public YamlTranslator(String fileName, boolean useOrderedDict) { - super(fileName, useOrderedDict, 0); + super(fileName, useOrderedDict, false, 0); this.yamlFile = FileUtils.validateExistingFile(fileName); } @@ -57,7 +57,21 @@ public YamlTranslator(String fileName, boolean useOrderedDict) { * @throws IllegalArgumentException if the file name is null or does not point to a valid, existing file. */ public YamlTranslator(String fileName, boolean useOrderedDict, int maxCodePoints) { - super(fileName, useOrderedDict, maxCodePoints); + super(fileName, useOrderedDict, false, maxCodePoints); + this.yamlFile = FileUtils.validateExistingFile(fileName); + } + + /** + * Constructor for parsing YAML file into a Python dictionary, controlling everything. + * + * @param fileName the name of the existing YAML file to parse + * @param useOrderedDict whether or not to use an ordered dictionary to maintain the order + * @param useUnicode whether or not to use PyUnicode instead of PyString + * @param maxCodePoints the maximum number of code points for the input file, or zero to accept the default + * @throws IllegalArgumentException if the file name is null or does not point to a valid, existing file. + */ + public YamlTranslator(String fileName, boolean useOrderedDict, boolean useUnicode, int maxCodePoints) { + super(fileName, useOrderedDict, useUnicode, maxCodePoints); this.yamlFile = FileUtils.validateExistingFile(fileName); } diff --git a/core/src/main/python/wlsdeploy/aliases/alias_entries.py b/core/src/main/python/wlsdeploy/aliases/alias_entries.py index 4cbabaa3d3..af5c848006 100644 --- a/core/src/main/python/wlsdeploy/aliases/alias_entries.py +++ b/core/src/main/python/wlsdeploy/aliases/alias_entries.py @@ -72,6 +72,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import dictionary_utils from wlsdeploy.util import string_utils +from wlsdeploy.util import unicode_helper as str_helper _class_name = 'AliasEntries' _logger = PlatformLogger('wlsdeploy.aliases') @@ -219,7 +220,7 @@ def get_dictionary_for_location(self, location, resolve=True): """ _method_name = 'get_dictionary_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) result = self.__get_dictionary_for_location(location, resolve) # not one caller checks to see if the dictionary returned is None if result is None: @@ -307,7 +308,7 @@ def get_model_subfolder_names_for_location(self, location): """ _method_name = 'get_model_subfolder_names_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) if folder_dict is not None and FOLDERS in folder_dict: subfolders_dict = folder_dict[FOLDERS] @@ -327,7 +328,7 @@ def get_model_folder_path_for_location(self, location): """ _method_name = 'get_model_folder_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) # Initialize return variable model_folder_path = '' @@ -363,7 +364,8 @@ def get_model_folder_path_for_location(self, location): elif location_folder != location_folders[-1]: # Throw AliasException if name_token is missing # from any location folder, except the last one - ex = exception_helper.create_alias_exception('WLSDPLY-08101', str(location), name_token) + ex = exception_helper.create_alias_exception('WLSDPLY-08101', + str_helper.to_string(location), name_token) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex @@ -391,7 +393,7 @@ def get_wlst_attribute_path_for_location(self, location): """ _method_name = 'get_wlst_attribute_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_ATTRIBUTES_PATH) result = alias_utils.replace_tokens_in_path(location, tokenized_path) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) @@ -407,7 +409,7 @@ def get_wlst_subfolders_path_for_location(self, location): """ _method_name = 'get_wlst_subfolders_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_SUBFOLDERS_PATH) result = alias_utils.replace_tokens_in_path(location, tokenized_path) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) @@ -423,7 +425,7 @@ def get_wlst_list_path_for_location(self, location): """ _method_name = 'get_wlst_list_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_LIST_PATH) result = alias_utils.replace_tokens_in_path(location, tokenized_path) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) @@ -439,7 +441,7 @@ def get_wlst_create_path_for_location(self, location): """ _method_name = 'get_wlst_list_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_CREATE_PATH) result = alias_utils.replace_tokens_in_path(location, tokenized_path) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) @@ -456,7 +458,7 @@ def is_location_child_folder_type(self, location, child_folders_type): """ _method_name = 'is_location_child_folder_type' - _logger.entering(str(location), ChildFoldersTypes.from_value(child_folders_type), + _logger.entering(str_helper.to_string(location), ChildFoldersTypes.from_value(child_folders_type), class_name=_class_name, method_name=_method_name) result = False folder_dict = self.__get_dictionary_for_location(location, False) @@ -485,7 +487,7 @@ def get_wlst_flattened_folder_info_for_location(self, location): """ _method_name = 'get_wlst_flattened_folder_info_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) result = None folder_dict = self.__get_dictionary_for_location(location, False) @@ -512,7 +514,7 @@ def get_wlst_flattened_folder_list_path_for_location(self, location): """ _method_name = 'get_wlst_flattened_folder_list_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_CREATE_PATH) tokenized_child_path = alias_utils.strip_trailing_folders_in_path(tokenized_path, 1) result = alias_utils.replace_tokens_in_path(location, tokenized_child_path) @@ -529,7 +531,7 @@ def get_wlst_flattened_folder_create_path_for_location(self, location): """ _method_name = 'get_wlst_flattened_folder_create_path_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) tokenized_path = self.__get_path_for_location(location, WLST_CREATE_PATH) tokenized_child_path = alias_utils.strip_trailing_folders_in_path(tokenized_path, 2) result = alias_utils.replace_tokens_in_path(location, tokenized_child_path) @@ -545,7 +547,7 @@ def get_name_token_for_location(self, location): """ _method_name = 'get_name_token_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) result = None @@ -608,7 +610,7 @@ def get_wlst_mbean_name_for_location(self, location): """ _method_name = 'get_wlst_mbean_name_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) mbean_name = None @@ -647,7 +649,7 @@ def get_wlst_mbean_type_for_location(self, location): :raises AliasException: if an error occurs """ _method_name = 'get_wlst_mbean_type_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) # some callers use this method to check for location valid. # they should call is_model_location_valid(location) directly instead. @@ -675,7 +677,7 @@ def get_online_bean_name_for_location(self, location): :raises AliasException: if an error occurs """ _method_name = 'get_online_bean_name_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) online_bean = '' folder_dict = self.__get_dictionary_for_location(location, False) @@ -695,7 +697,7 @@ def get_alias_attribute_entries_by_location(self, location): """ _method_name = 'get_alias_attribute_entries_by_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) model_attr_dict = dict() if folder_dict is not None and ATTRIBUTES in folder_dict: @@ -724,8 +726,9 @@ def get_alias_attribute_entry_by_model_name(self, location, model_attribute_name :raises AliasException: if an error occurs """ _method_name = 'get_alias_attribute_entry_by_model_name' + _logger.entering(str_helper.to_string(location), model_attribute_name, + class_name=_class_name, method_name=_method_name) - _logger.entering(str(location), model_attribute_name, class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) if folder_dict is not None and ATTRIBUTES in folder_dict: if model_attribute_name in folder_dict[ATTRIBUTES]: @@ -755,7 +758,7 @@ def get_alias_attribute_entry_by_wlst_name(self, location, wlst_attribute_name): """ _method_name = 'get_alias_attribute_entry_by_wlst_name' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) if self._is_wlst_attribute_skipped(folder_dict, wlst_attribute_name) or \ self._is_wlst_attribute_ignored(wlst_attribute_name): @@ -794,8 +797,9 @@ def is_valid_model_folder_name_for_location(self, location, model_folder_name): :raises: AliasException: if an error occurs """ _method_name = 'is_valid_model_folder_name_for_location' + _logger.entering(str_helper.to_string(location), model_folder_name, + class_name=_class_name, method_name=_method_name) - _logger.entering(str(location), model_folder_name, class_name=_class_name, method_name=_method_name) valid_version_range = None if len(location.get_model_folders()) == 0 and model_folder_name in self.get_model_domain_subfolder_names(): sub_location = LocationContext(location).append_location(model_folder_name) @@ -849,7 +853,7 @@ def is_version_valid_location(self, location): """ _method_name = 'is_version_valid_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) code = ValidationCodes.VALID message = '' @@ -873,8 +877,9 @@ def is_valid_model_attribute_name_for_location(self, location, model_attribute_n :raises: AliasException: if an error occurs """ _method_name = 'is_valid_model_attribute_name_for_location' + _logger.entering(str_helper.to_string(location), model_attribute_name, + class_name=_class_name, method_name=_method_name) - _logger.entering(str(location), model_attribute_name, class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, True) valid_version_range = None if folder_dict is None: @@ -1004,7 +1009,7 @@ def __get_dictionary_for_location(self, location, resolve_path_tokens=True): """ _method_name = '__get_dictionary_for_location' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) if location is None: ex = exception_helper.create_alias_exception('WLSDPLY-08115') _logger.throwing(ex, class_name=_class_name, method_name=_method_name) @@ -1504,7 +1509,7 @@ def _resolve_curly_braces(self, value): :param value: the original value :return: the modified value, or the original if not curly braces were embedded """ - str_value = str(value) + str_value = str_helper.to_string(value) if '${' in str_value: parts = alias_utils.parse_curly_braces(str_value) return parts[self._wlst_mode] @@ -1544,7 +1549,7 @@ def __get_valid_version_range_for_folder(self, location): """ _method_name = '__get_valid_version_range_for_folder' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) version_range = None parent_dict = self._category_dict path_name = '' @@ -1590,7 +1595,7 @@ def __get_path_for_location(self, location, path_type=WLST_ATTRIBUTES_PATH): """ _method_name = '__get_path_for_location' - _logger.entering(str(location), path_type, class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), path_type, class_name=_class_name, method_name=_method_name) folder_dict = self.__get_dictionary_for_location(location, False) if folder_dict is not None and path_type in folder_dict: paths_index = folder_dict[path_type] diff --git a/core/src/main/python/wlsdeploy/aliases/alias_utils.py b/core/src/main/python/wlsdeploy/aliases/alias_utils.py index f7106200e3..7fece0ab0e 100644 --- a/core/src/main/python/wlsdeploy/aliases/alias_utils.py +++ b/core/src/main/python/wlsdeploy/aliases/alias_utils.py @@ -54,6 +54,7 @@ from wlsdeploy.aliases.alias_constants import WLST_TYPE from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH from wlsdeploy.util import model_helper +from wlsdeploy.util import unicode_helper as str_helper _class_name = 'alias_utils' _logger = PlatformLogger('wlsdeploy.aliases') @@ -130,7 +131,7 @@ def merge_model_and_existing_properties(model_props, existing_props, string_prop elif TypeUtils.isInstanceOfClass(Properties().getClass(), model_props): model_properties = model_props else: - ex = exception_helper.create_deploy_exception('WLSDPLY-08002', str(type(model_props))) + ex = exception_helper.create_deploy_exception('WLSDPLY-08002', str_helper.to_string(type(model_props))) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex @@ -139,14 +140,14 @@ def merge_model_and_existing_properties(model_props, existing_props, string_prop elif TypeUtils.isInstanceOfClass(Properties().getClass(), existing_props): existing_properties = existing_props else: - ex = exception_helper.create_deploy_exception('WLSDPLY-08003', str(type(existing_props))) + ex = exception_helper.create_deploy_exception('WLSDPLY-08003', str_helper.to_string(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, str(value)) + existing_properties.setProperty(key, str_helper.to_string(value)) if model_props_is_string: result = _properties_to_string(existing_properties, string_props_separator_char) else: @@ -393,7 +394,7 @@ def resolve_path_index(folder_dict, paths_index, path_attribute_name_used, locat _method_name = 'resolve_path_index' # Don't log folder dictionary because it is likely very large - _logger.entering(paths_index, path_attribute_name_used, str(location), + _logger.entering(paths_index, path_attribute_name_used, str_helper.to_string(location), class_name=_class_name, method_name=_method_name) if WLST_PATHS in folder_dict: if paths_index in folder_dict[WLST_PATHS]: @@ -421,7 +422,7 @@ def replace_tokens_in_path(location, path): """ _method_name = 'replace_tokens_in_path' - _logger.entering(str(location), path, class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), path, class_name=_class_name, method_name=_method_name) name_tokens = location.get_name_tokens() new_path = path if name_tokens: @@ -648,7 +649,7 @@ def convert_to_model_type(data_type, value, delimiter=None): # java.lang.String() is able to properly convert it to the cipher text string. However, # we don't really want to return a java.lang.String to the caller so convert that Java # String back to a Python string...ugly but effective. - new_value = str(String(value)) + new_value = str_helper.to_string(String(value)) elif value is not None and isinstance(value, ObjectName): new_value = value.getKeyProperty('Name') else: @@ -675,7 +676,7 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None): # java.lang.String() is able to properly convert it to the cipher text string. However, # we don't really want to return a java.lang.String to the caller so convert that Java # String back to a Python string...ugly but effective. - new_value = str(String(value)) + new_value = str_helper.to_string(String(value)) else: try: new_value = TypeUtils.convertToType(data_type, value, delimiter) @@ -728,7 +729,8 @@ def get_child_folder_type_value_from_enum_value(child_folder_type): enum_text = ChildFoldersTypes.from_value(child_folder_type) result = enum_text.lower() except ValueError, ve: - ex = exception_helper.create_alias_exception('WLSDPLY-08016', child_folder_type, str(ve), error=ve) + ex = exception_helper.create_alias_exception('WLSDPLY-08016', child_folder_type, + str_helper.to_string(ve), error=ve) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex return result @@ -814,7 +816,7 @@ def create_list(list_value, message_key): 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)) + ex = exception_helper.create_deploy_exception(message_key, str_helper.to_string(item_type)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex @@ -866,7 +868,8 @@ def _convert_value_to_model_type(data_type, value, delimiter): converted = _create_array(converted, model_delimiter) converted = model_delimiter.join(converted) except TypeError, te: - ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, str(te)) + ex = exception_helper.create_alias_exception('WLSDPLY-08021', value, data_type, delimiter, + str_helper.to_string(te)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex return converted @@ -1018,7 +1021,7 @@ def _properties_to_string(props, string_props_separator_char): value = entry_set.getValue() if len(result) > 0: result += string_props_separator_char - result += str(key) + '=' + str(value) + result += str_helper.to_string(key) + '=' + str_helper.to_string(value) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) return result @@ -1093,7 +1096,7 @@ def _create_string_jarray(iterable): elif isinstance(element, ObjectName): myarray[idx] = ObjectName.unquote(element.getKeyProperty('Name')) else: - myarray[idx] = str(element) + myarray[idx] = str_helper.to_string(element) idx += 1 return myarray @@ -1112,7 +1115,7 @@ def _create_array(iterable, delimiter): if isinstance(element, ObjectName): myarray.append(element.getKeyProperty('Name')) elif delimiter or isinstance(element, String): - myarray.append(str(element)) + myarray.append(str_helper.to_string(element)) else: myarray.append(element) return myarray diff --git a/core/src/main/python/wlsdeploy/aliases/aliases.py b/core/src/main/python/wlsdeploy/aliases/aliases.py index 9a71a58a1a..764fd04274 100644 --- a/core/src/main/python/wlsdeploy/aliases/aliases.py +++ b/core/src/main/python/wlsdeploy/aliases/aliases.py @@ -50,6 +50,7 @@ from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import string_utils +from wlsdeploy.util import unicode_helper as str_helper class Aliases(object): @@ -143,7 +144,8 @@ def get_model_subfolder_names(self, location): try: return self._alias_entries.get_model_subfolder_names_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19000', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19000', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_name_token(self, location): """ @@ -156,7 +158,8 @@ def get_name_token(self, location): try: return self._alias_entries.get_name_token_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19001', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19001', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_model_folder_path(self, location): """ @@ -169,7 +172,8 @@ def get_model_folder_path(self, location): try: return self._alias_entries.get_model_folder_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19002', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19002', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_folder_short_name(self, location): """ @@ -205,7 +209,8 @@ def get_wlst_attributes_path(self, location): try: return self._alias_entries.get_wlst_attribute_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19003', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19003', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_subfolders_path(self, location): """ @@ -219,7 +224,8 @@ def get_wlst_subfolders_path(self, location): try: return self._alias_entries.get_wlst_subfolders_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19004', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19004', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_list_path(self, location): """ @@ -233,7 +239,8 @@ def get_wlst_list_path(self, location): try: return self._alias_entries.get_wlst_list_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19005', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19005', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_create_path(self, location): """ @@ -247,7 +254,8 @@ def get_wlst_create_path(self, location): try: return self._alias_entries.get_wlst_create_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19006', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19006', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_flattened_folder_list_path(self, location): """ @@ -262,7 +270,8 @@ def get_wlst_flattened_folder_list_path(self, location): try: return self._alias_entries.get_wlst_flattened_folder_list_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19007', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19007', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_flattened_folder_create_path(self, location): """ @@ -276,7 +285,8 @@ def get_wlst_flattened_folder_create_path(self, location): try: return self._alias_entries.get_wlst_flattened_folder_create_path_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19007', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19007', str_helper.to_string(location), + ae.getLocalizedMessage()) ########################################################################### # Child folder-related methods # @@ -311,7 +321,8 @@ def supports_multiple_mbean_instances(self, location): try: return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.MULTIPLE) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19008', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19008', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_subfolders_in_order(self, location): """ @@ -341,7 +352,8 @@ def requires_artificial_type_subfolder_handling(self, location): return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19024', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19024', str_helper.to_string(location), + ae.getLocalizedMessage()) def is_artificial_type_folder(self, location): """ @@ -355,7 +367,8 @@ def is_artificial_type_folder(self, location): try: return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.NONE) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19026', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19026', str_helper.to_string(location), + ae.getLocalizedMessage()) def is_custom_folder_allowed(self, location): """ @@ -372,7 +385,8 @@ def is_custom_folder_allowed(self, location): return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19035', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19035', str_helper.to_string(location), + ae.getLocalizedMessage()) def is_security_provider_type(self, location): """ @@ -389,7 +403,8 @@ def is_security_provider_type(self, location): return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19036', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19036', str_helper.to_string(location), + ae.getLocalizedMessage()) ########################################################################### # WLST Folder create-related methods # @@ -407,7 +422,8 @@ def get_wlst_mbean_name(self, location): try: return self._alias_entries.get_wlst_mbean_name_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19009', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19009', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_mbean_type(self, location): """ @@ -421,7 +437,8 @@ def get_wlst_mbean_type(self, location): try: return self._alias_entries.get_wlst_mbean_type_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19010', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19010', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_wlst_flattened_folder_info(self, location): """ @@ -435,7 +452,8 @@ def get_wlst_flattened_folder_info(self, location): try: return self._alias_entries.get_wlst_flattened_folder_info_for_location(location) except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19013', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19013', str_helper.to_string(location), + ae.getLocalizedMessage()) ########################################################################### # WLST attribute-related methods # @@ -522,7 +540,7 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode if uses_path_tokens and model_val is not None: for index, item in enumerate(model_val): - item_value = self._model_context.replace_token_string(str(item)) + item_value = self._model_context.replace_token_string(str_helper.to_string(item)) model_val[index] = item_value _read_type, read_delimiter = \ @@ -562,8 +580,8 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode if masked: value = '' - self._raise_exception(ae, _method_name, 'WLSDPLY-19014', model_attribute_name, value, str(location), - ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19014', model_attribute_name, value, + str_helper.to_string(location), ae.getLocalizedMessage()) def get_wlst_attribute_name(self, location, model_attribute_name, check_read_only=True): """ @@ -578,7 +596,7 @@ def get_wlst_attribute_name(self, location, model_attribute_name, check_read_onl :raises: Tool type exception: if an error occurs due to a bad location or bad alias data """ _method_name = 'get_wlst_attribute_name' - self._logger.entering(str(location), model_attribute_name, + self._logger.entering(str_helper.to_string(location), model_attribute_name, class_name=self._class_name, method_name=_method_name) try: @@ -598,8 +616,8 @@ def get_wlst_attribute_name(self, location, model_attribute_name, check_read_onl return wlst_attribute_name except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19015', model_attribute_name, str(location), - ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19015', model_attribute_name, + str_helper.to_string(location), ae.getLocalizedMessage()) def get_wlst_get_required_attribute_names(self, location): """ @@ -726,7 +744,7 @@ def is_valid_model_folder_name(self, location, model_folder_name): :raises: Tool type exception: if an error occurred """ _method_name = 'is_valid_model_folder_name' - self._logger.entering(str(location), model_folder_name, + self._logger.entering(str_helper.to_string(location), model_folder_name, class_name=self._class_name, method_name=_method_name) try: result, valid_version_range = \ @@ -1005,7 +1023,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst :raises: Tool type exception: if an error occurs """ _method_name = 'get_model_attribute_name_and_value' - self._logger.entering(str(location), wlst_attribute_name, wlst_attribute_value, + self._logger.entering(str_helper.to_string(location), wlst_attribute_name, wlst_attribute_value, class_name=self._class_name, method_name=_method_name) try: @@ -1071,7 +1089,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst elif default_value is None: model_attribute_value = converted_value - elif str(converted_value) != str(default_value): + elif str_helper.to_string(converted_value) != str_helper.to_string(default_value): if _strings_are_empty(converted_value, default_value): model_attribute_value = None else: @@ -1082,7 +1100,8 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst return model_attribute_name, model_attribute_value except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19028', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19028', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_model_attribute_name(self, location, wlst_attribute_name, check_read_only=True): """ @@ -1098,7 +1117,7 @@ def get_model_attribute_name(self, location, wlst_attribute_name, check_read_onl _method_name = 'get_model_attribute_name' try: - self._logger.entering(str(location), wlst_attribute_name, + self._logger.entering(str_helper.to_string(location), wlst_attribute_name, class_name=self._class_name, method_name=_method_name) model_attribute_name = None @@ -1111,7 +1130,8 @@ def get_model_attribute_name(self, location, wlst_attribute_name, check_read_onl result=model_attribute_name) return model_attribute_name except AliasException, ae: - self._raise_exception(ae, _method_name, 'WLSDPLY-19039', str(location), ae.getLocalizedMessage()) + self._raise_exception(ae, _method_name, 'WLSDPLY-19039', str_helper.to_string(location), + ae.getLocalizedMessage()) def get_model_attribute_names(self, location): """ @@ -1121,9 +1141,9 @@ def get_model_attribute_names(self, location): :raises: Tool type exception: if an error occurs """ _method_name = 'get_model_attribute_names' + self._logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) try: - self._logger.entering(str(location), class_name=self._class_name, method_name=_method_name) attributes_dict = self._alias_entries.get_alias_attribute_entries_by_location(location) result = list(attributes_dict.keys()) self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=result) @@ -1140,7 +1160,7 @@ def get_model_attribute_names_and_types(self, location): :raises: Tool type exception: if an error occurs """ _method_name = 'get_model_attribute_names_and_types' - self._logger.entering(str(location), class_name=self._class_name, method_name=_method_name) + self._logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) try: result = {} @@ -1176,10 +1196,10 @@ def is_valid_model_attribute_name(self, location, model_attribute_name): :raises: Tool type exception: if an error occurred """ _method_name = 'is_valid_model_attribute_name' + self._logger.entering(str_helper.to_string(location), model_attribute_name, + class_name=self._class_name, method_name=_method_name) try: - self._logger.entering(str(location), model_attribute_name, - class_name=self._class_name, method_name=_method_name) result, valid_version_range = \ self._alias_entries.is_valid_model_attribute_name_for_location(location, model_attribute_name) @@ -1233,7 +1253,7 @@ def get_model_attribute_default_value(self, location, model_attribute_name): :raises: Tool type exception: if an error occurred """ _method_name = 'get_model_attribute_default_value' - self._logger.entering(str(location), model_attribute_name, + self._logger.entering(str_helper.to_string(location), model_attribute_name, class_name=self._class_name, method_name=_method_name) try: default_value = None @@ -1271,8 +1291,9 @@ def get_preferred_model_type(self, location, model_attribute_name): :raises: Tool Exception if an AliasException encountered """ _method_name = 'get_preferred_model_type' - self._logger.entering(str(location), model_attribute_name, + self._logger.entering(str_helper.to_string(location), model_attribute_name, class_name=self._class_name, method_name=_method_name) + result = None try: attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name) @@ -1293,8 +1314,9 @@ def get_wlst_read_type(self, location, model_attribute_name): :raises: Tool Exception when AliasException occurs retrieving read type """ _method_name = 'get_wlst_read_type' - self._logger.entering(str(location), model_attribute_name, + self._logger.entering(str_helper.to_string(location), model_attribute_name, class_name=self._class_name, method_name=_method_name) + result = None try: attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name) @@ -1313,7 +1335,7 @@ def decrypt_password(self, text): :return: the clear text :raises EncryptionException: if an error occurs while decrypting the password """ - if text is None or len(str(text)) == 0 or \ + if text is None or len(str_helper.to_string(text)) == 0 or \ (self._model_context and not self._model_context.is_using_encryption()) or \ not EncryptionUtils.isEncryptedString(text): @@ -1449,7 +1471,7 @@ def _convert_to_string(value): if type(value) in [str, unicode]: str_converted_value = value else: - str_converted_value = str(value) + str_converted_value = str_helper.to_string(value) return str_converted_value diff --git a/core/src/main/python/wlsdeploy/aliases/location_context.py b/core/src/main/python/wlsdeploy/aliases/location_context.py index 409d55f88a..71bb1b0fa1 100644 --- a/core/src/main/python/wlsdeploy/aliases/location_context.py +++ b/core/src/main/python/wlsdeploy/aliases/location_context.py @@ -2,6 +2,7 @@ Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ +from wlsdeploy.util import unicode_helper as str_helper class LocationContext(object): @@ -150,7 +151,7 @@ def is_empty(self): return len(self._model_folders) == 0 def __str__(self): - location_model_folders = 'model_folders = %s' % (str(self._model_folders)) + location_model_folders = 'model_folders = %s' % (str_helper.to_string(self._model_folders)) tmp = '' for key, value in self._name_tokens.iteritems(): tmp += "'%s': '%s'," % (key, value) @@ -159,5 +160,16 @@ def __str__(self): location_name_tokens = " 'name_tokens' = {%s}" % tmp return '%s, %s' % (location_model_folders, location_name_tokens) + def __unicode__(self): + location_model_folders = u'model_folders = %s' % (str_helper.to_string(self._model_folders)) + tmp = u'' + for key in self._name_tokens.keys(): + value = self._name_tokens[key] + tmp += u"'%s': '%s'," % (str_helper.to_string(key), str_helper.to_string(value)) + if len(tmp) > 0: + tmp = tmp[:-1] + location_name_tokens = u" 'name_tokens' = {%s}" % str_helper.to_string(tmp) + return u'%s, %s' % (location_model_folders, location_name_tokens) + def __len__(self): return len(self._model_folders) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index d083e90ec7..d2f4f029f4 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -31,6 +31,7 @@ import oracle.weblogic.deploy.yaml.YamlException as JYamlException from wlsdeploy.exception.expection_types import ExceptionType +from wlsdeploy.util import unicode_helper as str_helper _EXCEPTION_TYPE_MAP = { ExceptionType.ALIAS: 'create_alias_exception', @@ -68,7 +69,7 @@ def create_exception(exception_type, key, *args, **kwargs): if exception_type in _EXCEPTION_TYPE_MAP: method_name = _EXCEPTION_TYPE_MAP[exception_type] else: - raise TypeError('Unknown exception type: ' + str(exception_type)) + raise TypeError(str_helper.to_string('Unknown exception type: ') + str_helper.to_string(exception_type)) return globals()[method_name](key, *args, **kwargs) @@ -205,6 +206,7 @@ def create_validate_exception(key, *args, **kwargs): ex = ValidateException(key) return ex + def create_compare_exception(key, *args, **kwargs): """ Create a ComapareException from a message id, list of message parameters and Throwable error. @@ -435,7 +437,7 @@ def convert_error_to_exception(): for ex_string in ex_strings: exception_message += ex_string - exception_type = str(exc_type) + exception_type = str_helper.to_string(exc_type) if exception_type.find("exceptions.IOError") == 0: custom_exception = PyIOErrorException(exception_message) diff --git a/core/src/main/python/wlsdeploy/json/json_translator.py b/core/src/main/python/wlsdeploy/json/json_translator.py index ea9780339f..d9786fca12 100644 --- a/core/src/main/python/wlsdeploy/json/json_translator.py +++ b/core/src/main/python/wlsdeploy/json/json_translator.py @@ -19,6 +19,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger import wlsdeploy.exception.exception_helper as exception_helper +import wlsdeploy.util.unicode_helper as str_helper class JsonToPython(object): @@ -33,7 +34,7 @@ def __init__(self, file_name, use_ordering=False): self._file_name = file_name self._logger = PlatformLogger('wlsdeploy.json') try: - self._translator = JJsonTranslator(file_name, use_ordering) + self._translator = JJsonTranslator(file_name, use_ordering, str_helper.use_unicode()) except JIllegalArgumentException, iae: json_ex = \ exception_helper.create_json_exception('WLSDPLY-18014', file_name, iae.getLocalizedMessage(), error=iae) @@ -70,7 +71,7 @@ def __init__(self, file_name, input_stream, use_ordering=False): self._logger = PlatformLogger('wlsdeploy.json') try: - self._translator = JJsonStreamTranslator(file_name, input_stream, use_ordering) + self._translator = JJsonStreamTranslator(file_name, input_stream, use_ordering, str_helper.use_unicode()) except JIllegalArgumentException, iae: json_ex = \ exception_helper.create_json_exception('WLSDPLY-18014', file_name, iae.getLocalizedMessage(), error=iae) diff --git a/core/src/main/python/wlsdeploy/logging/platform_logger.py b/core/src/main/python/wlsdeploy/logging/platform_logger.py index b318c5595f..a6dc5af45c 100644 --- a/core/src/main/python/wlsdeploy/logging/platform_logger.py +++ b/core/src/main/python/wlsdeploy/logging/platform_logger.py @@ -12,6 +12,7 @@ import java.util.logging.LogRecord as JLogRecord import wlsdeploy.exception.exception_helper as exception_helper +import wlsdeploy.util.unicode_helper as str_helper class PlatformLogger(object): @@ -265,6 +266,7 @@ def _get_log_record(self, level, clazz, method, message, error, *args): return record + def _get_args_as_java_array(*args): """ Convert the Python args list into a Java array of strings. @@ -280,7 +282,7 @@ def _get_args_as_java_array(*args): elif isinstance(arg, JObject): result.add(arg.toString()) else: - result.add(unicode(arg)) + result.add(str_helper.to_string(arg)) else: - result.add(str(arg)) + result.add(str_helper.to_string(arg)) return result.toArray() diff --git a/core/src/main/python/wlsdeploy/tool/compare/model_comparer.py b/core/src/main/python/wlsdeploy/tool/compare/model_comparer.py index 874a3fea64..f197b8c319 100644 --- a/core/src/main/python/wlsdeploy/tool/compare/model_comparer.py +++ b/core/src/main/python/wlsdeploy/tool/compare/model_comparer.py @@ -17,7 +17,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model_helper - +import wlsdeploy.util.unicode_helper as str_helper class ModelComparer(object): """ @@ -365,7 +365,7 @@ def _compare_attribute(self, current_value, past_value, location, key, change_fo else: if not isinstance(past_value, dict): - comment = key + ": '" + str(past_value) + "'" + comment = key + ": '" + str_helper.to_string(past_value) + "'" change_folder.addComment(key, comment) change_folder[key] = current_value @@ -384,7 +384,7 @@ def _compare_properties(self, current_value, past_value, key, change_folder): if property_key in past_value: past_property_value = past_value[property_key] if past_property_value != current_property_value: - comment = property_key + ": '" + str(past_property_value) + "'" + comment = property_key + ": '" + str_helper.to_string(past_property_value) + "'" property_dict.addComment(property_key, comment) property_dict[property_key] = current_property_value else: diff --git a/core/src/main/python/wlsdeploy/tool/create/atp_helper.py b/core/src/main/python/wlsdeploy/tool/create/atp_helper.py index a8842f224e..67f5e17542 100644 --- a/core/src/main/python/wlsdeploy/tool/create/atp_helper.py +++ b/core/src/main/python/wlsdeploy/tool/create/atp_helper.py @@ -1,14 +1,13 @@ """ Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - - """ import re from xml.dom.minidom import parse from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger +import wlsdeploy.util.unicode_helper as str_helper _logger = PlatformLogger('wlsdeploy.create') @@ -88,11 +87,11 @@ def get_atp_connect_string(tnsnames_ora_path, tns_sid_name): _logger.throwing(ex, class_name='atp_helper', method_name='get_atp_connect_string') raise ex except IOError, ioe: - ex = exception_helper.create_create_exception("WLSDPLY-12570", str(ioe)) + ex = exception_helper.create_create_exception("WLSDPLY-12570", str_helper.to_string(ioe)) _logger.throwing(ex, class_name='atp_helper', method_name='get_atp_connect_string') raise ex except Exception, ex: - ex = exception_helper.create_create_exception("WLSDPLY-12570", str(ex)) + ex = exception_helper.create_create_exception("WLSDPLY-12570", str_helper.to_string(ex)) _logger.throwing(ex, class_name='atp_helper', method_name='get_atp_connect_string') raise ex diff --git a/core/src/main/python/wlsdeploy/tool/create/creator.py b/core/src/main/python/wlsdeploy/tool/create/creator.py index 05768c4071..282322a2d8 100644 --- a/core/src/main/python/wlsdeploy/tool/create/creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/creator.py @@ -16,6 +16,7 @@ from wlsdeploy.util import model_helper from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.util.model import Model +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper from wlsdeploy.tool.deploy import deployer_utils @@ -55,7 +56,7 @@ def _create_named_mbeans(self, type_name, model_nodes, base_location, log_create """ _method_name = '_create_named_mbeans' - self.logger.entering(type_name, str(base_location), log_created, + self.logger.entering(type_name, str_helper.to_string(base_location), log_created, class_name=self.__class_name, method_name=_method_name) if model_nodes is None or len(model_nodes) == 0 or not self._is_type_valid(base_location, type_name): return @@ -112,8 +113,7 @@ def _create_mbean(self, type_name, model_nodes, base_location, log_created=False :raises: CreateException: if an error occurs """ _method_name = '_create_mbean' - - self.logger.entering(type_name, str(base_location), log_created, + self.logger.entering(type_name, str_helper.to_string(base_location), log_created, class_name=self.__class_name, method_name=_method_name) if model_nodes is None or len(model_nodes) == 0: @@ -196,21 +196,21 @@ def _create_subfolders(self, location, model_nodes): sub_location = LocationContext(location).append_location(key) if self.aliases.requires_artificial_type_subfolder_handling(sub_location): - self.logger.finest('WLSDPLY-12116', key, str(sub_location), subfolder_nodes, + self.logger.finest('WLSDPLY-12116', key, str_helper.to_string(sub_location), subfolder_nodes, class_name=self.__class_name, method_name=_method_name) self._create_named_subtype_mbeans(key, subfolder_nodes, location, True) elif self.aliases.supports_multiple_mbean_instances(sub_location): - self.logger.finest('WLSDPLY-12109', key, str(sub_location), subfolder_nodes, + self.logger.finest('WLSDPLY-12109', key, str_helper.to_string(sub_location), subfolder_nodes, class_name=self.__class_name, method_name=_method_name) self._create_named_mbeans(key, subfolder_nodes, location) elif self.aliases.is_artificial_type_folder(sub_location): # these should have been handled inside create_named_subtype_mbeans - ex = exception_helper.create_create_exception('WLSDPLY-12120', str(sub_location), - key, str(location)) + ex = exception_helper.create_create_exception('WLSDPLY-12120', str_helper.to_string(sub_location), + key, str_helper.to_string(location)) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex else: - self.logger.finest('WLSDPLY-12110', key, str(sub_location), subfolder_nodes, + self.logger.finest('WLSDPLY-12110', key, str_helper.to_string(sub_location), subfolder_nodes, class_name=self.__class_name, method_name=_method_name) self._create_mbean(key, subfolder_nodes, location) diff --git a/core/src/main/python/wlsdeploy/tool/create/custom_folder_helper.py b/core/src/main/python/wlsdeploy/tool/create/custom_folder_helper.py index 891fc02703..80eef44235 100644 --- a/core/src/main/python/wlsdeploy/tool/create/custom_folder_helper.py +++ b/core/src/main/python/wlsdeploy/tool/create/custom_folder_helper.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved. +Copyright (c) 2019, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ from java.lang import IllegalArgumentException @@ -10,6 +10,7 @@ from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.exception import exception_helper from wlsdeploy.tool.util.wlst_helper import WlstHelper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -72,8 +73,8 @@ def update_security_folder(self, location, model_type, model_subtype, model_name property_map = dict() for property_descriptor in bean_info.getPropertyDescriptors(): - self.logger.finer('WLSDPLY-12126', str(property_descriptor), class_name=self.__class_name, - method_name=_method_name) + self.logger.finer('WLSDPLY-12126', str_helper.to_string(property_descriptor), + class_name=self.__class_name, method_name=_method_name) property_map[property_descriptor.getName()] = property_descriptor for model_key in model_nodes: @@ -91,12 +92,12 @@ def update_security_folder(self, location, model_type, model_subtype, model_name method = property_descriptor.writeMethod if not method: # this must be a read-only attribute, just log it and continue with next attribute - self.logger.info('WLSDPLY-12129', str(model_key), class_name=self.__class_name, + self.logger.info('WLSDPLY-12129', str_helper.to_string(model_key), class_name=self.__class_name, method_name=_method_name) continue - self.logger.finer('WLSDPLY-12127', str(model_key), str(model_value), class_name=self.__class_name, - method_name=_method_name) + self.logger.finer('WLSDPLY-12127', str_helper.to_string(model_key), str_helper.to_string(model_value), + class_name=self.__class_name, method_name=_method_name) # determine the data type from the set method @@ -127,7 +128,8 @@ def update_security_folder(self, location, model_type, model_subtype, model_name # failure converting value or calling method except (IllegalAccessException, IllegalArgumentException, InvocationTargetException), ex: ex = exception_helper.create_exception(self.exception_type, 'WLSDPLY-12131', method, - str(model_value), ex.getLocalizedMessage(), error=ex) + str_helper.to_string(model_value), ex.getLocalizedMessage(), + error=ex) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex diff --git a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py index c64fb56725..a51ac461a6 100644 --- a/core/src/main/python/wlsdeploy/tool/create/domain_creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/domain_creator.py @@ -98,7 +98,7 @@ from wlsdeploy.util import model from wlsdeploy.util import model_helper from wlsdeploy.util import string_utils - +import wlsdeploy.util.unicode_helper as str_helper class DomainCreator(Creator): """ @@ -699,7 +699,7 @@ def __set_core_domain_params(self): if USE_SAMPLE_DATABASE in self._domain_info: use_sample_db = self._domain_info[USE_SAMPLE_DATABASE] if not isinstance(use_sample_db, basestring): - use_sample_db = str(use_sample_db) + use_sample_db = str_helper.to_string(use_sample_db) self.wlst_helper.set_option_if_needed(USE_SAMPLE_DATABASE, use_sample_db) self.__set_domain_name() @@ -707,7 +707,6 @@ def __set_core_domain_params(self): self.__set_admin_server_name() self.logger.exiting(class_name=self.__class_name, method_name=_method_name) - return def __create_mbeans_used_by_topology_mbeans(self, topology_folder_list): """ @@ -720,7 +719,7 @@ def __create_mbeans_used_by_topology_mbeans(self, topology_folder_list): domain_name_token = self.aliases.get_name_token(location) location.add_name_token(domain_name_token, self._domain_name) - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) self.__create_log_filters(location) topology_folder_list.remove(LOG_FILTER) @@ -754,7 +753,7 @@ def __create_log_filters(self, location): """ _method_name = '__create_log_filters' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) log_filter_nodes = dictionary_utils.get_dictionary_element(self._topology, LOG_FILTER) if len(log_filter_nodes) > 0: @@ -770,7 +769,7 @@ def __create_reliable_delivery_policy(self, location): """ _method_name = '__create_reliable_delivery_policy' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) policy_nodes = dictionary_utils.get_dictionary_element(self._topology, WS_RELIABLE_DELIVERY_POLICY) if len(policy_nodes) > 0: @@ -786,7 +785,7 @@ def __create_xml_entity_cache(self, location): """ _method_name = '__create_xml_entity_cache' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) cache_nodes = dictionary_utils.get_dictionary_element(self._topology, XML_ENTITY_CACHE) if len(cache_nodes) > 0: @@ -802,7 +801,7 @@ def __create_xml_registry(self, location): """ _method_name = '__create_xml_registry' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) registry_nodes = dictionary_utils.get_dictionary_element(self._topology, XML_REGISTRY) if len(registry_nodes) > 0: @@ -816,7 +815,7 @@ def __create_ws_security(self, location): :param location: the current location """ _method_name = '__create_ws_security' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) ws_security = dictionary_utils.get_dictionary_element(self._topology, WEB_SERVICE_SECURITY) if len(ws_security) > 0: @@ -832,7 +831,7 @@ def __create_machines(self, location): """ _method_name = '__create_machines' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) machine_nodes = dictionary_utils.get_dictionary_element(self._topology, MACHINE) unix_machine_nodes = dictionary_utils.get_dictionary_element(self._topology, UNIX_MACHINE) @@ -854,7 +853,7 @@ def __create_machines_clusters_and_servers(self, delete_now=True): location = LocationContext() domain_name_token = self.aliases.get_name_token(location) location.add_name_token(domain_name_token, self._domain_name) - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) self.__create_machines(location) # @@ -918,7 +917,7 @@ def __create_migratable_targets(self, location, delete_now=True): """ _method_name = '__create_migratable_targets' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) migratable_target_nodes = dictionary_utils.get_dictionary_element(self._topology, MIGRATABLE_TARGET) if len(migratable_target_nodes) > 0: @@ -935,8 +934,9 @@ def __create_other_domain_artifacts(self, location, mbean_type_list): :raises: CreateException: if an error occurs """ _method_name = '__create_other_domain_artifacts' + self.logger.entering(str_helper.to_string(location), mbean_type_list, + class_name=self.__class_name, method_name=_method_name) - self.logger.entering(str(location), mbean_type_list, class_name=self.__class_name, method_name=_method_name) for mbean_type in mbean_type_list: mbean_nodes = dictionary_utils.get_dictionary_element(self._topology, mbean_type) diff --git a/core/src/main/python/wlsdeploy/tool/create/security_provider_creator.py b/core/src/main/python/wlsdeploy/tool/create/security_provider_creator.py index 7e6b6ef965..65011daea9 100644 --- a/core/src/main/python/wlsdeploy/tool/create/security_provider_creator.py +++ b/core/src/main/python/wlsdeploy/tool/create/security_provider_creator.py @@ -12,6 +12,7 @@ from wlsdeploy.tool.create.creator import Creator from wlsdeploy.tool.deploy import deployer_utils from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -68,7 +69,7 @@ def create_security_configuration(self, location): """ _method_name = '__create_security_configuration' - self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self.__class_name, method_name=_method_name) security_configuration_nodes = dictionary_utils.get_dictionary_element(self._topology, SECURITY_CONFIGURATION) # in WLS 11g, the SecurityConfiguration mbean is not created until the domain is written. @@ -97,9 +98,8 @@ def _create_named_subtype_mbeans(self, type_name, model_nodes, base_location, lo :raises: CreateException: if an error occurs """ _method_name = '_create_named_subtype_mbeans' - - self.logger.entering(type_name, str(base_location), log_created, class_name=self.__class_name, - method_name=_method_name) + self.logger.entering(type_name, str_helper.to_string(base_location), log_created, + class_name=self.__class_name,method_name=_method_name) if not self._is_type_valid(base_location, type_name): return @@ -122,7 +122,7 @@ def _create_named_subtype_mbeans(self, type_name, model_nodes, base_location, lo list_path = self.aliases.get_wlst_list_path(location) existing_folder_names = self._get_existing_folders(list_path) known_providers = self.aliases.get_model_subfolder_names(location) - allow_custom = str(self.aliases.is_custom_folder_allowed(location)) + allow_custom = str_helper.to_string(self.aliases.is_custom_folder_allowed(location)) for model_name in model_nodes: model_node = model_nodes[model_name] diff --git a/core/src/main/python/wlsdeploy/tool/create/ssl_helper.py b/core/src/main/python/wlsdeploy/tool/create/ssl_helper.py index 4c8fecf436..b044b4d96f 100644 --- a/core/src/main/python/wlsdeploy/tool/create/ssl_helper.py +++ b/core/src/main/python/wlsdeploy/tool/create/ssl_helper.py @@ -10,6 +10,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger +import wlsdeploy.util.unicode_helper as str_helper _logger = PlatformLogger('wlsdeploy.create') @@ -105,11 +106,11 @@ def get_ssl_connect_string(tnsnames_ora_path, tns_sid_name): _logger.throwing(ex, class_name='ssl_helper', method_name='get_ssl_connect_string') raise ex except IOError, ioe: - ex = exception_helper.create_create_exception("WLSDPLY-12570", str(ioe)) + ex = exception_helper.create_create_exception("WLSDPLY-12570", str_helper.to_string(ioe)) _logger.throwing(ex, class_name='ssl_helper', method_name='get_ssl_connect_string') raise ex except Exception, ex: - ex = exception_helper.create_create_exception("WLSDPLY-12570", str(ex)) + ex = exception_helper.create_create_exception("WLSDPLY-12570", str_helper.to_string(ex)) _logger.throwing(ex, class_name='ssl_helper', method_name='get_ssl_connect_string') raise ex diff --git a/core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py b/core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py index 0d5e014302..12c92c84b1 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/applications_deployer.py @@ -51,6 +51,7 @@ from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model_helper from wlsdeploy.util import string_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.tool.util import appmodule_helper import wlsdeploy.util.variables as variables @@ -340,7 +341,7 @@ def __online_deploy_apps_and_libs(self, base_location): def __get_parent_by_location(self, location): _method_name = '_get_parent_by_location' - self.logger.entering(str(location), class_name=self._class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) location_folders = location.get_model_folders() if len(location_folders) == 0: parent_dict = self.model.get_model_app_deployments() @@ -411,8 +412,9 @@ def __get_parent_by_location(self, location): def __get_parent_dict_and_name_for_resource_group(self, location, parent_dict, parent_path): _method_name = '__get_parent_dict_and_name_for_resource_group' + self.logger.entering(str_helper.to_string(location), parent_path, + class_name=self._class_name, method_name=_method_name) - self.logger.entering(str(location), parent_path, class_name=self._class_name, method_name=_method_name) if RESOURCE_GROUP not in parent_dict: ex = exception_helper.create_deploy_exception('WLSDPLY-09305', RESOURCE_GROUP, parent_path) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) @@ -432,8 +434,9 @@ def __get_parent_dict_and_name_for_resource_group(self, location, parent_dict, p def __get_existing_apps(self, base_location): _method_name = '__get_existing_apps' + self.logger.entering(str_helper.to_string(base_location), + class_name=self._class_name, method_name=_method_name) - self.logger.entering(str(base_location), class_name=self._class_name, method_name=_method_name) ref_dictionary = OrderedDict() location = LocationContext(base_location).append_location(APPLICATION) @@ -488,8 +491,9 @@ def __get_existing_apps(self, base_location): def __get_library_references(self, base_location): _method_name = '__get_library_references' + self.logger.entering(str_helper.to_string(base_location), + class_name=self._class_name, method_name=_method_name) - self.logger.entering(str(base_location), class_name=self._class_name, method_name=_method_name) # In 12.1.3 and older release this internal library is accidentally exposed in libraryruntimes mbean internal_skip_list = ['bea_wls_async_response'] @@ -1092,7 +1096,7 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode if not os.path.exists(full_source_path): ex = exception_helper.create_deploy_exception('WLSDPLY-09318', type_name, application_name, - str(full_source_path)) + str_helper.to_string(full_source_path)) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex @@ -1106,7 +1110,7 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode # build the dictionary of named arguments to pass to the deploy_application method args = list() - kwargs = {'path': str(full_source_path), 'targets': str(targets)} + kwargs = {'path': str_helper.to_string(full_source_path), 'targets': str_helper.to_string(targets)} if plan is not None: if not os.path.isabs(plan): plan = self.model_context.get_domain_home() + '/' + plan @@ -1115,15 +1119,15 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode ex = exception_helper.create_deploy_exception('WLSDPLY-09319', type_name, application_name, plan) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex - kwargs['planPath'] = str(plan) + kwargs['planPath'] = str_helper.to_string(plan) if resource_group is not None: - kwargs['resourceGroup'] = str(resource_group) + kwargs['resourceGroup'] = str_helper.to_string(resource_group) if resource_group_template is not None: - kwargs['resourceGroupTemplate'] = str(resource_group_template) + kwargs['resourceGroupTemplate'] = str_helper.to_string(resource_group_template) if partition is not None: - kwargs['partition'] = str(partition) + kwargs['partition'] = str_helper.to_string(partition) if stage_mode is not None: - kwargs['stageMode'] = str(stage_mode) + kwargs['stageMode'] = str_helper.to_string(stage_mode) if options is not None: for key, value in options.iteritems(): kwargs[key] = value @@ -1192,13 +1196,13 @@ def __get_deployment_ordering(self, apps): if name_sorted_keys is not None: result_deploy_order.extend(name_sorted_keys) - self.logger.fine('WLSDPLY-09326', str(result_deploy_order), + self.logger.fine('WLSDPLY-09326', str_helper.to_string(result_deploy_order), class_name=self._class_name, method_name=_method_name) return result_deploy_order def _fix_plan_file(self, plan_dir, plan_path): plan_file_name = 'plan.xml' - if plan_path is not None and len(str(plan_path)) > 0: + if plan_path is not None and len(str_helper.to_string(plan_path)) > 0: plan_file_name = plan_path plan_file = os.path.join(self.model_context.get_domain_home(), plan_dir, plan_file_name) @@ -1269,7 +1273,7 @@ def _get_deploy_options(model_apps, app_name, library_module, application_versio option_name = 'stageMode' if value is not None: - deploy_options[option_name] = str(value) + deploy_options[option_name] = str_helper.to_string(value) if library_module == 'true': deploy_options['libraryModule'] = 'true' diff --git a/core/src/main/python/wlsdeploy/tool/deploy/applications_version_helper.py b/core/src/main/python/wlsdeploy/tool/deploy/applications_version_helper.py index 5994a8cddf..f27131d39e 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/applications_version_helper.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/applications_version_helper.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2020, Oracle Corporation and/or its affiliates. +Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ import os @@ -20,6 +20,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.deploy import deployer_utils from wlsdeploy.util import string_utils +import wlsdeploy.util.unicode_helper as str_helper class ApplicationsVersionHelper(object): @@ -75,7 +76,8 @@ def get_library_versioned_name(self, source_path, model_name, from_archive=False 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) + ex = exception_helper.create_deploy_exception('WLSDPLY-09325', model_name, source_path, + str_helper.to_string(e), error=e) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex @@ -118,7 +120,8 @@ def get_application_versioned_name(self, source_path, model_name, from_archive=F 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) + ex = exception_helper.create_deploy_exception('WLSDPLY-09329', model_name, source_path, + str_helper.to_string(e), error=e) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex diff --git a/core/src/main/python/wlsdeploy/tool/deploy/deployer.py b/core/src/main/python/wlsdeploy/tool/deploy/deployer.py index 1d7fda7cf8..86c3fa4c3d 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/deployer.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/deployer.py @@ -28,6 +28,7 @@ from wlsdeploy.tool.util.topology_helper import TopologyHelper from wlsdeploy.tool.util.wlst_helper import WlstHelper import wlsdeploy.util.dictionary_utils as dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -287,7 +288,7 @@ def get_location_type(self, location): :return: the type of the last element in the location """ _method_name = 'get_location_type' - self.logger.entering(str(location), class_name=self._class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) folders = location.get_model_folders() if len(folders) == 0: @@ -338,8 +339,9 @@ def _extract_from_archive_if_needed(self, location, key, value): :raise: DeployException: if an error occurs """ _method_name = '_extract_from_archive_if_needed' + self.logger.entering(str_helper.to_string(location), key, value, + class_name=self._class_name, method_name=_method_name) - self.logger.entering(str(location), key, value, class_name=self._class_name, method_name=_method_name) result = False short_value = deployer_utils.get_rel_path_from_uri(self.model_context, value) if deployer_utils.is_path_into_archive(short_value): @@ -363,8 +365,9 @@ def __process_archive_entry(self, location, key, value): :return: True if the artifact was extracted, False otherwise """ _method_name = '__process_archive_entry' + self.logger.entering(str_helper.to_string(location), key, value, + class_name=self._class_name, method_name=_method_name) - 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): @@ -439,7 +442,7 @@ def __process_directory_entry(self, path): :return: True, if the directory was created, False otherwise """ _method_name = '__process_directory_entry' - self.logger.entering(str(path), class_name=self._class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(path), class_name=self._class_name, method_name=_method_name) result = False if not os.path.isdir(path): diff --git a/core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py b/core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py index f23c175c29..8e8ff186db 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py @@ -52,6 +52,7 @@ from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.exit_code import ExitCode from wlsdeploy.aliases.model_constants import RESOURCE_GROUP @@ -84,7 +85,7 @@ def create_and_cd(location, existing_names, aliases): :param aliases: the alias helper used to determine path names """ method_name = 'create_and_cd' - _logger.entering(str(location), existing_names, _class_name, method_name) + _logger.entering(str_helper.to_string(location), existing_names, _class_name, method_name) mbean_name = get_mbean_name(location, existing_names, aliases) create_path = aliases.get_wlst_create_path(location) @@ -313,7 +314,7 @@ def ensure_no_uncommitted_changes_or_edit_sessions(ignore_edit_session_check=Fal raise ex if current_editor is not None and not ignore_edit_session_check: - ex = exception_helper.create_deploy_exception('WLSDPLY-09104', str(current_editor)) + ex = exception_helper.create_deploy_exception('WLSDPLY-09104', str_helper.to_string(current_editor)) _logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex except PyWLSTException, e: @@ -474,7 +475,7 @@ def get_cluster_for_server(server_name, aliases): _wlst_helper.cd(attr_path) cluster_name = _wlst_helper.get(CLUSTER) except DeployException, de: - _logger.fine('WLSDPLY-09205', server_name, str(location), de.getLocalizedMessage, + _logger.fine('WLSDPLY-09205', server_name, str_helper.to_string(location), de.getLocalizedMessage, SERVER, class_name=_class_name, method_name=_method_name) _logger.exiting(result=cluster_name, class_name=_class_name, method_name=_method_name) return cluster_name @@ -516,7 +517,7 @@ def list_non_dynamic_changes(model_context, non_dynamic_changes_string): _method_name = 'list_non_dynamic_changes' _logger.entering(class_name=_class_name, method_name=_method_name) output_dir = model_context.get_output_dir() - if len(str(non_dynamic_changes_string)) > 0 and output_dir is not None: + if len(str_helper.to_string(non_dynamic_changes_string)) > 0 and output_dir is not None: file_name = os.path.join(output_dir, 'non_dynamic_changes.file') pw = FileUtils.getPrintWriter(file_name) pw.println(non_dynamic_changes_string) @@ -642,7 +643,7 @@ def check_if_dynamic_cluster(server_name, cluster_name, aliases): try: _wlst_helper.cd(attr_path) except DeployException, de: - _logger.fine('WLSDPLY-09205', cluster_name, str(location), de.getLocalizedMessage, + _logger.fine('WLSDPLY-09205', cluster_name, str_helper.to_string(location), de.getLocalizedMessage, CLUSTER, class_name=_class_name, method_name=_method_name) return True location.append_location(DYNAMIC_SERVERS) diff --git a/core/src/main/python/wlsdeploy/tool/deploy/odl_deployer.py b/core/src/main/python/wlsdeploy/tool/deploy/odl_deployer.py index f7869dd52f..af51e36d35 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/odl_deployer.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/odl_deployer.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved. +Copyright (c) 2019, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ from java.io import File @@ -20,6 +20,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper _ADD_JVM_NUMBER = "AddJvmNumber" _CLASS = "Class" @@ -185,49 +186,49 @@ def _configure_handler(self, handler_name, handler, document, existing_names, co class_name=self.__class_name, method_name=_method_name) return try: - document.addHandler(handler_name, str(handler_class)) + document.addHandler(handler_name, str_helper.to_string(handler_class)) except IllegalArgumentException, iae: self.logger.severe('WLSDPLY-19702', handler_name, handler_path, iae.getLocalizedMessage(), class_name=self.__class_name, method_name=_method_name) elif handler_class is not None: try: - document.setHandlerClass(handler_name, str(handler_class)) + document.setHandlerClass(handler_name, str_helper.to_string(handler_class)) except IllegalArgumentException, iae: self._log_invalid_set(_CLASS, handler_class, iae, _method_name, handler_path) level = dictionary_utils.get_element(handler, _LEVEL) if level is not None: try: - document.setHandlerLevel(handler_name, str(level)) + document.setHandlerLevel(handler_name, str_helper.to_string(level)) except IllegalArgumentException, iae: self._log_invalid_set(_LEVEL, level, iae, _method_name, handler_path) error_manager = dictionary_utils.get_element(handler, _ERROR_MANAGER) if error_manager is not None: try: - document.setHandlerErrorManager(handler_name, str(error_manager)) + document.setHandlerErrorManager(handler_name, str_helper.to_string(error_manager)) except IllegalArgumentException, iae: self._log_invalid_set(_ERROR_MANAGER, error_manager, iae, _method_name, handler_path) handler_filter = dictionary_utils.get_element(handler, _FILTER) if handler_filter is not None: try: - document.setHandlerFilter(handler_name, str(handler_filter)) + document.setHandlerFilter(handler_name, str_helper.to_string(handler_filter)) except IllegalArgumentException, iae: self._log_invalid_set(_FILTER, level, iae, _method_name, handler_path) formatter = dictionary_utils.get_element(handler_filter, _FORMATTER) if formatter is not None: try: - document.setHandlerFormatter(handler_name, str(formatter)) + document.setHandlerFormatter(handler_name, str_helper.to_string(formatter)) except IllegalArgumentException, iae: self._log_invalid_set(_FORMATTER, formatter, iae, _method_name, handler_path) encoding = dictionary_utils.get_element(handler, _ENCODING) if encoding is not None: try: - document.setHandlerEncoding(handler_name, str(encoding)) + document.setHandlerEncoding(handler_name, str_helper.to_string(encoding)) except IllegalArgumentException, iae: self._log_invalid_set(_ENCODING, encoding, iae, _method_name, handler_path) @@ -268,14 +269,14 @@ def _configure_logger(self, logger_name, logger, document, existing_names, confi level = dictionary_utils.get_element(logger, _LEVEL) if level is not None: try: - document.setLoggerLevel(logger_name, str(level)) + document.setLoggerLevel(logger_name, str_helper.to_string(level)) except IllegalArgumentException, iae: self._log_invalid_set(_LEVEL, level, iae, _method_name, logger_path) logger_filter = dictionary_utils.get_element(logger, _FILTER) if logger_filter is not None: try: - document.setLoggerFilter(logger_name, str(logger_filter)) + document.setLoggerFilter(logger_name, str_helper.to_string(logger_filter)) except IllegalArgumentException, iae: self._log_invalid_set(_FILTER, logger_filter, iae, _method_name, logger_path) @@ -321,4 +322,4 @@ def _get_property_text(value): :param value: the value to be evaluated :return: the corresponding text value """ - return str(value) + return str_helper.to_string(value) diff --git a/core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py b/core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py index cfa4204223..c2454d25a3 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py @@ -24,6 +24,7 @@ from wlsdeploy.tool.util.target_helper import TargetHelper from wlsdeploy.tool.util.topology_helper import TopologyHelper from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper class TopologyUpdater(Deployer): @@ -278,6 +279,6 @@ def _create_list_of_setservergroups_targets(self): location.remove_name_token(name_token) self.logger.exiting(class_name=self._class_name, method_name=_method_name, - result='configured_clusters=' + str(existing_configured_clusters) + - ' managed servers=' + str(existing_managed_servers)) + result='configured_clusters=' + str_helper.to_string(existing_configured_clusters) + + ' managed servers=' + str_helper.to_string(existing_managed_servers)) return existing_configured_clusters, existing_managed_servers diff --git a/core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py index 731989ad47..a8088623a8 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py @@ -1,14 +1,10 @@ """ -Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. +Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ -from java.io import File -from java.io import IOException from java.lang import IllegalArgumentException -from java.lang import SecurityException -from oracle.weblogic.deploy.util import FileUtils from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict from oracle.weblogic.deploy.util import WLSDeployArchive from oracle.weblogic.deploy.util import WLSDeployArchiveIOException @@ -16,11 +12,11 @@ from wlsdeploy.aliases import model_constants from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.aliases.wlst_modes import WlstModes -from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.deploy import deployer_utils from wlsdeploy.tool.discover import discoverer from wlsdeploy.tool.discover.discoverer import Discoverer +import wlsdeploy.util.unicode_helper as str_helper _class_name = 'CoherenceResourcesDiscoverer' _logger = PlatformLogger(discoverer.get_discover_logger_name()) @@ -108,7 +104,7 @@ def get_coherence_cache_config(self, location): :return: model name for the coherence cache config: resource dictionary containing the discovered cache config """ _method_name = '_get_coherence_cache_config' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) result = OrderedDict() model_top_folder_name = model_constants.COHERENCE_CACHE_CONFIG location.append_location(model_top_folder_name) @@ -135,7 +131,7 @@ def get_coherence_resource(self, location): :return: model name for coherence resource: dictionary containing coherence resources. """ _method_name = '_get_coherence_resource' - _logger.entering(str(location), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(location), class_name=_class_name, method_name=_method_name) result = OrderedDict() model_top_folder_name = model_constants.COHERENCE_RESOURCE location.append_location(model_top_folder_name) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 1421eacf13..8164caff92 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -1,8 +1,7 @@ """ -Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved. +Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ -from java.io import File from java.lang import IllegalArgumentException from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict @@ -21,6 +20,7 @@ from wlsdeploy.tool.discover.discoverer import Discoverer from wlsdeploy.tool.discover.jms_resources_discoverer import JmsResourcesDiscoverer from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper _class_name = 'CommonResourcesDiscoverer' _logger = PlatformLogger(discoverer.get_discover_logger_name()) @@ -453,8 +453,8 @@ def _fix_passwords_in_mail_session_properties(dictionary): iterator = properties.stringPropertyNames().iterator() while iterator.hasNext(): key = iterator.next() - new_key = str(key).strip() - value = str(properties.getProperty(key)) + new_key = str_helper.to_string(key).strip() + value = str_helper.to_string(properties.getProperty(key)) tokenized = value.startswith('@@') if StringUtils.matches(match_pattern, new_key) and not tokenized: value = replacement diff --git a/core/src/main/python/wlsdeploy/tool/discover/custom_folder_helper.py b/core/src/main/python/wlsdeploy/tool/discover/custom_folder_helper.py index 00589d3041..7582dc4b22 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/custom_folder_helper.py +++ b/core/src/main/python/wlsdeploy/tool/discover/custom_folder_helper.py @@ -24,6 +24,7 @@ from wlsdeploy.tool.util.mbean_utils import MBeanUtils from wlsdeploy.tool.util.variable_injector import STANDARD_PASSWORD_INJECTOR from wlsdeploy.tool.util.wlst_helper import WlstHelper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -67,7 +68,7 @@ def discover_custom_mbean(self, base_location, model_type, mbean_name): attribute_helper = self._info_helper.get_info_attribute_helper(location) if attribute_helper is None: - _logger.warning('WLSDPLY-06753', model_type, str(attribute_helper), mbean_name, + _logger.warning('WLSDPLY-06753', model_type, str_helper.to_string(attribute_helper), mbean_name, class_name=_class_name, method_name=_method_name) else: subfolder_result[mbean_name] = PyOrderedDict() @@ -93,7 +94,7 @@ def get_model_attribute_map(self, location, attribute_helper): :return: model ready dictionary of the discovered MBean """ _method_name = 'get_model_attribute_map' - _logger.entering(str(attribute_helper), class_name=_class_name, method_name=_method_name) + _logger.entering(str_helper.to_string(attribute_helper), class_name=_class_name, method_name=_method_name) mbean_attributes = PyOrderedDict() for attribute_name in attribute_helper.get_mbean_attributes(): model_value = self.get_model_attribute_value(attribute_helper, attribute_name) @@ -126,8 +127,8 @@ def get_model_attribute_value(self, attribute_helper, attribute_name, wlst_value if model_type == alias_constants.PASSWORD: print_orig = alias_constants.MASKED print_conv = print_orig - _logger.finer('WLSDPLY-06770', mbean_string, attribute_name, model_type, str(print_conv), - class_name=_class_name, method_name=_method_name) + _logger.finer('WLSDPLY-06770', mbean_string, attribute_name, model_type, + str_helper.to_string(print_conv), class_name=_class_name, method_name=_method_name) default_value = self.__get_default_value(attribute_helper, attribute_name) if not is_empty(model_value): if not is_empty(default_value): @@ -151,9 +152,9 @@ def convert(self, value, value_type): :return: converted data type and value """ _method_name = 'convert_method' - if str(value_type).startswith(' maxlen: maxlen = len(name) - format_string = '%-' + str(maxlen + 1) + 's # %s' + format_string = '%-' + str_helper.to_string(maxlen + 1) + 's # %s' for attr_name in attr_list: line = format_string % (attr_name + ":", attribute_map[attr_name]) _print_indent(line, indent_level, in_object_array) diff --git a/core/src/main/python/wlsdeploy/tool/modelhelp/model_sample_printer.py b/core/src/main/python/wlsdeploy/tool/modelhelp/model_sample_printer.py index aaa23b8263..8a6d8f6df7 100644 --- a/core/src/main/python/wlsdeploy/tool/modelhelp/model_sample_printer.py +++ b/core/src/main/python/wlsdeploy/tool/modelhelp/model_sample_printer.py @@ -8,6 +8,7 @@ from wlsdeploy.tool.modelhelp import model_help_utils from wlsdeploy.tool.modelhelp.model_help_utils import ControlOptions from wlsdeploy.exception import exception_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.exit_code import ExitCode from oracle.weblogic.deploy.util import WLSBeanHelp as WLSBeanHelp @@ -209,7 +210,7 @@ def _get_att_short_help(self, model_location, attr_name): if att_default is None: att_default = '' else: - att_default = ' (default=' + str(att_default) + ')' + att_default = ' (default=' + str_helper.to_string(att_default) + ')' online_bean = self._aliases.get_online_bean_name(model_location) @@ -240,7 +241,8 @@ def _print_attributes_sample(self, model_location, indent_level): if len(attr_infos[name]) > maxlen_type: maxlen_type = len(attr_infos[name]) - format_string = '%-' + str(maxlen_attr + 1) + 's # %-' + str(maxlen_type + 1) + 's' + format_string = '%-' + str_helper.to_string(maxlen_attr + 1) + 's # %-' + \ + str_helper.to_string(maxlen_type + 1) + 's' for attr_name in attr_list: att_help = self._get_att_short_help(model_location, attr_name) line = format_string % (attr_name + ":", attr_infos[attr_name]) + att_help @@ -260,10 +262,10 @@ def _print_section_attribute_bean_help(self, model_path_tokens, valid_section_fo section_name = model_path_tokens[0] attribute = model_path_tokens[1] - if (len(model_path_tokens) == 2): + if len(model_path_tokens) == 2: attributes_location = self._aliases.get_model_section_attribute_location(section_name) if attributes_location is not None: - if (self._print_attribute_bean_help(attributes_location, 0, attribute)): + if self._print_attribute_bean_help(attributes_location, 0, attribute): return ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, @@ -285,9 +287,8 @@ def _print_folder_attribute_bean_help(self, control_option, model_location, inde """ _method_name = '_print_folder_attribute_bean_help' - if (tokens_left == 0 - and model_help_utils.show_attributes(control_option) - and self._print_attribute_bean_help(model_location, indent, token)): + if tokens_left == 0 and model_help_utils.show_attributes(control_option) and \ + self._print_attribute_bean_help(model_location, indent, token): return ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, @@ -308,21 +309,21 @@ def _print_attribute_bean_help(self, model_location, indent_level, the_attribute attr_infos = self._aliases.get_model_attribute_names_and_types(model_location) if attr_infos and the_attribute in attr_infos: - line = '%s # %s' % (the_attribute + ":", attr_infos[the_attribute]) - _print_indent(line, indent_level) + line = '%s # %s' % (the_attribute + ":", attr_infos[the_attribute]) + _print_indent(line, indent_level) - att_default = self._aliases.get_model_attribute_default_value(model_location, the_attribute) - if att_default is not None: - att_default = str(att_default) + att_default = self._aliases.get_model_attribute_default_value(model_location, the_attribute) + if att_default is not None: + att_default = str_helper.to_string(att_default) - att_help = WLSBeanHelp.get(the_bean, the_attribute, 60, att_default) + att_help = WLSBeanHelp.get(the_bean, the_attribute, 60, att_default) - if att_help: - print("") - print(att_help) - print("") + if att_help: + print("") + print(att_help) + print("") - return True + return True return False @@ -348,7 +349,7 @@ def _get_member_name(self, location, index): short_name = self._aliases.get_folder_short_name(location) if len(short_name) == 0: short_name = location.get_current_model_folder() - return "'" + short_name + "-" + str(index + 1) + "'" + return "'%s-%s'" % (short_name, str_helper.to_string(index + 1)) def _print_indent(msg, level=1): diff --git a/core/src/main/python/wlsdeploy/tool/prepare/model_preparer.py b/core/src/main/python/wlsdeploy/tool/prepare/model_preparer.py index cd00592dd5..25cddcd79a 100644 --- a/core/src/main/python/wlsdeploy/tool/prepare/model_preparer.py +++ b/core/src/main/python/wlsdeploy/tool/prepare/model_preparer.py @@ -27,6 +27,7 @@ from wlsdeploy.util import cla_helper from wlsdeploy.util import model from wlsdeploy.util import target_configuration_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.model import Model from wlsdeploy.util.model_translator import FileToPython from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -225,7 +226,7 @@ def _add_model_variables(self, model_dictionary, all_variables): if isinstance(value, dict): self._add_model_variables(value, all_variables) else: - matches = variables.get_variable_matches(str(value)) + matches = variables.get_variable_matches(str_helper.to_string(value)) for token, variable_key in matches: all_variables.append(variable_key) diff --git a/core/src/main/python/wlsdeploy/tool/util/attribute_setter.py b/core/src/main/python/wlsdeploy/tool/util/attribute_setter.py index d5538cdbfa..334430cf45 100644 --- a/core/src/main/python/wlsdeploy/tool/util/attribute_setter.py +++ b/core/src/main/python/wlsdeploy/tool/util/attribute_setter.py @@ -76,6 +76,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.util import model_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -657,7 +658,8 @@ def set_encrypted(self, location, key, value, wlst_value): :param wlst_value: the existing value of the attribute from WLST :raises BundleAwareException of the specified type: if an error occurs """ - encrypted_value = self.__weblogic_helper.encrypt(str(value), self.__model_context.get_domain_home()) + encrypted_value = \ + self.__weblogic_helper.encrypt(str_helper.to_string(value), self.__model_context.get_domain_home()) self.set_attribute(location, key, encrypted_value, wlst_merge_value=wlst_value) # @@ -687,7 +689,7 @@ def set_attribute(self, location, model_key, model_value, wlst_merge_value=None, if wlst_param is None: self.__logger.info('WLSDPLY-20011', model_key, class_name=self._class_name, method_name=_method_name) elif wlst_value is None: - self.__logger.info('WLSDPLY-20012', model_key, str(model_value), + self.__logger.info('WLSDPLY-20012', model_key, str_helper.to_string(model_value), class_name=self._class_name, method_name=_method_name) else: if self.__logger.is_finer_enabled(): @@ -710,7 +712,7 @@ def set_attribute_with_cmo(self, location, key, value, wlst_value=None, masked=F if wlst_attr_name is None: self.__logger.info('WLSDPLY-20011', key, class_name=self._class_name, method_name=_method_name) elif wlst_attr_value is None: - log_value = str(value) + log_value = str_helper.to_string(value) if masked: log_value = '' self.__logger.info('WLSDPLY-20012', key, log_value, class_name=self._class_name, method_name=_method_name) @@ -966,7 +968,7 @@ def __get_domain_location(self, location): :return: the domain location """ _method_name = '__get_domain_location' - self.__logger.entering(str(location), class_name=self._class_name, method_name=_method_name) + self.__logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) location = LocationContext(location) while len(location.get_model_folders()) > 0: @@ -990,7 +992,8 @@ def __get_parent_location(self, location, folder_name): location.pop_location() except: # index throws a ValueError if the item is not in the list... - ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19205', folder_name, str(location)) + ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19205', folder_name, + str_helper.to_string(location)) self.__logger.throwing(class_name=self._class_name, method_name=method_name, error=ex) raise ex return location @@ -1004,7 +1007,7 @@ def __get_existing_object_list(self, location): """ _method_name = '__get_existing_object_list' - self.__logger.entering(str(location), class_name=self._class_name, method_name=_method_name) + self.__logger.entering(str_helper.to_string(location), class_name=self._class_name, method_name=_method_name) list_path = self.__aliases.get_wlst_list_path(location) existing_names = self.__wlst_helper.get_existing_object_list(list_path) self.__logger.exiting(class_name=self._class_name, method_name=_method_name, result=existing_names) @@ -1025,7 +1028,8 @@ def __merge_existing_items(self, items, existing_value, location, key): :raises BundleAwareException of the specified type: if the WLDF Action/Notification is not found """ _method_name = '__merge_existing_items' - self.__logger.entering(str(items), str(existing_value), class_name=self._class_name, method_name=_method_name) + self.__logger.entering(str_helper.to_string(items), str_helper.to_string(existing_value), + class_name=self._class_name, method_name=_method_name) result = alias_utils.create_list(existing_value, 'WLSDPLY-08001') items_iterator = alias_utils.create_list(items, 'WLSDPLY-08000') diff --git a/core/src/main/python/wlsdeploy/tool/util/credential_injector.py b/core/src/main/python/wlsdeploy/tool/util/credential_injector.py index c30a547327..2fe1f76128 100644 --- a/core/src/main/python/wlsdeploy/tool/util/credential_injector.py +++ b/core/src/main/python/wlsdeploy/tool/util/credential_injector.py @@ -23,6 +23,7 @@ from wlsdeploy.tool.util.variable_injector import VARIABLE_VALUE from wlsdeploy.tool.util.variable_injector import VariableInjector from wlsdeploy.util import target_configuration_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util import variables from wlsdeploy.util.target_configuration import CONFIG_OVERRIDES_SECRETS_METHOD from wlsdeploy.util.target_configuration import SECRETS_METHOD @@ -266,6 +267,6 @@ def _add_model_variables(self, model_dictionary, variables): if isinstance(value, dict): self._add_model_variables(value, variables) else: - text = str(value) + text = str_helper.to_string(value) if text.startswith('@@'): variables.append(text) diff --git a/core/src/main/python/wlsdeploy/tool/util/filter_helper.py b/core/src/main/python/wlsdeploy/tool/util/filter_helper.py index 914bea4ffc..00f62f9d44 100644 --- a/core/src/main/python/wlsdeploy/tool/util/filter_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/filter_helper.py @@ -11,6 +11,7 @@ from wlsdeploy.util import dictionary_utils from wlsdeploy.util import path_utils from wlsdeploy.util.model_translator import FileToPython +import wlsdeploy.util.unicode_helper as str_helper __class_name = 'filter_helper' __logger = PlatformLogger('wlsdeploy.tool.util') @@ -79,7 +80,8 @@ def apply_filters(model, tool_type, model_context): method_name=_method_name) except Exception, ex: - __logger.severe('WLSDPLY-20018', str(ex), error=ex, class_name=__class_name, method_name=_method_name) + __logger.severe('WLSDPLY-20018', str_helper.to_string(ex), error=ex, + class_name=__class_name, method_name=_method_name) return filter_applied @@ -107,7 +109,8 @@ def _apply_filter(model, the_filter, model_context, filter_file_location): __logger.info('WLSDPLY-20033', name, class_name=__class_name, method_name=_method_name) return _apply_path_filter(model, path) - __logger.severe('WLSDPLY-20019', str(filter_file_location), class_name=__class_name, method_name=_method_name) + __logger.severe('WLSDPLY-20019', str_helper.to_string(filter_file_location), + class_name=__class_name, method_name=_method_name) return False @@ -124,7 +127,7 @@ def _apply_id_filter(model, id, model_context): filter_method = dictionary_utils.get_element(__id_filter_map, id) if filter_method is None: - __logger.severe('WLSDPLY-20020', str(id), class_name=__class_name, method_name=_method_name) + __logger.severe('WLSDPLY-20020', str_helper.to_string(id), class_name=__class_name, method_name=_method_name) return False else: filter_method(model, model_context) @@ -142,7 +145,8 @@ def _apply_path_filter(model, script_path): _method_name = '_apply_path_filter' if not os.path.isfile(script_path): - __logger.severe('WLSDPLY-20021', str(script_path), class_name=__class_name, method_name=_method_name) + __logger.severe('WLSDPLY-20021', str_helper.to_string(script_path), + class_name=__class_name, method_name=_method_name) return False python_path = os.path.dirname(script_path) @@ -158,7 +162,7 @@ def _apply_path_filter(model, script_path): return True except Exception, ex: - __logger.severe('WLSDPLY-20022', str(script_path), ex, error=ex, class_name=__class_name, - method_name=_method_name) + __logger.severe('WLSDPLY-20022', str_helper.to_string(script_path), ex, error=ex, + class_name=__class_name, method_name=_method_name) return False diff --git a/core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py b/core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py index 4d3f0aa125..0d95871801 100644 --- a/core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py +++ b/core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py @@ -43,6 +43,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.util.filters.model_traverse import ModelTraverse from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper _class_name = 'wko_filter' _logger = PlatformLogger('wlsdeploy.tool.util') @@ -124,7 +125,7 @@ def check_clustered_server_ports(model, _model_context): server_port = server_fields[LISTEN_PORT] if server_cluster and (server_port is not None): - server_port_text = str(server_port) + server_port_text = str_helper.to_string(server_port) if '@@' in server_port_text: # prepareModel filters the model before and after it is tokenized, # so disregard variable values in the tokenized pass diff --git a/core/src/main/python/wlsdeploy/tool/util/k8s_helper.py b/core/src/main/python/wlsdeploy/tool/util/k8s_helper.py index c25fd396b2..61cbab2550 100644 --- a/core/src/main/python/wlsdeploy/tool/util/k8s_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/k8s_helper.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2020, 2021, Oracle and/or its affiliates. +Copyright (c) 2020, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. Methods and constants for building Kubernetes resource files, @@ -17,6 +17,7 @@ from wlsdeploy.aliases.model_constants import SERVER from wlsdeploy.aliases.model_constants import TOPOLOGY from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper def get_domain_name(model_dictionary): @@ -74,7 +75,7 @@ def get_server_count(cluster_name, cluster_values, model_dictionary): servers = dictionary_utils.get_dictionary_element(topology, SERVER) for server_name, server_value in servers.items(): server_cluster = dictionary_utils.get_element(server_value, CLUSTER) - if str(server_cluster) == cluster_name: + if str_helper.to_string(server_cluster) == cluster_name: count = count + 1 return count diff --git a/core/src/main/python/wlsdeploy/tool/util/library_helper.py b/core/src/main/python/wlsdeploy/tool/util/library_helper.py index f965da658d..4cde26989e 100644 --- a/core/src/main/python/wlsdeploy/tool/util/library_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/library_helper.py @@ -12,7 +12,8 @@ from wlsdeploy.tool.util.archive_helper import ArchiveHelper from wlsdeploy.tool.util.wlst_helper import WlstHelper -import wlsdeploy.util.dictionary_utils as dictionary_utils +from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper class LibraryHelper(object): @@ -145,7 +146,7 @@ def _copy_domain_library(self, domain_lib): target_dir = File(self.domain_home, 'lib').getPath() try: - copy(str(source_path), str(target_dir)) + copy(str_helper.to_string(source_path), str_helper.to_string(target_dir)) except IOError: ex = exception_helper.create_create_exception('WLSDPLY-12234', source_path, target_dir) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) @@ -162,7 +163,7 @@ def _copy_domain_bin(self, domain_bin): target_dir = File(self.domain_home, 'bin').getPath() try: - copy(str(source_path), str(target_dir)) + copy(str_helper.to_string(source_path), str_helper.to_string(target_dir)) except IOError: ex = exception_helper.create_create_exception('WLSDPLY-12253', source_path, target_dir) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) diff --git a/core/src/main/python/wlsdeploy/tool/util/mbean_utils.py b/core/src/main/python/wlsdeploy/tool/util/mbean_utils.py index b9d16792f7..2d20d77115 100644 --- a/core/src/main/python/wlsdeploy/tool/util/mbean_utils.py +++ b/core/src/main/python/wlsdeploy/tool/util/mbean_utils.py @@ -13,6 +13,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.util.wlst_helper import WlstHelper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -111,7 +112,8 @@ def __collapse_attributes(self, location): interface_helper = self.__get_interface_helper(location) interface_attributes = self.get_mbean_attributes(interface_helper) - self.__remove_duplicates(interface_attributes, str(interface_helper), info_attributes, str(info_helper)) + self.__remove_duplicates(interface_attributes, str_helper.to_string(interface_helper), info_attributes, + str_helper.to_string(info_helper)) # This is the main list to drive from info_attributes = self.__slim_list(info_attributes, info_helper) # Because there are very few valid attributes in the Interface methods that are not in either the LSA map @@ -391,10 +393,11 @@ def _get_mbean_interface(self): if self.__mbean_interface is None: _logger.entering(class_name=self.__class__.__name__, method_name=_method_name) interfaces = [interface for interface in self._get_mbean_interfaces() - if re.search(self.__interface_matcher, str(interface)) is not None] + if re.search(self.__interface_matcher, str_helper.to_string(interface)) is not None] if len(interfaces) == 0: ex = exception_helper.create_exception(self._get_exception_type(), 'WLSDPLY-01777', - str(self._get_mbean_interfaces()), self.get_mbean_instance()) + str_helper.to_string(self._get_mbean_interfaces()), + self.get_mbean_instance()) _logger.throwing(ex, class_name=self.__class__.__name__, method_name=_method_name) raise ex else: @@ -402,7 +405,7 @@ def _get_mbean_interface(self): _logger.fine('WLSDPLY-01770', interfaces, self.get_mbean_instance(), class_name=self.__class__.__name__, method_name=_method_name) self.__mbean_interface = interfaces[0] - self.__mbean_name = str(self.__mbean_interface.getSimpleName()) + self.__mbean_name = str_helper.to_string(self.__mbean_interface.getSimpleName()) self.__mbean_interface_name = get_interface_name(self._get_mbean_interface()) _logger.exiting(class_name=self.__class__.__name__, method_name=_method_name, result=self.__mbean_interface_name) @@ -451,7 +454,7 @@ def _get_from_bean_proxy(self, getter): _logger.finer('WLSDPLY-01786', self._get_mbean_name(), getter, class_name=self.__class__.__name__, method_name=_method_name) except (Exception, JException), e: - _logger.finest('WLSDPLY-01785', self._get_mbean_name(), getter, str(e), + _logger.finest('WLSDPLY-01785', self._get_mbean_name(), getter, str_helper.to_string(e), class_name=self.__class__.__name__, method_name=_method_name) return success, value @@ -464,7 +467,7 @@ def get_interface_name(mbean_interface): getname = getattr(mbean_interface, 'getTypeName') result = getname() except (Exception, JException): - result = str(mbean_interface) + result = str_helper.to_string(mbean_interface) return result @@ -608,7 +611,7 @@ def get_type(self, attribute_name): """ method_list = self.__get_mbean_attribute(attribute_name) if method_list is not None: - return str(method_list[0].getReturnType()) + return str_helper.to_string(method_list[0].getReturnType()) return None def get_default_value(self, attribute_name): @@ -697,7 +700,7 @@ def __is_getter(self, method): def __is_setter(self, method): setter = self.__get_method_name(method) - return setter.startswith('set') and str(setter.getReturnType) == 'void' + return setter.startswith('set') and str_helper.to_string(setter.getReturnType) == 'void' def __is_subfolder_method(self, method): name = self.__get_method_name(method) @@ -826,7 +829,8 @@ def setter(self, attribute_name): descriptor = self.__get_mbean_attribute(attribute_name) if descriptor is not None: setter = descriptor.getWriteMethod() - if setter is not None and (str(setter.getReturnType()) == 'void' or str(setter.getReturnType()) == ""): + if setter is not None and (str_helper.to_string(setter.getReturnType()) == 'void' or + str_helper.to_string(setter.getReturnType()) == ""): return setter.getName() return None @@ -848,7 +852,8 @@ def is_clear_text_encrypted(self, attribute_name): :param attribute_name: name of the attribute to test :return: True if the attribute is a clear text security attribute """ - return self.is_encrypted(attribute_name) and str(self.get_type(attribute_name)) == 'java.lang.String' + return self.is_encrypted(attribute_name) and \ + str_helper.to_string(self.get_type(attribute_name)) == 'java.lang.String' def get_type(self, attribute_name): """ diff --git a/core/src/main/python/wlsdeploy/tool/util/target_helper.py b/core/src/main/python/wlsdeploy/tool/util/target_helper.py index 5c462a4978..fbfb3f38b9 100644 --- a/core/src/main/python/wlsdeploy/tool/util/target_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/target_helper.py @@ -23,6 +23,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.util import string_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -119,7 +120,7 @@ def target_server_groups_to_servers(self, server_groups_to_target): server_group_targeting_limits = \ self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map) - self.logger.finer('WLSDPLY-12240', str(server_group_targeting_limits), + self.logger.finer('WLSDPLY-12240', str_helper.to_string(server_group_targeting_limits), class_name=self.__class_name, method_name=_method_name) # Get the map of server names to server groups to target @@ -128,8 +129,8 @@ def target_server_groups_to_servers(self, server_groups_to_target): server_names, server_groups_to_target, server_group_targeting_limits) # type: dict - self.logger.finer('WLSDPLY-12242', str(server_to_server_groups_map), class_name=self.__class_name, - method_name=_method_name) + self.logger.finer('WLSDPLY-12242', str_helper.to_string(server_to_server_groups_map), + class_name=self.__class_name, method_name=_method_name) final_assignment_map = dict() # Target servers and dynamic clusters to the server group resources @@ -173,7 +174,8 @@ def target_server_groups_to_servers(self, server_groups_to_target): self.logger.info('WLSDPLY-12248', no_targets, class_name=self.__class_name, method_name=_method_name) - self.logger.exiting(result=str(final_assignment_map), class_name=self.__class_name, method_name=_method_name) + self.logger.exiting(result=str_helper.to_string(final_assignment_map), + class_name=self.__class_name, method_name=_method_name) return final_assignment_map def target_server_groups_to_dynamic_clusters(self, server_groups_to_target): @@ -210,10 +212,11 @@ def target_server_groups_to_dynamic_clusters(self, server_groups_to_target): dynamic_cluster_assigns = \ self.get_dc_to_server_groups_map(dynamic_cluster_names, server_groups_to_target, dc_server_group_targeting_limits) # type: dict - self.logger.finer('WLSDPLY-12240', str(dc_server_group_targeting_limits), + self.logger.finer('WLSDPLY-12240', str_helper.to_string(dc_server_group_targeting_limits), class_name=self.__class_name, method_name=_method_name) - self.logger.exiting(result=str(dynamic_cluster_assigns), class_name=self.__class_name, method_name=_method_name) + self.logger.exiting(result=str_helper.to_string(dynamic_cluster_assigns), + class_name=self.__class_name, method_name=_method_name) return dynamic_cluster_assigns def target_server_groups(self, server_assigns): @@ -224,11 +227,12 @@ def target_server_groups(self, server_assigns): :param server_assigns: map of server to server group """ _method_name = 'target_server_groups' - self.logger.entering(str(server_assigns), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(server_assigns), + class_name=self.__class_name, method_name=_method_name) for server, server_groups in server_assigns.iteritems(): server_name = self.wlst_helper.get_quoted_name_for_wlst(server) - self.logger.info('WLSDPLY-12224', str(server_groups), server_name, + self.logger.info('WLSDPLY-12224', str_helper.to_string(server_groups), server_name, class_name=self.__class_name, method_name=_method_name) self.wlst_helper.set_server_groups(server_name, server_groups, self.model_context.get_model_config().get_set_server_grps_timeout()) @@ -244,7 +248,8 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns): :param dynamic_cluster_assigns: The assignments from domainInfo targeting limits applied to dynamic lusters """ _method_name = 'target_dynamic_server_groups' - self.logger.entering(str(dynamic_cluster_assigns), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(dynamic_cluster_assigns), + class_name=self.__class_name, method_name=_method_name) domain_typedef = self.model_context.get_domain_typedef() @@ -274,7 +279,8 @@ def target_dynamic_clusters(self, server_assigns): :param server_assigns: map of server to server group """ _method_name = 'target_dynamic_clusters' - self.logger.entering(str(server_assigns), class_name=self.__class_name, method_name=_method_name) + self.logger.entering(str_helper.to_string(server_assigns), + class_name=self.__class_name, method_name=_method_name) for cluster, server_groups in server_assigns.iteritems(): cluster_name = self.wlst_helper.get_quoted_name_for_wlst(cluster) @@ -298,10 +304,10 @@ def _target_jrf_resources(self, dynamic_cluster_assigns): names_only.append(name) if self.model_context.is_wlst_online() and \ self.model_context.get_domain_typedef().is_restricted_jrf_domain_type(): - self.logger.warning('WLSDPLY-12244', str(names_only), class_name=self.__class_name, + self.logger.warning('WLSDPLY-12244', str_helper.to_string(names_only), class_name=self.__class_name, _method_name=_method_name) else: - self.logger.info('WLSDPLY-12236', str(names_only), + self.logger.info('WLSDPLY-12236', str_helper.to_string(names_only), class_name=self.__class_name, method_name=_method_name) self.wlst_helper.apply_jrf_with_context(names_only, self.model_context) @@ -418,9 +424,10 @@ def _get_server_group_targeting_limits(self, server_group_targeting_limits, clus :return: the map of server groups to server names to target """ _method_name = '_get_server_group_targeting_limits' - - self.logger.entering(str(server_group_targeting_limits), str(clusters_map), + self.logger.entering(str_helper.to_string(server_group_targeting_limits), + str_helper.to_string(clusters_map), class_name=self.__class_name, method_name=_method_name) + sg_targeting_limits = copy.deepcopy(server_group_targeting_limits) for server_group_name, sg_targeting_limit in sg_targeting_limits.iteritems(): if type(sg_targeting_limit) is str: @@ -462,9 +469,9 @@ def _get_dynamic_cluster_server_group_targeting_limits(self, targeting_limits, c :return: the map of server groups to server names to target """ _method_name = '_get_dynamic_cluster_server_group_targeting_limits' - - self.logger.entering(str(targeting_limits), str(clusters_map), + self.logger.entering(str_helper.to_string(targeting_limits), str_helper.to_string(clusters_map), class_name=self.__class_name, method_name=_method_name) + dc_sg_targeting_limits = copy.deepcopy(targeting_limits) for server_group_name, dc_sg_targeting_limit in dc_sg_targeting_limits.iteritems(): if type(dc_sg_targeting_limit) is str: @@ -503,9 +510,10 @@ def _get_server_to_server_groups_map(self, admin_server_name, server_names, serv :return: the map of server names to the list of server groups to target to that server """ _method_name = '_get_server_to_server_groups_map' - - self.logger.entering(admin_server_name, str(server_names), str(server_groups), str(sg_targeting_limits), + self.logger.entering(admin_server_name, str_helper.to_string(server_names), + str_helper.to_string(server_groups), str_helper.to_string(sg_targeting_limits), class_name=self.__class_name, method_name=_method_name) + result = OrderedDict() revised_server_groups = self._revised_list_server_groups(server_groups, sg_targeting_limits) for server_name in server_names: @@ -534,9 +542,10 @@ def get_dc_to_server_groups_map(self, dynamic_cluster_names, server_groups, dc_s :return: result: map of dynamic cluster to server groups """ _method_name = 'get_dc_to_server_groups_list' - - self.logger.entering(str(dynamic_cluster_names), str(server_groups), str(dc_sg_targeting_limits), + self.logger.entering(str_helper.to_string(dynamic_cluster_names), str_helper.to_string(server_groups), + str_helper.to_string(dc_sg_targeting_limits), class_name=self.__class_name, method_name=_method_name) + result = OrderedDict() revised_server_groups = self._revised_list_server_groups(server_groups, dc_sg_targeting_limits) for cluster_name in dynamic_cluster_names: diff --git a/core/src/main/python/wlsdeploy/tool/util/targets/additional_output_helper.py b/core/src/main/python/wlsdeploy/tool/util/targets/additional_output_helper.py index 3760d31712..c74b3862d4 100644 --- a/core/src/main/python/wlsdeploy/tool/util/targets/additional_output_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/targets/additional_output_helper.py @@ -23,6 +23,7 @@ from wlsdeploy.util import dictionary_utils from wlsdeploy.util import path_utils from wlsdeploy.util import target_configuration_helper +import wlsdeploy.util.unicode_helper as str_helper __class_name = 'vz_config_helper' __logger = PlatformLogger('wlsdeploy.tool.util') @@ -218,7 +219,7 @@ def _build_template_hash(model, model_context, aliases, credential_injector, dom cluster_values = dictionary_utils.get_dictionary_element(cluster_list, cluster_name) server_count = k8s_helper.get_server_count(cluster_name, cluster_values, model.get_model()) - cluster_hash[REPLICAS] = str(server_count) + cluster_hash[REPLICAS] = str_helper.to_string(server_count) cluster_hash[SET_CLUSTER_REPLICAS] = target_configuration.sets_cluster_replicas() clusters.append(cluster_hash) diff --git a/core/src/main/python/wlsdeploy/tool/util/targets/crd_file_updater.py b/core/src/main/python/wlsdeploy/tool/util/targets/crd_file_updater.py index cb841dcd00..1c2de65934 100644 --- a/core/src/main/python/wlsdeploy/tool/util/targets/crd_file_updater.py +++ b/core/src/main/python/wlsdeploy/tool/util/targets/crd_file_updater.py @@ -15,6 +15,7 @@ from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.util.targets import schema_helper from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.yaml.yaml_translator import PythonToYaml from wlsdeploy.yaml.yaml_translator import YamlToPython @@ -59,7 +60,7 @@ def update_from_model(crd_file, model, crd_helper): reader = YamlToPython(crd_file.getPath(), True) documents = reader.parse_documents() except YamlException, ex: - __logger.severe('WLSDPLY-01673', crd_file, str(ex), error=ex, class_name=__class_name, + __logger.severe('WLSDPLY-01673', crd_file, str_helper.to_string(ex), error=ex, class_name=__class_name, method_name=_method_name) return @@ -69,7 +70,7 @@ def update_from_model(crd_file, model, crd_helper): writer = PythonToYaml(documents) writer.write_to_yaml_file(crd_file.getPath()) except YamlException, ex: - __logger.severe('WLSDPLY-01674', crd_file, str(ex), error=ex, class_name=__class_name, + __logger.severe('WLSDPLY-01674', crd_file, str_helper.to_string(ex), error=ex, class_name=__class_name, method_name=_method_name) return diff --git a/core/src/main/python/wlsdeploy/tool/util/variable_injector.py b/core/src/main/python/wlsdeploy/tool/util/variable_injector.py index dd67e9a809..ad4e1784d5 100644 --- a/core/src/main/python/wlsdeploy/tool/util/variable_injector.py +++ b/core/src/main/python/wlsdeploy/tool/util/variable_injector.py @@ -28,6 +28,7 @@ from wlsdeploy.json.json_translator import JsonToPython from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import path_utils +import wlsdeploy.util.unicode_helper as str_helper WEBLOGIC_DEPLOY_HOME_TOKEN = '@@WLSDEPLOY@@' @@ -452,8 +453,8 @@ def _process_attribute(self, model, attribute, location, injector_values): _logger.fine('WLSDPLY-19525', variable_name, attribute_value, attribute, variable_value, class_name=_class_name, method_name=_method_name) else: - _logger.finer('WLSDPLY-19526', attribute_value, attribute, str(location), class_name=_class_name, - method_name=_method_name) + _logger.finer('WLSDPLY-19526', attribute_value, attribute, str_helper.to_string(location), + class_name=_class_name, method_name=_method_name) if variable_value is not None: variable_dict[variable_name] = self._check_replace_variable_value(location, attribute, @@ -844,7 +845,7 @@ def _format_variable_value(value): return 'True' return 'False' else: - return str(value) + return str_helper.to_string(value) def _compile_pattern(pattern): diff --git a/core/src/main/python/wlsdeploy/tool/util/variable_injector_functions.py b/core/src/main/python/wlsdeploy/tool/util/variable_injector_functions.py index 30ad3424dd..cc0140d61b 100644 --- a/core/src/main/python/wlsdeploy/tool/util/variable_injector_functions.py +++ b/core/src/main/python/wlsdeploy/tool/util/variable_injector_functions.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates. +Copyright (c) 2018, 2022, Oracle Corporation and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ import re @@ -9,6 +9,7 @@ from oracle.weblogic.deploy.aliases import AliasException from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.logging.platform_logger import PlatformLogger +import wlsdeploy.util.unicode_helper as str_helper _class_name = 'variable_injector' _logger = PlatformLogger('wlsdeploy.tool.util') @@ -123,7 +124,7 @@ def __traverse_location(iterate_location, attribute, name_list, aliases, last_fo iterate_location.remove_name_token(name_token) iterate_location.pop_location() except AliasException, ae: - _logger.warning('WLSDPLY-19531', str(iterate_location), attribute, ae.getLocalizedMessage(), - class_name=_class_name, method_name=_method_name) + _logger.warning('WLSDPLY-19531', str_helper.to_string(iterate_location), attribute, + ae.getLocalizedMessage(), class_name=_class_name, method_name=_method_name) __traverse_location(iterate_location, attribute, name_list, aliases, current_folder, short_folder) return name_list diff --git a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py index 09283297e4..b0d0981396 100644 --- a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py @@ -16,6 +16,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.util.string_output_stream import StringOutputStream +import wlsdeploy.util.unicode_helper as str_helper wlst_functions = None @@ -1413,7 +1414,8 @@ def get_mbi(self, path=None): if current_path is not None: self.cd(current_path) - self.__logger.exiting(result=str(result), class_name=self.__class_name, method_name=_method_name) + self.__logger.exiting(result=str_helper.to_string(result), + class_name=self.__class_name, method_name=_method_name) return result def set_shared_secret_store_with_password(self, wallet_path, password): @@ -1638,4 +1640,4 @@ def _format_exception(e): message = cause.getLocalizedMessage() cause = cause.getCause() return message - return str(e) + return str_helper.to_string(e) diff --git a/core/src/main/python/wlsdeploy/tool/validate/kubernetes_validator.py b/core/src/main/python/wlsdeploy/tool/validate/kubernetes_validator.py index ef44be43d1..e56b6a7610 100644 --- a/core/src/main/python/wlsdeploy/tool/validate/kubernetes_validator.py +++ b/core/src/main/python/wlsdeploy/tool/validate/kubernetes_validator.py @@ -9,6 +9,7 @@ from wlsdeploy.tool.util.targets import model_crd_helper from wlsdeploy.tool.util.targets import schema_helper from wlsdeploy.util import dictionary_utils +import wlsdeploy.util.unicode_helper as str_helper class KubernetesValidator(object): @@ -69,7 +70,7 @@ def validate_folder(self, model_folder, schema_folder, schema_path, model_path): :param model_path: the path of model elements (including array indices), used for logging """ _method_name = 'validate_folder' - self._log_debug(str(model_path)) + self._log_debug(str_helper.to_string(model_path)) if not isinstance(model_folder, dict): self._logger.severe("WLSDPLY-05038", model_path, class_name=self._class_name, method_name=_method_name) @@ -155,19 +156,21 @@ def _validate_object_array(self, model_value, property_map, schema_path, model_p def _validate_simple_map(self, model_value, property_name, model_path): _method_name = '_validate_simple_map' if not isinstance(model_value, dict): - self._logger.severe("WLSDPLY-05032", property_name, model_path, str(type(model_value)), + self._logger.severe("WLSDPLY-05032", property_name, model_path, str_helper.to_string(type(model_value)), class_name=self._class_name, method_name=_method_name) def _validate_simple_array(self, model_value, property_name, model_path): _method_name = '_validate_simple_array' if isinstance(model_value, dict): - self._logger.severe("WLSDPLY-05017", property_name, model_path, "list", str(type(model_value)), + self._logger.severe("WLSDPLY-05017", property_name, model_path, "list", + str_helper.to_string(type(model_value)), class_name=self._class_name, method_name=_method_name) def _validate_simple_type(self, model_value, property_type, property_name, model_path): _method_name = '_validate_simple_type' if isinstance(model_value, list) or isinstance(model_value, dict): - self._logger.severe("WLSDPLY-05017", property_name, model_path, property_type, str(type(model_value)), + self._logger.severe("WLSDPLY-05017", property_name, model_path, property_type, + str_helper.to_string(type(model_value)), class_name=self._class_name, method_name=_method_name) def _check_folder_path(self, schema_path, model_path): diff --git a/core/src/main/python/wlsdeploy/tool/validate/validation_utils.py b/core/src/main/python/wlsdeploy/tool/validate/validation_utils.py index ef8512e3c6..2eee6266c5 100644 --- a/core/src/main/python/wlsdeploy/tool/validate/validation_utils.py +++ b/core/src/main/python/wlsdeploy/tool/validate/validation_utils.py @@ -6,6 +6,7 @@ import types from oracle.weblogic.deploy.exception import ExceptionHelper +import wlsdeploy.util.unicode_helper as str_helper divider_string = '-----------------------------------------------' @@ -38,7 +39,7 @@ def extract_path_tokens(tokenized_value): if tokenized_value.isunicode(): path_pattern = unicode(_path_token_pattern) elif not isinstance(tokenized_value, basestring): - path_value = str(tokenized_value) + path_value = str_helper.to_string(tokenized_value) tokens = re.findall(path_pattern, path_value) if len(tokens) == 0: # tokenized_value didn't contain any variable expressions, so @@ -85,10 +86,10 @@ def get_python_data_type(value): data_type = type(value) if data_type in data_types_map: rtnval = data_types_map[data_type] - elif str(data_type) in data_types_map: - rtnval = data_types_map[str(data_type)] + elif str_helper.to_string(data_type) in data_types_map: + rtnval = data_types_map[str_helper.to_string(data_type)] else: - rtnval = str(data_type) + rtnval = str_helper.to_string(data_type) return rtnval diff --git a/core/src/main/python/wlsdeploy/tool/validate/validator.py b/core/src/main/python/wlsdeploy/tool/validate/validator.py index d7dd28e0c2..098863038f 100644 --- a/core/src/main/python/wlsdeploy/tool/validate/validator.py +++ b/core/src/main/python/wlsdeploy/tool/validate/validator.py @@ -12,7 +12,6 @@ from oracle.weblogic.deploy.util import VariableException from wlsdeploy.aliases import model_constants -from wlsdeploy.aliases.aliases import Aliases from wlsdeploy.aliases.location_context import LocationContext from wlsdeploy.aliases.validation_codes import ValidationCodes from wlsdeploy.aliases.wlst_modes import WlstModes @@ -26,6 +25,7 @@ from wlsdeploy.tool.validate.validator_logger import ValidatorLogger from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util import variables from wlsdeploy.util.enum import Enum from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -373,10 +373,12 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_ if attribute_location is not None: valid_attr_infos = self._aliases.get_model_attribute_names_and_types(attribute_location) - self._logger.finer('WLSDPLY-05012', str(attribute_location), str(valid_attr_infos), + self._logger.finer('WLSDPLY-05012', str_helper.to_string(attribute_location), + str_helper.to_string(valid_attr_infos), class_name=_class_name, method_name=_method_name) path_tokens_attr_keys = self._aliases.get_model_uses_path_tokens_attribute_names(attribute_location) - self._logger.finer('WLSDPLY-05013', str(attribute_location), str(path_tokens_attr_keys), + self._logger.finer('WLSDPLY-05013', str_helper.to_string(attribute_location), + str_helper.to_string(path_tokens_attr_keys), class_name=_class_name, method_name=_method_name) model_folder_path = model_section_key + ":/" @@ -410,7 +412,7 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_ # Append section_dict_key to location context validation_location.append_location(section_dict_key) - self._logger.finest('validation_location = {0}', str(validation_location), + self._logger.finest('validation_location = {0}', str_helper.to_string(validation_location), class_name=_class_name, method_name=_method_name) # Call self.__validate_section_folder() passing in section_dict_value as the model_node to process @@ -488,13 +490,13 @@ def __validate_section_folder(self, model_node, validation_location): new_location = LocationContext(validation_location) name_token = self._aliases.get_name_token(new_location) - self._logger.finest('WLSDPLY-05014', str(validation_location), name_token, + self._logger.finest('WLSDPLY-05014', str_helper.to_string(validation_location), name_token, class_name=_class_name, method_name=_method_name) if name_token is not None: new_location.add_name_token(name_token, expanded_name) - self._logger.finest('2 new_location={0}', new_location, + self._logger.finest('2 new_location={0}', str_helper.to_string(new_location), class_name=_class_name, method_name=_method_name) value_dict = model_node[name] @@ -565,12 +567,13 @@ def __process_model_node(self, model_node, validation_location): valid_folder_keys = self._aliases.get_model_subfolder_names(validation_location) valid_attr_infos = self._aliases.get_model_attribute_names_and_types(validation_location) - self._logger.finest('5 model_node={0}', str(model_node), class_name=_class_name, method_name=_method_name) + self._logger.finest('5 model_node={0}', str_helper.to_string(model_node), + class_name=_class_name, method_name=_method_name) self._logger.finest('5 aliases.get_model_subfolder_names(validation_location) returned: {0}', - str(valid_folder_keys), + str_helper.to_string(valid_folder_keys), class_name=_class_name, method_name=_method_name) self._logger.finest('5 aliases.get_model_attribute_names_and_types(validation_location) returned: {0}', - str(valid_attr_infos), + str_helper.to_string(valid_attr_infos), class_name=_class_name, method_name=_method_name) self._logger.finest('5 model_folder_path={0}', model_folder_path, class_name=_class_name, method_name=_method_name) @@ -659,7 +662,8 @@ def __process_model_node(self, model_node, validation_location): def __validate_attributes(self, attributes_dict, valid_attr_infos, validation_location): _method_name = '__validate_attributes' - self._logger.finest('validation_location={0}, attributes_dict={0}', str(validation_location), str(attributes_dict), + self._logger.finest('validation_location={0}, attributes_dict={0}', str_helper.to_string(validation_location), + str_helper.to_string(attributes_dict), class_name=_class_name, method_name=_method_name) model_folder_path = self._aliases.get_model_folder_path(validation_location) @@ -668,7 +672,8 @@ def __validate_attributes(self, attributes_dict, valid_attr_infos, validation_lo return path_tokens_attr_keys = self._aliases.get_model_uses_path_tokens_attribute_names(validation_location) - self._logger.finer('WLSDPLY-05013', str(validation_location), str(path_tokens_attr_keys), + self._logger.finer('WLSDPLY-05013', str_helper.to_string(validation_location), + str_helper.to_string(path_tokens_attr_keys), class_name=_class_name, method_name=_method_name) for attribute_name, attribute_value in attributes_dict.iteritems(): @@ -680,19 +685,20 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos _method_name = '__validate_attribute' log_value = self.__get_attribute_log_value(attribute_name, attribute_value, valid_attr_infos) - self._logger.entering(attribute_name, log_value, str(valid_attr_infos), str(path_tokens_attr_keys), - model_folder_path, str(validation_location), + self._logger.entering(attribute_name, log_value, str_helper.to_string(valid_attr_infos), + str_helper.to_string(path_tokens_attr_keys), model_folder_path, + str_helper.to_string(validation_location), class_name=_class_name, method_name=_method_name) if variables.has_variables(attribute_name): self._report_unsupported_variable_usage(attribute_name, model_folder_path) - if variables.has_variables(str(attribute_value)): + if variables.has_variables(str_helper.to_string(attribute_value)): attribute_value = self.__validate_variable_substitution(attribute_value, model_folder_path) if attribute_name in valid_attr_infos: expected_data_type = valid_attr_infos[attribute_name] - actual_data_type = str(type(attribute_value)) + actual_data_type = str_helper.to_string(type(attribute_value)) self._logger.finer('WLSDPLY-05016', attribute_name, expected_data_type, actual_data_type, class_name=_class_name, method_name=_method_name) if validation_utils.is_compatible_data_type(expected_data_type, actual_data_type) is False: @@ -716,7 +722,7 @@ def __validate_attribute(self, attribute_name, attribute_value, valid_attr_infos def __validate_properties(self, properties_dict, valid_prop_infos, validation_location): _method_name = '__validate_properties' - self._logger.entering(str(properties_dict), str(validation_location), + self._logger.entering(str_helper.to_string(properties_dict), str_helper.to_string(validation_location), class_name=_class_name, method_name=_method_name) for property_name, property_value in properties_dict.iteritems(): @@ -729,18 +735,18 @@ def __validate_property(self, property_name, property_value, valid_prop_infos, m _method_name = '__validate_property' - self._logger.entering(property_name, property_value, str(valid_prop_infos), model_folder_path, - class_name=_class_name, method_name=_method_name) + self._logger.entering(property_name, property_value, str_helper.to_string(valid_prop_infos), + model_folder_path, class_name=_class_name, method_name=_method_name) if variables.has_variables(property_name): property_name = self.__validate_variable_substitution(property_name, model_folder_path) - if variables.has_variables(str(property_value)): + if variables.has_variables(str_helper.to_string(property_value)): property_value = self.__validate_variable_substitution(property_value, model_folder_path) if property_name in valid_prop_infos: expected_data_type = valid_prop_infos[property_name] - actual_data_type = str(type(property_value)) + actual_data_type = str_helper.to_string(type(property_value)) self._logger.finer('WLSDPLY-05018', property_name, expected_data_type, actual_data_type, class_name=_class_name, method_name=_method_name) if validation_utils.is_compatible_data_type(expected_data_type, actual_data_type) is False: @@ -837,7 +843,8 @@ def __validate_single_path_in_archive(self, path, attribute_name, model_folder_p class_name=_class_name, method_name=_method_name) else: tokens = validation_utils.extract_path_tokens(path) - self._logger.finest('tokens={0}', str(tokens), class_name=_class_name, method_name=_method_name) + self._logger.finest('tokens={0}', str_helper.to_string(tokens), + class_name=_class_name, method_name=_method_name) # TODO(mwooten) - This would be a good place to validate any path token found... if not self._model_context.has_token_prefix(path): @@ -873,15 +880,17 @@ def __validate_server_group_targeting_limits(self, attribute_key, attribute_valu if attribute_value is not None: if not isinstance(attribute_value, dict): - self._logger.severe('WLSDPLY-05032', attribute_key, model_folder_path, str(type(attribute_value)), + self._logger.severe('WLSDPLY-05032', attribute_key, model_folder_path, + str_helper.to_string(type(attribute_value)), class_name=_class_name, method_name=__method_name) else: model_folder_path += '/' + attribute_key for key, value in attribute_value.iteritems(): if type(key) is not str: # Force the key to a string for any value validation issues reported below - key = str(key) - self._logger.severe('WLSDPLY-05033', key, model_folder_path, str(type(key)), + key = str_helper.to_string(key) + self._logger.severe('WLSDPLY-05033', str_helper.to_string, model_folder_path, + str_helper.to_string(type(key)), class_name=_class_name, method_name=__method_name) else: if variables.has_variables(key): @@ -897,7 +906,8 @@ def __validate_server_group_targeting_limits(self, attribute_key, attribute_valu elif type(value) is str: self._validate_single_server_group_target_limits_value(key, value, model_folder_path) else: - self._logger.severe('WLSDPLY-05034', key, model_folder_path, str(type(value)), + self._logger.severe('WLSDPLY-05034', key, model_folder_path, + str_helper.to_string(type(value)), class_name=_class_name, method_name=__method_name) self._logger.exiting(class_name=_class_name, method_name=__method_name) @@ -905,11 +915,12 @@ def __validate_server_group_targeting_limits(self, attribute_key, attribute_valu def _validate_single_server_group_target_limits_value(self, key, value, model_folder_path): _method_name = '_validate_single_server_group_target_limits_value' - if type(value) is str: - if variables.has_variables(str(value)): - self._report_unsupported_variable_usage(str(value), model_folder_path) + if type(value) in [unicode, str]: + if variables.has_variables(str_helper.to_string(value)): + self._report_unsupported_variable_usage(str_helper.to_string(value), model_folder_path) else: - self._logger.severe('WLSDPLY-05035', key, str(value), model_folder_path, str(type(value)), + self._logger.severe('WLSDPLY-05035', key, str_helper.to_string(value), model_folder_path, + str_helper.to_string(type(value)), class_name=_class_name, method_name=_method_name) def __validate_wlsroles_section(self, attribute_value): diff --git a/core/src/main/python/wlsdeploy/util/cla_utils.py b/core/src/main/python/wlsdeploy/util/cla_utils.py index 1ef97d6226..1a535881b1 100644 --- a/core/src/main/python/wlsdeploy/util/cla_utils.py +++ b/core/src/main/python/wlsdeploy/util/cla_utils.py @@ -21,6 +21,7 @@ from wlsdeploy.json.json_translator import JsonToPython from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.util import path_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.exit_code import ExitCode from wlsdeploy.util.target_configuration import TargetConfiguration from wlsdeploy.util.validate_configuration import VALIDATION_METHODS @@ -434,7 +435,7 @@ def is_help_key(self, key): return self.HELP_SWITCH == key def get_oracle_home_key(self): - return str(self.ORACLE_HOME_SWITCH) + return str_helper.to_string(self.ORACLE_HOME_SWITCH) def is_oracle_home_key(self, key): return self.ORACLE_HOME_SWITCH == key @@ -472,7 +473,7 @@ def _validate_oracle_home_arg(self, value): return oh_name def get_java_home_key(self): - return str(self.JAVA_HOME_SWITCH) + return str_helper.to_string(self.JAVA_HOME_SWITCH) def is_java_home_key(self, key): return self.JAVA_HOME_SWITCH == key diff --git a/core/src/main/python/wlsdeploy/util/dictionary_utils.py b/core/src/main/python/wlsdeploy/util/dictionary_utils.py index b4e34f5438..473b1a7aa1 100644 --- a/core/src/main/python/wlsdeploy/util/dictionary_utils.py +++ b/core/src/main/python/wlsdeploy/util/dictionary_utils.py @@ -5,6 +5,7 @@ import java.util.Properties as JProperties import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict +import wlsdeploy.util.unicode_helper as str_helper def get_dictionary_element(dictionary, element_name): @@ -79,7 +80,7 @@ def format_dictionary_element_name(parent, key): :param key: key to element in dictionary :return: string representation of element """ - return str(parent) + '[' + str(key) + ']' + return str_helper.to_string(parent) + '[' + str_helper.to_string(key) + ']' def create_property_object(properties_string): diff --git a/core/src/main/python/wlsdeploy/util/model_context.py b/core/src/main/python/wlsdeploy/util/model_context.py index 6b6c05f081..65f37d01da 100644 --- a/core/src/main/python/wlsdeploy/util/model_context.py +++ b/core/src/main/python/wlsdeploy/util/model_context.py @@ -21,6 +21,7 @@ from wlsdeploy.util import string_utils from wlsdeploy.util import model_config from wlsdeploy.util.target_configuration import TargetConfiguration +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.validate_configuration import ValidateConfiguration from wlsdeploy.util.weblogic_helper import WebLogicHelper @@ -843,7 +844,7 @@ def replace_tokens(self, resource_type, resource_name, attribute_name, resource_ return uri = URI(attribute_value) uri_scheme = uri.getScheme() - if uri_scheme is not None and str(uri_scheme).startswith('file'): + if uri_scheme is not None and str_helper.to_string(uri_scheme).startswith('file'): attribute_value = uri.getPath() message = "Replacing {0} in {1} {2} {3} with {4}" diff --git a/core/src/main/python/wlsdeploy/util/string_utils.py b/core/src/main/python/wlsdeploy/util/string_utils.py index 4eaef002ea..3115c652cb 100644 --- a/core/src/main/python/wlsdeploy/util/string_utils.py +++ b/core/src/main/python/wlsdeploy/util/string_utils.py @@ -1,14 +1,14 @@ """ -Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates. All rights reserved. +Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. This module provides string manipulation helper methods that are not found in the WLST version of Jython """ -import java.lang.String as JString import java.util.Properties as Properties import java.io.FileInputStream as FileInputStream import java.io.IOException as IOException +from oracle.weblogic.deploy.aliases import VersionUtils import wlsdeploy.exception.exception_helper as exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger @@ -16,8 +16,6 @@ __logger = PlatformLogger('wlsdeploy.util') _class_name = 'string_utils' -STANDARD_VERSION_NUMBER_PLACES = 5 - def is_empty(text): """ @@ -116,47 +114,4 @@ def is_weblogic_version_or_above(wls_version, str_version): :param str_version: the string representation of the version to be compared to the weblogic version :return: True if the provided version is equal or greater than the version represented by the wls_version argument """ - result = False - array_version = str_version.split('.') - array_wl_version = _get_wl_version_array(wls_version) - - len_compare = len(array_wl_version) - if len(array_version) < len_compare: - len_compare = len(array_version) - - idx = 0 - while idx < len_compare: - compare_value = JString(array_version[idx]).compareTo(JString(array_wl_version[idx])) - if compare_value < 0: - result = True - break - elif compare_value > 0: - result = False - break - elif idx + 1 == len_compare: - result = True - - idx += 1 - - return result - - -# We need to pad the actual version number for comparison purposes so -# that is is never shorter than the specified version. Otherwise, -# actual version 12.2.1 will be considered to be equal to 12.2.1.1 -# -def _get_wl_version_array(wl_version): - """ - Get the WebLogic version number padded to the standard number of digits. - :param wl_version: WebLogic version number - :return: the padded WebLogic version number - """ - result = wl_version.split('.') - - if len(result) < STANDARD_VERSION_NUMBER_PLACES: - index = len(result) - while index < STANDARD_VERSION_NUMBER_PLACES: - result.append('0') - index += 1 - - return result \ No newline at end of file + return VersionUtils.compareVersions(wls_version, str_version) >= 0 diff --git a/core/src/main/python/wlsdeploy/util/tool_main.py b/core/src/main/python/wlsdeploy/util/tool_main.py index e177e5ad02..11c6e1d62b 100644 --- a/core/src/main/python/wlsdeploy/util/tool_main.py +++ b/core/src/main/python/wlsdeploy/util/tool_main.py @@ -18,9 +18,9 @@ from wlsdeploy.aliases.wlst_modes import WlstModes from wlsdeploy.tool.util import model_context_helper from wlsdeploy.util import cla_helper +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.util.exit_code import ExitCode - def run_tool(main, process_args, args, program_name, class_name, logger): """ The standardized entry point into each tool. @@ -39,7 +39,8 @@ def run_tool(main, process_args, args, program_name, class_name, logger): logger.entering(args[0], class_name=class_name, method_name=_method_name) for index, arg in enumerate(args): - logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=class_name, method_name=_method_name) + logger.finer('sys.argv[{0}] = {1}', str_helper.to_string(index), str_helper.to_string(arg), + class_name=class_name, method_name=_method_name) model_context_obj = model_context_helper.create_exit_context(program_name) try: @@ -93,7 +94,8 @@ def __handle_unexpected_exception(ex, model_context, class_name, method_name, lo :param logger: the logger to use """ program_name = model_context.get_program_name() - logger.severe('WLSDPLY-20035', program_name, sys.exc_info()[0]) + logger.severe('WLSDPLY-20035', program_name, sys.exc_info()[0], error=ex, + class_name=class_name, method_name=method_name) if hasattr(ex, 'stackTrace'): # this works best for java exceptions, and gets the full stacktrace all the way back to weblogic.WLST diff --git a/core/src/main/python/wlsdeploy/util/unicode_helper.py b/core/src/main/python/wlsdeploy/util/unicode_helper.py new file mode 100644 index 0000000000..03540b202c --- /dev/null +++ b/core/src/main/python/wlsdeploy/util/unicode_helper.py @@ -0,0 +1,23 @@ +""" +Copyright (c) 2022, Oracle Corporation and/or its affiliates. All rights reserved. +Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +This module provides methods to help properly handle unicode across WLST versions of Jython +""" +import sys + +# DO NOT import any WDT Python code into this file--ever! + +__use_unicode = sys.version_info >= (2, 7) + + +def use_unicode(): + return __use_unicode + + +def to_string(value): + if __use_unicode: + return unicode(value, 'UTF8', 'strict') + else: + return str(value) + diff --git a/core/src/main/python/wlsdeploy/util/variables.py b/core/src/main/python/wlsdeploy/util/variables.py index e922f853d7..94bb211ab7 100644 --- a/core/src/main/python/wlsdeploy/util/variables.py +++ b/core/src/main/python/wlsdeploy/util/variables.py @@ -17,6 +17,7 @@ from wlsdeploy.util import path_utils from wlsdeploy.util import string_utils +import wlsdeploy.util.unicode_helper as str_helper from wlsdeploy.exception import exception_helper from wlsdeploy.logging import platform_logger from wlsdeploy.util import dictionary_utils @@ -275,13 +276,13 @@ def _substitute(text, variables, model_context, error_info, attribute_name=None) # check environment variables before @@FILE:/dir/@@ENV:name@@.txt@@ matches = _environment_pattern.findall(text) for token, key in matches: - if not os.environ.has_key(str(key)): + if str_helper.to_string(key) not in os.environ: allow_unresolved = validation_config.allow_unresolved_environment_tokens() _report_token_issue('WLSDPLY-01737', method_name, allow_unresolved, key) _increment_error_count(error_info, allow_unresolved) problem_found = True continue - value = os.environ.get(str(key)) + value = os.environ.get(str_helper.to_string(key)) text = text.replace(token, value) # check secret variables before @@FILE:/dir/@@SECRET:name:key@@.txt@@ @@ -369,7 +370,7 @@ def _read_value_from_file(file_path, allow_unresolved): if line is None: line = '' - return str(line).strip() + return str_helper.to_string(line).strip() def _resolve_secret_token(name, key, model_context): @@ -408,7 +409,7 @@ def _init_secret_token_map(model_context): # add name/key pairs for files in sub-directories of directories in WDT_MODEL_SECRETS_DIRS. - locations = os.environ.get(str(_secret_dirs_variable), None) + locations = os.environ.get(str_helper.to_string(_secret_dirs_variable), None) if locations is not None: for secret_dir in locations.split(","): if not os.path.isdir(secret_dir): @@ -425,7 +426,7 @@ def _init_secret_token_map(model_context): # add name/key pairs for files in directories assigned in WDT_MODEL_SECRETS_NAME_DIR_PAIRS. # these pairs will override if they were previously added as sub-directory pairs. - dir_pairs_text = os.environ.get(str(_secret_dir_pairs_variable), None) + dir_pairs_text = os.environ.get(str_helper.to_string(_secret_dir_pairs_variable), None) if dir_pairs_text is not None: dir_pairs = dir_pairs_text.split(',') for dir_pair in dir_pairs: @@ -521,10 +522,10 @@ def substitute_key(text, variables): matches = _environment_pattern.findall(text) for token, key in matches: # log, or throw an exception if key is not found. - if not os.environ.has_key(str(key)): + if str_helper.to_string(key) not in os.environ: continue - value = os.environ.get(str(key)) + value = os.environ.get(str_helper.to_string(key)) text = text.replace(token, value) return text diff --git a/core/src/main/python/wlsdeploy/util/weblogic_helper.py b/core/src/main/python/wlsdeploy/util/weblogic_helper.py index 8c7bbdf565..cca4b98f1f 100644 --- a/core/src/main/python/wlsdeploy/util/weblogic_helper.py +++ b/core/src/main/python/wlsdeploy/util/weblogic_helper.py @@ -11,6 +11,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.util import string_utils +import wlsdeploy.util.unicode_helper as str_helper import os import re @@ -32,10 +33,10 @@ def __init__(self, logger, wls_version=None): """ self.logger = logger if wls_version is not None: - self.wl_version = str(wls_version) - self.wl_version_actual = str(version_helper.getReleaseBuildVersion()) + self.wl_version = str_helper.to_string(wls_version) + self.wl_version_actual = str_helper.to_string(version_helper.getReleaseBuildVersion()) else: - self.wl_version = str(version_helper.getReleaseBuildVersion()) + self.wl_version = str_helper.to_string(version_helper.getReleaseBuildVersion()) self.wl_version_actual = self.wl_version def get_actual_weblogic_version(self): diff --git a/core/src/main/python/wlsdeploy/util/weblogic_roles_helper.py b/core/src/main/python/wlsdeploy/util/weblogic_roles_helper.py index 8a2de2c63c..53453d7c00 100644 --- a/core/src/main/python/wlsdeploy/util/weblogic_roles_helper.py +++ b/core/src/main/python/wlsdeploy/util/weblogic_roles_helper.py @@ -6,6 +6,7 @@ from java.io import File from java.lang import String from wlsdeploy.exception import exception_helper +import wlsdeploy.util.unicode_helper as str_helper import com.bea.common.security.utils.encoders.BASE64Encoder as BASE64Encoder import com.bea.common.security.xacml.DocumentParseException as DocumentParseException @@ -131,15 +132,18 @@ def _update_xacml_role_mapper_ldift(self, role_entries_map): os.rename(update_filename, ldift_filename) except ValueError, ve: - ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'ValueError', str(ve), error=ve) + ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'ValueError', + str_helper.to_string(ve), error=ve) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex except IOError, ioe: - ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'IOError', str(ioe), error=ioe) + ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'IOError', + str_helper.to_string(ioe), error=ioe) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex except OSError, ose: - ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'OSError', str(ose), error=ose) + ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-01805', 'OSError', + str_helper.to_string(ose), error=ose) self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex diff --git a/core/src/main/python/wlsdeploy/yaml/yaml_translator.py b/core/src/main/python/wlsdeploy/yaml/yaml_translator.py index 8056c60e98..b99347f713 100644 --- a/core/src/main/python/wlsdeploy/yaml/yaml_translator.py +++ b/core/src/main/python/wlsdeploy/yaml/yaml_translator.py @@ -25,6 +25,7 @@ from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger +import wlsdeploy.util.unicode_helper as str_helper class YamlToPython(object): @@ -38,9 +39,10 @@ def __init__(self, file_name, use_ordering=False, max_size=0): self._file_name = file_name self._use_ordering = use_ordering + self._use_unicode = str_helper.use_unicode() self._logger = PlatformLogger('wlsdeploy.yaml') try: - self._translator = JYamlTranslator(self._file_name, self._use_ordering, max_size) + self._translator = JYamlTranslator(self._file_name, self._use_ordering, self._use_unicode, max_size) except JIllegalArgumentException, iae: yaml_ex = \ exception_helper.create_yaml_exception('WLSDPLY-18008', file_name, iae.getLocalizedMessage(), error=iae) @@ -86,14 +88,16 @@ class YamlStreamToPython(object): """ _class_name = 'YamlStreamToPython' - def __init__(self, file_name, input_stream, use_ordering=False): + def __init__(self, file_name, input_stream, use_ordering=False, max_size=0): _method_name = '__init__' self._file_name = file_name self._use_ordering = use_ordering + self._use_unicode = str_helper.use_unicode() self._logger = PlatformLogger('wlsdeploy.yaml') try: - self._translator = JYamlStreamTranslator(self._file_name, input_stream, self._use_ordering) + self._translator = JYamlStreamTranslator(self._file_name, input_stream, self._use_ordering, + self._use_unicode, max_size) except JIllegalArgumentException, iae: yaml_ex = \ exception_helper.create_yaml_exception('WLSDPLY-18008', file_name, iae.getLocalizedMessage(), error=iae) @@ -185,7 +189,7 @@ def convert_scalar_to_java_type(self, py_value): elif type(py_value) is int: result = JInteger(py_value) elif type(py_value) is long: - result = JLong(JString(str(py_value))) + result = JLong(JString(str_helper.to_string(py_value))) elif type(py_value) is float: result = JDouble(py_value) elif isinstance(py_value, PyRealBoolean): diff --git a/core/src/test/python/aliases_test.py b/core/src/test/python/aliases_test.py index a0453710c8..463657b090 100644 --- a/core/src/test/python/aliases_test.py +++ b/core/src/test/python/aliases_test.py @@ -9,8 +9,10 @@ from java.lang import String, Long from java.util import Properties +import weblogic.version as version_helper from oracle.weblogic.deploy.aliases import AliasException from oracle.weblogic.deploy.aliases import TypeUtils +from oracle.weblogic.deploy.aliases import VersionUtils from wlsdeploy.aliases import alias_utils from wlsdeploy.aliases.aliases import Aliases @@ -619,6 +621,11 @@ def testDomainAttributeMethods(self): return def testMTAliasLoading(self): + # MT code is not functional in 14.1.1 so skip this test if using 14.1.1 or higher + version = version_helper.getReleaseBuildVersion() + if VersionUtils.compareVersions(version, '14.1.1') >= 0: + return + aliases = Aliases(self.model_context, WlstModes.OFFLINE) attr_expected = '/JDBCSystemResource/my-datasource/JdbcResource/my-datasource/JDBCDriverParams/NO_NAME_0' diff --git a/documentation/2.0/content/release-notes/release-2.4.2.md b/documentation/2.0/content/release-notes/release-2.4.2.md new file mode 100644 index 0000000000..62721d88f5 --- /dev/null +++ b/documentation/2.0/content/release-notes/release-2.4.2.md @@ -0,0 +1,29 @@ ++++ +title = "Release 2.4.2" +date = 2022-11-10T15:27:38-05:00 +weight = 5 +pre = " " ++++ + +### Changes in Release 2.4.2 +- [Major New Features](#major-new-features) +- [Other Changes](#other-changes) +- [Bugs Fixes](#bug-fixes) +- [Known Issues](#known-issues) + + +#### Major New Features +None + +#### Other Changes +None + +#### Bug Fixes +- #1241: Resolved Issue #1240 that was causing a NullPointerException with discoverDomain. +- #1252: Reworked the unicode handling to resolve customer issues with 14.1.1 when using non-ASCII characters. + +#### Known Issues +- Due to the changes made for WDT-663 in WDT 2.4.0, the resulting remotely discovered model contains extra fields that would not normally be there. + This is an area of ongoing work to clean up the online aliases to not depend on these extra remote calls to produce a clean model. + + diff --git a/integration-tests/system-test/pom.xml b/integration-tests/system-test/pom.xml index 6f775245e4..1ff01e9dc8 100644 --- a/integration-tests/system-test/pom.xml +++ b/integration-tests/system-test/pom.xml @@ -147,6 +147,14 @@ db.use.container.network ${db.use.container.network} + + system-test-skip-jrf-tests + ${system-test-skip-jrf-tests} + + + system-test-skip-rjrf-tests + ${system-test-skip-rjrf-tests} + diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java index 3b79ed51c0..f2064090ab 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.BooleanSupplier; import oracle.weblogic.deploy.integration.annotations.TestingLogger; import oracle.weblogic.deploy.integration.utils.CommandResult; @@ -26,6 +27,9 @@ public class BaseTest { @TestingLogger private static final PlatformLogger logger = WLSDeployLogFactory.getLogger("integration.tests"); + + protected static final boolean SKIP_JRF_TESTS = skipJrfTests(); + protected static final boolean SKIP_RESTRICTED_JRF_TESTS = skipRestrictedJrfTests(); protected static final String FS = File.separator; private static final String SAMPLE_ARCHIVE_FILE = "archive.zip"; private static final String UPDATED_SAMPLE_ARCHIVE_FILE = "archive2.zip"; @@ -49,6 +53,16 @@ public class BaseTest { protected static final String ORACLE_DB_IMG_TAG = "12.2.0.1-slim"; private static final String DB_CONTAINER_NAME = generateDatabaseContainerName(); + private static boolean skipJrfTests() { + String value = System.getProperty("system-test-skip-jrf-tests", "false").toLowerCase(); + return Boolean.parseBoolean(value); + } + + private static boolean skipRestrictedJrfTests() { + String value = System.getProperty("system-test-skip-rjrf-tests", "false").toLowerCase(); + return Boolean.parseBoolean(value); + } + private static String generateDatabaseContainerName() { String branchName = System.getenv("BRANCH_NAME"); @@ -94,8 +108,10 @@ protected static void setup() throws Exception { protected static void cleanup() throws Exception { logger.info("cleaning up the test environment ..."); - String command = "docker rm -f " + DB_CONTAINER_NAME; - Runner.run(command); + if (!SKIP_JRF_TESTS) { + String command = "docker rm -f " + DB_CONTAINER_NAME; + Runner.run(command); + } } protected static Path getTargetDir() { @@ -111,9 +127,11 @@ protected static void chmodScriptFiles(String... filenames) throws Exception { } protected static void pullOracleDBDockerImage() throws Exception { - logger.info("Pulling Oracle DB image from OCIIR ..."); + if (!SKIP_JRF_TESTS) { + logger.info("Pulling Oracle DB image from OCIR ..."); - pullDockerImage(ORACLE_DB_IMG, ORACLE_DB_IMG_TAG); + pullDockerImage(ORACLE_DB_IMG, ORACLE_DB_IMG_TAG); + } } private static void pullDockerImage(String imagename, String imagetag) throws Exception { @@ -207,25 +225,29 @@ protected static String getSampleVariableFile() { } protected static void createDBContainer() throws Exception { - logger.info("Creating an Oracle db docker container ..."); - String command = "docker rm -f " + DB_CONTAINER_NAME; - Runner.run(command); - - String exposePort = ""; - if (System.getProperty("db.use.container.network").equals("false")) { - exposePort = " -p1521:1521 -p5500:5500 "; - } + if (!SKIP_JRF_TESTS) { + logger.info("Creating an Oracle db docker container ..."); + String command = "docker rm -f " + DB_CONTAINER_NAME; + Runner.run(command); + + String exposePort = ""; + if (System.getProperty("db.use.container.network").equals("false")) { + exposePort = " -p1521:1521 -p5500:5500 "; + } - command = "docker run -d --name " + DB_CONTAINER_NAME + " --env=\"DB_PDB=InfraPDB1\"" + + command = "docker run -d --name " + DB_CONTAINER_NAME + " --env=\"DB_PDB=InfraPDB1\"" + " --env=\"DB_DOMAIN=us.oracle.com\" --env=\"DB_BUNDLE=basic\" " + exposePort - + ORACLE_DB_IMG + ":" + ORACLE_DB_IMG_TAG; - Runner.run(command); + + ORACLE_DB_IMG + ":" + ORACLE_DB_IMG_TAG; + Runner.run(command); + } } static void waitForDatabase() throws IOException, InterruptedException { - // Wait for the database container to be healthy before continuing - String command = "docker inspect --format='{{json .State.Health}}' " + DB_CONTAINER_NAME; - checkCmdInLoop(command, "\"Status\":\"healthy"); + if (!SKIP_JRF_TESTS) { + // Wait for the database container to be healthy before continuing + String command = "docker inspect --format='{{json .State.Health}}' " + DB_CONTAINER_NAME; + checkCmdInLoop(command, "\"Status\":\"healthy"); + } } protected static void replaceStringInFile(Path original, Path output, String originalString, String newString) @@ -237,14 +259,17 @@ protected static void replaceStringInFile(Path original, Path output, String ori } protected String getDBContainerIP() throws Exception { - if (System.getProperty("db.use.container.network").equals("false")) { - return "localhost"; - } - String getDBContainerIP = "docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' " + + String dbHost = ""; + if (!SKIP_JRF_TESTS) { + if (System.getProperty("db.use.container.network").equals("false")) { + return "localhost"; + } + String getDBContainerIP = "docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' " + DB_CONTAINER_NAME; - String dbhost = Runner.run(getDBContainerIP).stdout().trim(); - logger.info("DEBUG: DB_HOST=" + dbhost); - return dbhost; + dbHost = Runner.run(getDBContainerIP).stdout().trim(); + logger.info("DEBUG: DB_HOST=" + dbHost); + } + return dbHost; } protected void verifyModelFileContents(String modelFileName, List textToFind) throws Exception { @@ -313,4 +338,18 @@ private static void checkCmdInLoop(String cmd, String matchStr) throws IOExcepti } } } + + static class JrfChecker implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return !SKIP_JRF_TESTS; + } + } + + static class RestrictedJrfChecker implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + return !SKIP_RESTRICTED_JRF_TESTS; + } + } } diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 8edbda3837..66f40bdc6c 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -45,6 +45,8 @@ public class ITWdt extends BaseTest { private static boolean rcuDomainCreated = false; + private static boolean test30DomainCreated = false; + @BeforeAll public static void staticPrepare() throws Exception { logger.info("prepare for WDT testing ..."); @@ -56,10 +58,12 @@ public static void staticPrepare() throws Exception { // setup the test environment setup(); - // pull Oracle DB image for FMW RCU testing - pullOracleDBDockerImage(); - // create a db container for RCU - createDBContainer(); + if (!SKIP_JRF_TESTS) { + // pull Oracle DB image for FMW RCU testing + pullOracleDBDockerImage(); + // create a db container for RCU + createDBContainer(); + } } @AfterAll @@ -173,7 +177,7 @@ void test04CreateDomainNoArchivefile(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with required arguments + * test createDomain.sh with required arguments using simple-topology-constant.yaml (domain = domain1) * @throws Exception - if any error occurs */ @DisplayName("Test 5: createDomain with domain_parent") @@ -192,8 +196,8 @@ void test05CreateDomain(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with different domain name in -domain_home and model file - * in model file, it specifies the domain name as 'domain1' + * test createDomain.sh using simple-topology-constant.yaml with different domain name in + * -domain_home and model file in model file, it specifies the domain name as 'domain1' * in -domain_home argument, it specifies the domain home as 'domain2' * @throws Exception - if any error occurs */ @@ -215,7 +219,7 @@ void test06CreateDomainDifferentDomainName(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with WLS domain_type + * test createDomain.sh with WLS domain_type using simple-topology-constant.yaml (domain = domain2) * @throws Exception -if any error occurs */ @Order(7) @@ -254,7 +258,7 @@ void test08CreateDomainNoVariableFile(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with variable_file argument + * test createDomain.sh with variable_file argument using simple-topology1.yaml (domain = domain2) * @throws Exception - if any error occurs */ @DisplayName("Test 9: createDomain with variable file") @@ -274,7 +278,7 @@ void test09CreateDomainWithVariableFile(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with wlst_path set to mwhome/wlserver + * test createDomain.sh with wlst_path set to mwhome/wlserver using simple-topology1.yaml (domain = domain2) * @throws Exception - if any error occurs */ @DisplayName("Test 10: createDomain with WLS wlst_path") @@ -295,7 +299,7 @@ void test10CreateDomainWithWlstPath(TestInfo testInfo) throws Exception { } /** - * test createDomain.sh with -wlst_path set to mwhome/oracle_common + * test createDomain.sh with -wlst_path set to mwhome/oracle_common using simple-topology1.yaml (domain = domain2) * @throws Exception - if any error occurs */ @DisplayName("Test 11: createDomain with oracle_commmon wlst_path") @@ -324,6 +328,7 @@ void test11CreateDomainWithOracleCommonWlstPath(TestInfo testInfo) throws Except @Tag("gate") @Test void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); try (PrintWriter out = getTestMethodWriter(testInfo)) { Path source = Paths.get(getSampleModelFile("2")); Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); @@ -349,6 +354,7 @@ void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); waitForDatabase(); try (PrintWriter out = getTestMethodWriter(testInfo)) { Path source = Paths.get(getSampleModelFile("2")); @@ -378,6 +384,7 @@ void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test14OnlineUpdate1(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); assumeTrue(rcuDomainCreated, "testDOnlineUpdate skipped because testDCreateJRFDomainRunRCU failed"); // Setup boot.properties @@ -424,6 +431,7 @@ void test14OnlineUpdate1(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test15OnlineUpdate2(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); assumeTrue(rcuDomainCreated, "testDOnlineUpdate2 skipped because testDCreateJRFDomainRunRCU failed"); String domainHome = domainParentDir + FS + "jrfDomain1"; @@ -466,6 +474,7 @@ void test15OnlineUpdate2(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + domainParentDir + FS + "restrictedJRFD1 -model_file " + getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + @@ -487,6 +496,7 @@ void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); try (PrintWriter out = getTestMethodWriter(testInfo)) { Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); String cmd = discoverDomainScript @@ -529,6 +539,7 @@ private void verifyFDiscoverDomainWithRequiredArgument(String expectedModelFile) @Tag("gate") @Test void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + @@ -544,15 +555,16 @@ void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { } } - /** - * test discoverDomain.sh with -variable_file argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") - @Order(19) - @Tag("gate") - @Test - void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { + /** + * test discoverDomain.sh with -variable_file argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") + @Order(19) + @Tag("gate") + @Test + void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.properties"); @@ -573,13 +585,13 @@ void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { verifyModelFile(discoveredVariableFile.toString()); verifyGDiscoverDomainWithVariableFile(discoveredModelFile.toString()); } - } + } - private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { - List checkContents = new ArrayList<>(); - checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); - verifyModelFileContents(expectedModelFile, checkContents); - } + private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { + List checkContents = new ArrayList<>(); + checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); + verifyModelFileContents(expectedModelFile, checkContents); + } /** * test discoverDomain.sh with -domain_type as JRF @@ -590,9 +602,10 @@ private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) thr @Tag("gate") @Test void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { - assumeTrue(rcuDomainCreated, "testHDiscoverDomainJRFDomainType skipped because testDCreateJRFDomainRunRCU failed"); + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + assumeTrue(rcuDomainCreated, "test20DiscoverDomainJRFDomainType skipped because testDCreateJRFDomainRunRCU failed"); - try (PrintWriter out = getTestMethodWriter(testInfo)) { + try (PrintWriter out = getTestMethodWriter(testInfo)) { Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); String cmd = discoverDomainScript @@ -613,14 +626,14 @@ void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { } private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { - List checkContents = new ArrayList<>(); - checkContents.add("AWT Application Context Startup Class"); - try { - verifyModelFileContents(expectedModelFile, checkContents); - throw new Exception("JRF blacklist components found in model file"); - } catch (Exception e) { - // empty this is expected result - } + List checkContents = new ArrayList<>(); + checkContents.add("AWT Application Context Startup Class"); + try { + verifyModelFileContents(expectedModelFile, checkContents); + throw new Exception("JRF blacklist components found in model file"); + } catch (Exception e) { + // empty this is expected result + } } /** @@ -842,6 +855,7 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + test30DomainCreated = true; } String domainHome = domainParentDir + FS + domainDir; @@ -914,15 +928,13 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { stopAdminServer(domainHome); } - } else { // Best effort to clean up server tryKillTheAdminServer(domainHome, "admin-server"); throw new Exception("testDOnlineUpdate failed - cannot bring up server"); } - - } + /** * test discoverDomain.sh that model can create a working domain * @throws Exception - if any error occurs @@ -932,6 +944,8 @@ void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { @Tag("gate") @Test void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { + assumeTrue(test30DomainCreated, + "test31DiscoverDomainWithModelFile skipped because test30OnlineUpdateApp domain creation failed"); Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredVariable.properties"); @@ -963,8 +977,9 @@ void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { stopAdminServer(domainHome); } } + /** - * test discoverDomain.sh with -domain_type as JRF + * test prepareModel.sh with -target as wko * @throws Exception - if any error occurs */ @DisplayName("Test 32: Prepare model") @@ -987,11 +1002,13 @@ void test32PrepareModel(TestInfo testInfo) throws Exception { verifyResult(result, "prepareModel.sh completed successfully"); // verify model file - String tempWkoModel = outputFiles + FS + wkoModelFile; - - cmd = "grep -c 'Partition' " + tempWkoModel; + String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; + cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; + CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); + cmd = "grep -c 'Machine' " + tempWkoModel; CommandResult result3 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertNotEquals(0, result3.exitValue(), "Partition section was not removed from model"); + assertNotEquals(0, result3.exitValue(), "Machine section was not removed from model"); } } diff --git a/integration-tests/system-test/src/test/resources/simple-topology-onlinebase.yaml b/integration-tests/system-test/src/test/resources/simple-topology-onlinebase.yaml index f055c97458..19591b5f2a 100644 --- a/integration-tests/system-test/src/test/resources/simple-topology-onlinebase.yaml +++ b/integration-tests/system-test/src/test/resources/simple-topology-onlinebase.yaml @@ -4,30 +4,34 @@ domainInfo: ServerStartMode: prod topology: Name: domain2 - AdminServerName: 'admin-server' + AdminServerName: admin-server ProductionModeEnabled: true Cluster: - 'cluster1': + cluster1: ClientCertProxyEnabled: true FrontendHost: localhost DynamicServers: ServerTemplate: template1 + # ServerTemplate: i_più_vistia CalculatedListenPorts: true - ServerNamePrefix: 'managed-server-' + ServerNamePrefix: 'Server1-' + # ServerNamePrefix: 'Felicità-' DynamicClusterSize: 2 MaxDynamicClusterSize: 2 Server: - 'admin-server': + admin-server: ListenPort: 7001 ServerTemplate: template1: ListenPort: 8001 + # i_più_vistia̜: + # ListenPort: 8001 appDeployments: Application: # Quote needed because of hyphen in string - 'simple-app': - SourcePath: 'wlsdeploy/applications/simple-app.war' - Target: 'admin-server' + simple-app: + SourcePath: wlsdeploy/applications/simple-app.war + Target: admin-server ModuleType: war StagingMode: nostage PlanStagingMode: nostage diff --git a/integration-tests/system-test/src/test/resources/simple-topology-targetwko.yaml b/integration-tests/system-test/src/test/resources/simple-topology-targetwko.yaml index e6ba5a877d..030763c8d7 100644 --- a/integration-tests/system-test/src/test/resources/simple-topology-targetwko.yaml +++ b/integration-tests/system-test/src/test/resources/simple-topology-targetwko.yaml @@ -42,8 +42,6 @@ topology: Machine: # this machine and any references to it should be removed machine-1: - VirtualTarget: - target-2: # confirm that model traversal deals with artificial type folders correctly SecurityConfiguration: @@ -57,11 +55,25 @@ topology: ProviderClassName: 'com.defaultClass' resources: - Partition: - my-partition: - ResourceGroup: - my-resource-group: - + JDBCSystemResource: + datasource-1: + Target: AdminServer,staticCluster + JdbcResource: + DatasourceType: GENERIC + JDBCConnectionPoolParams: + ConnectionReserveTimeoutSeconds: 10 + InitialCapacity: 0 + MaxCapacity: 5 + MinCapacity: 0 + TestConnectionsOnReserve: true + TestTableName: SQL ISVALID + JDBCDriverParams: + DriverName: oracle.jdbc.OracleDriver + PasswordEncrypted: tiger + URL: jdbc:oracle:thin:@//localhost:1521/myDB + Properties: + user: + Value: scott appDeployments: Application: myApp: diff --git a/pom.xml b/pom.xml index f101dab65d..4a5e968bae 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,8 @@ ${env.WLST_DIR} true + false + false true true gate