Skip to content

Commit

Permalink
made new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ApekshaBhosale committed Feb 24, 2025
1 parent e882245 commit 4d57634
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
import reactor.core.publisher.Mono;

@Data
@AllArgsConstructor
Expand All @@ -16,5 +15,5 @@ public class ExecuteActionMetaDTO {
String environmentId;
HttpHeaders headers;
boolean operateWithoutPermission = false;
Mono<Plugin> plugin;
Plugin plugin;
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,30 +287,21 @@ private Mono<ExecuteActionDTO> populateExecuteActionDTO(ExecuteActionDTO execute
@Override
public Mono<ActionExecutionResult> executeAction(
Flux<Part> partFlux, String environmentId, HttpHeaders httpHeaders, Boolean operateWithoutPermission) {

// Cache the multipart data so it can be reused
Mono<List<Part>> cachedPartsMono = partFlux.collectList().cache();

// Build the metadata DTO
ExecuteActionMetaDTO executeActionMetaDTO = ExecuteActionMetaDTO.builder()
.headers(httpHeaders)
.operateWithoutPermission(operateWithoutPermission)
.environmentId(environmentId)
.build();

// Derive ExecuteActionDTO from cached parts
Mono<ExecuteActionDTO> executeActionDTOMono =
cachedPartsMono.flatMap(parts -> createExecuteActionDTO(Flux.fromIterable(parts)));

// Fetch the plugin using the cached data
createExecuteActionDTO(partFlux).cache();
Mono<Plugin> pluginMono = executeActionDTOMono.flatMap(executeActionDTO -> newActionService
.findById(executeActionDTO.getActionId())
.flatMap(newAction -> pluginService.findById(newAction.getPluginId()))
.cache());
executeActionMetaDTO.setPlugin(pluginMono);
// Execute the action with both plugin name and parts

return pluginMono.flatMap(plugin -> {
String pluginName = plugin.getName();
executeActionMetaDTO.setPlugin(plugin);
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.tag("plugin", pluginName)
Expand Down Expand Up @@ -342,8 +333,7 @@ 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();
Mono<Plugin> pluginMono = Mono.just(executeActionMetaDTO.getPlugin());
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono);

// 4. Execute the query
Expand Down

0 comments on commit 4d57634

Please sign in to comment.