Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDGPATRON-160 - Updated raml pieces #139

Merged
merged 18 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9b6a4e9
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
7f367e8
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
6c8b93d
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
95108ac
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
42dfc7e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
8ee0678
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
0f22b74
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
57bea13
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
9e9d293
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
8e4a27e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
4fc663b
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
da0a17e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
ac69dec
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 19, 2024
b8ada70
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
0c6b0bb
Merge branch 'master' into EDGPATRON-160
gurleenkaurbp Dec 20, 2024
461b120
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
4c5e82c
Merge remote-tracking branch 'origin/EDGPATRON-160' into EDGPATRON-160
gurleenkaurbp Dec 20, 2024
b325745
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp committed Dec 18, 2024
commit 57bea138fb8566dba281b8f766d03ea6cef766e5
29 changes: 28 additions & 1 deletion src/main/java/org/folio/edge/patron/PatronHandler.java
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ public void handlePostPatronRequest(RoutingContext ctx) {
public void handlePutPatronRequest(RoutingContext ctx) {
handlePatronRequest(ctx, (patronClient, body) ->
patronClient.putPatron(ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID), body,
resp -> handleProxyResponse(ctx, resp),
resp -> handlePutPatronResponse(ctx, resp),
t -> handleProxyException(ctx, t)));
}

@@ -422,6 +422,33 @@ protected void handleRegistrationStatusResponse(RoutingContext ctx, HttpResponse
}
}

protected void handlePutPatronResponse(RoutingContext ctx, HttpResponse<Buffer> resp) {
HttpServerResponse serverResponse = ctx.response();

int statusCode = resp.statusCode();
serverResponse.setStatusCode(statusCode);

String respBody = resp.bodyAsString();
if (logger.isDebugEnabled() ) {
logger.debug("handlePutPatronResponse:: response {} ", respBody);
}

String contentType = resp.getHeader(HttpHeaders.CONTENT_TYPE.toString());

if (resp.statusCode() < 400 && Objects.nonNull(respBody)){
setContentType(serverResponse, contentType);
serverResponse.end(respBody); //not an error case, pass on the response body as received
}
else {
String errorMsg = (statusCode == 404 || statusCode == 400)
? getFormattedErrorMsg(statusCode, respBody)
: getErrorMessage(statusCode, respBody);
setContentType(serverResponse, APPLICATION_JSON);
serverResponse.end(errorMsg);
}
}


@Override
protected void handleProxyException(RoutingContext ctx, Throwable t) {
logger.error("Exception retrieving data from mod-patron:", t);