From 5c1493a6f4c489e688b51eb948e03213c34c269d Mon Sep 17 00:00:00 2001 From: Marek Kopecky Date: Tue, 10 Sep 2024 14:54:08 +0200 Subject: [PATCH] Add support for different versions of datasource subsystem --- .../commands/datasources/AddDataSource.groovy | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy index f8306ba9..17908149 100644 --- a/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy +++ b/commands/src/main/resources/org/wildfly/extras/creaper/commands/datasources/AddDataSource.groovy @@ -1,3 +1,9 @@ +// security parameters used as elements: https://issues.redhat.com/browse/WFLY-18324 +stringSubsystemValues = datasources.'@xmlns'.text().tokenize(":")[-1].tokenize(".") +major = stringSubsystemValues[0].toInteger() +minor = stringSubsystemValues[1].toInteger() +securityParamsAsElements = major <= 7 && minor < 2 + // attributes of datasourceAttrs = ['pool-name': poolName] if (nn(jta)) datasourceAttrs['jta'] = jta @@ -45,9 +51,15 @@ def dsDefinition = { } if (nn(userName, password, securityDomain)) { securityAttrs = [:] - if (nn(userName)) securityAttrs['user-name'] = userName - if (nn(password)) securityAttrs['password'] = password + if (!securityParamsAsElements) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) securityAttrs['user-name'] = userName + if (nn(password)) securityAttrs['password'] = password + } security(securityAttrs) { + if (securityParamsAsElements) { // see https://issues.redhat.com/browse/WFLY-18324 + if (nn(userName)) 'user-name'(userName) + if (nn(password)) 'password'(password) + } if (nn(securityDomain)) 'security-domain'(securityDomain) } }