Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 0c8fa83

Browse files
committed
added option to enable verbose HAPI client logging
1 parent 2d17db8 commit 0c8fa83

5 files changed

Lines changed: 372 additions & 13 deletions

File tree

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/FttpClientFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ public void testConnection()
9797
private final String proxyUsername;
9898
private final String proxyPassword;
9999

100+
private final boolean hapiClientVerbose;
101+
100102
public FttpClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath, int connectTimeout,
101103
int socketTimeout, int connectionRequestTimeout, String fttpBasicAuthUsername, String fttpBasicAuthPassword,
102104
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget, String proxySchemeHostPort,
103-
String proxyUsername, String proxyPassword)
105+
String proxyUsername, String proxyPassword, boolean hapiClientVerbose)
104106
{
105107
this.trustStorePath = trustStorePath;
106108
this.certificatePath = certificatePath;
@@ -121,6 +123,8 @@ public FttpClientFactory(Path trustStorePath, Path certificatePath, Path private
121123
this.proxySchemeHostPort = proxySchemeHostPort;
122124
this.proxyUsername = proxyUsername;
123125
this.proxyPassword = proxyPassword;
126+
127+
this.hapiClientVerbose = hapiClientVerbose;
124128
}
125129

126130
@EventListener({ ContextRefreshedEvent.class })
@@ -166,7 +170,7 @@ protected FttpClient createFttpClient()
166170

167171
return new FttpClientImpl(trustStore, keyStore, keyStorePassword, connectTimeout, socketTimeout,
168172
connectionRequestTimeout, fttpBasicAuthUsername, fttpBasicAuthPassword, fttpServerBase, fttpApiKey,
169-
fttpStudy, fttpTarget, proxySchemeHostPort, proxyUsername, proxyPassword);
173+
fttpStudy, fttpTarget, proxySchemeHostPort, proxyUsername, proxyPassword, hapiClientVerbose);
170174
}
171175

172176
private KeyStore readTrustStore(Path trustPath)

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/FttpClientImpl.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ public class FttpClientImpl implements FttpClient, InitializingBean
4949
private final String proxyUsername;
5050
private final String proxyPassword;
5151

52+
private final boolean hapiClientVerbose;
53+
5254
public FttpClientImpl(KeyStore trustStore, KeyStore keyStore, char[] keyStorePassword, int connectTimeout,
5355
int socketTimeout, int connectionRequestTimeout, String fttpBasicAuthUsername, String fttpBasicAuthPassword,
54-
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget,
55-
56-
String proxySchemeHostPort, String proxyUsername, String proxyPassword)
56+
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget, String proxySchemeHostPort,
57+
String proxyUsername, String proxyPassword, boolean hapiClientVerbose)
5758
{
5859
clientFactory = createClientFactory(trustStore, keyStore, keyStorePassword, connectTimeout, socketTimeout,
5960
connectionRequestTimeout);
@@ -69,6 +70,8 @@ public FttpClientImpl(KeyStore trustStore, KeyStore keyStore, char[] keyStorePas
6970
this.proxySchemeHostPort = proxySchemeHostPort;
7071
this.proxyUsername = proxyUsername;
7172
this.proxyPassword = proxyPassword;
73+
74+
this.hapiClientVerbose = hapiClientVerbose;
7275
}
7376

7477
protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(KeyStore trustStore, KeyStore keyStore,
@@ -235,16 +238,26 @@ public void testConnection()
235238
private IGenericClient createGenericClient()
236239
{
237240
IGenericClient client = clientFactory.newGenericClient(fttpServerBase);
238-
client.registerInterceptor(new LoggingInterceptor());
239241

240-
if (configuredWithBasicAuth())
241-
client.registerInterceptor(new BasicAuthInterceptor(fttpBasicAuthUsername, fttpBasicAuthPassword));
242+
configuredWithBasicAuth(client);
243+
configureLoggingInterceptor(client);
242244

243245
return client;
244246
}
245247

246-
private boolean configuredWithBasicAuth()
248+
private void configuredWithBasicAuth(IGenericClient client)
249+
{
250+
if (fttpBasicAuthUsername != null && fttpBasicAuthPassword != null)
251+
client.registerInterceptor(new BasicAuthInterceptor(fttpBasicAuthUsername, fttpBasicAuthPassword));
252+
}
253+
254+
private void configureLoggingInterceptor(IGenericClient client)
247255
{
248-
return fttpBasicAuthUsername != null && fttpBasicAuthPassword != null;
256+
if (hapiClientVerbose)
257+
{
258+
LoggingInterceptor loggingInterceptor = new LoggingInterceptor(true);
259+
loggingInterceptor.setLogger(new HapiClientLogger(logger));
260+
client.registerInterceptor(loggingInterceptor);
261+
}
249262
}
250263
}

0 commit comments

Comments
 (0)