base changes to populate system info to executeActionDTO (#37091)
## Description > This PR is the base change for adding any system related info to the ExecuteActionDTO. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11610567421> > Commit: 2f5ab4b54717c021b780490320924e9b4d93522e > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11610567421&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Thu, 31 Oct 2024 11:33:58 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Introduced a new interface and implementation for enhanced action execution solutions. - Added functionality to populate action execution data with system and user information. - **Bug Fixes** - Improved structure and maintainability of action execution logic. - **Tests** - Updated test class to include a mock for the new action execution helper, ensuring future compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
This commit is contained in:
parent
ee02c0f17e
commit
a647668814
|
|
@ -0,0 +1,5 @@
|
|||
package com.appsmith.server.helpers;
|
||||
|
||||
import com.appsmith.server.helpers.ce.ActionExecutionSolutionHelperCE;
|
||||
|
||||
public interface ActionExecutionSolutionHelper extends ActionExecutionSolutionHelperCE {}
|
||||
|
|
@ -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 {}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.appsmith.server.applications.base.ApplicationService;
|
|||
import com.appsmith.server.configurations.CommonConfig;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.datasourcestorages.base.DatasourceStorageService;
|
||||
import com.appsmith.server.helpers.ActionExecutionSolutionHelper;
|
||||
import com.appsmith.server.helpers.PluginExecutorHelper;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
|
|
@ -40,7 +41,8 @@ public class ActionExecutionSolutionImpl extends ActionExecutionSolutionCEImpl i
|
|||
EnvironmentPermission environmentPermission,
|
||||
ConfigService configService,
|
||||
TenantService tenantService,
|
||||
CommonConfig commonConfig) {
|
||||
CommonConfig commonConfig,
|
||||
ActionExecutionSolutionHelper actionExecutionSolutionHelper) {
|
||||
super(
|
||||
newActionService,
|
||||
actionPermission,
|
||||
|
|
@ -60,6 +62,7 @@ public class ActionExecutionSolutionImpl extends ActionExecutionSolutionCEImpl i
|
|||
environmentPermission,
|
||||
configService,
|
||||
tenantService,
|
||||
commonConfig);
|
||||
commonConfig,
|
||||
actionExecutionSolutionHelper);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.appsmith.server.domains.User;
|
|||
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 class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
|
|||
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 class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
|
|||
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 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
|
|||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.appsmith.server.datasourcestorages.base.DatasourceStorageService;
|
|||
import com.appsmith.server.domains.NewAction;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.helpers.ActionExecutionSolutionHelper;
|
||||
import com.appsmith.server.helpers.PluginExecutorHelper;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
|
|
@ -132,6 +133,9 @@ class ActionExecutionSolutionCEImplTest {
|
|||
@SpyBean
|
||||
CommonConfig commonConfig;
|
||||
|
||||
@SpyBean
|
||||
ActionExecutionSolutionHelper actionExecutionSolutionHelper;
|
||||
|
||||
@Autowired
|
||||
EnvironmentPermission environmentPermission;
|
||||
|
||||
|
|
@ -162,7 +166,8 @@ class ActionExecutionSolutionCEImplTest {
|
|||
environmentPermission,
|
||||
configService,
|
||||
tenantService,
|
||||
commonConfig);
|
||||
commonConfig,
|
||||
actionExecutionSolutionHelper);
|
||||
|
||||
ObservationRegistry.ObservationConfig mockObservationConfig =
|
||||
Mockito.mock(ObservationRegistry.ObservationConfig.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user