Skip to content

Commit a180119

Browse files
committed
Merge branch 'robert.patrick-main-patch-97149' into 'main'
Fixes NullPointerException so that the Validation exception is properly thrown (OWLS-114150) See merge request weblogic-cloud/weblogic-deploy-tooling!1547
2 parents 1bbfc70 + 913c997 commit a180119

File tree

5 files changed

+52
-25
lines changed

5 files changed

+52
-25
lines changed

core/src/main/java/oracle/weblogic/deploy/validate/PasswordValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public boolean validate(String username, String pass) throws ValidateException {
6666
final String METHOD = "validate";
6767

6868
LOGGER.entering(CLASS, METHOD, username);
69-
String user = username.trim();
69+
String user = StringUtils.isEmpty(username) ? username : username.trim();
7070

7171
if (StringUtils.isEmpty(user)) {
7272
ValidateException ex = new ValidateException("WLSDPLY-05400");

core/src/main/python/create.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
4343
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4444
from wlsdeploy.tool.util import wlst_helper
45-
from wlsdeploy.tool.validate.content_validator import ContentValidator
45+
from wlsdeploy.tool.validate.content_validator import CreateDomainContentValidator
4646
from wlsdeploy.util import cla_helper
4747
from wlsdeploy.util import env_helper
4848
from wlsdeploy.util import getcreds
@@ -370,9 +370,8 @@ def main(model_context):
370370
validate_crd_sections=False)
371371

372372
# check for any content problems in the merged, substituted model
373-
content_validator = ContentValidator(model_context, aliases)
373+
content_validator = CreateDomainContentValidator(model_context, aliases)
374374
content_validator.validate_model(model_dictionary)
375-
content_validator.validate_user_passwords(model_dictionary)
376375

377376
archive_helper = None
378377
archive_file_name = model_context.get_archive_file_name()

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,6 @@ def __init__(self, model_dictionary, model_context, aliases):
126126
_method_name = '__init__'
127127
Creator.__init__(self, model_dictionary, model_context, aliases)
128128

129-
# domainInfo section is required to get the admin password, everything else
130-
# is optional and will use the template defaults
131-
if model.get_model_domain_info_key() not in model_dictionary:
132-
ex = exception_helper.create_create_exception('WLSDPLY-12200', self.__program_name,
133-
model.get_model_domain_info_key(),
134-
self.model_context.get_model_file())
135-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
136-
raise ex
137-
138129
self.topology_helper = TopologyHelper(self.aliases, ExceptionType.CREATE, self.logger)
139130
self.security_provider_creator = SecurityProviderCreator(model_dictionary, model_context, aliases,
140131
ExceptionType.CREATE, self.logger)

core/src/main/python/wlsdeploy/tool/validate/content_validator.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from wlsdeploy.aliases.model_constants import CLUSTER
1616
from wlsdeploy.aliases.model_constants import DEFAULT_REALM
1717
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
18+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO_ALIAS
1819
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
1920
from wlsdeploy.aliases.model_constants import PASSWORD
2021
from wlsdeploy.aliases.model_constants import PASSWORD_VALIDATOR
@@ -88,6 +89,38 @@ def validate_dynamic_clusters(self, model_dict):
8889
else:
8990
server_templates.append(server_template)
9091

92+
93+
class CreateDomainContentValidator(ContentValidator):
94+
_class_name = 'CreateDomainContentValidator'
95+
_logger = PlatformLogger('wlsdeploy.validate')
96+
97+
def __init__(self, model_context, aliases):
98+
ContentValidator.__init__(self, model_context, aliases)
99+
100+
def validate_model(self, model_dict):
101+
_method_name = 'validate_model'
102+
self._logger.entering(class_name=self._class_name, method_name=_method_name)
103+
104+
self.validate_domain_info_section(model_dict)
105+
self.validate_user_passwords(model_dict)
106+
ContentValidator.validate_model(self, model_dict)
107+
108+
self._logger.exiting(class_name=self._class_name, method_name=_method_name)
109+
110+
def validate_domain_info_section(self, model_dict):
111+
"""
112+
Validate domainInfo section exists in the model.
113+
:param model_dict: A Python dictionary of the model to be validated
114+
:return: ValidationException: if problems occur during validation
115+
"""
116+
_method_name = 'validate_domain_info_section'
117+
if DOMAIN_INFO not in model_dict:
118+
ex = exception_helper.create_validate_exception('WLSDPLY-12200', self._model_context.get_program_name(),
119+
DOMAIN_INFO,
120+
self._model_context.get_model_file())
121+
self._logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
122+
raise ex
123+
91124
def validate_user_passwords(self, model_dict):
92125
"""
93126
Validate user passwords in the model is password validation is enabled
@@ -236,6 +269,10 @@ def _get_admin_credentials(self, model_dict):
236269

237270
domain_info_folder = dictionary_utils.get_dictionary_element(model_dict, DOMAIN_INFO)
238271
admin_username = dictionary_utils.get_element(domain_info_folder, ADMIN_USERNAME)
272+
if admin_username is None:
273+
location = LocationContext()
274+
location.append_location(DOMAIN_INFO_ALIAS)
275+
admin_username = self._aliases.get_model_attribute_default_value(location, ADMIN_USERNAME)
239276
admin_password = dictionary_utils.get_element(domain_info_folder, ADMIN_PASSWORD)
240277
admin_password = self._aliases.decrypt_password(admin_password)
241278

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/DomainInfo.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
"wlst_type": "DomainInfo",
55
"folders": { },
66
"attributes": {
7-
"AdminPassword": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AdminPassword", "wlst_path": "WP001", "default_value": null, "wlst_type": "password" } ],
8-
"AdminUserName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AdminUserName", "wlst_path": "WP001", "default_value": null, "wlst_type": "credential" } ],
9-
"AppDir": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AppDir", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "uses_path_tokens": "true" } ],
10-
"OPSSSecrets": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OPSSSecrets", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "secret_suffix": "opsssecrets", "secret_key": "walletPassword" } ],
11-
"ServerGroupTargetingLimits": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
12-
"DynamicClusterServerGroupTargetingLimits": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "dynamicClusterServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
13-
"ServerStartMode": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerStartMode", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
14-
"UseSampleDatabase": [ {"version": "[12.2.1,)", "wlst_mode": "offline", "wlst_name": "UseSampleDatabase", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
15-
"EnableJMSStoreDBPersistence": [ {"version": "[12.2.1.1,)", "wlst_mode": "offline", "wlst_name": "EnableJMSStoreDBPersistence", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
16-
"EnableJTATLogDBPersistence": [ {"version": "[12.2.1.1,)", "wlst_mode": "offline", "wlst_name": "EnableJTATLogDBPersistence", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
17-
"domainBin": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "domainBin", "wlst_path": "WP001", "default_value": null, "wlst_type": "list", "uses_path_tokens": "true" } ],
18-
"domainLibraries": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "domainLibraries", "wlst_path": "WP001", "default_value": null, "wlst_type": "list", "uses_path_tokens": "true" } ]
7+
"AdminPassword": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AdminPassword", "wlst_path": "WP001", "default_value": null, "wlst_type": "password" } ],
8+
"AdminUserName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AdminUserName", "wlst_path": "WP001", "default_value": "weblogic", "wlst_type": "credential" } ],
9+
"AppDir": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AppDir", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "uses_path_tokens": "true" } ],
10+
"OPSSSecrets": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OPSSSecrets", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "secret_suffix": "opsssecrets", "secret_key": "walletPassword" } ],
11+
"ServerGroupTargetingLimits": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
12+
"DynamicClusterServerGroupTargetingLimits": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "dynamicClusterServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
13+
"ServerStartMode": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerStartMode", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
14+
"UseSampleDatabase": [ {"version": "[12.2.1,)", "wlst_mode": "offline", "wlst_name": "UseSampleDatabase", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
15+
"EnableJMSStoreDBPersistence": [ {"version": "[12.2.1.1,)", "wlst_mode": "offline", "wlst_name": "EnableJMSStoreDBPersistence", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
16+
"EnableJTATLogDBPersistence": [ {"version": "[12.2.1.1,)", "wlst_mode": "offline", "wlst_name": "EnableJTATLogDBPersistence", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
17+
"domainBin": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "domainBin", "wlst_path": "WP001", "default_value": null, "wlst_type": "list", "uses_path_tokens": "true" } ],
18+
"domainLibraries": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "domainLibraries", "wlst_path": "WP001", "default_value": null, "wlst_type": "list", "uses_path_tokens": "true" } ]
1919
},
2020
"wlst_attributes_path": "WP001",
2121
"wlst_paths": {

0 commit comments

Comments
 (0)