diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java index f1153ffa2d..9c10df1ad6 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java @@ -4,6 +4,7 @@ import com.appsmith.external.helpers.Identifiable; import com.appsmith.external.views.FromRequest; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonView; import lombok.AccessLevel; import lombok.Getter; @@ -91,6 +92,12 @@ public abstract class BaseDomain implements Persistable, AppsmithDomain, @JsonView(Views.Public.class) public Set userPermissions = new HashSet<>(); + // This field will only be used for git related functionality to sync the action object across different instances. + // This field will be deprecated once we move to the new git sync implementation. + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @JsonView({Views.Internal.class, Git.class}) + String gitSyncId; + public void sanitiseToExportDBObject() { this.setCreatedAt(null); this.setUpdatedAt(null); diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BranchAwareDomain.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BranchAwareDomain.java index d33855af90..aae686b3c7 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BranchAwareDomain.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BranchAwareDomain.java @@ -11,7 +11,7 @@ import static com.appsmith.external.helpers.StringUtils.dotted; @Setter @Getter @FieldNameConstants -public abstract class BranchAwareDomain extends GitSyncedDomain { +public abstract class BranchAwareDomain extends BaseDomain { // This field will be used to store the default/root resource IDs for branched resources generated for git // connected applications and will be used to connect resources across the branches @JsonView(Views.Internal.class) @@ -23,7 +23,7 @@ public abstract class BranchAwareDomain extends GitSyncedDomain { super.sanitiseToExportDBObject(); } - public static class Fields extends GitSyncedDomain.Fields { + public static class Fields extends BaseDomain.Fields { public static final String defaultResources_applicationId = dotted(defaultResources, DefaultResources.Fields.applicationId); public static final String defaultResources_branchName = diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Datasource.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Datasource.java index cdf0931e96..4a2c979007 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Datasource.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Datasource.java @@ -25,7 +25,7 @@ import java.util.Set; @NoArgsConstructor @Document @FieldNameConstants -public class Datasource extends GitSyncedDomain { +public class Datasource extends BranchAwareDomain { @Transient public static final String DEFAULT_NAME_PREFIX = "Untitled datasource"; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceStorage.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceStorage.java index 361356d23e..ccd3cb1234 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceStorage.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceStorage.java @@ -26,7 +26,7 @@ import static com.appsmith.external.constants.PluginConstants.DEFAULT_REST_DATAS @NoArgsConstructor @Document @FieldNameConstants -public class DatasourceStorage extends GitSyncedDomain { +public class DatasourceStorage extends BaseDomain { @JsonView(Views.Public.class) String datasourceId; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/GitSyncedDomain.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/GitSyncedDomain.java deleted file mode 100644 index 10b9ca1b55..0000000000 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/GitSyncedDomain.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.appsmith.external.models; - -import com.appsmith.external.views.Git; -import com.appsmith.external.views.Views; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.FieldNameConstants; - -@Getter -@Setter -@FieldNameConstants -public abstract class GitSyncedDomain extends BaseDomain { - // This field will only be used for git related functionality to sync the action object across different instances. - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - @JsonView({Views.Internal.class, Git.class}) - String gitSyncId; - - public static class Fields extends BaseDomain.Fields {} -} 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 2f142d6db2..d8889bd077 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 @@ -310,8 +310,10 @@ public class ApplicationImportServiceCEImpl } if (applicationJson.getCustomJSLibList() != null) { - List importedCustomJSLibList = - applicationJson.getCustomJSLibList().stream().collect(Collectors.toList()); + List importedCustomJSLibList = applicationJson.getCustomJSLibList().stream() + .peek(customJSLib -> customJSLib.setGitSyncId( + null)) // setting this null so that this custom js lib can be imported again + .collect(Collectors.toList()); applicationJson.setCustomJSLibList(importedCustomJSLibList); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/CustomJSLibCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/CustomJSLibCE.java index 843075e356..4e3c5bca54 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/CustomJSLibCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/CustomJSLibCE.java @@ -1,6 +1,5 @@ package com.appsmith.server.domains.ce; -import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.BranchAwareDomain; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; @@ -23,7 +22,7 @@ import java.util.Set; @ToString @NoArgsConstructor @FieldNameConstants -public class CustomJSLibCE extends BaseDomain { +public class CustomJSLibCE extends BranchAwareDomain { /* Library name */ @JsonView({Views.Public.class, Git.class}) String name; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java index 82a423f9ae..ff8f44ab5b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/importable/artifactbased/ArtifactBasedImportableServiceCE.java @@ -1,7 +1,6 @@ package com.appsmith.server.imports.importable.artifactbased; import com.appsmith.external.models.BaseDomain; -import com.appsmith.external.models.GitSyncedDomain; import com.appsmith.server.domains.Artifact; import com.appsmith.server.domains.Context; import com.appsmith.server.dtos.ImportingMetaDTO; @@ -36,19 +35,11 @@ public interface ArtifactBasedImportableServiceCE entityInCurrentArtifact, T entity) { - if (entity instanceof GitSyncedDomain gitSyncedEntity) { - return entityInCurrentArtifact.get(gitSyncedEntity.getGitSyncId()); - } else { - return entity; - } + return entityInCurrentArtifact.get(entity.getGitSyncId()); } default T getExistingEntityInOtherBranchForImportedEntity( MappedImportableResourcesDTO mappedImportableResourcesDTO, Map entityInOtherArtifact, T entity) { - if (entity instanceof GitSyncedDomain gitSyncedEntity) { - return entityInOtherArtifact.get(gitSyncedEntity.getGitSyncId()); - } else { - return entity; - } + return entityInOtherArtifact.get(entity.getGitSyncId()); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog2.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog2.java index a40385b6cc..ca7ad5f15a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog2.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog2.java @@ -4,7 +4,6 @@ import com.appsmith.external.converters.ISOStringToInstantConverter; import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.BranchAwareDomain; import com.appsmith.external.models.Datasource; -import com.appsmith.external.models.GitSyncedDomain; import com.appsmith.external.models.PluginType; import com.appsmith.external.models.Policy; import com.appsmith.server.acl.AclPermission; @@ -116,7 +115,7 @@ public class DatabaseChangelog2 { ActionCollection.class, makeIndex( defaultResources + "." + FieldName.APPLICATION_ID, - GitSyncedDomain.Fields.gitSyncId, + BaseDomain.Fields.gitSyncId, FieldName.DELETED) .named("defaultApplicationId_gitSyncId_deleted")); @@ -125,7 +124,7 @@ public class DatabaseChangelog2 { NewAction.class, makeIndex( defaultResources + "." + FieldName.APPLICATION_ID, - GitSyncedDomain.Fields.gitSyncId, + BaseDomain.Fields.gitSyncId, FieldName.DELETED) .named("defaultApplicationId_gitSyncId_deleted")); @@ -134,7 +133,7 @@ public class DatabaseChangelog2 { NewPage.class, makeIndex( defaultResources + "." + FieldName.APPLICATION_ID, - GitSyncedDomain.Fields.gitSyncId, + BaseDomain.Fields.gitSyncId, FieldName.DELETED) .named("defaultApplicationId_gitSyncId_deleted")); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration051AddNewActionCollectionIdIndex.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration051AddNewActionCollectionIdIndex.java index a7e44a852d..72766b584c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration051AddNewActionCollectionIdIndex.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration051AddNewActionCollectionIdIndex.java @@ -1,6 +1,5 @@ package com.appsmith.server.migrations.db.ce; -import com.appsmith.external.models.GitSyncedDomain; import com.appsmith.server.domains.NewAction; import io.mongock.api.annotations.ChangeUnit; import io.mongock.api.annotations.Execution; @@ -41,14 +40,14 @@ public class Migration051AddNewActionCollectionIdIndex { Document unpublishedDoc = new Document(); unpublishedDoc.put(NewAction.Fields.unpublishedAction_collectionId, 1); - unpublishedDoc.put(GitSyncedDomain.Fields.deletedAt, 1); + unpublishedDoc.put(NewAction.Fields.deletedAt, 1); Index unpublishedCollectionIdIndex = new CompoundIndexDefinition(unpublishedDoc).named(unpublishedCollectionIdIndexName); ensureIndexes(mongoTemplate, NewAction.class, unpublishedCollectionIdIndex); Document publishedDoc = new Document(); publishedDoc.put(NewAction.Fields.publishedAction_collectionId, 1); - publishedDoc.put(GitSyncedDomain.Fields.deletedAt, 1); + publishedDoc.put(NewAction.Fields.deletedAt, 1); Index publishedCollectionIdIndex = new CompoundIndexDefinition(publishedDoc).named(publishedCollectionIdIndexName); ensureIndexes(mongoTemplate, NewAction.class, publishedCollectionIdIndex);