Skip to content

Commit 9ffff6d

Browse files
Added more error checking to GraphQL login
1 parent fca1360 commit 9ffff6d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>de.samply</groupId>
1212
<artifactId>directory_sync_service</artifactId>
13-
<version>1.5.11</version>
13+
<version>1.5.12</version>
1414
<name>directory_sync_service</name>
1515
<description>Directory sync</description>
1616
<url>https://github.com/samply/directory_sync_service</url>

src/main/java/de/samply/directory_sync_service/directory/graphql/DirectoryApiGraphql.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,26 @@ public boolean login() {
9696

9797
String endpoint = directoryEndpointsGraphql.getLoginEndpoint();
9898
JsonObject result = directoryCallsGraphql.runGraphqlCommand(endpoint, graphqlCommand);
99-
10099
if (result == null) {
101100
logger.warn("login: result is null");
102101
return false;
103102
}
104103

105-
String token = result.get("signin").getAsJsonObject().get("token").getAsString();
104+
JsonElement signin = result.get("signin");
105+
if (signin == null) {
106+
logger.warn("login: signin is null");
107+
logger.warn("login: result: " + Util.jsonStringFomObject(result));
108+
return false;
109+
}
110+
111+
JsonElement tokenObject = signin.getAsJsonObject().get("token");
112+
if (tokenObject == null) {
113+
logger.warn("login: tokenObject is null");
114+
logger.warn("login: signin: " + Util.jsonStringFomObject(signin));
115+
return false;
116+
}
117+
118+
String token = tokenObject.getAsString();
106119
if (token == null) {
107120
logger.warn("login: token is null");
108121
return false;

src/main/java/de/samply/directory_sync_service/fhir/FhirApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public Patient extractPatientFromSpecimen(Specimen specimen) {
382382
.replaceFirst("Patient/", ""))
383383
.execute();
384384
} catch (Exception e) {
385-
logger.warn("extractPatientFromSpecimen: caught exception", Util.traceFromException(e));
385+
logger.warn("extractPatientFromSpecimen: caught exception: " + Util.traceFromException(e));
386386
}
387387

388388
return patient;

0 commit comments

Comments
 (0)