22Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
5- The entry point for the discoverDomain tool.
5+ The entry point for the injectVariables tool.
66"""
77import os
88import sys
99
1010from java .io import File
1111from java .lang import IllegalArgumentException
12- from java .lang import IllegalStateException
1312from oracle .weblogic .deploy .util import CLAException
1413from oracle .weblogic .deploy .util import FileUtils
1514from oracle .weblogic .deploy .util import TranslateException
16- from oracle .weblogic .deploy .util import WLSDeployArchive
1715from oracle .weblogic .deploy .util import WLSDeployArchiveIOException
1816from oracle .weblogic .deploy .util import WebLogicDeployToolingVersion
1917
20-
2118sys .path .append (os .path .dirname (os .path .realpath (sys .argv [0 ])))
2219
2320import wlsdeploy .tool .util .variable_injector as variable_injector
2421from wlsdeploy .aliases .wlst_modes import WlstModes
2522from wlsdeploy .exception import exception_helper
26- from wlsdeploy .exception .expection_types import ExceptionType
2723from wlsdeploy .logging .platform_logger import PlatformLogger
2824from wlsdeploy .tool .util import model_context_helper
2925from wlsdeploy .tool .util .variable_injector import VariableInjector
30- from wlsdeploy .tool .util .wlst_helper import WlstHelper
31- from wlsdeploy .util import model_translator
26+ from wlsdeploy .util import model_translator , cla_helper
3227from wlsdeploy .util .cla_utils import CommandLineArgUtil
3328from wlsdeploy .util .model import Model
3429from wlsdeploy .util .model_translator import FileToPython
@@ -67,7 +62,10 @@ def __process_args(args):
6762 cla_util = CommandLineArgUtil (_program_name , __required_arguments , __optional_arguments )
6863 required_arg_map , optional_arg_map = cla_util .process_args (args )
6964
70- __process_model_args (optional_arg_map )
65+ cla_helper .verify_required_args_present (_program_name , __required_arguments , required_arg_map )
66+
67+ # determine if the model file was passed separately or requires extraction from the archive.
68+ cla_helper .validate_model_present (_program_name , optional_arg_map )
7169 __process_injector_file (optional_arg_map )
7270 __process_keywords_file (optional_arg_map )
7371 __process_properties_file (optional_arg_map )
@@ -77,76 +75,6 @@ def __process_args(args):
7775 return model_context_helper .create_context (_program_name , combined_arg_map )
7876
7977
80- def __verify_required_args_present (required_arg_map ):
81- """
82- Verify that the required args are present.
83- :param required_arg_map: the required arguments map
84- :raises CLAException: if one or more of the required arguments are missing
85- """
86- _method_name = '__verify_required_args_present'
87-
88- for req_arg in __required_arguments :
89- if req_arg not in required_arg_map :
90- ex = exception_helper .create_cla_exception ('WLSDPLY-20005' , _program_name , req_arg )
91- ex .setExitCode (CommandLineArgUtil .USAGE_ERROR_EXIT_CODE )
92- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
93- raise ex
94- return
95-
96-
97- def __process_model_args (optional_arg_map ):
98- """
99- Verify that either the model_file or archive_file was provided and exists.
100- If the model_file was not provided, the archive_file must be provided and the indicated archive file
101- must contain a model file. Extract the model file if the archive_file was provided.
102- :param optional_arg_map: the optional arguments map
103- :raises CLAException: if the arguments are invalid or an error occurs extracting the model from the archive
104- """
105- _method_name = '__process_model_args'
106- global __tmp_model_dir
107-
108- if CommandLineArgUtil .MODEL_FILE_SWITCH in optional_arg_map :
109- model_file_name = optional_arg_map [CommandLineArgUtil .MODEL_FILE_SWITCH ]
110-
111- try :
112- FileUtils .validateExistingFile (model_file_name )
113- except IllegalArgumentException , iae :
114- ex = exception_helper .create_cla_exception ('WLSDPLY-20006' , _program_name , model_file_name ,
115- iae .getLocalizedMessage (), error = iae )
116- ex .setExitCode (CommandLineArgUtil .ARG_VALIDATION_ERROR_EXIT_CODE )
117- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
118- raise ex
119- elif CommandLineArgUtil .ARCHIVE_FILE_SWITCH in optional_arg_map :
120- archive_file_name = optional_arg_map [CommandLineArgUtil .ARCHIVE_FILE_SWITCH ]
121-
122- try :
123- archive_file = WLSDeployArchive (archive_file_name )
124- contains_model = archive_file .containsModel ()
125- if not contains_model :
126- ex = exception_helper .create_cla_exception ('WLSDPLY-19603' , archive_file_name )
127- ex .setExitCode (CommandLineArgUtil .ARG_VALIDATION_ERROR_EXIT_CODE )
128- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
129- raise ex
130- else :
131- __tmp_model_dir = FileUtils .createTempDirectory (_program_name )
132- tmp_model_file = \
133- FileUtils .fixupFileSeparatorsForJython (archive_file .extractModel (__tmp_model_dir ).getAbsolutePath ())
134- except (IllegalArgumentException , IllegalStateException , WLSDeployArchiveIOException ), archex :
135- ex = exception_helper .create_cla_exception ('WLSDPLY-20010' , _program_name , archive_file_name ,
136- archex .getLocalizedMessage (), error = archex )
137- ex .setExitCode (CommandLineArgUtil .ARG_VALIDATION_ERROR_EXIT_CODE )
138- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
139- raise ex
140- optional_arg_map [CommandLineArgUtil .MODEL_FILE_SWITCH ] = FileUtils .fixupFileSeparatorsForJython (tmp_model_file )
141- else :
142- ex = exception_helper .create_cla_exception ('WLSDPLY-20015' , _program_name , CommandLineArgUtil .MODEL_FILE_SWITCH ,
143- CommandLineArgUtil .ARCHIVE_FILE_SWITCH )
144- ex .setExitCode (CommandLineArgUtil .USAGE_ERROR_EXIT_CODE )
145- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
146- raise ex
147- return
148-
149-
15078def __process_injector_file (optional_arg_map ):
15179 _method_name = '__process_injector_file'
15280 if CommandLineArgUtil .VARIABLE_INJECTOR_FILE_SWITCH in optional_arg_map :
0 commit comments