From 63674260450e915078c15d94f6eebf3a3152331e Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 7 Sep 2026 08:35:18 +0200 Subject: fix: possible NPE and throw IllegalStateException for gICS --- .../consent/GicsGetBroadConsentService.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/main/java/dev/dnpm/etl') diff --git a/src/main/java/dev/dnpm/etl/processor/consent/GicsGetBroadConsentService.java b/src/main/java/dev/dnpm/etl/processor/consent/GicsGetBroadConsentService.java index 2439e44..3b75e7c 100644 --- a/src/main/java/dev/dnpm/etl/processor/consent/GicsGetBroadConsentService.java +++ b/src/main/java/dev/dnpm/etl/processor/consent/GicsGetBroadConsentService.java @@ -75,15 +75,25 @@ public class GicsGetBroadConsentService extends AbstractConsentService { return evaluateConsentResponse(consentStatusResponse); } + /** + * This method is used to retrieve broad consent data from the gICS service. + * + * @param personIdentifierValue patient identifier used for consent data + * @param requestDate Ignored, just present for compatibility with other consent services + * @param consentDomain Ignored, just present for compatibility with other consent services + * @return A {@link Bundle} containing the consent data or empty Bundle if consent fails + */ @Override public Bundle getConsent( String personIdentifierValue, Date requestDate, ConsentDomain consentDomain) { - return fhirContext - .newJsonParser() - .parseResource( - Bundle.class, - requestResponse( - personIdentifierValue, gIcsConfigProperties.getBroadConsentDomainName())); + final var response = + requestResponse(personIdentifierValue, gIcsConfigProperties.getBroadConsentDomainName()); + + if (null == response) { + throw new IllegalStateException("Failed to retrieve consent data from gICS"); + } + + return fhirContext.newJsonParser().parseResource(Bundle.class, response); } @Nullable -- cgit v1.2.3