From c806c3714b3f068524d5b858481e1eda7af7e5ba Mon Sep 17 00:00:00 2001 From: Will Simpson Date: Tue, 2 Jan 2024 16:54:42 +0000 Subject: [PATCH 1/2] Repurposed plain text status checks for the APIs into simple json check. --- .../api/memberV3/server/MemberV3ApiServiceImplV3_0.java | 8 +++++--- .../server/delegator/MemberV3ApiServiceDelegator.java | 2 +- .../delegator/impl/MemberV3ApiServiceDelegatorImpl.java | 5 +++-- .../src/main/resources/orcid-api-security-context.xml | 1 + .../main/java/org/orcid/core/manager/StatusManager.java | 2 ++ .../org/orcid/core/manager/impl/StatusManagerImpl.java | 7 +++++++ .../api/publicV3/server/PublicV3ApiServiceImplV3_0.java | 8 +++++--- .../server/delegator/PublicV3ApiServiceDelegator.java | 2 +- .../delegator/impl/PublicV3ApiServiceDelegatorImpl.java | 5 +++-- .../impl/PublicV3ApiServiceVersionedDelegatorImpl.java | 4 ++-- 10 files changed, 30 insertions(+), 14 deletions(-) diff --git a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/MemberV3ApiServiceImplV3_0.java b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/MemberV3ApiServiceImplV3_0.java index 5f87a3cabb1..7f0058de4e7 100644 --- a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/MemberV3ApiServiceImplV3_0.java +++ b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/MemberV3ApiServiceImplV3_0.java @@ -163,10 +163,12 @@ public Response viewSwaggerO2c() { * @return Plain text message indicating health of service */ @GET - @Produces(value = { MediaType.TEXT_PLAIN }) + @Produces(value = { MediaType.APPLICATION_JSON }) @Path(STATUS_PATH) - public Response viewStatusText() { - return serviceDelegator.viewStatusText(); + public Response viewStatusSimple() { + httpRequest.setAttribute("skipAccessLog", true); + httpRequest.setAttribute("isMonitoring", true); + return serviceDelegator.viewStatusSimple(); } @GET diff --git a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator.java b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator.java index 6eb75b2fa2f..a737daddc44 100644 --- a/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator.java +++ b/orcid-api-web/src/main/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator.java @@ -9,7 +9,7 @@ public interface MemberV3ApiServiceDelegator statusMap = statusManager.createStatusMapSimple(); + return Response.ok(statusMap).build(); } @Override diff --git a/orcid-api-web/src/main/resources/orcid-api-security-context.xml b/orcid-api-web/src/main/resources/orcid-api-security-context.xml index f591c40d24d..4b7e954309f 100644 --- a/orcid-api-web/src/main/resources/orcid-api-security-context.xml +++ b/orcid-api-web/src/main/resources/orcid-api-security-context.xml @@ -22,6 +22,7 @@ + diff --git a/orcid-core/src/main/java/org/orcid/core/manager/StatusManager.java b/orcid-core/src/main/java/org/orcid/core/manager/StatusManager.java index c6963b464e2..c5a4f1fef90 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/StatusManager.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/StatusManager.java @@ -15,5 +15,7 @@ public interface StatusManager { String TOMCAT_UP = "tomcatUp"; Map createStatusMap(); + + Map createStatusMapSimple(); } diff --git a/orcid-core/src/main/java/org/orcid/core/manager/impl/StatusManagerImpl.java b/orcid-core/src/main/java/org/orcid/core/manager/impl/StatusManagerImpl.java index 94b84be767e..f7898b9c925 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/impl/StatusManagerImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/impl/StatusManagerImpl.java @@ -41,6 +41,13 @@ public Map createStatusMap() { return result; } + @Override + public Map createStatusMapSimple() { + Map result = new LinkedHashMap<>(); + result.put(TOMCAT_UP, true); + return result; + } + private boolean isConnectionOk(MiscDao miscDao) { try { Date dbDate = miscDao.retrieveDatabaseDatetime(); diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java index 090606de574..1507919ad57 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/PublicV3ApiServiceImplV3_0.java @@ -128,10 +128,12 @@ public Response viewSwagger() { @GET - @Produces(value = { MediaType.TEXT_PLAIN }) + @Produces(value = { MediaType.APPLICATION_JSON }) @Path(STATUS_PATH) - public Response viewStatusText() { - return serviceDelegator.viewStatusText(); + public Response viewStatusSimple() { + httpRequest.setAttribute("skipAccessLog", true); + httpRequest.setAttribute("isMonitoring", true); + return serviceDelegator.viewStatusSimple(); } @GET diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java index 1cb65965e31..368107244b6 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/PublicV3ApiServiceDelegator.java @@ -14,7 +14,7 @@ public interface PublicV3ApiServiceDelegator statusMap = statusManager.createStatusMapSimple(); + return Response.ok(statusMap).build(); } @Override diff --git a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceVersionedDelegatorImpl.java b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceVersionedDelegatorImpl.java index 8ab83369285..96d5062bc89 100644 --- a/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceVersionedDelegatorImpl.java +++ b/orcid-pub-web/src/main/java/org/orcid/api/publicV3/server/delegator/impl/PublicV3ApiServiceVersionedDelegatorImpl.java @@ -38,8 +38,8 @@ public void setPublicV3ApiServiceDelegator( } @Override - public Response viewStatusText() { - return publicV3ApiServiceDelegator.viewStatusText(); + public Response viewStatusSimple() { + return publicV3ApiServiceDelegator.viewStatusSimple(); } @Override From 7cb41ffeb20b9758cf47e84913bf317bcbb39200 Mon Sep 17 00:00:00 2001 From: Will Simpson Date: Tue, 2 Jan 2024 17:11:56 +0000 Subject: [PATCH 2/2] Corrected white space. --- orcid-api-web/src/main/resources/orcid-api-security-context.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orcid-api-web/src/main/resources/orcid-api-security-context.xml b/orcid-api-web/src/main/resources/orcid-api-security-context.xml index 4b7e954309f..f9a141aeec8 100644 --- a/orcid-api-web/src/main/resources/orcid-api-security-context.xml +++ b/orcid-api-web/src/main/resources/orcid-api-security-context.xml @@ -22,7 +22,7 @@ - +