@@ -49,15 +49,15 @@ public class FttpClientImpl implements FttpClient, InitializingBean
4949 private final String proxyUsername ;
5050 private final String proxyPassword ;
5151
52- public FttpClientImpl (KeyStore trustStore , KeyStore keyStore , char [] keyStorePassword , String fttpBasicAuthUsername ,
53- String fttpBasicAuthPassword , String fttpServerBase , String fttpApiKey , String fttpStudy , String fttpTarget ,
54- String proxySchemeHostPort , String proxyUsername , String proxyPassword )
55- {
56- this .proxySchemeHostPort = proxySchemeHostPort ;
57- this .proxyUsername = proxyUsername ;
58- this .proxyPassword = proxyPassword ;
52+ private final boolean hapiClientVerbose ;
5953
60- clientFactory = createClientFactory (trustStore , keyStore , keyStorePassword );
54+ public FttpClientImpl (KeyStore trustStore , KeyStore keyStore , char [] keyStorePassword , int connectTimeout ,
55+ int socketTimeout , int connectionRequestTimeout , String fttpBasicAuthUsername , String fttpBasicAuthPassword ,
56+ String fttpServerBase , String fttpApiKey , String fttpStudy , String fttpTarget , String proxySchemeHostPort ,
57+ String proxyUsername , String proxyPassword , boolean hapiClientVerbose )
58+ {
59+ clientFactory = createClientFactory (trustStore , keyStore , keyStorePassword , connectTimeout , socketTimeout ,
60+ connectionRequestTimeout );
6161
6262 this .fttpServerBase = fttpServerBase ;
6363 this .fttpBasicAuthUsername = fttpBasicAuthUsername ;
@@ -66,10 +66,16 @@ public FttpClientImpl(KeyStore trustStore, KeyStore keyStore, char[] keyStorePas
6666 this .fttpApiKey = fttpApiKey ;
6767 this .fttpStudy = fttpStudy ;
6868 this .fttpTarget = fttpTarget ;
69+
70+ this .proxySchemeHostPort = proxySchemeHostPort ;
71+ this .proxyUsername = proxyUsername ;
72+ this .proxyPassword = proxyPassword ;
73+
74+ this .hapiClientVerbose = hapiClientVerbose ;
6975 }
7076
7177 protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory (KeyStore trustStore , KeyStore keyStore ,
72- char [] keyStorePassword )
78+ char [] keyStorePassword , int connectTimeout , int socketTimeout , int connectionRequestTimeout )
7379 {
7480 Objects .requireNonNull (trustStore , "trustStore" );
7581 Objects .requireNonNull (keyStore , "keyStore" );
@@ -81,6 +87,10 @@ protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(KeyStore t
8187 hapiClientFactory .setServerValidationMode (ServerValidationModeEnum .NEVER );
8288 configureProxy (hapiClientFactory );
8389
90+ hapiClientFactory .setConnectTimeout (connectTimeout );
91+ hapiClientFactory .setSocketTimeout (socketTimeout );
92+ hapiClientFactory .setConnectionRequestTimeout (connectionRequestTimeout );
93+
8494 fhirContext .setRestfulClientFactory (hapiClientFactory );
8595 return hapiClientFactory ;
8696 }
@@ -228,16 +238,26 @@ public void testConnection()
228238 private IGenericClient createGenericClient ()
229239 {
230240 IGenericClient client = clientFactory .newGenericClient (fttpServerBase );
231- client .registerInterceptor (new LoggingInterceptor ());
232241
233- if ( configuredWithBasicAuth ())
234- client . registerInterceptor ( new BasicAuthInterceptor ( fttpBasicAuthUsername , fttpBasicAuthPassword ) );
242+ configuredWithBasicAuth (client );
243+ configureLoggingInterceptor ( client );
235244
236245 return client ;
237246 }
238247
239- private boolean configuredWithBasicAuth ()
248+ private void configuredWithBasicAuth (IGenericClient client )
240249 {
241- return fttpBasicAuthUsername != null && fttpBasicAuthPassword != null ;
250+ if (fttpBasicAuthUsername != null && fttpBasicAuthPassword != null )
251+ client .registerInterceptor (new BasicAuthInterceptor (fttpBasicAuthUsername , fttpBasicAuthPassword ));
252+ }
253+
254+ private void configureLoggingInterceptor (IGenericClient client )
255+ {
256+ if (hapiClientVerbose )
257+ {
258+ LoggingInterceptor loggingInterceptor = new LoggingInterceptor (true );
259+ loggingInterceptor .setLogger (new HapiClientLogger (logger ));
260+ client .registerInterceptor (loggingInterceptor );
261+ }
242262 }
243263}
0 commit comments