2
2
Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
5
- The entry point for the discoverDomain tool.
5
+ The entry point for the injectVariables tool.
6
6
"""
7
7
import os
8
8
import sys
9
9
10
10
from java .io import File
11
11
from java .lang import IllegalArgumentException
12
- from java .lang import IllegalStateException
13
12
from oracle .weblogic .deploy .util import CLAException
14
13
from oracle .weblogic .deploy .util import FileUtils
15
14
from oracle .weblogic .deploy .util import TranslateException
16
- from oracle .weblogic .deploy .util import WLSDeployArchive
17
15
from oracle .weblogic .deploy .util import WLSDeployArchiveIOException
18
16
from oracle .weblogic .deploy .util import WebLogicDeployToolingVersion
19
17
20
-
21
18
sys .path .append (os .path .dirname (os .path .realpath (sys .argv [0 ])))
22
19
23
20
import wlsdeploy .tool .util .variable_injector as variable_injector
24
21
from wlsdeploy .aliases .wlst_modes import WlstModes
25
22
from wlsdeploy .exception import exception_helper
26
- from wlsdeploy .exception .expection_types import ExceptionType
27
23
from wlsdeploy .logging .platform_logger import PlatformLogger
28
24
from wlsdeploy .tool .util import model_context_helper
29
25
from 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
32
27
from wlsdeploy .util .cla_utils import CommandLineArgUtil
33
28
from wlsdeploy .util .model import Model
34
29
from wlsdeploy .util .model_translator import FileToPython
@@ -67,7 +62,10 @@ def __process_args(args):
67
62
cla_util = CommandLineArgUtil (_program_name , __required_arguments , __optional_arguments )
68
63
required_arg_map , optional_arg_map = cla_util .process_args (args )
69
64
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 )
71
69
__process_injector_file (optional_arg_map )
72
70
__process_keywords_file (optional_arg_map )
73
71
__process_properties_file (optional_arg_map )
@@ -77,76 +75,6 @@ def __process_args(args):
77
75
return model_context_helper .create_context (_program_name , combined_arg_map )
78
76
79
77
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
-
150
78
def __process_injector_file (optional_arg_map ):
151
79
_method_name = '__process_injector_file'
152
80
if CommandLineArgUtil .VARIABLE_INJECTOR_FILE_SWITCH in optional_arg_map :
0 commit comments