From 4c94bd049cc0071d06b999f0618a9cb84cd77b99 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 8 Jul 2024 15:52:01 -0400 Subject: [PATCH 01/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index e0896f30..87493e98 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,7 +181,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String body = getObject(key); JsonObject jsonObject = GSON.fromJson(body, JsonObject.class); - if (jsonObject.get("action").getAsString().equals("added") || jsonObject.get("action").getAsString().equals("removed")) { + if (jsonObject.get("action") != null) { //Instatllation and uninstallation events have action property InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); @@ -189,7 +189,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA logReadError(key); } - } else { + } else { //push events if (jsonObject.get("deleted").getAsBoolean()) { PushPayload payload = getGitHubPushPayloadByKey(body, key); if (payload != null) { From 857b7af6213f278b98bb5eecc36b5901c6be2b4b Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 10:31:40 -0400 Subject: [PATCH 02/25] changed if case --- .../githubdelivery/GithubDeliveryS3Client.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 87493e98..2d24593b 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -179,26 +179,26 @@ private void submitGitHubDeliveryEventsByHour(String prefix, WorkflowsApi workfl private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsApi) { String deliveryid = key.split("/")[2]; //since key is in YYYY-MM-DD/HH/deliveryid format try { - String body = getObject(key); - JsonObject jsonObject = GSON.fromJson(body, JsonObject.class); - if (jsonObject.get("action") != null) { //Instatllation and uninstallation events have action property - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); + String obj = getObject(key); + JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); + if (jsonObject.get("eventType").getAsString().equals("installation_repositories")) { + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { logReadError(key); } - } else { //push events + } else if (jsonObject.get("eventType").getAsString().equals("push")) { //push events if (jsonObject.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(body, key); + PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { logReadError(key); } } else { - PushPayload payload = getGitHubPushPayloadByKey(body, key); + PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); } else { @@ -206,6 +206,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } } } + else { + LOG.error("Invalid JSON format for event {}", key); + } LOG.info("Successfully submitted events for key {}", key); } catch (IOException e) { exceptionMessage(e, String.format("Could not submit github event from key %s", key), 1); From 020bd3373d89b7eff9a293899bd6761c4a565ee4 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 10:40:36 -0400 Subject: [PATCH 03/25] changed if case --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 2d24593b..4722f0ab 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -205,8 +205,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA logReadError(key); } } - } - else { + } else { LOG.error("Invalid JSON format for event {}", key); } LOG.info("Successfully submitted events for key {}", key); From 3f69b57a76dd1e5090908a21a9c3377c8cf966a1 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:26:31 -0400 Subject: [PATCH 04/25] fix --- .../dockstore/githubdelivery/GithubDeliveryS3Client.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 4722f0ab..732beb58 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,8 +181,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); + String body = jsonObject.get("body").getAsString(); if (jsonObject.get("eventType").getAsString().equals("installation_repositories")) { - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(jsonObject.get("body").getAsString(), key); + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { @@ -191,14 +192,14 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } else if (jsonObject.get("eventType").getAsString().equals("push")) { //push events if (jsonObject.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { logReadError(key); } } else { - PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); } else { From d0c8afaafc243295abd8676968094a8f17099c44 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:30:02 -0400 Subject: [PATCH 05/25] fix --- .../dockstore/githubdelivery/GithubDeliveryS3Client.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 732beb58..1fc3d330 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,8 +181,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); - String body = jsonObject.get("body").getAsString(); - if (jsonObject.get("eventType").getAsString().equals("installation_repositories")) { + String eventType = jsonObject.get("event_type").toString(); + String body = jsonObject.get("body").toString(); + if (eventType.equals("installation_repositories")) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); @@ -190,7 +191,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA logReadError(key); } - } else if (jsonObject.get("eventType").getAsString().equals("push")) { //push events + } else if (eventType.equals("push")) { //push events if (jsonObject.get("deleted").getAsBoolean()) { PushPayload payload = getGitHubPushPayloadByKey(body, key); if (payload != null) { From 72a6690ce19f2ba993f620153cb46f24692017cd Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:33:08 -0400 Subject: [PATCH 06/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 1fc3d330..6021c27a 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -183,7 +183,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); String eventType = jsonObject.get("event_type").toString(); String body = jsonObject.get("body").toString(); - if (eventType.equals("installation_repositories")) { + if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); @@ -191,7 +191,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA logReadError(key); } - } else if (eventType.equals("push")) { //push events + } else if ("push".equals(eventType)) { //push events if (jsonObject.get("deleted").getAsBoolean()) { PushPayload payload = getGitHubPushPayloadByKey(body, key); if (payload != null) { From b1e7d93c263cbdb88a7c74188f5babef34ed9dc0 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:35:43 -0400 Subject: [PATCH 07/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 6021c27a..35f07d88 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,7 +181,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); - String eventType = jsonObject.get("event_type").toString(); + String eventType = jsonObject.get("eventType").toString(); String body = jsonObject.get("body").toString(); if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); From 6d475d7fd2a28e37293c86c2443292eacf4efb0f Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:41:56 -0400 Subject: [PATCH 08/25] test --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 35f07d88..546302f3 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -183,6 +183,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); String eventType = jsonObject.get("eventType").toString(); String body = jsonObject.get("body").toString(); + System.out.println(eventType); if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); if (payload != null) { @@ -209,6 +210,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } } else { LOG.error("Invalid JSON format for event {}", key); + return; } LOG.info("Successfully submitted events for key {}", key); } catch (IOException e) { From 0a27c0966e88cc0c3dbab5e4d03555b6d603beab Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 15:48:07 -0400 Subject: [PATCH 09/25] test --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 546302f3..8eeae6d2 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,8 +181,8 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); - String eventType = jsonObject.get("eventType").toString(); - String body = jsonObject.get("body").toString(); + String eventType = jsonObject.get("eventType").getAsString(); + String body = jsonObject.get("body").getAsString(); System.out.println(eventType); if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); From 4d3105269a771053777ecdac66b561b2aa1c4ef0 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Thu, 11 Jul 2024 16:27:35 -0400 Subject: [PATCH 10/25] test --- .../githubdelivery/GithubDeliveryS3Client.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 8eeae6d2..83311aae 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,27 +181,24 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); - String eventType = jsonObject.get("eventType").getAsString(); - String body = jsonObject.get("body").getAsString(); - System.out.println(eventType); - if ("installation_repositories".equals(eventType)) { - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body, key); + if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { logReadError(key); } - } else if ("push".equals(eventType)) { //push events + } else if ("push".equals(jsonObject.get("eventType").getAsString())) { //push events if (jsonObject.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(body, key); + PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { logReadError(key); } } else { - PushPayload payload = getGitHubPushPayloadByKey(body, key); + PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); } else { From 65b555fe01c79d41833d2cd9765c71f08de96637 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 13:21:16 -0400 Subject: [PATCH 11/25] test --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 83311aae..7e7524c6 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.dockstore.common.S3ClientHelper; @@ -189,8 +190,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA logReadError(key); } - } else if ("push".equals(jsonObject.get("eventType").getAsString())) { //push events - if (jsonObject.get("deleted").getAsBoolean()) { + } else if ("push".equals(jsonObject.get("eventType").getAsString())) { + JsonObject body = jsonObject.get("body").getAsJsonObject(); //push events + if (body.get("deleted").getAsBoolean()) { PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); From dda46b7f5f61df73b5d76c8cbc3cf3ec891b1198 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 13:22:44 -0400 Subject: [PATCH 12/25] test --- .../java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 1 - 1 file changed, 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 7e7524c6..d9e78aca 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -28,7 +28,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.dockstore.common.S3ClientHelper; From a9cd5109cc4b4ece4e78254b5fadddca187ff7f9 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 13:38:35 -0400 Subject: [PATCH 13/25] test --- .../dockstore/githubdelivery/GithubDeliveryS3Client.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index d9e78aca..9992e691 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -181,8 +181,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA try { String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); + JsonObject body = jsonObject.get("body").getAsJsonObject(); if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(jsonObject.get("body").getAsString(), key); + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body.getAsString(), key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { @@ -190,16 +191,16 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } } else if ("push".equals(jsonObject.get("eventType").getAsString())) { - JsonObject body = jsonObject.get("body").getAsJsonObject(); //push events + //push events if (body.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(body.getAsString(), key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { logReadError(key); } } else { - PushPayload payload = getGitHubPushPayloadByKey(jsonObject.get("body").getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(body.getAsString(), key); if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); } else { From e28663fcb5c0a6f9181709e8aa32c6752d0fcd11 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 13:40:04 -0400 Subject: [PATCH 14/25] test --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 9992e691..f027c4cb 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -191,7 +191,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } } else if ("push".equals(jsonObject.get("eventType").getAsString())) { - //push events + //push events if (body.get("deleted").getAsBoolean()) { PushPayload payload = getGitHubPushPayloadByKey(body.getAsString(), key); if (payload != null) { From 3164279e476fba4d3a64b470581b92c7e486ce47 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 13:44:01 -0400 Subject: [PATCH 15/25] test --- .../dockstore/githubdelivery/GithubDeliveryS3Client.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index f027c4cb..01c089a7 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,8 +182,9 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); + String bodyString = jsonObject.get("body").getAsString(); if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(body.getAsString(), key); + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { @@ -193,14 +194,14 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } else if ("push".equals(jsonObject.get("eventType").getAsString())) { //push events if (body.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(body.getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); if (payload != null) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { logReadError(key); } } else { - PushPayload payload = getGitHubPushPayloadByKey(body.getAsString(), key); + PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); } else { From ff634c8a8ed28c8525e6ac609045358c5652cd18 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:22:05 -0400 Subject: [PATCH 16/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 01c089a7..6ec989c9 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,7 +182,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = jsonObject.get("body").getAsString(); + String bodyString = body.toString().substring(1, body.toString().length()-1); //removes the quotes that gets added with the toString method if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { From 3f62bda80cf17347175821807abcc0a279dc1164 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:27:15 -0400 Subject: [PATCH 17/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 6ec989c9..fabafad1 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,7 +182,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = body.toString().substring(1, body.toString().length()-1); //removes the quotes that gets added with the toString method + String bodyString = body.toString().substring(1, body.toString().length() - 1); //removes the quotes that gets added with the toString method if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { From 20c595501dadd2d39ffc29d84be974503f9a27e2 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:31:14 -0400 Subject: [PATCH 18/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index fabafad1..87dcf93b 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,7 +182,8 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = body.toString().substring(1, body.toString().length() - 1); //removes the quotes that gets added with the toString method + String bodyString = body.toString().substring(1, body.toString().length() - 1); + System.out.println(bodyString);//removes the quotes that gets added with the toString method if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { From 20645ab720f502e600ce11e35475432c79d3749e Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:32:18 -0400 Subject: [PATCH 19/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 87dcf93b..5b967428 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,8 +182,8 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = body.toString().substring(1, body.toString().length() - 1); - System.out.println(bodyString);//removes the quotes that gets added with the toString method + String bodyString = body.toString().substring(1, body.toString().length() - 1); //removes the quotes that gets added with the toString method + System.out.println(bodyString); if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { From 059f3b764d57b2d5a16ba9c669e9c12162d2b509 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:36:00 -0400 Subject: [PATCH 20/25] fix --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 5b967428..af1ae084 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,7 +182,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = body.toString().substring(1, body.toString().length() - 1); //removes the quotes that gets added with the toString method + String bodyString = body.toString(); //removes the quotes that gets added with the toString method System.out.println(bodyString); if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); From 4696bb57859c924b44527472d3c95bb7904de590 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Mon, 15 Jul 2024 14:39:24 -0400 Subject: [PATCH 21/25] remove println --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index af1ae084..3a74f3f6 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -182,8 +182,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String obj = getObject(key); JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); - String bodyString = body.toString(); //removes the quotes that gets added with the toString method - System.out.println(bodyString); + String bodyString = body.toString(); if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { From bc47419f6898c7d2a39026432b0a7a1fe36f6a83 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Tue, 16 Jul 2024 14:36:02 -0400 Subject: [PATCH 22/25] review feedback --- .../GithubDeliveryS3Client.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 3a74f3f6..e07d4dde 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -179,37 +179,34 @@ private void submitGitHubDeliveryEventsByHour(String prefix, WorkflowsApi workfl private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsApi) { String deliveryid = key.split("/")[2]; //since key is in YYYY-MM-DD/HH/deliveryid format try { - String obj = getObject(key); - JsonObject jsonObject = GSON.fromJson(obj, JsonObject.class); + String s3GithubObject = getObject(key); + JsonObject jsonObject = GSON.fromJson(s3GithubObject, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); String bodyString = body.toString(); - if ("installation_repositories".equals(jsonObject.get("eventType").getAsString())) { + String eventType = jsonObject.get("event_type").getAsString(); + if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { - logReadError(key); + logReadError(eventType, key); } - } else if ("push".equals(jsonObject.get("eventType").getAsString())) { + } else if ("push".equals(eventType)) { //push events - if (body.get("deleted").getAsBoolean()) { - PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); - if (payload != null) { + PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); + if (payload != null) { + if (body.get("deleted").getAsBoolean()) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); } else { - logReadError(key); - } - } else { - PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); - if (payload != null) { workflowsApi.handleGitHubRelease(payload, deliveryid); - } else { - logReadError(key); } + } else { + logReadError(eventType, key); } + } else { - LOG.error("Invalid JSON format for event {}", key); + LOG.error("Invalid eventType {} format for key {}", eventType, key); return; } LOG.info("Successfully submitted events for key {}", key); @@ -219,7 +216,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA LOG.error("Could not submit github event from key {}", key, e); } } - private void logReadError(String key) { - LOG.error("Could not read github event from key {}", key); + private void logReadError(String eventType, String key) { + LOG.error("Could not read github {} event from key {}", eventType, key); } } From 2d56295250510232cf5596278072080d2a5b2c7a Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Tue, 16 Jul 2024 14:58:35 -0400 Subject: [PATCH 23/25] review feedback --- .../githubdelivery/GithubDeliveryS3Client.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index e07d4dde..33704111 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -124,26 +124,26 @@ private String getObject(String key) throws IOException { ResponseInputStream object = s3Client.getObject(objectRequest); return IOUtils.toString(object, StandardCharsets.UTF_8); } - private PushPayload getGitHubPushPayloadByKey(String body, String key) throws IOException, NoSuchKeyException { + private PushPayload getGitHubPushPayloadByKey(String eventType, String body, String key) throws IOException, NoSuchKeyException { try { PushPayload pushPayload; pushPayload = MAPPER.readValue(body, PushPayload.class); if (pushPayload == null) { - logReadError(key); + logReadError(eventType, key); } return pushPayload; } catch (JsonSyntaxException e) { - exceptionMessage(e, String.format("Could not read github event from key %s", key), 1); + exceptionReadError(e, eventType, key); } return null; } - private InstallationRepositoriesPayload getGitHubInstallationRepositoriesPayloadByKey(String body, String key) throws IOException, NoSuchKeyException { + private InstallationRepositoriesPayload getGitHubInstallationRepositoriesPayloadByKey(String eventType, String body, String key) throws IOException, NoSuchKeyException { try { InstallationRepositoriesPayload installationRepositoriesPayload; installationRepositoriesPayload = MAPPER.readValue(body, InstallationRepositoriesPayload.class); return installationRepositoriesPayload; } catch (JsonSyntaxException e) { - exceptionMessage(e, String.format("Could not read github event from key %s", key), 1); + exceptionReadError(e, eventType, key); } return null; } @@ -185,7 +185,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA String bodyString = body.toString(); String eventType = jsonObject.get("event_type").getAsString(); if ("installation_repositories".equals(eventType)) { - InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(bodyString, key); + InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(eventType, bodyString, key); if (payload != null) { workflowsApi.handleGitHubInstallation(payload, deliveryid); } else { @@ -194,7 +194,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA } else if ("push".equals(eventType)) { //push events - PushPayload payload = getGitHubPushPayloadByKey(bodyString, key); + PushPayload payload = getGitHubPushPayloadByKey(eventType, bodyString, key); if (payload != null) { if (body.get("deleted").getAsBoolean()) { workflowsApi.handleGitHubBranchDeletion(payload.getRepository().getFullName(), payload.getSender().getLogin(), payload.getRef(), deliveryid, payload.getInstallation().getId()); @@ -219,4 +219,8 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA private void logReadError(String eventType, String key) { LOG.error("Could not read github {} event from key {}", eventType, key); } + private void exceptionReadError(Exception e, String eventType, String key) { + exceptionMessage(e, String.format("Could not read github %s event from key %s", eventType, key), 1); + + } } From a34cc5ee50ce349395665d4f9d406fb16b0c0d0b Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Tue, 16 Jul 2024 14:58:42 -0400 Subject: [PATCH 24/25] review feedback --- .../java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 1 - 1 file changed, 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index 33704111..ac64c8bb 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -221,6 +221,5 @@ private void logReadError(String eventType, String key) { } private void exceptionReadError(Exception e, String eventType, String key) { exceptionMessage(e, String.format("Could not read github %s event from key %s", eventType, key), 1); - } } From 75b96ba127cc578d7b1c6ff3cb413e9d6762398b Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Tue, 16 Jul 2024 15:02:11 -0400 Subject: [PATCH 25/25] review feedback --- .../io/dockstore/githubdelivery/GithubDeliveryS3Client.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java index ac64c8bb..0929249f 100644 --- a/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java +++ b/githubdelivery/src/main/java/io/dockstore/githubdelivery/GithubDeliveryS3Client.java @@ -183,7 +183,7 @@ private void submitGitHubDeliveryEventsByKey(String key, WorkflowsApi workflowsA JsonObject jsonObject = GSON.fromJson(s3GithubObject, JsonObject.class); JsonObject body = jsonObject.get("body").getAsJsonObject(); String bodyString = body.toString(); - String eventType = jsonObject.get("event_type").getAsString(); + String eventType = jsonObject.get("eventType").getAsString(); if ("installation_repositories".equals(eventType)) { InstallationRepositoriesPayload payload = getGitHubInstallationRepositoriesPayloadByKey(eventType, bodyString, key); if (payload != null) {