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
Expand Up @@ -46,20 +46,23 @@ public class ApplicationExportServiceCEImpl implements ArtifactBasedExportServic
protected final ExportableService<ActionCollection> actionCollectionExportableService;
private final ExportableService<Theme> themeExportableService;
private final Map<String, String> applicationConstantsMap = new HashMap<>();
private final JsonSchemaVersions jsonSchemaVersions;

public ApplicationExportServiceCEImpl(
ApplicationService applicationService,
ApplicationPermission applicationPermission,
ExportableService<NewPage> newPageExportableService,
ExportableService<NewAction> newActionExportableService,
ExportableService<ActionCollection> actionCollectionExportableService,
ExportableService<Theme> themeExportableService) {
ExportableService<Theme> themeExportableService,
JsonSchemaVersions jsonSchemaVersions) {
this.applicationService = applicationService;
this.newPageExportableService = newPageExportableService;
this.newActionExportableService = newActionExportableService;
this.actionCollectionExportableService = actionCollectionExportableService;
this.themeExportableService = themeExportableService;
this.applicationPermission = applicationPermission;
this.jsonSchemaVersions = jsonSchemaVersions;
applicationConstantsMap.putAll(
Map.of(FieldName.ARTIFACT_CONTEXT, FieldName.APPLICATION, FieldName.ID, FieldName.APPLICATION_ID));
}
Expand Down Expand Up @@ -120,8 +123,10 @@ public Mono<Void> getArtifactReadyForExport(
GitArtifactMetadata gitArtifactMetadata = application.getGitApplicationMetadata();
Instant applicationLastCommittedAt =
gitArtifactMetadata != null ? gitArtifactMetadata.getLastCommittedAt() : null;
boolean isClientSchemaMigrated = !JsonSchemaVersions.clientVersion.equals(application.getClientSchemaVersion());
boolean isServerSchemaMigrated = !JsonSchemaVersions.serverVersion.equals(application.getServerSchemaVersion());
boolean isClientSchemaMigrated =
!jsonSchemaVersions.getClientVersion().equals(application.getClientSchemaVersion());
boolean isServerSchemaMigrated =
!jsonSchemaVersions.getServerVersion().equals(application.getServerSchemaVersion());

exportingMetaDTO.setArtifactLastCommittedAt(applicationLastCommittedAt);
exportingMetaDTO.setClientSchemaMigrated(isClientSchemaMigrated);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.exports.exportable.ExportableService;
import com.appsmith.server.exports.internal.artifactbased.ArtifactBasedExportService;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.solutions.ApplicationPermission;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
Expand All @@ -24,14 +25,16 @@ public ApplicationExportServiceImpl(
ExportableService<NewPage> newPageExportableService,
ExportableService<NewAction> newActionExportableService,
ExportableService<ActionCollection> actionCollectionExportableService,
ExportableService<Theme> themeExportableService) {
ExportableService<Theme> themeExportableService,
JsonSchemaVersions jsonSchemaVersions) {

super(
applicationService,
applicationPermission,
newPageExportableService,
newActionExportableService,
actionCollectionExportableService,
themeExportableService);
themeExportableService,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;
import com.appsmith.server.services.ApplicationPageService;
Expand All @@ -19,24 +20,26 @@
public class GitApplicationHelperCECompatibleImpl extends GitApplicationHelperCEImpl
implements GitArtifactHelperCECompatible<Application> {
public GitApplicationHelperCECompatibleImpl(
CommonGitFileUtils gitFileUtils,
CommonGitFileUtils commonGitFileUtils,
GitPrivateRepoHelper gitPrivateRepoHelper,
ApplicationService applicationService,
ApplicationPageService applicationPageService,
ApplicationPermission applicationPermission,
NewPageService newPageService,
ActionCollectionService actionCollectionService,
NewActionService newActionService,
ResponseUtils responseUtils) {
ResponseUtils responseUtils,
JsonSchemaVersions jsonSchemaVersions) {
super(
gitFileUtils,
commonGitFileUtils,
gitPrivateRepoHelper,
applicationService,
applicationPageService,
applicationPermission,
newPageService,
actionCollectionService,
newActionService,
responseUtils);
responseUtils,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class GitApplicationHelperCEImpl implements GitArtifactHelperCE<Applicati
private final ActionCollectionService actionCollectionService;
private final NewActionService newActionService;
private final ResponseUtils responseUtils;
private final JsonSchemaVersions jsonSchemaVersions;

@Override
public AclPermission getArtifactReadPermission() {
Expand Down Expand Up @@ -147,8 +148,8 @@ public Mono<Application> updateArtifactWithSchemaVersions(Artifact artifact) {
Application update = new Application();

// Reset migration related fields before commit to detect the updates correctly between the commits
update.setClientSchemaVersion(JsonSchemaVersions.clientVersion);
update.setServerSchemaVersion(JsonSchemaVersions.serverVersion);
update.setClientSchemaVersion(jsonSchemaVersions.getClientVersion());
update.setServerSchemaVersion(jsonSchemaVersions.getServerVersion());
update.setIsManualUpdate(false);

return applicationService.update(artifact.getId(), update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;
import com.appsmith.server.services.ApplicationPageService;
Expand All @@ -28,7 +29,8 @@ public GitApplicationHelperImpl(
NewPageService newPageService,
ActionCollectionService actionCollectionService,
NewActionService newActionService,
ResponseUtils responseUtils) {
ResponseUtils responseUtils,
JsonSchemaVersions jsonSchemaVersions) {
super(
gitFileUtils,
gitPrivateRepoHelper,
Expand All @@ -38,6 +40,7 @@ public GitApplicationHelperImpl(
newPageService,
actionCollectionService,
newActionService,
responseUtils);
responseUtils,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ExportServiceCEImpl implements ExportServiceCE {
private final ExportableService<Plugin> pluginExportableService;
private final ExportableService<CustomJSLib> customJSLibExportableService;
protected final Gson gson;
private final JsonSchemaVersions jsonSchemaVersions;

public ExportServiceCEImpl(
SessionUserService sessionUserService,
Expand All @@ -62,7 +63,8 @@ public ExportServiceCEImpl(
Gson gson,
ExportableService<Datasource> datasourceExportableService,
ExportableService<Plugin> pluginExportableService,
ExportableService<CustomJSLib> customJSLibExportableService) {
ExportableService<CustomJSLib> customJSLibExportableService,
JsonSchemaVersions jsonSchemaVersions) {
this.sessionUserService = sessionUserService;
this.analyticsService = analyticsService;
this.workspaceService = workspaceService;
Expand All @@ -71,6 +73,7 @@ public ExportServiceCEImpl(
this.datasourceExportableService = datasourceExportableService;
this.pluginExportableService = pluginExportableService;
this.customJSLibExportableService = customJSLibExportableService;
this.jsonSchemaVersions = jsonSchemaVersions;
}

@Override
Expand Down Expand Up @@ -122,8 +125,8 @@ public Mono<? extends ArtifactExchangeJson> exportByExportableArtifactIdAndBranc

ArtifactExchangeJson artifactExchangeJson = artifactBasedExportService.createNewArtifactExchangeJson();
// Set json schema version which will be used to check the compatibility while importing the JSON
artifactExchangeJson.setServerSchemaVersion(JsonSchemaVersions.serverVersion);
artifactExchangeJson.setClientSchemaVersion(JsonSchemaVersions.clientVersion);
artifactExchangeJson.setServerSchemaVersion(jsonSchemaVersions.getServerVersion());
artifactExchangeJson.setClientSchemaVersion(jsonSchemaVersions.getClientVersion());

// Find the transaction artifact with appropriate permission
Mono<? extends Artifact> exportableArtifactMono = artifactBasedExportService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.exports.exportable.ExportableService;
import com.appsmith.server.exports.internal.artifactbased.ArtifactBasedExportService;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.services.SessionUserService;
import com.appsmith.server.services.WorkspaceService;
Expand All @@ -26,7 +27,8 @@ public ExportServiceImpl(
Gson gson,
ExportableService<Datasource> datasourceExportableService,
ExportableService<Plugin> pluginExportableService,
ExportableService<CustomJSLib> customJSLibExportableService) {
ExportableService<CustomJSLib> customJSLibExportableService,
JsonSchemaVersions jsonSchemaVersions) {
super(
sessionUserService,
analyticsService,
Expand All @@ -35,6 +37,7 @@ public ExportServiceImpl(
gson,
datasourceExportableService,
pluginExportableService,
customJSLibExportableService);
customJSLibExportableService,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class PartialExportServiceCEImpl implements PartialExportServiceCE {
private final ExportableService<ActionCollection> actionCollectionExportableService;
private final SessionUserService sessionUserService;
private final AnalyticsService analyticsService;
private final JsonSchemaVersions jsonSchemaVersions;

@Override
public Mono<ApplicationJson> getPartialExportResources(
Expand All @@ -77,8 +78,8 @@ public Mono<ApplicationJson> getPartialExportResources(
exportingMetaDTO.setExportWithConfiguration(false);

// Set json schema version which will be used to check the compatibility while importing the JSON
applicationJson.setServerSchemaVersion(JsonSchemaVersions.serverVersion);
applicationJson.setClientSchemaVersion(JsonSchemaVersions.clientVersion);
applicationJson.setServerSchemaVersion(jsonSchemaVersions.getServerVersion());
applicationJson.setClientSchemaVersion(jsonSchemaVersions.getClientVersion());

AclPermission permission = applicationPermission.getExportPermission(false, false);
Mono<String> branchedPageIdMono =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.appsmith.server.domains.Plugin;
import com.appsmith.server.exports.exportable.ExportableService;
import com.appsmith.server.jslibs.base.CustomJSLibService;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;
import com.appsmith.server.services.AnalyticsService;
Expand All @@ -31,7 +32,8 @@ public PartialExportServiceImpl(
ExportableService<NewAction> newActionExportableService,
ExportableService<ActionCollection> actionCollectionExportableService,
SessionUserService sessionUserService,
AnalyticsService analyticsService) {
AnalyticsService analyticsService,
JsonSchemaVersions jsonSchemaVersions) {
super(
applicationService,
applicationPermission,
Expand All @@ -44,6 +46,7 @@ public PartialExportServiceImpl(
newActionExportableService,
actionCollectionExportableService,
sessionUserService,
analyticsService);
analyticsService,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class AutoCommitEligibilityHelperImpl extends AutoCommitEligibilityHelper
private final CommonGitFileUtils commonGitFileUtils;
private final DSLMigrationUtils dslMigrationUtils;
private final GitRedisUtils gitRedisUtils;
private final JsonSchemaVersions jsonSchemaVersions;

@Override
@FeatureFlagged(featureFlagName = FeatureFlagEnum.release_git_autocommit_eligibility_enabled)
Expand All @@ -49,7 +50,7 @@ public Mono<Boolean> isServerAutoCommitRequired(String workspaceId, GitArtifactM
defaultApplicationId,
branchName,
serverSchemaVersion);
return JsonSchemaVersions.serverVersion > serverSchemaVersion ? TRUE : FALSE;
return jsonSchemaVersions.getServerVersion() > serverSchemaVersion ? TRUE : FALSE;
})
.defaultIfEmpty(FALSE)
.cache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.appsmith.external.models.ApplicationGitReference;
import com.appsmith.git.files.FileUtilsImpl;
import com.appsmith.server.helpers.ce.CommonGitFileUtilsCE;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.services.SessionUserService;
import com.google.gson.Gson;
Expand All @@ -23,7 +24,14 @@ public CommonGitFileUtils(
FileOperations fileOperations,
AnalyticsService analyticsService,
SessionUserService sessionUserService,
Gson gson) {
super(applicationGitFileUtils, fileUtils, fileOperations, analyticsService, sessionUserService);
Gson gson,
JsonSchemaVersions jsonSchemaVersions) {
super(
applicationGitFileUtils,
fileUtils,
fileOperations,
analyticsService,
sessionUserService,
jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.appsmith.server.helpers;

import com.appsmith.server.helpers.ce.ResponseUtilsCE;
import com.appsmith.server.migrations.JsonSchemaVersions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ResponseUtils extends ResponseUtilsCE {}
public class ResponseUtils extends ResponseUtilsCE {

public ResponseUtils(JsonSchemaVersions jsonSchemaVersions) {
super(jsonSchemaVersions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class CommonGitFileUtilsCE {
@Value("${appsmith.index.lock.file.time}")
public final int INDEX_LOCK_FILE_STALE_TIME = 300;

private final JsonSchemaVersions jsonSchemaVersions;

private ArtifactGitFileUtils<?> getArtifactBasedFileHelper(ArtifactType artifactType) {
if (ArtifactType.APPLICATION.equals(artifactType)) {
return applicationGitFileUtils;
Expand Down Expand Up @@ -359,7 +361,7 @@ public Mono<Integer> getMetadataServerSchemaMigrationVersion(
workspaceId, defaultArtifactId, repoName, branchName, isResetToLastCommitRequired, artifactType)
.map(metadataMap -> {
return metadataMap.getOrDefault(
CommonConstants.SERVER_SCHEMA_VERSION, JsonSchemaVersions.serverVersion);
CommonConstants.SERVER_SCHEMA_VERSION, jsonSchemaVersions.getServerVersion());
});

return Mono.create(
Expand Down Expand Up @@ -422,7 +424,7 @@ public Mono<JSONObject> getPageDslVersionNumber(

private Integer getServerSchemaVersion(JsonObject metadataJsonObject) {
if (metadataJsonObject == null) {
return JsonSchemaVersions.serverVersion;
return jsonSchemaVersions.getServerVersion();
}

JsonElement serverSchemaVersion = metadataJsonObject.get(SERVER_SCHEMA_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.migrations.JsonSchemaVersions;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
Expand All @@ -26,8 +27,11 @@

@Slf4j
@Component
@RequiredArgsConstructor
public class ResponseUtilsCE {

protected final JsonSchemaVersions jsonSchemaVersions;

public PageDTO updatePageDTOWithDefaultResources(PageDTO page) {
DefaultResources defaultResourceIds = page.getDefaultResources();
if (defaultResourceIds == null
Expand Down Expand Up @@ -315,8 +319,8 @@ public Application updateApplicationWithDefaultResources(Application application

if (application.getClientSchemaVersion() == null
|| application.getServerSchemaVersion() == null
|| (JsonSchemaVersions.clientVersion.equals(application.getClientSchemaVersion())
&& JsonSchemaVersions.serverVersion.equals(application.getServerSchemaVersion()))) {
|| (jsonSchemaVersions.getClientVersion().equals(application.getClientSchemaVersion())
&& jsonSchemaVersions.getServerVersion().equals(application.getServerSchemaVersion()))) {
application.setIsAutoUpdate(false);
} else {
application.setIsAutoUpdate(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ImportServiceCEImpl implements ImportServiceCE {
private final ImportableService<Datasource> datasourceImportableService;
private final GsonBuilder gsonBuilder;
private final ArtifactExchangeJsonAdapter artifactExchangeJsonAdapter;
private final JsonSchemaMigration jsonSchemaMigration;

/**
* This method provides the importService specific to the artifact based on the ArtifactType.
Expand Down Expand Up @@ -420,7 +421,7 @@ private Mono<Artifact> importArtifactInWorkspace(
String artifactContextString = artifactSpecificConstantsMap.get(FieldName.ARTIFACT_CONTEXT);

// step 1: Schema Migration
ArtifactExchangeJson importedDoc = JsonSchemaMigration.migrateArtifactToLatestSchema(artifactExchangeJson);
ArtifactExchangeJson importedDoc = jsonSchemaMigration.migrateArtifactToLatestSchema(artifactExchangeJson);

// Step 2: Validation of artifact Json
// check for validation error and raise exception if error found
Expand Down
Loading