Skip to content

Commit 459c5a0

Browse files
committed
fixing issues related to using the RCU connection string and the resulting JDBC URL used in create domain
1 parent 0a82c26 commit 459c5a0

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

core/src/main/java/oracle/weblogic/deploy/create/RCURunner.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ private RCURunner(String domainType, String oracleHome, String javaHome, String
9494

9595
this.oracleHome = validateExistingDirectory(oracleHome, "ORACLE_HOME");
9696
this.javaHome = validateExistingDirectory(javaHome, "JAVA_HOME");
97-
this.rcuDb = validateNonEmptyString(rcuDb, "rcu_db");
97+
98+
// The rcu_db string could be in the long format so quote the argument to prevent the shell
99+
// from trying to interpret the parens...
100+
//
101+
this.rcuDb = quoteStringForCommandLine(rcuDb, "rcu_db");
98102
this.rcuPrefix = validateNonEmptyString(rcuPrefix, "rcu_prefix");
99103
this.rcuSchemas = validateNonEmptyListOfStrings(rcuSchemas, "rcu_schema_list");
100104
this.rcuVariables = rcuVariables;
@@ -383,6 +387,11 @@ private static File validateExistingDirectory(String directoryName, String direc
383387
return result;
384388
}
385389

390+
private static String quoteStringForCommandLine(String text, String textTypeName) throws CreateException {
391+
String result = validateNonEmptyString(text, textTypeName);
392+
return StringUtils.quoteString(result);
393+
}
394+
386395
private static String validateNonEmptyString(String text, String textTypeName) throws CreateException {
387396
return validateNonEmptyString(text, textTypeName, false);
388397
}

core/src/main/java/oracle/weblogic/deploy/util/StringUtils.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static String getStringFromList(List<String> list, char separator) {
6666
}
6767

6868
/**
69-
* String surrounding quotes from the string, if they are present.
69+
* Strip surrounding quotes from the string, if they are present.
7070
*
7171
* @param string the string from which to remove the surround quotes
7272
* @return the string without any surrounding quotes or the string itself if no quotes were present
@@ -83,6 +83,24 @@ public static String stripQuotes(String string) {
8383
return result;
8484
}
8585

86+
/**
87+
* Add surrounding quotes to the string, if not already present.
88+
*
89+
* @param string the string to surround with double quotes
90+
* @return the string with surrounding double quotes or the string itself is single or double quotes were present
91+
*/
92+
public static String quoteString(String string) {
93+
String result = "\"" + string + "\"";
94+
if (!StringUtils.isEmpty(string) && string.length() > 1) {
95+
char first = string.charAt(0);
96+
char last = string.charAt(string.length() - 1);
97+
if ((first == '"' && last == '"') || (first == '\'' && last == '\'')) {
98+
result = string;
99+
}
100+
}
101+
return result;
102+
}
103+
86104
/**
87105
* Determine if the provided string value matches the provided pattern.
88106
*

core/src/main/python/wlsdeploy/util/weblogic_helper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ def get_jdbc_url_from_rcu_connect_string(self, rcu_connect_string):
123123
:param rcu_connect_string: the RCU connect string
124124
:return: the JDBC URL
125125
"""
126-
return 'jdbc:oracle:thin:@' + rcu_connect_string
126+
jdbc_url = rcu_connect_string
127+
if not rcu_connect_string.startswith('jdbc:oracle:'):
128+
if rcu_connect_string.startswith('('):
129+
# Long format
130+
jdbc_url = 'jdbc:oracle:thin:@' + rcu_connect_string
131+
elif rcu_connect_string.rfind('/') != -1:
132+
# host:port/service format
133+
jdbc_url = 'jdbc:oracle:thin:@//' + rcu_connect_string
134+
else:
135+
# host:port:sid format
136+
jdbc_url = 'jdbc:oracle:thin:@' + rcu_connect_string
137+
return jdbc_url
127138

128139
def get_stb_data_source_jdbc_driver_name(self):
129140
"""

0 commit comments

Comments
 (0)