Skip to content

Commit

Permalink
Added more error checking to GraphQL login
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCroftDKFZ committed Feb 14, 2025
1 parent fca1360 commit 9ffff6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>de.samply</groupId>
<artifactId>directory_sync_service</artifactId>
<version>1.5.11</version>
<version>1.5.12</version>
<name>directory_sync_service</name>
<description>Directory sync</description>
<url>https://github.com/samply/directory_sync_service</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,26 @@ public boolean login() {

String endpoint = directoryEndpointsGraphql.getLoginEndpoint();
JsonObject result = directoryCallsGraphql.runGraphqlCommand(endpoint, graphqlCommand);

if (result == null) {
logger.warn("login: result is null");
return false;
}

String token = result.get("signin").getAsJsonObject().get("token").getAsString();
JsonElement signin = result.get("signin");
if (signin == null) {
logger.warn("login: signin is null");
logger.warn("login: result: " + Util.jsonStringFomObject(result));
return false;
}

JsonElement tokenObject = signin.getAsJsonObject().get("token");
if (tokenObject == null) {
logger.warn("login: tokenObject is null");
logger.warn("login: signin: " + Util.jsonStringFomObject(signin));
return false;
}

String token = tokenObject.getAsString();
if (token == null) {
logger.warn("login: token is null");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public Patient extractPatientFromSpecimen(Specimen specimen) {
.replaceFirst("Patient/", ""))
.execute();
} catch (Exception e) {
logger.warn("extractPatientFromSpecimen: caught exception", Util.traceFromException(e));
logger.warn("extractPatientFromSpecimen: caught exception: " + Util.traceFromException(e));
}

return patient;
Expand Down

0 comments on commit 9ffff6d

Please sign in to comment.