Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.appsmith.server.dtos;

import com.appsmith.server.domains.Plugin;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -14,4 +15,5 @@ public class ExecuteActionMetaDTO {
String environmentId;
HttpHeaders headers;
boolean operateWithoutPermission = false;
Plugin plugin;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -292,11 +293,38 @@ public Mono<ActionExecutionResult> executeAction(
.operateWithoutPermission(operateWithoutPermission)
.environmentId(environmentId)
.build();
Mono<ExecuteActionDTO> executeActionDTOMono = createExecuteActionDTO(partFlux);
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.name(ACTION_EXECUTION_SERVER_EXECUTION)
.tap(Micrometer.observation(observationRegistry));
Mono<ExecuteActionDTO> executeActionDTOMono =
createExecuteActionDTO(partFlux).cache();
Mono<Plugin> 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));
});
}

/**
Expand All @@ -322,7 +350,9 @@ public Mono<ActionExecutionResult> executeAction(

// 3. Instantiate the implementation class based on the query type
Mono<DatasourceStorage> datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO);
Mono<Plugin> pluginMono = getCachedPluginForActionExecution(datasourceStorageMono);
Mono<Plugin> pluginMono = executeActionMetaDTO.getPlugin() != null
? Mono.just(executeActionMetaDTO.getPlugin())
: getCachedPluginForActionExecution(datasourceStorageMono);
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono);

// 4. Execute the query
Expand Down
Loading