From be9e7dfc918398a2f3d0211388e6e830c61131a7 Mon Sep 17 00:00:00 2001
From: DavidCroftDKFZ <46788708+DavidCroftDKFZ@users.noreply.github.com>
Date: Mon, 18 Nov 2024 11:51:34 +0100
Subject: [PATCH] Added diagnostics to cover potential problems when using
GraphQL
---
pom.xml | 2 +-
.../directory_sync_service/directory/DirectoryCalls.java | 2 ++
...ergeDirectoryCollectionGetToDirectoryCollectionPut.java | 2 +-
.../directory/graphql/DirectoryCallsGraphql.java | 7 +++++++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index a97e4b1..cd48b43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
de.samply
directory_sync_service
- 1.5.4
+ 1.5.5
directory_sync_service
Directory sync
https://github.com/samply/directory_sync_service
diff --git a/src/main/java/de/samply/directory_sync_service/directory/DirectoryCalls.java b/src/main/java/de/samply/directory_sync_service/directory/DirectoryCalls.java
index c47a500..b3cda34 100644
--- a/src/main/java/de/samply/directory_sync_service/directory/DirectoryCalls.java
+++ b/src/main/java/de/samply/directory_sync_service/directory/DirectoryCalls.java
@@ -88,7 +88,9 @@ public boolean endpointExists(String endpoint) {
protected String executeRequest(HttpUriRequest request) {
String result = null;
try {
+ logger.debug("executeRequest: execute request" );
CloseableHttpResponse response = httpClient.execute(request);
+ logger.debug("executeRequest: request executed" );
if (response.getStatusLine().getStatusCode() < 300) {
HttpEntity httpEntity = response.getEntity();
if (httpEntity == null)
diff --git a/src/main/java/de/samply/directory_sync_service/directory/MergeDirectoryCollectionGetToDirectoryCollectionPut.java b/src/main/java/de/samply/directory_sync_service/directory/MergeDirectoryCollectionGetToDirectoryCollectionPut.java
index e4e1b97..9c5aaf3 100644
--- a/src/main/java/de/samply/directory_sync_service/directory/MergeDirectoryCollectionGetToDirectoryCollectionPut.java
+++ b/src/main/java/de/samply/directory_sync_service/directory/MergeDirectoryCollectionGetToDirectoryCollectionPut.java
@@ -53,7 +53,7 @@ public static boolean merge(DirectoryCollectionGet directoryCollectionGet, Direc
* @return The DirectoryCollectionPut object with merged data, or null if an exception occurs.
*/
private static DirectoryCollectionPut merge(String collectionId, DirectoryCollectionGet directoryCollectionGet, DirectoryCollectionPut directoryCollectionPut) {
- logger.info("Merging DirectoryCollectionGet into DirectoryCollectionPut for collectionId: " + collectionId);
+ logger.debug("Merging DirectoryCollectionGet into DirectoryCollectionPut for collectionId: " + collectionId);
try {
directoryCollectionPut.setName(collectionId, directoryCollectionGet.getName(collectionId));
directoryCollectionPut.setDescription(collectionId, directoryCollectionGet.getDescription(collectionId));
diff --git a/src/main/java/de/samply/directory_sync_service/directory/graphql/DirectoryCallsGraphql.java b/src/main/java/de/samply/directory_sync_service/directory/graphql/DirectoryCallsGraphql.java
index b69e79e..00310b0 100644
--- a/src/main/java/de/samply/directory_sync_service/directory/graphql/DirectoryCallsGraphql.java
+++ b/src/main/java/de/samply/directory_sync_service/directory/graphql/DirectoryCallsGraphql.java
@@ -49,7 +49,9 @@ public boolean endpointIsValidGraphql(String endpoint) {
logger.debug("endpointIsValidGraphql: url: " + url);
HttpGet request = new HttpGet(url);
+ logger.debug("endpointIsValidGraphql: execute request");
String response = executeRequest(request);
+ logger.debug("endpointIsValidGraphql: finished executing request");
if (response == null) {
logger.warn("endpointIsValidGraphql: HTTP response is null");
return false;
@@ -57,12 +59,15 @@ public boolean endpointIsValidGraphql(String endpoint) {
try {
// Use gson to turn the response into a JSON object
+ logger.debug("endpointIsValidGraphql: turn response into JSON");
JsonObject jsonResponse = gson.fromJson(response, JsonObject.class);
if (jsonResponse == null) {
logger.warn("endpointIsValidGraphql: jsonResponse is null");
return false;
}
+ logger.debug("endpointIsValidGraphql: check response for error");
+
// Check if the response contains an error
if (jsonResponse.has("errors")) {
logger.warn("endpointIsValidGraphql: jsonResponse has the following errors:");
@@ -77,6 +82,8 @@ public boolean endpointIsValidGraphql(String endpoint) {
return false;
}
+ logger.debug("endpointIsValidGraphql: all good, returning true");
+
return true;
}