Skip to content

Commit c148c18

Browse files
authored
Merge pull request #67 from oracle/Issue#64-Deprecate-using-${-as-variable-substitution-expression
Issue#64 deprecate using ${ as variable substitution expression
2 parents 83d1b8b + 98bb9a7 commit c148c18

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

core/src/main/python/wlsdeploy/tool/validate/validator.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,7 @@ def __validate_domain_info_section(self, model_section_key, model_dict, validati
362362
# section_dict_value is either the dict of a folder in the
363363
# section, or the value of an attribute in the section
364364
if '${' in section_dict_key:
365-
section_dict_key, validation_result = self.__validate_variable_substitution(section_dict_key,
366-
model_folder_path,
367-
validation_result)
365+
validation_result.add_error('WLSDPLY-05035', model_folder_path, section_dict_key)
368366

369367
self._logger.finer('WLSDPLY-05011', section_dict_key, section_dict_value,
370368
class_name=_class_name, method_name=_method_name)
@@ -536,8 +534,7 @@ def __validate_section_folder(self, model_node, validation_location, validation_
536534
for name in model_node:
537535
expanded_name = name
538536
if '${' in name:
539-
expanded_name, validation_result = \
540-
self.__validate_variable_substitution(name, model_folder_path, validation_result)
537+
_report_unsupported_variable_usage(name, model_folder_path, validation_result)
541538

542539
self._logger.finest('3 expanded_name={0}', expanded_name,
543540
class_name=_class_name, method_name=_method_name)
@@ -830,18 +827,12 @@ def __validate_variable_substitution(self, tokenized_value, model_folder_path, v
830827
# FIXME(mwooten) - the cla_utils should be fixing all windows paths to use forward slashes already...
831828
# assuming that the value is not None
832829
variables_file_name = self._model_context.get_variable_file()
833-
if self._validation_mode == _ValidationModes.STANDALONE:
834-
if variables_file_name is None:
835-
validation_result.add_info('WLSDPLY-05021', model_folder_path, property_name)
836-
else:
837-
validation_result.add_info('WLSDPLY-05022', model_folder_path, property_name,
838-
variables_file_name)
839-
elif self._validation_mode == _ValidationModes.TOOL:
840-
if variables_file_name is None:
841-
validation_result.add_error('WLSDPLY-05021', model_folder_path, property_name)
842-
else:
843-
validation_result.add_error('WLSDPLY-05022', model_folder_path, property_name,
844-
variables_file_name)
830+
if variables_file_name is None:
831+
self._logger.warning('WLSDPLY-05021', model_folder_path, property_name,
832+
class_name=_class_name, method_name=_method_name)
833+
else:
834+
self._logger.warning('WLSDPLY-05022', model_folder_path, property_name, variables_file_name,
835+
class_name=_class_name, method_name=_method_name)
845836

846837
self._logger.exiting(class_name=_class_name, method_name=_method_name, result=untokenized_value)
847838
return untokenized_value, validation_result

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,13 @@ WLSDPLY-05029={0} is not one of the attribute names allowed in model location {1
340340
WLSDPLY-05030=Model location {0} uses variable {1} to represent the name of a model subfolder or attribute. \
341341
Substitution variables can only be used for folder instance names and attribute values.
342342
WLSDPLY-05031=Attribute {0} in model location {1} references a relative file location {2}. This makes the model \
343-
subject to failure unless the tool in voked from the correct location to resolve the relative path to the file. \
343+
subject to failure unless the tool invoked from the correct location to resolve the relative path to the file. \
344344
It is recommended to use a path token if the absolute path is expected to change between systems.
345345
WLSDPLY-05032=Attribute {0} in model location {1} should be a dictionary but was a {2}
346346
WLSDPLY-05033=Attribute {0} in model location {1} should be a string but was a {2}
347347
WLSDPLY-05034=The value for attribute {0} in model location {1} should be a string or a list but was a {2}
348+
WLSDPLY-05035=The {0} attribute with value {1} in model location {2}, should be a string but was a {3}
349+
WLSDPLY-05036=Attribute {0} in model location {1}, uses the {2} macro expression for an integer or references to other another server template configuration element. The Oracle documentation for server templates, cites this as being not supported.
348350

349351

350352
# wlsdeploy/tools/validate/usage_printer.py

core/src/test/python/validation_test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ class ValidationTestCase(unittest.TestCase):
2323
_class_name = 'ValidationTestCase'
2424
_resources_dir = '../../test-classes'
2525
_model_file = _resources_dir + '/test_jms_mail.json'
26-
_variable_file = _resources_dir + "/test_sub_variable_file.properties"
26+
_variable_file = None
27+
_archive_file = None
28+
# _variable_file = _resources_dir + "/test_sub_variable_file.properties"
2729
# _model_file = _resources_dir + '/test_empty.json'
2830
# _variable_file = _resources_dir + "/test_invalid_variable_file.properties"
29-
# _variable_file = None
30-
_archive_file = _resources_dir + "/test_jms_archive.zip"
31+
# _archive_file = _resources_dir + "/test_jms_archive.zip"
3132
_logger = PlatformLogger('wlsdeploy.validate')
3233

3334
def setUp(self):
@@ -41,11 +42,15 @@ def testModelValidation(self):
4142
mw_home = os.environ['MW_HOME']
4243
args_map = {
4344
'-oracle_home': mw_home,
44-
'-model_file': self._model_file,
45-
'-variable_file': self._variable_file,
46-
'-archive_file': self._archive_file
45+
'-model_file': self._model_file
4746
}
4847

48+
if self._variable_file is not None:
49+
args_map['-variable_file'] = self._variable_file
50+
51+
if self._variable_file is not None:
52+
args_map['-archive_file'] = self._archive_file
53+
4954
model_context = ModelContext('ValidationTestCase', args_map)
5055

5156
try:

0 commit comments

Comments
 (0)