-
Notifications
You must be signed in to change notification settings - Fork 4.5k
base changes to populate system info to executeActionDTO #37091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4955c00
79849be
6f02386
2f5ab4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.appsmith.server.helpers; | ||
|
|
||
| import com.appsmith.server.helpers.ce.ActionExecutionSolutionHelperCE; | ||
|
|
||
| public interface ActionExecutionSolutionHelper extends ActionExecutionSolutionHelperCE {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.appsmith.server.helpers; | ||
|
|
||
| import com.appsmith.server.helpers.ce.ActionExecutionSolutionHelperCEImpl; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class ActionExecutionSolutionHelperImpl extends ActionExecutionSolutionHelperCEImpl | ||
| implements ActionExecutionSolutionHelper {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.appsmith.server.helpers.ce; | ||
|
|
||
| import com.appsmith.external.dtos.ExecuteActionDTO; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| public interface ActionExecutionSolutionHelperCE { | ||
| Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.appsmith.server.helpers.ce; | ||
|
|
||
| import com.appsmith.external.dtos.ExecuteActionDTO; | ||
| import org.springframework.stereotype.Component; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| @Component | ||
| public class ActionExecutionSolutionHelperCEImpl implements ActionExecutionSolutionHelperCE { | ||
| @Override | ||
| public Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO) { | ||
| return Mono.just(executeActionDTO); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| import com.appsmith.server.dtos.ExecuteActionMetaDTO; | ||
| import com.appsmith.server.exceptions.AppsmithError; | ||
| import com.appsmith.server.exceptions.AppsmithException; | ||
| import com.appsmith.server.helpers.ActionExecutionSolutionHelper; | ||
| import com.appsmith.server.helpers.DatasourceAnalyticsUtils; | ||
| import com.appsmith.server.helpers.DateUtils; | ||
| import com.appsmith.server.helpers.PluginExecutorHelper; | ||
|
|
@@ -119,6 +120,7 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE | |
| private final EnvironmentPermission environmentPermission; | ||
| private final ConfigService configService; | ||
| private final TenantService tenantService; | ||
| private final ActionExecutionSolutionHelper actionExecutionSolutionHelper; | ||
| private final CommonConfig commonConfig; | ||
|
|
||
| static final String PARAM_KEY_REGEX = "^k\\d+$"; | ||
|
|
@@ -147,7 +149,8 @@ public ActionExecutionSolutionCEImpl( | |
| EnvironmentPermission environmentPermission, | ||
| ConfigService configService, | ||
| TenantService tenantService, | ||
| CommonConfig commonConfig) { | ||
| CommonConfig commonConfig, | ||
| ActionExecutionSolutionHelper actionExecutionSolutionHelper) { | ||
| this.newActionService = newActionService; | ||
| this.actionPermission = actionPermission; | ||
| this.observationRegistry = observationRegistry; | ||
|
|
@@ -167,6 +170,7 @@ public ActionExecutionSolutionCEImpl( | |
| this.configService = configService; | ||
| this.tenantService = tenantService; | ||
| this.commonConfig = commonConfig; | ||
| this.actionExecutionSolutionHelper = actionExecutionSolutionHelper; | ||
|
|
||
| this.patternList.add(Pattern.compile(PARAM_KEY_REGEX)); | ||
| this.patternList.add(Pattern.compile(BLOB_KEY_REGEX)); | ||
|
|
@@ -245,15 +249,29 @@ private Mono<ExecuteActionDTO> populateExecuteActionDTO(ExecuteActionDTO execute | |
| Mono<String> instanceIdMono = configService.getInstanceId(); | ||
| Mono<String> defaultTenantIdMono = tenantService.getDefaultTenantId(); | ||
|
|
||
| return Mono.zip(instanceIdMono, defaultTenantIdMono).map(tuple -> { | ||
| String instanceId = tuple.getT1(); | ||
| String tenantId = tuple.getT2(); | ||
| executeActionDTO.setActionId(newAction.getId()); | ||
| executeActionDTO.setWorkspaceId(newAction.getWorkspaceId()); | ||
| executeActionDTO.setInstanceId(instanceId); | ||
| executeActionDTO.setTenantId(tenantId); | ||
| return executeActionDTO; | ||
| }); | ||
| Mono<ExecuteActionDTO> systemInfoPopulatedExecuteActionDTOMono = | ||
| actionExecutionSolutionHelper.populateExecuteActionDTOWithSystemInfo(executeActionDTO); | ||
|
|
||
| return systemInfoPopulatedExecuteActionDTOMono.flatMap( | ||
| populatedExecuteActionDTO -> Mono.zip(instanceIdMono, defaultTenantIdMono) | ||
| .map(tuple -> { | ||
| String instanceId = tuple.getT1(); | ||
| String tenantId = tuple.getT2(); | ||
| populatedExecuteActionDTO.setActionId(newAction.getId()); | ||
| populatedExecuteActionDTO.setWorkspaceId(newAction.getWorkspaceId()); | ||
| populatedExecuteActionDTO.setInstanceId(instanceId); | ||
| populatedExecuteActionDTO.setTenantId(tenantId); | ||
| return populatedExecuteActionDTO; | ||
| })); | ||
| } | ||
|
|
||
| /** | ||
| * Populates the requestParams with logged in userId. | ||
| * If the user is not logged in, set the parameter as anonymousUserId | ||
| * | ||
| */ | ||
| protected Mono<ExecuteActionDTO> populateExecuteActionDTOWithUserId(ExecuteActionDTO executeActionDTO) { | ||
| return Mono.just(executeActionDTO); | ||
|
Comment on lines
+268
to
+274
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation doesn't match method's documented behavior. The method is documented to populate the userId but currently returns the DTO unmodified. This could lead to unexpected behavior. Consider implementing the documented behavior: protected Mono<ExecuteActionDTO> populateExecuteActionDTOWithUserId(ExecuteActionDTO executeActionDTO) {
- return Mono.just(executeActionDTO);
+ return sessionUserService.getCurrentUser()
+ .map(user -> {
+ executeActionDTO.setUserId(user.getId());
+ return executeActionDTO;
+ })
+ .defaultIfEmpty(executeActionDTO);
}
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add implementation to populate system information.
The current implementation returns the DTO without populating any system information, which doesn't fulfill the PR objective of populating system info into executeActionDTO.
Consider adding system information like:
@Override public Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO) { - return Mono.just(executeActionDTO); + return Mono.just(executeActionDTO) + .map(dto -> { + // Add relevant system information + // Example: OS, Java version, etc. + return dto; + }) + .switchIfEmpty(Mono.error(new IllegalArgumentException("ExecuteActionDTO cannot be null"))); }