diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java index e00e3db11957..3d0703c82582 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java @@ -27,6 +27,7 @@ import com.appsmith.server.imports.internal.artifactbased.ArtifactBasedImportServiceCE; import com.appsmith.server.layouts.UpdateLayoutService; import com.appsmith.server.migrations.ApplicationVersion; +import com.appsmith.server.migrations.JsonSchemaMigration; import com.appsmith.server.newactions.base.NewActionService; import com.appsmith.server.services.ApplicationPageService; import com.appsmith.server.solutions.ActionPermission; @@ -53,6 +54,7 @@ import static com.appsmith.server.helpers.ImportExportUtils.setPropertiesToExistingApplication; import static com.appsmith.server.helpers.ImportExportUtils.setPublishedApplicationProperties; +import static org.springframework.util.StringUtils.hasText; @RequiredArgsConstructor @Slf4j @@ -69,6 +71,7 @@ public class ApplicationImportServiceCEImpl private final ApplicationPermission applicationPermission; private final PagePermission pagePermission; private final ActionPermission actionPermission; + private final JsonSchemaMigration jsonSchemaMigration; private final ImportableService themeImportableService; private final ImportableService newPageImportableService; private final ImportableService customJSLibImportableService; @@ -639,4 +642,26 @@ public Mono> getDatasourceIdSetConsumedInArtifact(String baseArtifac public Flux getBranchedArtifactIdsByBranchedArtifactId(String branchedArtifactId) { return applicationService.findAllBranchedApplicationIdsByBranchedApplicationId(branchedArtifactId, null); } + + @Override + public Mono migrateArtifactExchangeJson( + String branchedArtifactId, ArtifactExchangeJson artifactExchangeJson) { + ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson; + + if (!hasText(branchedArtifactId)) { + return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null); + } + + return applicationService.findById(branchedArtifactId).flatMap(application -> { + String baseArtifactId = application.getBaseId(); + String branchName = null; + + if (application.getGitArtifactMetadata() != null) { + branchName = application.getGitArtifactMetadata().getBranchName(); + } + + return jsonSchemaMigration.migrateApplicationJsonToLatestSchema( + applicationJson, baseArtifactId, branchName); + }); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java index e86f89d66e02..fa5fe049b317 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java @@ -12,6 +12,7 @@ import com.appsmith.server.imports.importable.ImportableService; import com.appsmith.server.imports.internal.artifactbased.ArtifactBasedImportService; import com.appsmith.server.layouts.UpdateLayoutService; +import com.appsmith.server.migrations.JsonSchemaMigration; import com.appsmith.server.newactions.base.NewActionService; import com.appsmith.server.services.ApplicationPageService; import com.appsmith.server.solutions.ActionPermission; @@ -35,6 +36,7 @@ public ApplicationImportServiceImpl( ApplicationPermission applicationPermission, PagePermission pagePermission, ActionPermission actionPermission, + JsonSchemaMigration jsonSchemaMigration, ImportableService themeImportableService, ImportableService newPageImportableService, ImportableService customJSLibImportableService, @@ -50,6 +52,7 @@ public ApplicationImportServiceImpl( applicationPermission, pagePermission, actionPermission, + jsonSchemaMigration, themeImportableService, newPageImportableService, customJSLibImportableService, diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java index 0f3c5095fe6b..e409f047288e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java @@ -411,23 +411,32 @@ private Mono importArtifactInWorkspace( String artifactContextString = artifactSpecificConstantsMap.get(FieldName.ARTIFACT_CONTEXT); // step 1: Schema Migration - ArtifactExchangeJson importedDoc = jsonSchemaMigration.migrateArtifactToLatestSchema(artifactExchangeJson); - - // Step 2: Validation of artifact Json - // check for validation error and raise exception if error found - String errorField = validateArtifactExchangeJson(importedDoc); - if (!errorField.isEmpty()) { - log.error("Error in importing {}. Field {} is missing", artifactContextString, errorField); - if (errorField.equals(artifactContextString)) { - return Mono.error( - new AppsmithException( + Mono migratedArtifactJsonMono = artifactBasedImportService + .migrateArtifactExchangeJson(branchedArtifactId, artifactExchangeJson) + .flatMap(importedDoc -> { + // Step 2: Validation of artifact Json + // check for validation error and raise exception if error found + String errorField = validateArtifactExchangeJson(importedDoc); + if (!errorField.isEmpty()) { + log.error("Error in importing {}. Field {} is missing", artifactContextString, errorField); + + if (errorField.equals(artifactContextString)) { + return Mono.error( + new AppsmithException( + AppsmithError.VALIDATION_FAILURE, + "Field '" + artifactContextString + + "'. Sorry! It seems you've imported a page-level JSON instead of an application. Please use the import within the page.")); + } + + return Mono.error(new AppsmithException( AppsmithError.VALIDATION_FAILURE, - "Field '" + artifactContextString - + "' Sorry! Seems like you've imported a page-level json instead of an application. Please use the import within the page.")); - } - return Mono.error(new AppsmithException( - AppsmithError.VALIDATION_FAILURE, "Field '" + errorField + "' is missing in the JSON.")); - } + "Field '" + errorField + "' is missing in the JSON.")); + } + + artifactBasedImportService.syncClientAndSchemaVersion(importedDoc); + return Mono.just(importedDoc); + }) + .cache(); ImportingMetaDTO importingMetaDTO = new ImportingMetaDTO( workspaceId, @@ -441,7 +450,6 @@ private Mono importArtifactInWorkspace( permissionGroups); MappedImportableResourcesDTO mappedImportableResourcesDTO = new MappedImportableResourcesDTO(); - artifactBasedImportService.syncClientAndSchemaVersion(importedDoc); Mono workspaceMono = workspaceService .findById(workspaceId, permissionProvider.getRequiredPermissionOnTargetWorkspace()) @@ -469,56 +477,63 @@ private Mono importArtifactInWorkspace( .switchIfEmpty(Mono.just(List.of())) .doOnNext(importingMetaDTO::setBranchedArtifactIds); - // this would import customJsLibs for all type of artifacts - Mono artifactSpecificImportableEntities = - artifactBasedImportService.generateArtifactSpecificImportableEntities( - importedDoc, importingMetaDTO, mappedImportableResourcesDTO); - - /* - Calling the workspaceMono first to avoid creating multiple mongo transactions. - If the first db call inside a transaction is a Flux, then there's a chance of creating multiple mongo - transactions which will lead to NoSuchTransaction exception. - */ - final Mono importableArtifactMono = workspaceMono - .then(Mono.defer(() -> Mono.when(branchedArtifactIdsMono, artifactSpecificImportableEntities))) - .then(Mono.defer(() -> artifactBasedImportService.updateAndSaveArtifactInContext( - importedDoc.getArtifact(), importingMetaDTO, mappedImportableResourcesDTO, currUserMono))) - .cache(); - - final Mono importMono = importableArtifactMono - .then(Mono.defer(() -> generateImportableEntities( - importingMetaDTO, - mappedImportableResourcesDTO, - workspaceMono, - importableArtifactMono, - importedDoc))) - .then(importableArtifactMono) - .flatMap(importableArtifact -> updateImportableEntities( - artifactBasedImportService, importableArtifact, mappedImportableResourcesDTO, importingMetaDTO)) - .flatMap(importableArtifact -> updateImportableArtifact(artifactBasedImportService, importableArtifact)) - .onErrorResume(throwable -> { - String errorMessage = ImportExportUtils.getErrorMessage(throwable); - log.error("Error importing {}. Error: {}", artifactContextString, errorMessage, throwable); - return Mono.error( - new AppsmithException(AppsmithError.GENERIC_JSON_IMPORT_ERROR, workspaceId, errorMessage)); - }) - // execute dry run for datasource - .flatMap(importableArtifact -> dryOperationRepository - .executeAllDbOps(mappedImportableResourcesDTO) - .thenReturn(importableArtifact)) - .as(transactionalOperator::transactional); - - final Mono resultMono = importMono - .flatMap(importableArtifact -> sendImportedContextAnalyticsEvent( - artifactBasedImportService, importableArtifact, AnalyticsEvents.IMPORT)) - .zipWith(currUserMono) - .flatMap(tuple -> { - Artifact importableArtifact = tuple.getT1(); - User user = tuple.getT2(); - stopwatch.stopTimer(); - stopwatch.stopAndLogTimeInMillis(); - return sendImportRelatedAnalyticsEvent(importedDoc, importableArtifact, stopwatch, user); - }); + final Mono resultMono = migratedArtifactJsonMono.flatMap(importedDoc -> { + + // this would import customJsLibs for all type of artifacts + Mono artifactSpecificImportableEntities = + artifactBasedImportService.generateArtifactSpecificImportableEntities( + importedDoc, importingMetaDTO, mappedImportableResourcesDTO); + + /* + Calling the workspaceMono first to avoid creating multiple mongo transactions. + If the first db call inside a transaction is a Flux, then there's a chance of creating multiple mongo + transactions which will lead to NoSuchTransaction exception. + */ + final Mono importableArtifactMono = workspaceMono + .then(Mono.defer(() -> Mono.when(branchedArtifactIdsMono, artifactSpecificImportableEntities))) + .then(Mono.defer(() -> artifactBasedImportService.updateAndSaveArtifactInContext( + importedDoc.getArtifact(), importingMetaDTO, mappedImportableResourcesDTO, currUserMono))) + .cache(); + + final Mono importMono = importableArtifactMono + .then(Mono.defer(() -> generateImportableEntities( + importingMetaDTO, + mappedImportableResourcesDTO, + workspaceMono, + importableArtifactMono, + importedDoc))) + .then(importableArtifactMono) + .flatMap(importableArtifact -> updateImportableEntities( + artifactBasedImportService, + importableArtifact, + mappedImportableResourcesDTO, + importingMetaDTO)) + .flatMap(importableArtifact -> + updateImportableArtifact(artifactBasedImportService, importableArtifact)) + .onErrorResume(throwable -> { + String errorMessage = ImportExportUtils.getErrorMessage(throwable); + log.error("Error importing {}. Error: {}", artifactContextString, errorMessage, throwable); + return Mono.error(new AppsmithException( + AppsmithError.GENERIC_JSON_IMPORT_ERROR, workspaceId, errorMessage)); + }) + // execute dry run for datasource + .flatMap(importableArtifact -> dryOperationRepository + .executeAllDbOps(mappedImportableResourcesDTO) + .thenReturn(importableArtifact)) + .as(transactionalOperator::transactional); + + return importMono + .flatMap(importableArtifact -> sendImportedContextAnalyticsEvent( + artifactBasedImportService, importableArtifact, AnalyticsEvents.IMPORT)) + .zipWith(currUserMono) + .flatMap(tuple -> { + Artifact importableArtifact = tuple.getT1(); + User user = tuple.getT2(); + stopwatch.stopTimer(); + stopwatch.stopAndLogTimeInMillis(); + return sendImportRelatedAnalyticsEvent(importedDoc, importableArtifact, stopwatch, user); + }); + }); // Import Context is currently a slow API because it needs to import and create context, pages, actions // and action collection. This process may take time and the client may cancel the request. This leads to the diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java index 7dfd1560c6d3..7fd0e80d67b0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java @@ -153,4 +153,6 @@ Mono generateArtifactSpecificImportableEntities( Mono> getDatasourceIdSetConsumedInArtifact(String baseArtifactId); Flux getBranchedArtifactIdsByBranchedArtifactId(String branchedArtifactId); + + Mono migrateArtifactExchangeJson(String branchedArtifactId, ArtifactExchangeJson artifactExchangeJson); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java index badec22d19e5..df6caf59bb10 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java @@ -12,8 +12,6 @@ import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; -import java.util.Map; - @Slf4j @Component @RequiredArgsConstructor @@ -37,15 +35,21 @@ private Integer getCorrectSchemaVersion(Integer schemaVersion) { } /** - * This method migrates the server schema of artifactExchangeJson after choosing the right method for migration - * this will likely be overridden in EE codebase for more choices - * @param artifactExchangeJson artifactExchangeJson which is imported + * Migrates the server schema of the given ArtifactExchangeJson by selecting the appropriate migration method. + * This method may be overridden in the EE codebase for additional migration choices. + * + * @param artifactExchangeJson The artifact to be imported. + * @param baseArtifactId The base application ID to which it's being imported, + * if it's a Git-connected artifact; otherwise, null. + * @param branchName The branch name of the artifact being imported, + * if it's a Git-connected application; otherwise, null. */ public Mono migrateArtifactExchangeJsonToLatestSchema( - ArtifactExchangeJson artifactExchangeJson) { + ArtifactExchangeJson artifactExchangeJson, String baseArtifactId, String branchName) { if (ArtifactType.APPLICATION.equals(artifactExchangeJson.getArtifactJsonType())) { - return migrateApplicationJsonToLatestSchema((ApplicationJson) artifactExchangeJson, null, null); + return migrateApplicationJsonToLatestSchema( + (ApplicationJson) artifactExchangeJson, baseArtifactId, branchName); } return Mono.fromCallable(() -> artifactExchangeJson); @@ -62,82 +66,28 @@ public Mono migrateApplicationJsonToLatestSchema( return Mono.empty(); } - // Taking a tech debt over here for import of file application. - // All migration above version 9 is reactive - // TODO: make import flow migration reactive - return Mono.just(migrateServerSchema(appJson)) - .flatMap(migratedApplicationJson -> { - // In Server version 9, there was a bug where the Embedded REST API datasource URL - // was not being persisted correctly. Once the bug was fixed, - // any previously uncommitted changes started appearing as uncommitted modifications - // in the apps. To automatically commit these changes - // (which were now appearing as uncommitted), a migration process was needed. - // This migration fetches the datasource URL from the database - // and serializes it in Git if the URL exists. - // If the URL is missing, it copies the empty datasource configuration - // if the configuration is present in the database. - // Otherwise, it leaves the configuration unchanged. - // Due to an update in the migration logic after version 10 was shipped, - // the entire migration process was moved to version 11. - // This adjustment ensures that the same operation can be - // performed again for the changes introduced in version 10. - if (migratedApplicationJson.getServerSchemaVersion() == 9) { - migratedApplicationJson.setServerSchemaVersion(10); - } - - if (migratedApplicationJson.getServerSchemaVersion() == 10) { - if (Boolean.TRUE.equals(MigrationHelperMethods.doesRestApiRequireMigration( - migratedApplicationJson))) { - return jsonSchemaMigrationHelper - .addDatasourceConfigurationToDefaultRestApiActions( - baseApplicationId, branchName, migratedApplicationJson); - } - - migratedApplicationJson.setServerSchemaVersion(11); - } - - return Mono.just(migratedApplicationJson); - }) - .map(migratedAppJson -> { - applicationJson.setServerSchemaVersion(jsonSchemaVersions.getServerVersion()); - return applicationJson; - }); + return migrateServerSchema(applicationJson, baseApplicationId, branchName); }) .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INCOMPATIBLE_IMPORTED_JSON))); } - /** - * migrate artifacts to latest schema by adding the right DTOs, or any migration. - * This method would be deprecated soon enough - * @param artifactExchangeJson : the json to be imported - * @return transformed artifact exchange json - */ - @Deprecated(forRemoval = true, since = "Use migrateArtifactJsonToLatestSchema") - public ArtifactExchangeJson migrateArtifactToLatestSchema(ArtifactExchangeJson artifactExchangeJson) { - - if (!ArtifactType.APPLICATION.equals(artifactExchangeJson.getArtifactJsonType())) { - return artifactExchangeJson; - } - - ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson; - setSchemaVersions(applicationJson); - if (!isCompatible(applicationJson)) { - throw new AppsmithException(AppsmithError.INCOMPATIBLE_IMPORTED_JSON); - } - - applicationJson = migrateServerSchema(applicationJson); - return nonReactiveServerMigrationForImport(applicationJson); - } - /** * This method may be moved to the publisher chain itself - * @param applicationJson : applicationJson which needs to be transformed + * + * @param applicationJson : applicationJson which needs to be transformed + * @param baseApplicationId : baseApplicationId of the application to which it's being imported, + * if it's a git connected artifact, otherwise a null value would be passed. + * @param branchName : branch name of the artifact for which application json is getting imported + * if it's a git connected application. Otherwise, the value would be null * @return : transformed applicationJson */ - private ApplicationJson migrateServerSchema(ApplicationJson applicationJson) { + private Mono migrateServerSchema( + ApplicationJson applicationJson, String baseApplicationId, String branchName) { + Mono migrateApplicationJsonMono = Mono.just(applicationJson); + if (jsonSchemaVersions.getServerVersion().equals(applicationJson.getServerSchemaVersion())) { // No need to run server side migration - return applicationJson; + return migrateApplicationJsonMono; } // Run migration linearly // Updating the schema version after each migration is not required as we are not exiting by breaking the switch @@ -180,38 +130,33 @@ private ApplicationJson migrateServerSchema(ApplicationJson applicationJson) { case 8: MigrationHelperMethods.migrateThemeSettingsForAnvil(applicationJson); applicationJson.setServerSchemaVersion(9); - - // This is not supposed to have anymore additions to the schema. - default: - // Unable to detect the serverSchema - - } - - return applicationJson; - } - - /** - * This method is an alternative to reactive way of adding migrations to application json. - * this is getting used by flows which haven't implemented the reactive way yet. - * @param applicationJson : application json for which migration has to be done. - * @return return application json after migration - */ - private ApplicationJson nonReactiveServerMigrationForImport(ApplicationJson applicationJson) { - if (jsonSchemaVersions.getServerVersion().equals(applicationJson.getServerSchemaVersion())) { - return applicationJson; - } - - switch (applicationJson.getServerSchemaVersion()) { + // In Server version 9, there was a bug where the Embedded REST API datasource URL + // was not being persisted correctly. Once the bug was fixed, + // any previously uncommitted changes started appearing as uncommitted modifications + // in the apps. To automatically commit these changes + // (which were now appearing as uncommitted), a migration process was needed. + // This migration fetches the datasource URL from the database + // and serializes it in Git if the URL exists. + // If the URL is missing, it copies the empty datasource configuration + // if the configuration is present in the database. + // Otherwise, it leaves the configuration unchanged. + // Due to an update in the migration logic after version 10 was shipped, + // the entire migration process was moved to version 11. + // This adjustment ensures that the same operation can be + // performed again for the changes introduced in version 10. case 9: applicationJson.setServerSchemaVersion(10); case 10: - // this if for cases where we have empty datasource configs - MigrationHelperMethods.migrateApplicationJsonToVersionTen(applicationJson, Map.of()); + if (Boolean.TRUE.equals(MigrationHelperMethods.doesRestApiRequireMigration(applicationJson))) { + migrateApplicationJsonMono = migrateApplicationJsonMono.flatMap( + migratedJson -> jsonSchemaMigrationHelper.addDatasourceConfigurationToDefaultRestApiActions( + baseApplicationId, branchName, migratedJson)); + } applicationJson.setServerSchemaVersion(11); default: } applicationJson.setServerSchemaVersion(jsonSchemaVersions.getServerVersion()); - return applicationJson; + return migrateApplicationJsonMono; } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java index 6f26851a12a9..00dba526a9c8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java @@ -57,6 +57,7 @@ import org.springframework.util.StreamUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import java.io.IOException; import java.nio.charset.Charset; @@ -236,28 +237,38 @@ public Mono createPageFromDBTable( .switchIfEmpty(Mono.error( new AppsmithException(AppsmithError.INVALID_DATASOURCE, FieldName.DATASOURCE, datasourceId))); + // Should this be subscribed on a scheduler? + Mono applicationJsonMono = Mono.fromCallable(() -> { + ApplicationJson applicationJson = new ApplicationJson(); + try { + AppsmithBeanUtils.copyNestedNonNullProperties( + fetchTemplateApplication(FILE_PATH), applicationJson); + } catch (IOException e) { + log.error(e.getMessage()); + } + + return applicationJson; + }) + .subscribeOn(Schedulers.boundedElastic()) + .flatMap(applicationJson -> + jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null)); + return datasourceStorageMono .zipWhen(datasourceStorage -> Mono.zip( pageMono, pluginService.findById(datasourceStorage.getPluginId()), - datasourceStructureSolution.getStructure(datasourceStorage, false))) + datasourceStructureSolution.getStructure(datasourceStorage, false), + applicationJsonMono)) .flatMap(tuple -> { DatasourceStorage datasourceStorage = tuple.getT1(); NewPage page = tuple.getT2().getT1(); Plugin plugin = tuple.getT2().getT2(); DatasourceStructure datasourceStructure = tuple.getT2().getT3(); + ApplicationJson applicationJson = tuple.getT2().getT4(); final String layoutId = page.getUnpublishedPage().getLayouts().get(0).getId(); final String savedPageId = page.getId(); - - ApplicationJson applicationJson = new ApplicationJson(); - try { - AppsmithBeanUtils.copyNestedNonNullProperties( - fetchTemplateApplication(FILE_PATH), applicationJson); - } catch (IOException e) { - log.error(e.getMessage()); - } List pageList = applicationJson.getPageList(); if (pageList.isEmpty()) { @@ -558,8 +569,7 @@ private ApplicationJson fetchTemplateApplication(String filePath) throws IOExcep final String jsonContent = StreamUtils.copyToString( new DefaultResourceLoader().getResource(filePath).getInputStream(), Charset.defaultCharset()); - ApplicationJson applicationJson = gson.fromJson(jsonContent, ApplicationJson.class); - return (ApplicationJson) jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson); + return gson.fromJson(jsonContent, ApplicationJson.class); } /** diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java index 570f86e28bd7..31d88eaa56b5 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java @@ -291,7 +291,8 @@ private Mono createAppJson(String filePath) { return stringifiedFile .map(data -> gson.fromJson(data, ApplicationJson.class)) - .map(jsonSchemaMigration::migrateArtifactToLatestSchema) + .flatMap(applicationJson -> + jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null)) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/gac/DefaultBranchGACTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/gac/DefaultBranchGACTest.java deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/gac/GitServiceWithRBACTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/gac/GitServiceWithRBACTest.java deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java index ed04d0837170..c9486d45314f 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java @@ -84,7 +84,8 @@ private Mono createAppJson(String filePath) { .map(data -> { return gson.fromJson(data, ApplicationJson.class); }) - .map(jsonSchemaMigration::migrateArtifactToLatestSchema) + .flatMap(applicationJson -> + jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null)) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java index efb637ff6587..8a742fa911d3 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java @@ -357,7 +357,8 @@ private Mono createAppJson(String filePath) { .map(data -> { return gson.fromJson(data, ApplicationJson.class); }) - .map(jsonSchemaMigration::migrateArtifactToLatestSchema) + .flatMap(applicationJson -> + jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null)) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson); } @@ -2718,11 +2719,13 @@ public void applySchemaMigration_jsonFileWithFirstVersion_migratedToLatestVersio }) .cache(); - Mono migratedApplicationMono = v1ApplicationMono.map(applicationJson -> { - ApplicationJson applicationJson1 = new ApplicationJson(); - AppsmithBeanUtils.copyNestedNonNullProperties(applicationJson, applicationJson1); - return (ApplicationJson) jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson1); - }); + Mono migratedApplicationMono = v1ApplicationMono + .flatMap(applicationJson -> { + ApplicationJson applicationJson1 = new ApplicationJson(); + AppsmithBeanUtils.copyNestedNonNullProperties(applicationJson, applicationJson1); + return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson1, null, null); + }) + .map(applicationJson -> (ApplicationJson) applicationJson); StepVerifier.create(Mono.zip(v1ApplicationMono, migratedApplicationMono)) .assertNext(tuple -> { diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java index 9fbbfbe61200..42cedccfa5da 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java @@ -55,7 +55,9 @@ public void migrateArtifactToLatestSchema_whenFeatureFlagIsOff_returnsFallbackVa ApplicationJson applicationJson = gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json")); - ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson); + ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration + .migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null) + .block(); assertThat(artifactExchangeJson.getServerSchemaVersion()) .isEqualTo(jsonSchemaVersionsFallback.getServerVersion()); @@ -77,7 +79,9 @@ public void migrateArtifactToLatestSchema_whenFeatureFlagIsOn_returnsIncremented ApplicationJson applicationJson = gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json")); - ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson); + ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration + .migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null) + .block(); assertThat(artifactExchangeJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion()); assertThat(artifactExchangeJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion()); assertThat(artifactExchangeJson.getClientSchemaVersion()) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ee/ImportExportApplicationServiceEETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ee/ImportExportApplicationServiceEETest.java deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ee/ImportExportApplicationServiceGACTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ee/ImportExportApplicationServiceGACTest.java deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java index 7e46d65bf6a0..f5d0c4835408 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java @@ -130,7 +130,8 @@ private Mono createAppJson(String filePath) { .map(data -> { return gson.fromJson(data, ApplicationJson.class); }) - .map(jsonSchemaMigration::migrateArtifactToLatestSchema) + .flatMap(applicationJson -> + jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null)) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson); }