Skip to content

Commit 485062e

Browse files
authored
JIRA WDT-449 - allow no model present for standalone validate with lax method (#697)
1 parent bcdcc2d commit 485062e

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

core/src/main/python/validate.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
The WLS Deploy tooling entry point for the validateModel tool.
66
"""
77
import copy
8-
import os
98
import sys
109
from java.util.logging import Level
1110

@@ -26,6 +25,7 @@
2625
from wlsdeploy.tool.util import model_context_helper
2726
from wlsdeploy.tool.validate.validator import Validator
2827
from wlsdeploy.util import cla_helper
28+
from wlsdeploy.util import dictionary_utils
2929
from wlsdeploy.util import tool_exit
3030
from wlsdeploy.util import variables
3131
from wlsdeploy.util.cla_utils import CommandLineArgUtil
@@ -68,16 +68,26 @@ def __process_args(args):
6868
return model_context_helper.create_context(_program_name, argument_map)
6969

7070

71-
def __process_model_args(optional_arg_map):
71+
def __process_model_args(argument_map):
7272
"""
7373
Determine if the model file was passed separately or requires extraction from the archive.
74-
:param optional_arg_map: the optional arguments map
74+
:param argument_map: the arguments map
7575
:raises CLAException: if the arguments were not valid or an error occurred extracting the model from the archive
7676
"""
7777
_method_name = '__process_model_args'
7878

79-
cla_helper.validate_optional_archive(_program_name, optional_arg_map)
80-
cla_helper.validate_model_present(_program_name, optional_arg_map)
79+
cla_helper.validate_optional_archive(_program_name, argument_map)
80+
81+
try:
82+
cla_helper.validate_model_present(_program_name, argument_map)
83+
except CLAException, ce:
84+
# in lax validation mode, if no model is found, log at INFO and exit
85+
method = dictionary_utils.get_element(argument_map, CommandLineArgUtil.VALIDATION_METHOD)
86+
if method == CommandLineArgUtil.LAX_VALIDATION_METHOD:
87+
__logger.info('WLSDPLY-20032', _program_name, class_name=_class_name, method_name=_method_name)
88+
model_context = model_context_helper.create_exit_context(_program_name)
89+
tool_exit.end(model_context, CommandLineArgUtil.PROG_OK_EXIT_CODE)
90+
raise ce
8191
return
8292

8393

core/src/main/python/wlsdeploy/util/cla_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class CommandLineArgUtil(object):
108108
ARCHIVE_FILES_SEPARATOR = ','
109109
MODEL_FILES_SEPARATOR = ','
110110

111+
LAX_VALIDATION_METHOD = 'lax'
112+
STRICT_VALIDATION_METHOD = 'strict'
113+
VALIDATION_METHODS = [LAX_VALIDATION_METHOD, STRICT_VALIDATION_METHOD]
114+
111115
HELP_EXIT_CODE = 100
112116
USAGE_ERROR_EXIT_CODE = 99
113117
ARG_VALIDATION_ERROR_EXIT_CODE = 98
@@ -783,8 +787,8 @@ def _validate_validate_method_arg(self, value):
783787
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
784788
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
785789
raise ex
786-
elif value.lower() != 'strict' and value.lower() != 'lax':
787-
ex = exception_helper.create_cla_exception('WLSDPLY-20030', value, "strict, or lax")
790+
elif value not in self.VALIDATION_METHODS:
791+
ex = exception_helper.create_cla_exception('WLSDPLY-20030', value, self.VALIDATION_METHODS)
788792
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
789793
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
790794
raise ex
@@ -1068,7 +1072,7 @@ def _validate_target_arg(self, value):
10681072
config_dictionary = eval(file_handle.read())
10691073
target_configuration = TargetConfiguration(config_dictionary)
10701074
validation_method = target_configuration.get_validation_method()
1071-
if (validation_method is not None) and (validation_method not in ['strict', 'lax']):
1075+
if (validation_method is not None) and (validation_method not in self.VALIDATION_METHODS):
10721076
ex = exception_helper.create_cla_exception('WLSDPLY-01645', target_configuration_file)
10731077
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
10741078
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ WLSDPLY-20028=Failed to read the OPSS wallet passphrase input from the user: {0}
15191519
WLSDPLY-20029=Specified validation method to use was empty or null
15201520
WLSDPLY-20030=Specified validation method {0} is invalid, must be one of: {1}
15211521
WLSDPLY-20031={0} specified Variable File {1} is not a valid file: {2}
1522+
WLSDPLY-20032=No model specified and no model in archive, no validation performed
15221523

15231524
# Common messages used for tool exit and clean-up
15241525
WLSDPLY-21000={0} Messages:

0 commit comments

Comments
 (0)