From 20c14a87dec18151a580afea0e1573a10ac143ef Mon Sep 17 00:00:00 2001 From: malithie Date: Sat, 27 Jul 2024 09:07:03 +0530 Subject: [PATCH] Address review comments. --- .../execution/ActionExecutorServiceImpl.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/components/action-mgt/org.wso2.carbon.identity.action.execution/src/main/java/org/wso2/carbon/identity/action/execution/ActionExecutorServiceImpl.java b/components/action-mgt/org.wso2.carbon.identity.action.execution/src/main/java/org/wso2/carbon/identity/action/execution/ActionExecutorServiceImpl.java index e43b449a215..6db6bf866ca 100644 --- a/components/action-mgt/org.wso2.carbon.identity.action.execution/src/main/java/org/wso2/carbon/identity/action/execution/ActionExecutorServiceImpl.java +++ b/components/action-mgt/org.wso2.carbon.identity.action.execution/src/main/java/org/wso2/carbon/identity/action/execution/ActionExecutorServiceImpl.java @@ -87,7 +87,7 @@ public ActionExecutionStatus execute(ActionType actionType, Map Action action = actions.get(0); // As of now only one action is allowed. return Optional.ofNullable(action) .filter(activeAction -> activeAction.getStatus() == Action.Status.ACTIVE) - .map(activeAction -> executeAction(actionType, activeAction, actionRequest, eventContext, + .map(activeAction -> executeAction(activeAction, actionRequest, eventContext, actionExecutionResponseProcessor)) .orElse(new ActionExecutionStatus(ActionExecutionStatus.Status.FAILURE, eventContext)); } catch (ActionExecutionRuntimeException e) { @@ -112,8 +112,12 @@ private List getActionsByActionType(ActionType actionType, String tenant private void validateActions(List actions, ActionType actionType) throws ActionExecutionException { if (CollectionUtils.isEmpty(actions)) { - throw new ActionExecutionRuntimeException("No actions found for action type: " + actionType); + if (LOG.isDebugEnabled()) { + LOG.debug("No actions found for action type: " + actionType); + } + return; } + if (actions.size() > 1) { // when multiple actions are supported for an action type the logic below needs to be improved such that, // a successful processing from one action becomes the input to the successor. @@ -148,7 +152,7 @@ private ActionExecutionResponseProcessor getResponseProcessor(ActionType actionT return responseProcessor; } - private ActionExecutionStatus executeAction(ActionType actionType, Action action, + private ActionExecutionStatus executeAction(Action action, ActionExecutionRequest actionRequest, Map eventContext, ActionExecutionResponseProcessor actionExecutionResponseProcessor) @@ -165,7 +169,7 @@ private ActionExecutionStatus executeAction(ActionType actionType, Action action ActionInvocationResponse actionInvocationResponse = executeActionAsynchronously(action, authenticationMethod, payload); - return processActionResponse(actionType, action, actionInvocationResponse, eventContext, actionRequest, + return processActionResponse(action, actionInvocationResponse, eventContext, actionRequest, actionExecutionResponseProcessor); } catch (ActionMgtException | JsonProcessingException | ActionExecutionResponseProcessorException e) { throw new ActionExecutionRuntimeException("Error occurred while executing action: " + action.getId(), e); @@ -201,7 +205,7 @@ private void logActionRequest(Action action, String payload) { } } - private ActionExecutionStatus processActionResponse(ActionType actionType, Action action, + private ActionExecutionStatus processActionResponse(Action action, ActionInvocationResponse actionInvocationResponse, Map eventContext, ActionExecutionRequest actionRequest, @@ -210,12 +214,11 @@ private ActionExecutionStatus processActionResponse(ActionType actionType, Actio throws ActionExecutionResponseProcessorException { if (actionInvocationResponse.isSuccess()) { - return processSuccessResponse(actionType, action, + return processSuccessResponse(action, (ActionInvocationSuccessResponse) actionInvocationResponse.getResponse(), eventContext, actionRequest, actionExecutionResponseProcessor); } else if (actionInvocationResponse.isError() && actionInvocationResponse.getResponse() != null) { - return processErrorResponse(actionType, action, - (ActionInvocationErrorResponse) actionInvocationResponse.getResponse(), + return processErrorResponse(action, (ActionInvocationErrorResponse) actionInvocationResponse.getResponse(), eventContext, actionRequest, actionExecutionResponseProcessor); } else { logErrorResponse(action, actionInvocationResponse); @@ -224,7 +227,7 @@ private ActionExecutionStatus processActionResponse(ActionType actionType, Actio return new ActionExecutionStatus(ActionExecutionStatus.Status.FAILURE, eventContext); } - private ActionExecutionStatus processSuccessResponse(ActionType actionType, Action action, + private ActionExecutionStatus processSuccessResponse(Action action, ActionInvocationSuccessResponse successResponse, Map eventContext, ActionExecutionRequest actionRequest, @@ -245,7 +248,7 @@ private ActionExecutionStatus processSuccessResponse(ActionType actionType, Acti actionRequest.getEvent(), successResponseBuilder.build()); } - private ActionExecutionStatus processErrorResponse(ActionType actionType, Action action, + private ActionExecutionStatus processErrorResponse(Action action, ActionInvocationErrorResponse errorResponse, Map eventContext, ActionExecutionRequest actionRequest,