Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.appsmith.server.constants;

public class ImportExportConstants {

public static final String ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE =
"'. Sorry! It seems you've imported a page-level JSON instead of an application. Please use the import within the page.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.appsmith.external.models.Datasource;
import com.appsmith.server.constants.ArtifactType;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.constants.ImportExportConstants;
import com.appsmith.server.converters.ArtifactExchangeJsonAdapter;
import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.Artifact;
Expand Down Expand Up @@ -421,11 +422,10 @@ private Mono<Artifact> importArtifactInWorkspace(
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
+ ImportExportConstants.ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE));
}

return Mono.error(new AppsmithException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.appsmith.server.actioncollections.base.ActionCollectionService;
import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.constants.ImportExportConstants;
import com.appsmith.server.datasources.base.DatasourceService;
import com.appsmith.server.domains.ActionCollection;
import com.appsmith.server.domains.Application;
Expand Down Expand Up @@ -895,14 +896,11 @@ public void importArtifactFromInvalidJsonFileWithoutArtifactTest() {
importService.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null);

StepVerifier.create(resultMono)
.expectErrorMatches(
throwable -> throwable instanceof AppsmithException
&& throwable
.getMessage()
.equals(
AppsmithError.VALIDATION_FAILURE.getMessage(
"Field '" + FieldName.APPLICATION
+ "' Sorry! Seems like you've imported a page-level json instead of an application. Please use the import within the page.")))
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
&& throwable
.getMessage()
.equals(AppsmithError.VALIDATION_FAILURE.getMessage("Field '" + FieldName.APPLICATION
+ ImportExportConstants.ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE)))
.verify();
}

Expand Down