Skip to content

Commit

Permalink
Issue #LR-676:feat added organisationId validation to ownership trans…
Browse files Browse the repository at this point in the history
…fer API
  • Loading branch information
BharathwajShankar committed Apr 8, 2024
1 parent 2dd227b commit aa7e890
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void onReceive(Request request) throws Throwable {
}

private void handleOwnershipTransfer(Request request) {
validateOrganizationId(request.getRequest());
validateUserDetails(request.getRequest(), request.getRequestContext());
String userId = (String) ((Map<String, Object>) request.getRequest().get(JsonKey.ACTION_BY))
.get(JsonKey.USER_ID);
Expand All @@ -48,6 +49,13 @@ private void handleOwnershipTransfer(Request request) {
sender().tell(response, self());
}

private void validateOrganizationId(Map<String, Object> requestData) {
if (!requestData.containsKey(JsonKey.ORGANISATION_ID) ||
StringUtils.isBlank((String) requestData.get(JsonKey.ORGANISATION_ID))) {
throwInvalidRequestDataException("Organization ID is mandatory in the request.");
}
}

private void validateUserDetails(Map<String, Object> data, RequestContext requestContext) {
validateAndProceed(data, JsonKey.ACTION_BY, requestContext);
validateAndProceed(data, JsonKey.FROM_USER, requestContext);
Expand Down

0 comments on commit aa7e890

Please sign in to comment.