diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExecuteActionMetaDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExecuteActionMetaDTO.java index 6684a618222c..4764bf9725d8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExecuteActionMetaDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExecuteActionMetaDTO.java @@ -1,5 +1,6 @@ package com.appsmith.server.dtos; +import com.appsmith.server.domains.Plugin; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -14,4 +15,5 @@ public class ExecuteActionMetaDTO { String environmentId; HttpHeaders headers; boolean operateWithoutPermission = false; + Plugin plugin; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 3c717e069713..16d63cd7188b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -97,6 +97,7 @@ import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_REQUEST_PARSING; import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_SERVER_EXECUTION; import static com.appsmith.external.helpers.DataTypeStringUtils.getDisplayDataTypes; +import static com.appsmith.server.constants.ce.FieldNameCE.NONE; import static com.appsmith.server.helpers.WidgetSuggestionHelper.getSuggestedWidgets; import static java.lang.Boolean.FALSE; import static java.lang.Boolean.TRUE; @@ -292,11 +293,38 @@ public Mono executeAction( .operateWithoutPermission(operateWithoutPermission) .environmentId(environmentId) .build(); - Mono executeActionDTOMono = createExecuteActionDTO(partFlux); - return executeActionDTOMono - .flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO)) - .name(ACTION_EXECUTION_SERVER_EXECUTION) - .tap(Micrometer.observation(observationRegistry)); + Mono executeActionDTOMono = + createExecuteActionDTO(partFlux).cache(); + Mono pluginMono = executeActionDTOMono.flatMap(executeActionDTO -> newActionService + .findById(executeActionDTO.getActionId()) + .flatMap(newAction -> { + if (newAction.getPluginId() == null + || newAction.getPluginId().isEmpty()) { + return Mono.empty(); + } else { + return pluginService.findById(newAction.getPluginId()); + } + }) + .cache()); + + return pluginMono + .map(plugin -> { + executeActionMetaDTO.setPlugin(plugin); + return plugin.getName() != null ? plugin.getName() : NONE; + }) + .defaultIfEmpty(NONE) + .flatMap(pluginName -> { + String name = (String) pluginName; + if (NONE.equals(name)) { + executeActionMetaDTO.setPlugin(null); + } + return executeActionDTOMono + .flatMap(executeActionDTO -> + populateAndExecuteAction(executeActionDTO, executeActionMetaDTO)) + .tag("plugin", name) + .name(ACTION_EXECUTION_SERVER_EXECUTION) + .tap(Micrometer.observation(observationRegistry)); + }); } /** @@ -322,7 +350,9 @@ public Mono executeAction( // 3. Instantiate the implementation class based on the query type Mono datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO); - Mono pluginMono = getCachedPluginForActionExecution(datasourceStorageMono); + Mono pluginMono = executeActionMetaDTO.getPlugin() != null + ? Mono.just(executeActionMetaDTO.getPlugin()) + : getCachedPluginForActionExecution(datasourceStorageMono); Mono pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono); // 4. Execute the query