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

Commit 3f3c01b

Browse files
committed
Merge remote-tracking branch 'origin/issues/22_Blaze_fhir-bridge' into
develop
2 parents 1bdb200 + ac628ff commit 3f3c01b

15 files changed

Lines changed: 950 additions & 122 deletions

File tree

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,29 @@ public void testConnection()
8989
private final String fttpStudy;
9090
private final String fttpTarget;
9191

92+
private final int connectTimeout;
93+
private final int socketTimeout;
94+
private final int connectionRequestTimeout;
95+
9296
private final String proxySchemeHostPort;
9397
private final String proxyUsername;
9498
private final String proxyPassword;
9599

96-
public FttpClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath,
97-
String fttpBasicAuthUsername, String fttpBasicAuthPassword, String fttpServerBase, String fttpApiKey,
98-
String fttpStudy, String fttpTarget, String proxySchemeHostPort, String proxyUsername, String proxyPassword)
100+
private final boolean hapiClientVerbose;
101+
102+
public FttpClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath, int connectTimeout,
103+
int socketTimeout, int connectionRequestTimeout, String fttpBasicAuthUsername, String fttpBasicAuthPassword,
104+
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget, String proxySchemeHostPort,
105+
String proxyUsername, String proxyPassword, boolean hapiClientVerbose)
99106
{
100107
this.trustStorePath = trustStorePath;
101108
this.certificatePath = certificatePath;
102109
this.privateKeyPath = privateKeyPath;
103110

111+
this.connectTimeout = connectTimeout;
112+
this.socketTimeout = socketTimeout;
113+
this.connectionRequestTimeout = connectionRequestTimeout;
114+
104115
this.fttpBasicAuthUsername = fttpBasicAuthUsername;
105116
this.fttpBasicAuthPassword = fttpBasicAuthPassword;
106117

@@ -112,6 +123,8 @@ public FttpClientFactory(Path trustStorePath, Path certificatePath, Path private
112123
this.proxySchemeHostPort = proxySchemeHostPort;
113124
this.proxyUsername = proxyUsername;
114125
this.proxyPassword = proxyPassword;
126+
127+
this.hapiClientVerbose = hapiClientVerbose;
115128
}
116129

117130
@EventListener({ ContextRefreshedEvent.class })
@@ -155,8 +168,9 @@ protected FttpClient createFttpClient()
155168
logger.debug("Creating key-store from {} and {}", certificatePath.toString(), privateKeyPath.toString());
156169
KeyStore keyStore = readKeyStore(certificatePath, privateKeyPath, keyStorePassword);
157170

158-
return new FttpClientImpl(trustStore, keyStore, keyStorePassword, fttpBasicAuthUsername, fttpBasicAuthPassword,
159-
fttpServerBase, fttpApiKey, fttpStudy, fttpTarget, proxySchemeHostPort, proxyUsername, proxyPassword);
171+
return new FttpClientImpl(trustStore, keyStore, keyStorePassword, connectTimeout, socketTimeout,
172+
connectionRequestTimeout, fttpBasicAuthUsername, fttpBasicAuthPassword, fttpServerBase, fttpApiKey,
173+
fttpStudy, fttpTarget, proxySchemeHostPort, proxyUsername, proxyPassword, hapiClientVerbose);
160174
}
161175

162176
private KeyStore readTrustStore(Path trustPath)

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

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)