Skip to content

Commit 850087d

Browse files
authored
Combine alias helper into aliases class (#687)
* Jira WDT-312 - Merge AliasHelper into Aliases; remove unused methods, rename variables throughout
1 parent cd7baa4 commit 850087d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1172
-2036
lines changed

core/src/main/python/compare_model.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from wlsdeploy.exception import exception_helper
3333

3434
from wlsdeploy.logging.platform_logger import PlatformLogger
35-
from wlsdeploy.tool.util.alias_helper import AliasHelper
3635
from wlsdeploy.util import cla_helper
3736
from wlsdeploy.util import variables
3837
from wlsdeploy.util.model_translator import FileToPython
@@ -252,10 +251,9 @@ def _is_alias_folder(self, path):
252251
debug("DEBUG: Entering is_alias_folder %s", path)
253252
path_tokens = path.split(PATH_TOKEN)
254253
model_context = ModelContext("test", { })
255-
aliases = Aliases(model_context=model_context, wlst_mode=WlstModes.OFFLINE)
256254
location = LocationContext()
257255
last_token = path_tokens[-1]
258-
alias_helper = AliasHelper(aliases, _logger, ExceptionType.COMPARE)
256+
aliases = Aliases(model_context, wlst_mode=WlstModes.OFFLINE, exception_type=ExceptionType.COMPARE)
259257

260258
found = True
261259
name_token_next = False
@@ -268,8 +266,8 @@ def _is_alias_folder(self, path):
268266
location.append_location(path_token)
269267
if last_token == path_token:
270268
break
271-
name_token_next = alias_helper.supports_multiple_mbean_instances(location)
272-
attrib_names = alias_helper.get_model_attribute_names(location)
269+
name_token_next = aliases.supports_multiple_mbean_instances(location)
270+
attrib_names = aliases.get_model_attribute_names(location)
273271
if last_token in attrib_names:
274272
found = False
275273

core/src/main/python/create.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from wlsdeploy.tool.create.domain_creator import DomainCreator
3434
from wlsdeploy.tool.create.domain_typedef import CREATE_DOMAIN
3535
from wlsdeploy.tool.util import model_context_helper
36-
from wlsdeploy.tool.util.alias_helper import AliasHelper
3736
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
3837
from wlsdeploy.tool.util.wlst_helper import WlstHelper
3938
from wlsdeploy.tool.util import wlst_helper
@@ -230,14 +229,14 @@ def __process_opss_args(optional_arg_map):
230229
return
231230

232231

233-
def validate_rcu_args_and_model(model_context, model, archive_helper, alias_helper):
232+
def validate_rcu_args_and_model(model_context, model, archive_helper, aliases):
234233
_method_name = 'validate_rcu_args_and_model'
235234

236235
has_atpdbinfo = 0
237236
domain_info = model[model_constants.DOMAIN_INFO]
238237
if domain_info is not None:
239238
if model_constants.RCU_DB_INFO in domain_info:
240-
rcu_db_info = RcuDbInfo(model_context, alias_helper, domain_info[model_constants.RCU_DB_INFO])
239+
rcu_db_info = RcuDbInfo(model_context, aliases, domain_info[model_constants.RCU_DB_INFO])
241240
has_tns_admin = rcu_db_info.has_tns_admin()
242241
has_regular_db = rcu_db_info.is_regular_db()
243242
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
@@ -316,7 +315,7 @@ def main(args):
316315
model_context = model_context_helper.create_exit_context(_program_name)
317316
tool_exit.end(model_context, exit_code)
318317

319-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
318+
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.CREATE)
320319

321320
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "create", __wlst_mode)
322321

@@ -327,8 +326,7 @@ def main(args):
327326
domain_path = _get_domain_path(model_context, model_dictionary)
328327
archive_helper = ArchiveHelper(archive_file_name, domain_path, __logger, ExceptionType.CREATE)
329328

330-
alias_helper = AliasHelper(aliases, __logger, ExceptionType.CREATE)
331-
has_atp = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, alias_helper)
329+
has_atp = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases)
332330

333331
# check if there is an atpwallet and extract in the domain dir
334332
# it is to support non JRF domain but user wants to use ATP database
@@ -340,7 +338,7 @@ def main(args):
340338

341339
if has_atp:
342340
rcu_properties_map = model_dictionary[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO]
343-
rcu_db_info = RcuDbInfo(model_context, alias_helper, rcu_properties_map)
341+
rcu_db_info = RcuDbInfo(model_context, aliases, rcu_properties_map)
344342
atp_helper.fix_jps_config(rcu_db_info, model_context)
345343

346344
except WLSDeployArchiveIOException, ex:

core/src/main/python/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def main(args):
269269
model_context = model_context_helper.create_exit_context(_program_name)
270270
tool_exit.end(model_context, exit_code)
271271

272-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
272+
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
273273

274274
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "deploy", __wlst_mode)
275275

core/src/main/python/discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def main(args):
488488
ex.getLocalizedMessage(), error=ex, class_name=_class_name, method_name=_method_name)
489489
__log_and_exit(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
490490

491-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
491+
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DISCOVER)
492492
model = None
493493
discover_injector = None
494494
if model_context.get_variable_file() is not None:

core/src/main/python/encrypt.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
55
The main module for the WLSDeploy tool to encrypt passwords.
66
"""
7-
import os
87
import sys
98

109
from java.io import IOException
11-
from java.lang import IllegalArgumentException
1210
from java.lang import String, System
1311

1412
from oracle.weblogic.deploy.encrypt import EncryptionException
1513
from oracle.weblogic.deploy.util import CLAException
16-
from oracle.weblogic.deploy.util import FileUtils
1714
from oracle.weblogic.deploy.util import TranslateException
1815
from oracle.weblogic.deploy.util import VariableException
1916
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
@@ -27,7 +24,6 @@
2724
from wlsdeploy.exception.expection_types import ExceptionType
2825
from wlsdeploy.logging.platform_logger import PlatformLogger
2926
from wlsdeploy.tool.encrypt import encryption_utils
30-
from wlsdeploy.tool.util.alias_helper import AliasHelper
3127
from wlsdeploy.util import cla_utils
3228
from wlsdeploy.util import getcreds
3329
from wlsdeploy.util import variables as variable_helper
@@ -165,14 +161,13 @@ def __encrypt_model_and_variables(model_context):
165161
class_name=_class_name, method_name=_method_name)
166162
return CommandLineArgUtil.PROG_ERROR_EXIT_CODE
167163

168-
aliases = Aliases(model_context, wlst_mode=WlstModes.OFFLINE)
169-
alias_helper = AliasHelper(aliases, __logger, ExceptionType.ENCRYPTION)
164+
aliases = Aliases(model_context, wlst_mode=WlstModes.OFFLINE, exception_type=ExceptionType.ENCRYPTION)
170165

171166
for model_file, model in models.iteritems():
172167
try:
173168
passphrase = model_context.get_encryption_passphrase()
174169
model_change_count, variable_change_count = \
175-
encryption_utils.encrypt_model_dictionary(passphrase, model, alias_helper, variables)
170+
encryption_utils.encrypt_model_dictionary(passphrase, model, aliases, variables)
176171
except EncryptionException, ee:
177172
__logger.severe('WLSDPLY-04208', _program_name, ee.getLocalizedMessage(), error=ee,
178173
class_name=_class_name, method_name=_method_name)

core/src/main/python/prepare_model.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
from wlsdeploy.tool.util import filter_helper
4141
from wlsdeploy.tool.util import model_context_helper
4242
from wlsdeploy.tool.util import variable_injector_functions
43-
from wlsdeploy.tool.util.alias_helper import AliasHelper
4443
from wlsdeploy.tool.util.variable_injector import VariableInjector
4544
from wlsdeploy.tool.validate import validation_utils
4645
from wlsdeploy.tool.validate.validator import Validator
@@ -108,8 +107,8 @@ def __init__(self, model_files, model_context, logger, output_dir=None):
108107
self.model_files = model_files
109108
self.output_dir = output_dir
110109
self.model_context = model_context
111-
self._aliases = Aliases(model_context=model_context, wlst_mode=WlstModes.OFFLINE)
112-
self._alias_helper = AliasHelper(self._aliases, logger, ExceptionType.COMPARE)
110+
self._aliases = Aliases(model_context=model_context, wlst_mode=WlstModes.OFFLINE,
111+
exception_type=ExceptionType.COMPARE)
113112
self._logger = logger
114113
self._name_tokens_location = LocationContext()
115114
self._name_tokens_location.add_name_token('DOMAIN', "testdomain")
@@ -124,14 +123,14 @@ def __walk_model_section(self, model_section_key, model_dict, valid_section_fold
124123
return
125124

126125
# only specific top-level sections have attributes
127-
attribute_location = self._alias_helper.get_model_section_attribute_location(model_section_key)
126+
attribute_location = self._aliases.get_model_section_attribute_location(model_section_key)
128127

129128
valid_attr_infos = []
130129
path_tokens_attr_keys = []
131130

132131
if attribute_location is not None:
133-
valid_attr_infos = self._alias_helper.get_model_attribute_names_and_types(attribute_location)
134-
path_tokens_attr_keys = self._alias_helper.get_model_uses_path_tokens_attribute_names(attribute_location)
132+
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(attribute_location)
133+
path_tokens_attr_keys = self._aliases.get_model_uses_path_tokens_attribute_names(attribute_location)
135134

136135
model_section_dict = model_dict[model_section_key]
137136
for section_dict_key, section_dict_value in model_section_dict.iteritems():
@@ -158,16 +157,16 @@ def __walk_model_section(self, model_section_key, model_dict, valid_section_fold
158157
def __walk_section_folder(self, model_node, validation_location):
159158
_method_name = '__validate_section_folder'
160159

161-
model_folder_path = self._alias_helper.get_model_folder_path(validation_location)
160+
model_folder_path = self._aliases.get_model_folder_path(validation_location)
162161

163-
if self._alias_helper.supports_multiple_mbean_instances(validation_location):
162+
if self._aliases.supports_multiple_mbean_instances(validation_location):
164163

165164
for name in model_node:
166165
expanded_name = name
167166

168167
new_location = LocationContext(validation_location)
169168

170-
name_token = self._alias_helper.get_name_token(new_location)
169+
name_token = self._aliases.get_name_token(new_location)
171170

172171
if name_token is not None:
173172
new_location.add_name_token(name_token, expanded_name)
@@ -176,14 +175,14 @@ def __walk_section_folder(self, model_node, validation_location):
176175

177176
self.__walk_model_node(value_dict, new_location)
178177

179-
elif self._alias_helper.requires_artificial_type_subfolder_handling(validation_location):
178+
elif self._aliases.requires_artificial_type_subfolder_handling(validation_location):
180179

181180
for name in model_node:
182181
expanded_name = name
183182

184183
new_location = LocationContext(validation_location)
185184

186-
name_token = self._alias_helper.get_name_token(new_location)
185+
name_token = self._aliases.get_name_token(new_location)
187186

188187
if name_token is not None:
189188
new_location.add_name_token(name_token, expanded_name)
@@ -193,7 +192,7 @@ def __walk_section_folder(self, model_node, validation_location):
193192
self.__walk_model_node(value_dict, new_location)
194193

195194
else:
196-
name_token = self._alias_helper.get_name_token(validation_location)
195+
name_token = self._aliases.get_name_token(validation_location)
197196

198197
if name_token is not None:
199198
name = self._name_tokens_location.get_name_for_token(name_token)
@@ -208,18 +207,18 @@ def __walk_section_folder(self, model_node, validation_location):
208207
def __walk_model_node(self, model_node, validation_location):
209208
_method_name = '__process_model_node'
210209

211-
valid_folder_keys = self._alias_helper.get_model_subfolder_names(validation_location)
212-
valid_attr_infos = self._alias_helper.get_model_attribute_names_and_types(validation_location)
213-
model_folder_path = self._alias_helper.get_model_folder_path(validation_location)
210+
valid_folder_keys = self._aliases.get_model_subfolder_names(validation_location)
211+
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(validation_location)
212+
model_folder_path = self._aliases.get_model_folder_path(validation_location)
214213

215214
for key, value in model_node.iteritems():
216215

217216
if key in valid_folder_keys:
218217
new_location = LocationContext(validation_location).append_location(key)
219218

220-
if self._alias_helper.is_artificial_type_folder(new_location):
219+
if self._aliases.is_artificial_type_folder(new_location):
221220
# key is an ARTIFICIAL_TYPE folder
222-
valid_attr_infos = self._alias_helper.get_model_attribute_names_and_types(new_location)
221+
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(new_location)
223222

224223
self.__walk_attributes(value, valid_attr_infos, new_location)
225224
else:
@@ -237,17 +236,17 @@ def __walk_model_node(self, model_node, validation_location):
237236

238237
else:
239238
path_tokens_attr_keys = \
240-
self._alias_helper.get_model_uses_path_tokens_attribute_names(validation_location)
239+
self._aliases.get_model_uses_path_tokens_attribute_names(validation_location)
241240

242241
self.__walk_attribute(key, value, valid_attr_infos, path_tokens_attr_keys, model_folder_path,
243242
validation_location)
244243

245244
def __walk_attributes(self, attributes_dict, valid_attr_infos, validation_location):
246245
_method_name = '__validate_attributes'
247246

248-
path_tokens_attr_keys = self._alias_helper.get_model_uses_path_tokens_attribute_names(validation_location)
247+
path_tokens_attr_keys = self._aliases.get_model_uses_path_tokens_attribute_names(validation_location)
249248

250-
model_folder_path = self._alias_helper.get_model_folder_path(validation_location)
249+
model_folder_path = self._aliases.get_model_folder_path(validation_location)
251250

252251
for attribute_name, attribute_value in attributes_dict.iteritems():
253252
self.__walk_attribute(attribute_name, attribute_value, valid_attr_infos, path_tokens_attr_keys,
@@ -399,14 +398,14 @@ def walk(self):
399398
self.cache[key] = ''
400399

401400
# use a merged, substituted, filtered model to get domain name and create additional target output.
402-
full_model_dictionary = cla_helper.load_model(_program_name, self.model_context, self._alias_helper,
401+
full_model_dictionary = cla_helper.load_model(_program_name, self.model_context, self._aliases,
403402
"discover", WlstModes.OFFLINE)
404403

405404
target_configuration_helper.generate_k8s_script(self.model_context, self.cache, full_model_dictionary)
406405

407406
# create any additional outputs from full model dictionary
408407
target_configuration_helper.create_additional_output(Model(full_model_dictionary), self.model_context,
409-
self._alias_helper, ExceptionType.VALIDATE)
408+
self._aliases, ExceptionType.VALIDATE)
410409

411410
except ValidateException, te:
412411
self._logger.severe('WLSDPLY-20009', _program_name, model_file_name, te.getLocalizedMessage(),

core/src/main/python/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def main(args):
312312
model_context = model_context_helper.create_exit_context(_program_name)
313313
tool_exit.end(model_context, exit_code)
314314

315-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
315+
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
316316

317317
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "update", __wlst_mode)
318318

0 commit comments

Comments
 (0)