@@ -53,7 +53,7 @@ public class HttpUtil {
53
53
*/
54
54
public static Document getXMLContent (String url , String username , String password ) throws IOException {
55
55
56
- logger .finest ( "HTTPUtil.getXMLContent " + url );
56
+ logger .entering ( url );
57
57
String xmlString = Executor .newInstance (getOraClient (username , password ))
58
58
.execute (Request .Get (url ).connectTimeout (30000 ).socketTimeout (30000 ))
59
59
.returnContent ().asString ();
@@ -62,7 +62,7 @@ public static Document getXMLContent(String url, String username, String passwor
62
62
DocumentBuilder docBuilder = dbfac .newDocumentBuilder ();
63
63
InputSource is = new InputSource (new StringReader (xmlString ));
64
64
Document doc = docBuilder .parse (is );
65
- logger .finest ( "HTTPUtil.getXMLContent result " + XPathUtil .prettyPrint (doc ));
65
+ logger .exiting ( XPathUtil .prettyPrint (doc ));
66
66
return doc ;
67
67
} catch (ParserConfigurationException ex ) {
68
68
throw new IllegalStateException (ex );
@@ -74,6 +74,7 @@ public static Document getXMLContent(String url, String username, String passwor
74
74
}
75
75
76
76
private static HttpClient getOraClient (String userId , String password ) {
77
+ logger .entering (userId );
77
78
RequestConfig .Builder config = RequestConfig .custom ();
78
79
config .setCircularRedirectsAllowed (true );
79
80
config .setCookieSpec (CookieSpecs .STANDARD );
@@ -88,6 +89,7 @@ private static HttpClient getOraClient(String userId, String password) {
88
89
credentialsProvider .setCredentials (AuthScope .ANY , new UsernamePasswordCredentials (
89
90
userId , password ));
90
91
}
92
+ logger .exiting ();
91
93
return HttpClientBuilder .create ().setDefaultRequestConfig (config .build ())
92
94
.setDefaultCookieStore (cookieStore ).useSystemProperties ()
93
95
.setDefaultCredentialsProvider (credentialsProvider ).build ();
@@ -105,9 +107,18 @@ private static HttpClient getOraClient(String userId, String password) {
105
107
106
108
public static void downloadFile (String url , String fileName , String username , String password )
107
109
throws IOException {
108
- Executor .newInstance (getOraClient (username , password ))
109
- .execute (Request .Get (url ).connectTimeout (30000 ).socketTimeout (30000 ))
110
- .saveContent (new File (fileName ));
110
+ logger .entering (url );
111
+ try {
112
+ Executor .newInstance (getOraClient (username , password ))
113
+ .execute (Request .Get (url ).connectTimeout (30000 ).socketTimeout (30000 ))
114
+ .saveContent (new File (fileName ));
115
+ } catch (Exception ex ) {
116
+ String message = String .format ("Failed to download and save file %s from %s: %s" , fileName , url ,
117
+ ex .getLocalizedMessage ());
118
+ logger .info (message );
119
+ throw new IOException (message , ex );
120
+ }
121
+ logger .exiting (fileName );
111
122
}
112
123
113
124
/**
0 commit comments