diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index 4fac47c3d..139de9161 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -203,7 +203,7 @@ def compare(self): except YamlException, ye: _logger.severe('WLSDPLY-05708', file_name, ye.getLocalizedMessage(), error=ye, class_name=_class_name, method_name=_method_name) - return 2 + System.exit(ExitCode.ERROR) else: # write the change model to standard output in YAML format print(format_message('WLSDPLY-05707')) @@ -232,6 +232,12 @@ def debug(format_string, *arguments): else: _logger.finest(format_string, arguments) +def _check_model_extension(file): + model_file = JFile(file) + if not (FileUtils.isYamlFile(model_file) or FileUtils.isJsonFile(model_file)): + return False + else: + return True def main(): """ @@ -254,25 +260,16 @@ def main(): for f in [model1, model2]: if not os.path.exists(f): - raise CLAException("Model %s does not exists" % f) + raise CLAException(ExitCode.ERROR, 'WLSDPLY-85717', [f]) if os.path.isdir(f): - raise CLAException("Model %s is a directory" % f) - - model1_file = JFile(model1) - model2_file = JFile(model2) - - if not (FileUtils.isYamlFile(model1_file) or FileUtils.isJsonFile(model1_file)): - raise CLAException("Model extension must be either yaml or json") - - if not (FileUtils.isYamlFile(model1_file) and FileUtils.isYamlFile(model2_file) - or FileUtils.isJsonFile(model1_file) and FileUtils.isJsonFile(model2_file)): - ext = os.path.splitext(model1)[1] - raise CLAException("Model %s is not a %s file " % (model2, ext)) + raise CLAException(ExitCode.ERROR, 'WLSDPLY-85718', [f]) + if not _check_model_extension(f): + raise CLAException(ExitCode.ERROR, 'WLSDPLY-85719', [f]) obj = ModelFileDiffer(model1, model2, model_context, _outputdir) rc = obj.compare() if rc == VALIDATION_FAIL: - System.exit(2) + System.exit(ExitCode.ERROR) if _outputdir: fos = None @@ -317,7 +314,7 @@ def main(): System.exit(0) except CLAException, ex: - exit_code = 2 + exit_code = ex.getExitCode() if exit_code != ExitCode.HELP: _logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex, class_name=_class_name, method_name=_method_name) @@ -326,17 +323,17 @@ def main(): except CompareException, ce: cla_helper.clean_up_temp_files() _logger.severe('WLSDPLY-05704', ce.getLocalizedMessage(), class_name=_class_name, method_name=_method_name) - System.exit(2) + System.exit(ExitCode.ERROR) except PyWLSTException, pe: cla_helper.clean_up_temp_files() _logger.severe('WLSDPLY-05704', pe.getLocalizedMessage(), class_name=_class_name, method_name=_method_name) - System.exit(2) + System.exit(ExitCode.ERROR) except: exc_type, exc_obj, exc_tb = sys.exc_info() ee_string = traceback.format_exception(exc_type, exc_obj, exc_tb) cla_helper.clean_up_temp_files() _logger.severe('WLSDPLY-05704', ee_string) - System.exit(2) + System.exit(ExitCode.ERROR) def format_message(key, *args): diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index a1c326943..f8cb2e842 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -521,7 +521,9 @@ WLSDPLY-05714=NOT USED WLSDPLY-05715=There are {0} attributes that only exist in the previous model, see {1} WLSDPLY-05716=The Security Configuration Provider at location {0} has a difference and the current \ provider(s) will replace the previous provider(s) - +WLSDPLY-85717=Model {0} does not exists +WLSDPLY-85718=Model {0} is a directory +WLSDPLY-85719=Model {0} does not have the correct file extension, it must be either .yaml or .json # prepare_model.py WLSDPLY-05801=Error in prepare model: {0}