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 fade0699600b..cd7625dc464b 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 @@ -113,20 +113,18 @@ public ActionExecutionStatus execute(ActionType actionType, Map * Resolve the actions by given the action id list and execute them. * * @param actionType Action Type. - * @param actionIds Lis of action Ids of the actions that need to be executed. + * @param actionIdList Lis of action Ids of the actions that need to be executed. * @param eventContext The event context of the corresponding flow. * @param tenantDomain Tenant domain. * @return Action execution status. */ - public ActionExecutionStatus execute(ActionType actionType, String[] actionIds, Map eventContext, + public ActionExecutionStatus execute(ActionType actionType, String[] actionIdList, Map eventContext, String tenantDomain) throws ActionExecutionException { + validateActionIdList(actionType, actionIdList); + Action action = getActionByActionId(actionType, actionIdList[0], tenantDomain); try { - // As of now only one action is allowed. - if (actionIds.length != 1) { - throw new ActionExecutionException("Only support list with single action Id."); - } - return execute(getActionByActionId(actionType, actionIds[0], tenantDomain), eventContext); + return execute(action, eventContext); } catch (ActionExecutionRuntimeException e) { // todo: add to diagnostics LOG.debug("Skip executing actions for action type: " + actionType.name(), e); @@ -134,6 +132,18 @@ public ActionExecutionStatus execute(ActionType actionType, String[] actionIds, } } + private void validateActionIdList(ActionType actionType, String[] actionIdList) throws ActionExecutionException { + + // As of now only one action is allowed. + if (actionIdList == null || actionIdList.length == 0) { + throw new ActionExecutionException("No action Ids found for action type: " + actionType.name()); + } + if (actionIdList.length > 1) { + throw new ActionExecutionException("Multiple actions found for action type: " + actionType.name() + + ". Current implementation doesn't support multiple actions for a single action type."); + } + } + private ActionExecutionStatus execute(Action action, Map eventContext) throws ActionExecutionException { @@ -155,7 +165,7 @@ private Action getActionByActionId(ActionType actionType, String actionId, Strin return ActionExecutionServiceComponentHolder.getInstance().getActionManagementService().getActionByActionId( Action.ActionTypes.valueOf(actionType.name()).getActionType(), actionId, tenantDomain); } catch (ActionMgtException e) { - throw new ActionExecutionRuntimeException("Error occurred while retrieving action by action Id .", e); + throw new ActionExecutionRuntimeException("Error occurred while retrieving action by action Id.", e); } }