diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java index da222142a878..ec457dc42fe4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java @@ -39,6 +39,8 @@ public interface NewActionServiceCE extends CrudService { Mono validateAction(NewAction newAction); + Mono validateAction(NewAction newAction, boolean isDryOps); + Mono bulkValidateAndInsertActionInRepository(List newActionList); Mono bulkValidateAndUpdateActionInRepository(List newActionList); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java index bd276c9110c6..07999b8dd873 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java @@ -287,6 +287,11 @@ public Mono validateAndSaveActionToRepository(NewAction newAction) { @Override public Mono validateAction(NewAction newAction) { + return validateAction(newAction, false); + } + + @Override + public Mono validateAction(NewAction newAction, boolean isDryOps) { this.setGitSyncIdInNewAction(newAction); ActionDTO action = newAction.getUnpublishedAction(); @@ -370,15 +375,23 @@ public Mono validateAction(NewAction newAction) { } else { // TODO: check if datasource should be fetched with edit during action create or update. // Data source already exists. Find the same. - datasourceMono = datasourceService - .findById(action.getDatasource().getId()) - .switchIfEmpty(Mono.defer(() -> { - action.setIsValid(false); - invalids.add(AppsmithError.NO_RESOURCE_FOUND.getMessage( - FieldName.DATASOURCE, - action.getDatasource().getId())); - return Mono.just(action.getDatasource()); - })) + + if (isDryOps) { + datasourceMono = Mono.just(action.getDatasource()); + } else { + datasourceMono = datasourceService + .findById(action.getDatasource().getId()) + .switchIfEmpty(Mono.defer(() -> { + if (!isDryOps) { + action.setIsValid(false); + invalids.add(AppsmithError.NO_RESOURCE_FOUND.getMessage( + FieldName.DATASOURCE, + action.getDatasource().getId())); + } + return Mono.just(action.getDatasource()); + })); + } + datasourceMono = datasourceMono .map(datasource -> { // datasource is found. Update the action. newAction.setWorkspaceId(datasource.getWorkspaceId()); @@ -441,7 +454,7 @@ public Mono validateAction(NewAction newAction) { @Override public Mono bulkValidateAndInsertActionInRepository(List newActionList) { return Flux.fromIterable(newActionList) - .flatMap(this::validateAction) + .flatMap(newAction -> validateAction(newAction, true)) .collectList() .flatMap(repository::bulkInsert); } @@ -449,7 +462,7 @@ public Mono bulkValidateAndInsertActionInRepository(List newAct @Override public Mono bulkValidateAndUpdateActionInRepository(List newActionList) { return Flux.fromIterable(newActionList) - .flatMap(this::validateAction) + .flatMap(newAction -> validateAction(newAction, true)) .collectList() .flatMap(repository::bulkUpdate); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java index 40af07027215..68d61168fedd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java @@ -571,6 +571,7 @@ private void updateDatasourceInAction( .findFirst() .orElse(datasource); datasource.setIsAutoGenerated(false); + newAction.setWorkspaceId(datasource.getWorkspaceId()); } newAction.getUnpublishedAction().setDatasource(datasource);