diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationSnapshot.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationSnapshot.java index cad0fab99e..7847f1c9a5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationSnapshot.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ApplicationSnapshot.java @@ -36,6 +36,7 @@ public class ApplicationSnapshot extends BaseDomain { * @return Updated at timestamp in ISO format */ public String getUpdatedTime() { + if(this.getUpdatedAt() == null) return null; return DateUtils.ISO_FORMATTER.format(this.getUpdatedAt()); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ApplicationPagesDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ApplicationPagesDTO.java index c8ce8b16bd..7565a27b2d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ApplicationPagesDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ApplicationPagesDTO.java @@ -15,6 +15,4 @@ public class ApplicationPagesDTO { Application application; List pages; - - String latestSnapshotTime; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationSnapshotServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationSnapshotServiceCEImpl.java index 13d8aa1e57..bb8e490ecd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationSnapshotServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationSnapshotServiceCEImpl.java @@ -67,13 +67,8 @@ public class ApplicationSnapshotServiceCEImpl implements ApplicationSnapshotServ public Mono getWithoutDataByApplicationId(String applicationId, String branchName) { // get application first to check the permission and get child aka branched application ID return applicationService.findBranchedApplicationId(branchName, applicationId, applicationPermission.getEditPermission()) - .switchIfEmpty(Mono.error( - new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId)) - ) .flatMap(applicationSnapshotRepository::findWithoutData) - .switchIfEmpty(Mono.error( - new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId)) - ); + .defaultIfEmpty(new ApplicationSnapshot()); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/NewPageServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/NewPageServiceCEImpl.java index c53b705993..8a98fff4c2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/NewPageServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/NewPageServiceCEImpl.java @@ -6,7 +6,6 @@ import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Application; import com.appsmith.server.domains.ApplicationMode; import com.appsmith.server.domains.ApplicationPage; -import com.appsmith.server.domains.ApplicationSnapshot; import com.appsmith.server.domains.Layout; import com.appsmith.server.domains.NewPage; import com.appsmith.server.dtos.ApplicationPagesDTO; @@ -236,9 +235,6 @@ public class NewPageServiceCEImpl extends BaseService applicationSnapshotMono = applicationSnapshotRepository.findWithoutData(applicationId) - .defaultIfEmpty(new ApplicationSnapshot()); - Mono applicationMono = applicationService.findById(applicationId, permission) .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))) // Throw a 404 error if the application has never been published @@ -370,7 +366,7 @@ public class NewPageServiceCEImpl extends BaseService { log.debug("Populating applicationPagesDTO ..."); Application application = tuple.getT1(); @@ -382,12 +378,6 @@ public class NewPageServiceCEImpl extends BaseService applicationSnapshotMono = workspaceService.create(workspace) + .flatMap(createdWorkspace -> { + Application testApplication = new Application(); + testApplication.setName("Test app for snapshot"); + testApplication.setWorkspaceId(createdWorkspace.getId()); + return applicationPageService.createApplication(testApplication); + }) + .flatMap(application1 -> { + return applicationSnapshotService.getWithoutDataByApplicationId(application1.getId(), null); + }); + + StepVerifier.create(applicationSnapshotMono) + .assertNext(applicationSnapshot -> { + assertThat(applicationSnapshot.getId()).isNull(); + }) + .verifyComplete(); + } } \ No newline at end of file diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/NewPageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/NewPageServiceTest.java index 9247a37ba2..10628e1f44 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/NewPageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/NewPageServiceTest.java @@ -5,7 +5,6 @@ import com.appsmith.external.models.Policy; import com.appsmith.server.domains.Application; import com.appsmith.server.domains.ApplicationMode; import com.appsmith.server.domains.ApplicationPage; -import com.appsmith.server.domains.ApplicationSnapshot; import com.appsmith.server.domains.PermissionGroup; import com.appsmith.server.domains.Workspace; import com.appsmith.server.dtos.ApplicationPagesDTO; @@ -237,29 +236,4 @@ public class NewPageServiceTest { .verifyComplete(); } - @Test - @WithUserDetails("api_user") - public void findApplicationPagesByApplicationIdViewMode_WhenSnapshotExists_SnapshotTimeReturned() { - String randomId = UUID.randomUUID().toString(); - Workspace workspace = new Workspace(); - workspace.setName("org_" + randomId); - Mono applicationPagesDTOMono = workspaceService.create(workspace) - .flatMap(createdWorkspace -> { - Application application = new Application(); - application.setName("app_" + randomId); - return applicationPageService.createApplication(application, createdWorkspace.getId()); - }) - .flatMap(application -> { - ApplicationSnapshot snapshot = new ApplicationSnapshot(); - snapshot.setApplicationId(application.getId()); - snapshot.setChunkOrder(1); - return applicationSnapshotRepository.save(snapshot).thenReturn(application); - }) - .flatMap(application -> newPageService.findApplicationPagesByApplicationIdViewMode(application.getId(), false, false)); - - StepVerifier.create(applicationPagesDTOMono).assertNext(applicationPagesDTO -> { - assertThat(applicationPagesDTO.getLatestSnapshotTime()).isNotNull(); - }).verifyComplete(); - } - } \ No newline at end of file