11"""
2- Copyright (c) 2017, 2019 , Oracle Corporation and/or its affiliates. All rights reserved.
2+ Copyright (c) 2017, 2022 , Oracle Corporation and/or its affiliates. All rights reserved.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
66"""
77import re
88from xml .dom .minidom import parse
9+ from wlsdeploy .exception import exception_helper
910
11+ from wlsdeploy .logging .platform_logger import PlatformLogger
12+
13+ _logger = PlatformLogger ('wlsdeploy.create' )
1014
1115def set_ssl_properties (xmlDoc , atp_creds_path , keystore_password , truststore_password ):
1216 '''
@@ -63,7 +67,6 @@ def fix_jps_config(rcu_db_info, model_context):
6367
6468
6569def get_atp_connect_string (tnsnames_ora_path , tns_sid_name ):
66-
6770 try :
6871 f = open (tnsnames_ora_path , "r+" )
6972 try :
@@ -76,17 +79,24 @@ def get_atp_connect_string(tnsnames_ora_path, tns_sid_name):
7679 pattern = tns_sid_name + '\s*=\s*([(].*\n .*)'
7780 match = re .search (pattern , text )
7881 if match :
79- str = match .group (1 )
80- tnsConnectString = str .replace ('\r ' ,'' ).replace ('\n ' ,'' )
81- str = format_connect_string (tnsConnectString )
82- return str
83- except :
84- pass
85-
86- return None
87-
88-
89- def format_connect_string (connect_string ):
82+ connect_string = match .group (1 )
83+ tnsConnectString = connect_string .replace ('\r ' ,'' ).replace ('\n ' ,'' )
84+ connect_string = cleanup_connect_string (tnsConnectString )
85+ return connect_string , None
86+ else :
87+ ex = exception_helper .create_create_exception ("WLSDPLY-12563" , tns_sid_name )
88+ _logger .throwing (ex , class_name = 'atp_helper' , method_name = 'get_atp_connect_string' )
89+ raise ex
90+ except IOError , ioe :
91+ ex = exception_helper .create_create_exception ("WLSDPLY-12570" , str (ioe ))
92+ _logger .throwing (ex , class_name = 'atp_helper' , method_name = 'get_atp_connect_string' )
93+ raise ex
94+ except Exception , ex :
95+ ex = exception_helper .create_create_exception ("WLSDPLY-12570" , str (ex ))
96+ _logger .throwing (ex , class_name = 'atp_helper' , method_name = 'get_atp_connect_string' )
97+ raise ex
98+
99+ def cleanup_connect_string (connect_string ):
90100 """
91101 Formats connect string for ATP DB by removing unwanted whitespaces.
92102 Input:
@@ -109,5 +119,5 @@ def format_connect_string(connect_string):
109119 part3 = match .group (3 )
110120 part4 = match .group (4 ).replace (' ' , '' )
111121 connect_string = "%s%s%s%s" % (part1 , part2 , part3 , part4 )
112-
122+ # if no match then return original one
113123 return connect_string
0 commit comments