From ea8116863e3ea04eeeaf2d5d0e622e5ddb9a073f Mon Sep 17 00:00:00 2001 From: Abhijeet <41686026+abhvsn@users.noreply.github.com> Date: Fri, 27 Aug 2021 18:46:13 +0530 Subject: [PATCH] revert: "Add version check from import-export flow (#6552)" (#6935) --- .../server/domains/ApplicationJson.java | 2 -- .../server/exceptions/AppsmithError.java | 1 - .../ImportExportApplicationService.java | 13 ---------- .../ImportExportApplicationServiceTests.java | 24 ------------------- .../invalid-file-without-version.json | 10 -------- .../valid-application.json | 1 - 6 files changed, 51 deletions(-) delete mode 100644 app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/invalid-file-without-version.json diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationJson.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationJson.java index 0324cf9ce7..5cc80f3e40 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationJson.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationJson.java @@ -16,8 +16,6 @@ import java.util.Set; @Setter public class ApplicationJson { - String appsmithVersion; - Application exportedApplication; List datasourceList; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java index ce3aab16d9..ac2dbdfa67 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java @@ -77,7 +77,6 @@ public enum AppsmithError { REMOVE_LAST_ORG_ADMIN_ERROR(400, 4037, "The last admin can not be removed from an organization", AppsmithErrorAction.DEFAULT, null, ErrorType.INTERNAL_ERROR), INVALID_CRUD_PAGE_REQUEST(400, 4038, "Unable to process page generation request, {0}", AppsmithErrorAction.DEFAULT, null, ErrorType.BAD_REQUEST), - INVALID_IMPORTED_FILE_ERROR(400, 4039, "Provided file is from different version, please wait till Appsmith gets auto-updated to latest version. This may take a day or two. We are really sorry for the inconvenience caused", AppsmithErrorAction.DEFAULT, null, ErrorType.INTERNAL_ERROR), INTERNAL_SERVER_ERROR(500, 5000, "Internal server error while processing request", AppsmithErrorAction.LOG_EXTERNALLY, null, ErrorType.INTERNAL_ERROR), REPOSITORY_SAVE_FAILED(500, 5001, "Failed to save the repository. Try again.", AppsmithErrorAction.DEFAULT, null, ErrorType.INTERNAL_ERROR), PLUGIN_INSTALLATION_FAILED_DOWNLOAD_ERROR(500, 5002, "Plugin installation failed due to an error while " + diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ImportExportApplicationService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ImportExportApplicationService.java index 3cd53ebb3e..7c37900057 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ImportExportApplicationService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ImportExportApplicationService.java @@ -75,7 +75,6 @@ public class ImportExportApplicationService { private final NewActionService newActionService; private final SequenceService sequenceService; private final ExamplesOrganizationCloner examplesOrganizationCloner; - private final ReleaseNotesService releaseNotesService; private static final Set ALLOWED_CONTENT_TYPES = Set.of(MediaType.APPLICATION_JSON); private static final String INVALID_JSON_FILE = "invalid json file"; @@ -120,9 +119,6 @@ public class ImportExportApplicationService { .then(applicationMono) .flatMap(application -> { - // Insert the release version for exported file - applicationJson.setAppsmithVersion(releaseNotesService.getReleasedVersion()); - // Assign the default page names for published and unpublished field in applicationJson object ApplicationPage unpublishedDefaultPage = application.getPages() .stream() @@ -357,15 +353,6 @@ public class ImportExportApplicationService { if(!errorField.isEmpty()) { return Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, errorField, INVALID_JSON_FILE)); - } else if(importedDoc.getAppsmithVersion() == null) { - return Mono.error( - new AppsmithException( - AppsmithError.JSON_PROCESSING_ERROR, - ": Unable to find version field in the uploaded file. Can you please try exporting the " + - "application from source Appsmith server and then importing it once again" - )); - } else if(!releaseNotesService.getReleasedVersion().equals(importedDoc.getAppsmithVersion())) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_IMPORTED_FILE_ERROR)); } return pluginRepository.findAll() diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java index e54383b4b1..4b769d82ce 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java @@ -201,8 +201,6 @@ public class ImportExportApplicationServiceTests { NewPage defaultPage = pageList.get(0); - assertThat(applicationJson.getAppsmithVersion()).isNotNull(); - assertThat(exportedApp.getId()).isNull(); assertThat(exportedApp.getOrganizationId()).isNull(); assertThat(exportedApp.getPages()).isNull(); @@ -525,28 +523,6 @@ public class ImportExportApplicationServiceTests { .verifyComplete(); } - @Test - @WithUserDetails(value = "api_user") - public void importApplicationWithoutVersionTest() { - - FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/invalid-file-without-version.json"); - - Organization newOrganization = new Organization(); - newOrganization.setName("Template Organization"); - - final Mono resultMono = organizationService - .create(newOrganization) - .flatMap(organization -> importExportApplicationService - .extractFileAndSaveApplication(organization.getId(), filePart) - ); - - StepVerifier - .create(resultMono) - .expectErrorMatches(throwable -> throwable instanceof AppsmithException && - throwable.getMessage().contains(AppsmithError.JSON_PROCESSING_ERROR.getMessage(": Unable to find version field in the uploaded file."))) - .verify(); - } - private FilePart createFilePart(String filePath) { FilePart filepart = Mockito.mock(FilePart.class, Mockito.RETURNS_DEEP_STUBS); Flux dataBufferFlux = DataBufferUtils diff --git a/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/invalid-file-without-version.json b/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/invalid-file-without-version.json deleted file mode 100644 index 9d880bcbfb..0000000000 --- a/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/invalid-file-without-version.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "exportedApplication": {}, - "datasourceList": [], - "pageList": [ - { - "applicationId": "invalid_application" - } - ], - "actionList": [] -} \ No newline at end of file diff --git a/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/valid-application.json b/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/valid-application.json index 5e1aff9c19..569f8e6ba9 100644 --- a/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/valid-application.json +++ b/app/server/appsmith-server/src/test/resources/test_assets/ImportExportServiceTest/valid-application.json @@ -1,5 +1,4 @@ { - "appsmithVersion":"UNKNOWN", "exportedApplication": { "userPermissions": [ "canComment:applications",