1919import oracle .weblogic .deploy .util .ScriptRunnerException ;
2020import oracle .weblogic .deploy .util .StringUtils ;
2121
22+ import org .python .core .PyDictionary ;
23+ import org .python .core .PyString ;
24+
25+
2226/**
2327 * This class does all the work to drop and recreate the RCU schemas besed on the domain type definition.
2428 */
@@ -44,12 +48,19 @@ public class RCURunner {
4448 private static final String DB_ROLE = "SYSDBA" ;
4549 private static final String SCHEMA_PREFIX_SWITCH = "-schemaPrefix" ;
4650 private static final String COMPONENT_SWITCH = "-component" ;
51+ private static final String TABLESPACE_SWITCH = "-tablespace" ;
52+ private static final String TEMPTABLESPACE_SWITCH = "-tempTablespace" ;
53+ private static final String RCU_VARIABLES_SWITCH = "-variables" ;
4754 private static final String READ_STDIN_SWITCH = "-f" ;
55+ private static final String USE_SSL_SWITCH = "-useSSL" ;
56+ private static final String SERVER_DN_SWITCH = "-serverDN" ;
57+ private static final String SSLARGS = "-sslArgs" ;
58+
4859 private static final String SERVICE_TABLE_COMPONENT = "STB" ;
4960 private static final String WLS_COMPONENT = "WLS" ;
5061 private static final String WLS_RUNTIME_COMPONENT = "WLS_RUNTIME" ;
5162
52- private static final Pattern SCHEMA_DOES_NOT_EXIST_PATTERN = Pattern .compile ("(ORA-01918|RCU-6013)" );
63+ private static final Pattern SCHEMA_DOES_NOT_EXIST_PATTERN = Pattern .compile ("(ORA-01918|RCU-6013|ORA-12899 )" );
5364
5465 private static final int RCU_CREATE_COMMON_ARG_COUNT = 13 ;
5566
@@ -61,6 +72,12 @@ public class RCURunner {
6172 private String rcuDb ;
6273 private String rcuPrefix ;
6374 private List <String > rcuSchemas ;
75+ private boolean ATP_DB = false ;
76+ private String atpSSlArgs = null ;
77+ private String atpAdminUser = null ;
78+ private String atpDefaultTablespace = null ;
79+ private String atpTemporaryTablespace = null ;
80+ private String rcuVariables = null ;
6481
6582 /**
6683 * The constructor.
@@ -74,19 +91,74 @@ public class RCURunner {
7491 * @throws CreateException if a parameter validation error occurs
7592 */
7693 public RCURunner (String domainType , String oracleHome , String javaHome , String rcuDb , String rcuPrefix ,
77- List <String > rcuSchemas ) throws CreateException {
94+ List <String > rcuSchemas , String rcuVariables ) throws CreateException {
7895
7996 this .oracleHome = validateExistingDirectory (oracleHome , "ORACLE_HOME" );
8097 this .javaHome = validateExistingDirectory (javaHome , "JAVA_HOME" );
8198 this .rcuDb = validateNonEmptyString (rcuDb , "rcu_db" );
8299 this .rcuPrefix = validateNonEmptyString (rcuPrefix , "rcu_prefix" );
83100 this .rcuSchemas = validateNonEmptyListOfStrings (rcuSchemas , "rcu_schema_list" );
84- if (this .rcuSchemas .contains (SERVICE_TABLE_COMPONENT )) {
85- LOGGER .warning ("WLSDPLY-12000" , CLASS , domainType , SERVICE_TABLE_COMPONENT );
86- this .rcuSchemas .remove (SERVICE_TABLE_COMPONENT );
87- }
101+ this .rcuVariables = rcuVariables ;
102+ // if (this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
103+ // LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
104+ // this.rcuSchemas.remove(SERVICE_TABLE_COMPONENT);
105+ // }
106+ }
107+
108+ /**
109+ * The constructor - used only by ATP database
110+ *
111+ * @param domainType the domain type
112+ * @param oracleHome the ORACLE_HOME location
113+ * @param javaHome the JAVA_HOME location
114+ * @throws CreateException if a parameter validation error occurs
115+ */
116+ public RCURunner (String domainType , String oracleHome , String javaHome , List <String > rcuSchemas ,
117+ PyDictionary rcuProperties , String rcuVariables )
118+ throws CreateException {
119+
120+
121+ String tnsAdmin = rcuProperties .get (new PyString ("oracle.net.tns_admin" )).toString ();
122+ String keyStorePassword = rcuProperties .get (new PyString ("javax.net.ssl.keyStorePassword" )).toString ();
123+ String trustStorePassword = rcuProperties .get (new PyString ("javax.net.ssl.trustStorePassword" )).toString ();
124+
125+ StringBuffer sslArgs = new StringBuffer ();
126+ sslArgs .append ("oracle.net.tns_admin=" );
127+ sslArgs .append (tnsAdmin );
128+ sslArgs .append (",oracle.net.ssl_version=1.2" );
129+ sslArgs .append (",javax.net.ssl.trustStore=" );
130+ sslArgs .append (tnsAdmin + "/truststore.jks" );
131+ sslArgs .append (",javax.net.ssl.trustStoreType=JKS" );
132+ sslArgs .append (",javax.net.ssl.trustStorePassword=" );
133+ sslArgs .append (trustStorePassword );
134+ sslArgs .append (",javax.net.ssl.keyStore=" );
135+ sslArgs .append (tnsAdmin + "/keystore.jks" );
136+ sslArgs .append (",javax.net.ssl.keyStoreType=JKS" );
137+ sslArgs .append (",javax.net.ssl.keyStorePassword=" );
138+ sslArgs .append (keyStorePassword );
139+ sslArgs .append (",oracle.jdbc.fanEnabled=false" );
140+ sslArgs .append (",oracle.net.ssl_server_dn_match=true" );
141+
142+ ATP_DB = true ;
143+ atpSSlArgs = sslArgs .toString ();
144+
145+ this .oracleHome = validateExistingDirectory (oracleHome , "ORACLE_HOME" );
146+ this .javaHome = validateExistingDirectory (javaHome , "JAVA_HOME" );
147+ this .rcuDb = "jdbc:oracle:thin:@" + rcuProperties .get (new PyString ("tns.entry" )).toString ();
148+ this .rcuPrefix = rcuProperties .get (new PyString ("rcu_prefix" )).toString ();
149+ this .rcuSchemas = validateNonEmptyListOfStrings (rcuSchemas , "rcu_schema_list" );
150+ this .atpAdminUser = rcuProperties .get (new PyString ("atp.admin.user" )).toString ();
151+ this .atpDefaultTablespace = rcuProperties .get (new PyString ("atp.default.tablespace" )).toString ();
152+ this .atpTemporaryTablespace = rcuProperties .get (new PyString ("atp.temp.tablespace" )).toString ();
153+ this .rcuVariables = rcuVariables ;
154+
155+ // if (!this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
156+ // LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
157+ // this.rcuSchemas.add(SERVICE_TABLE_COMPONENT);
158+ // }
88159 }
89160
161+
90162 /**
91163 * Run RCU to drop and recreate the RCU schemas.
92164 *
@@ -130,6 +202,9 @@ public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateExcepti
130202 runner = new ScriptRunner (createEnv , RCU_CREATE_LOG_BASENAME );
131203 try {
132204 exitCode = runner .executeScript (rcuScript , scriptStdinLines , scriptArgs );
205+ if (ATP_DB && exitCode != 0 && isSchemaNotExistError (runner )) {
206+ exitCode = 0 ;
207+ }
133208 } catch (ScriptRunnerException sre ) {
134209 CreateException ce = new CreateException ("WLSDPLY-12003" , sre , CLASS , sre .getLocalizedMessage ());
135210 LOGGER .throwing (CLASS , METHOD , ce );
@@ -146,9 +221,19 @@ public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateExcepti
146221 // Private helper methods //
147222 ///////////////////////////////////////////////////////////////////////////
148223
224+ private void addATPEnv (Map <String , String > env ) {
225+ if (ATP_DB ) {
226+ env .put ("RCU_SSL_MODE" , "true" );
227+ env .put ("SKIP_CONNECTSTRING_VALIDATION" , "true" );
228+ env .put ("RCU_SKIP_PRE_REQS" , "ALL" );
229+ }
230+ }
231+
232+
149233 private Map <String , String > getRcuDropEnv () {
150234 Map <String , String > env = new HashMap <>(1 );
151235 env .put ("JAVA_HOME" , this .javaHome .getAbsolutePath ());
236+ addATPEnv (env );
152237 return env ;
153238 }
154239
@@ -164,10 +249,23 @@ private String[] getRcuDropArgs() {
164249 dropArgs .add (ORACLE_DB_TYPE );
165250 dropArgs .add (DB_CONNECT_SWITCH );
166251 dropArgs .add (rcuDb );
167- dropArgs .add (DB_USER_SWITCH );
168- dropArgs .add (DB_USER );
169- dropArgs .add (DB_ROLE_SWITCH );
170- dropArgs .add (DB_ROLE );
252+
253+ if (ATP_DB ) {
254+ dropArgs .add (DB_USER_SWITCH );
255+ dropArgs .add (this .atpAdminUser );
256+ dropArgs .add (USE_SSL_SWITCH );
257+ dropArgs .add ("true" );
258+ dropArgs .add (SERVER_DN_SWITCH );
259+ dropArgs .add ("CN=ignored" );
260+ dropArgs .add (SSLARGS );
261+ dropArgs .add (atpSSlArgs );
262+
263+ } else {
264+ dropArgs .add (DB_USER_SWITCH );
265+ dropArgs .add (DB_USER );
266+ dropArgs .add (DB_ROLE_SWITCH );
267+ dropArgs .add (DB_ROLE );
268+ }
171269 dropArgs .add (SCHEMA_PREFIX_SWITCH );
172270 dropArgs .add (rcuPrefix );
173271
@@ -176,8 +274,8 @@ private String[] getRcuDropArgs() {
176274 dropArgs .add (rcuSchema );
177275 }
178276 // Add STB to the drop list since it is never specified in the create list...
179- dropArgs .add (COMPONENT_SWITCH );
180- dropArgs .add (SERVICE_TABLE_COMPONENT );
277+ // dropArgs.add(COMPONENT_SWITCH);
278+ // dropArgs.add(SERVICE_TABLE_COMPONENT);
181279
182280 dropArgs .add (READ_STDIN_SWITCH );
183281
@@ -193,16 +291,37 @@ private String[] getRcuCreateArgs() {
193291 createArgs .add (ORACLE_DB_TYPE );
194292 createArgs .add (DB_CONNECT_SWITCH );
195293 createArgs .add (rcuDb );
196- createArgs .add (DB_USER_SWITCH );
197- createArgs .add (DB_USER );
198- createArgs .add (DB_ROLE_SWITCH );
199- createArgs .add (DB_ROLE );
294+ if (ATP_DB ) {
295+ createArgs .add (DB_USER_SWITCH );
296+ createArgs .add (this .atpAdminUser );
297+ createArgs .add (USE_SSL_SWITCH );
298+ createArgs .add ("true" );
299+ createArgs .add (SERVER_DN_SWITCH );
300+ createArgs .add ("CN=ignored" );
301+ createArgs .add (SSLARGS );
302+ createArgs .add (atpSSlArgs );
303+ } else {
304+ createArgs .add (DB_USER_SWITCH );
305+ createArgs .add (DB_USER );
306+ createArgs .add (DB_ROLE_SWITCH );
307+ createArgs .add (DB_ROLE );
308+ }
200309 createArgs .add (SCHEMA_PREFIX_SWITCH );
201310 createArgs .add (rcuPrefix );
202311
203312 for (String rcuSchema : rcuSchemas ) {
204313 createArgs .add (COMPONENT_SWITCH );
205314 createArgs .add (rcuSchema );
315+ if (ATP_DB ) {
316+ createArgs .add (TABLESPACE_SWITCH );
317+ createArgs .add (this .atpDefaultTablespace );
318+ createArgs .add (TEMPTABLESPACE_SWITCH );
319+ createArgs .add (this .atpTemporaryTablespace );
320+ }
321+ }
322+ if (rcuVariables != null ) {
323+ createArgs .add (RCU_VARIABLES_SWITCH );
324+ createArgs .add (this .rcuVariables );
206325 }
207326 createArgs .add (READ_STDIN_SWITCH );
208327
@@ -256,6 +375,19 @@ private static boolean isSchemaNotExistError(ScriptRunner runner) {
256375 return schemaDoesNotExist ;
257376 }
258377
378+ private static boolean isValueTooLargeError (ScriptRunner runner ) {
379+ List <String > stdoutBuffer = runner .getStdoutBuffer ();
380+ boolean schemaDoesNotExist = false ;
381+ for (String line : stdoutBuffer ) {
382+ Matcher matcher = SCHEMA_DOES_NOT_EXIST_PATTERN .matcher (line );
383+ if (matcher .find ()) {
384+ schemaDoesNotExist = true ;
385+ break ;
386+ }
387+ }
388+ return schemaDoesNotExist ;
389+ }
390+
259391 private static File validateExistingDirectory (String directoryName , String directoryTypeName )
260392 throws CreateException {
261393 final String METHOD = "validateExistingDirectory" ;
0 commit comments