Skip to content

Commit

Permalink
Repurposed plain text status checks for the APIs into simple json check.
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrsimpson committed Jan 2, 2024
1 parent ad5a15f commit c806c37
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface MemberV3ApiServiceDelegator<DISTINCTION, EDUCATION, EMPLOYMENT,

static final String LATEST_V3_VERSION = "3.0";

Response viewStatusText();
Response viewStatusSimple();

Response viewStatus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ public void setFilterVersionOfIdentifiers(Boolean filterVersionOfIdentifiers) {
}

@Override
public Response viewStatusText() {
return Response.ok(STATUS_OK_MESSAGE).build();
public Response viewStatusSimple() {
Map<String, Boolean> statusMap = statusManager.createStatusMapSimple();
return Response.ok(statusMap).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<sec:http pattern="/v3**/o2c.html" security="none"/>

<!-- Status check -->
<sec:http pattern="/v*/status" security="none"/>
<sec:http pattern="/v*/apiStatus" security="none"/>

<!-- Authenticate the client before reaching the token endpoint -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public interface StatusManager {
String TOMCAT_UP = "tomcatUp";

Map<String, Boolean> createStatusMap();

Map<String, Boolean> createStatusMapSimple();

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public Map<String, Boolean> createStatusMap() {
return result;
}

@Override
public Map<String, Boolean> createStatusMapSimple() {
Map<String, Boolean> result = new LinkedHashMap<>();
result.put(TOMCAT_UP, true);
return result;
}

private boolean isConnectionOk(MiscDao miscDao) {
try {
Date dbDate = miscDao.retrieveDatabaseDatetime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface PublicV3ApiServiceDelegator<DISTINCTION, EDUCATION, EMPLOYMENT,

static final String LATEST_V3_VERSION = "3.0";

Response viewStatusText();
Response viewStatusSimple();

Response viewStatus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ public void setFilterVersionOfIdentifiers(Boolean filterVersionOfIdentifiers) {
}

@Override
public Response viewStatusText() {
return Response.ok(STATUS_OK_MESSAGE).build();
public Response viewStatusSimple() {
Map<String, Boolean> statusMap = statusManager.createStatusMapSimple();
return Response.ok(statusMap).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public void setPublicV3ApiServiceDelegator(
}

@Override
public Response viewStatusText() {
return publicV3ApiServiceDelegator.viewStatusText();
public Response viewStatusSimple() {
return publicV3ApiServiceDelegator.viewStatusSimple();
}

@Override
Expand Down

0 comments on commit c806c37

Please sign in to comment.