From aa7e890af011f920857655d7bf6cacecef7375ed Mon Sep 17 00:00:00 2001 From: BharathwajShankar Date: Mon, 8 Apr 2024 17:45:13 +0530 Subject: [PATCH] Issue #LR-676:feat added organisationId validation to ownership transfer API --- .../sunbird/actor/user/UserOwnershipTransferActor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/src/main/java/org/sunbird/actor/user/UserOwnershipTransferActor.java b/service/src/main/java/org/sunbird/actor/user/UserOwnershipTransferActor.java index 93facffd2..686abebda 100644 --- a/service/src/main/java/org/sunbird/actor/user/UserOwnershipTransferActor.java +++ b/service/src/main/java/org/sunbird/actor/user/UserOwnershipTransferActor.java @@ -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) request.getRequest().get(JsonKey.ACTION_BY)) .get(JsonKey.USER_ID); @@ -48,6 +49,13 @@ private void handleOwnershipTransfer(Request request) { sender().tell(response, self()); } + private void validateOrganizationId(Map 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 data, RequestContext requestContext) { validateAndProceed(data, JsonKey.ACTION_BY, requestContext); validateAndProceed(data, JsonKey.FROM_USER, requestContext);