Skip to content

Commit

Permalink
Add new DefinedBy property to authenticator config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Sep 18, 2024
1 parent b7e7c8d commit 9e423ab
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,37 @@ public ActionExecutionStatus execute(ActionType actionType, Map<String, Object>
* 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<String, Object> eventContext,
public ActionExecutionStatus execute(ActionType actionType, String[] actionIdList, Map<String, Object> 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);
return new ActionExecutionStatus(ActionExecutionStatus.Status.FAILED, eventContext);
}
}

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<String, Object> eventContext)
throws ActionExecutionException {

Expand All @@ -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);
}
}

Expand Down

0 comments on commit 9e423ab

Please sign in to comment.