diff options
| author | Paul-Christian Volkmer | 2025-11-07 09:58:37 +0100 |
|---|---|---|
| committer | GitHub | 2025-11-07 09:58:37 +0100 |
| commit | 43e86eeac2f3211aa275e1934d17adf29f1cd6e1 (patch) | |
| tree | 943dd23606cbd1ead5037ed392be720edf6e4487 /src/main/java/dev/dnpm/etl | |
| parent | 9aa9afc6e29c01366720adf1f53c5c358f876edb (diff) | |
fix: use ..hc.core5.net.URIBuilder for URI (#187)v0.12.0-rc.2
Diffstat (limited to 'src/main/java/dev/dnpm/etl')
| -rw-r--r-- | src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java b/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java index 7ffd3e0..a69ba53 100644 --- a/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java +++ b/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java @@ -5,10 +5,12 @@ import ca.uhn.fhir.parser.DataFormatException; import dev.dnpm.etl.processor.config.AppFhirConfig; import dev.dnpm.etl.processor.config.GIcsConfigProperties; import java.net.URI; +import java.net.URISyntaxException; import java.util.Date; import kotlin.random.Random; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.hc.core5.net.URIBuilder; import org.hl7.fhir.r4.model.*; import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; import org.jspecify.annotations.NonNull; @@ -23,7 +25,6 @@ import org.springframework.retry.TerminatedRetryException; import org.springframework.retry.support.RetryTemplate; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; /** * Service to request Consent from remote gICS installation @@ -112,12 +113,21 @@ public class GicsConsentService implements IConsentService { return result; } - private URI endpointUri(String endpoint) { - assert this.gIcsConfigProperties.getUri() != null; - return UriComponentsBuilder.fromUriString(this.gIcsConfigProperties.getUri()) - .path(endpoint) - .build() - .toUri(); + private URI endpointUri(String endpoint) throws URISyntaxException { + if (null == this.gIcsConfigProperties.getUri()) { + throw new URISyntaxException("null", "URI must not be null"); + } + var gPasUrl1 = this.gIcsConfigProperties.getUri(); + if (this.gIcsConfigProperties.getUri().lastIndexOf("/") + == this.gIcsConfigProperties.getUri().length() - 1) { + gPasUrl1 = + this.gIcsConfigProperties + .getUri() + .substring(0, this.gIcsConfigProperties.getUri().length() - 1); + } + var urlBuilder = new URIBuilder(new URI(gPasUrl1)).appendPath(endpoint); + + return urlBuilder.build(); } private HttpHeaders headersWithHttpBasicAuth() { @@ -170,6 +180,10 @@ public class GicsConsentService implements IConsentService { terminatedRetryException.getMessage()); log.error(msg); return null; + } catch (URISyntaxException e) { + var msg = String.format("Invalid URI for consents status request: '%s", e.getMessage()); + log.error(msg); + return null; } } |
