Skip to content

Commit

Permalink
add log warning's for IM_A_TEAPOT http responses (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
w-hayes authored Mar 13, 2024
1 parent 2109005 commit b5183ea
Show file tree
Hide file tree
Showing 6 changed files with 514 additions and 317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ private Route routeLoginWithKeycloakRequest(final CheckHeader<UserSession> check
return complete(StatusCodes.FORBIDDEN);
}
} else {
return complete(StatusCodes.IM_A_TEAPOT);
LOGGER.warn("IM_A_TEAPOT");
return complete(GlobalConstants.IM_A_TEA_POT);
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,28 @@ private CompletionStage<HttpResponse> getMU() {
}

private Route onNotificationResolution(
final ActorSystem<Void> actorSystem,
final ActorRef<BackEnd.Event> backEnd) {
final ActorSystem<Void> actorSystem,
final ActorRef<BackEnd.Event> backEnd) {
return entity(Jackson.unmarshaller(NotificationResolutionProcessorData.class),
obj -> onComplete(BackEnd.askOnNotificationResolution(actorSystem, backEnd, obj), response -> {
if (response.isSuccess() && Boolean.TRUE.equals(response.get().updated())) {
return complete(StatusCodes.OK);
} else {
return complete(StatusCodes.IM_A_TEAPOT);
}
}));
obj -> onComplete(BackEnd.askOnNotificationResolution(actorSystem, backEnd, obj), response -> {
if (response.isSuccess() && Boolean.TRUE.equals(response.get().updated())) {
return complete(StatusCodes.OK);
} else {
LOGGER.warn("IM_A_TEAPOT");
return complete(GlobalConstants.IM_A_TEA_POT);
}
}));
}

private Route routeDashboardData(
final ActorSystem<Void> actorSystem,
final ActorRef<BackEnd.Event> backEnd) {
final ActorSystem<Void> actorSystem,
final ActorRef<BackEnd.Event> backEnd) {
return onComplete(BackEnd.askGetDashboardData(actorSystem, backEnd), response -> {
if (response.isSuccess()) {
return complete(StatusCodes.OK, response.get(), Jackson.marshaller());
} else {
return complete(StatusCodes.IM_A_TEAPOT);
LOGGER.warn("IM_A_TEAPOT");
return complete(GlobalConstants.IM_A_TEA_POT);
}
});
}
Expand All @@ -105,12 +107,18 @@ private Route routeLinkInteraction() {
try {
LOGGER.debug("{}", obj);
return onComplete(postLinkInteraction(obj),
response -> response.isSuccess()
? complete(response.get())
: complete(StatusCodes.IM_A_TEAPOT));
response -> {
if (!response.isSuccess()) {
LOGGER.warn("IM_A_TEAPOT");
}
return response.isSuccess()
? complete(response.get())
: complete(GlobalConstants.IM_A_TEA_POT);
});
} catch (JsonProcessingException e) {
LOGGER.warn("IM_A_TEAPOT");
LOGGER.error(e.getLocalizedMessage(), e);
return complete(StatusCodes.IM_A_TEAPOT);
return complete(GlobalConstants.IM_A_TEA_POT);
}
});
}
Expand All @@ -119,21 +127,32 @@ private Route routeLinkInteractionToGid() {
return entity(Jackson.unmarshaller(ApiModels.LinkInteractionToGidSyncBody.class), obj -> {
try {
return onComplete(postLinkInteractionToGid(obj),
response -> response.isSuccess()
? complete(response.get())
: complete(ApiModels.getHttpErrorResponse(StatusCodes.IM_A_TEAPOT)));
response -> {
if (!response.isSuccess()) {
LOGGER.warn("IM_A_TEAPOT");
}
return response.isSuccess()
? complete(response.get())
: complete(ApiModels.getHttpErrorResponse(GlobalConstants.IM_A_TEA_POT));
});
} catch (JsonProcessingException e) {
LOGGER.error(e.getLocalizedMessage(), e);
}
return complete(ApiModels.getHttpErrorResponse(StatusCodes.IM_A_TEAPOT));
LOGGER.warn("IM_A_TEAPOT");
return complete(ApiModels.getHttpErrorResponse(GlobalConstants.IM_A_TEA_POT));
});
}

private Route routeMU() {
return onComplete(getMU(),
response -> response.isSuccess()
? complete(response.get())
: complete(StatusCodes.IM_A_TEAPOT));
response -> {
if (!response.isSuccess()) {
LOGGER.warn("IM_A_TEAPOT");
}
return response.isSuccess()
? complete(response.get())
: complete(GlobalConstants.IM_A_TEA_POT);
});
}

private Route createRoute(
Expand All @@ -144,11 +163,11 @@ private Route createRoute(
this::routeLinkInteraction),
path(GlobalConstants.SEGMENT_PROXY_POST_LINK_INTERACTION_TO_GID,
this::routeLinkInteractionToGid),
path(GlobalConstants.SEGMENT_PROXY_ON_NOTIFICATION_RESOLUTION,
() -> onNotificationResolution(actorSystem, backEnd)))),
path(GlobalConstants.SEGMENT_PROXY_ON_NOTIFICATION_RESOLUTION,
() -> onNotificationResolution(actorSystem, backEnd)))),
get(() -> concat(path("mu", this::routeMU),
path(GlobalConstants.SEGMENT_PROXY_GET_DASHBOARD_DATA,
() -> routeDashboardData(actorSystem, backEnd))
() -> routeDashboardData(actorSystem, backEnd))
))));
}

Expand Down
Loading

0 comments on commit b5183ea

Please sign in to comment.