-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e58e95
commit e1adbc5
Showing
19 changed files
with
490 additions
and
143 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
...ver/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/GitAutoCommitHelper.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...-server/src/main/java/com/appsmith/server/helpers/ce/GitAutoCommitHelperCECompatible.java
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...ver/src/main/java/com/appsmith/server/helpers/ce/GitAutoCommitHelperCECompatibleImpl.java
This file was deleted.
Oops, something went wrong.
109 changes: 109 additions & 0 deletions
109
.../main/java/com/appsmith/server/helpers/ce/autocommit/AutoCommitEligibilityHelperImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.appsmith.server.helpers.ce.autocommit; | ||
|
||
import com.appsmith.server.constants.ArtifactType; | ||
import com.appsmith.server.domains.GitArtifactMetadata; | ||
import com.appsmith.server.domains.Layout; | ||
import com.appsmith.server.dtos.PageDTO; | ||
import com.appsmith.server.helpers.DSLMigrationUtils; | ||
import com.appsmith.server.helpers.GitUtils; | ||
import com.appsmith.server.migrations.JsonSchemaVersions; | ||
import com.appsmith.server.services.CommonGitService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.minidev.json.JSONObject; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
import static java.lang.Boolean.FALSE; | ||
import static java.lang.Boolean.TRUE; | ||
|
||
@Slf4j | ||
@Component | ||
public class AutoCommitEligibilityHelperImpl implements AutoCommitEligibiltyHelper { | ||
|
||
private final CommonGitService commonGitService; | ||
private final DSLMigrationUtils dslMigrationUtils; | ||
|
||
public AutoCommitEligibilityHelperImpl( | ||
@Lazy CommonGitService commonGitService, DSLMigrationUtils dslMigrationUtils) { | ||
this.commonGitService = commonGitService; | ||
this.dslMigrationUtils = dslMigrationUtils; | ||
} | ||
|
||
@Override | ||
public Mono<Boolean> isServerAutoCommitRequired(String workspaceId, GitArtifactMetadata gitMetadata) { | ||
|
||
String defaultApplicationId = gitMetadata.getDefaultArtifactId(); | ||
String branchName = gitMetadata.getBranchName(); | ||
String repoName = gitMetadata.getRepoName(); | ||
|
||
return commonGitService | ||
.getMetadataServerSchemaMigrationVersion( | ||
workspaceId, defaultApplicationId, branchName, repoName, ArtifactType.APPLICATION) | ||
.map(serverSchemaVersion -> { | ||
if (JsonSchemaVersions.serverVersion > serverSchemaVersion) { | ||
return TRUE; | ||
} | ||
|
||
return FALSE; | ||
}) | ||
.onErrorResume(error -> { | ||
log.debug( | ||
"error while retrieving the metadata for defaultApplicationId : {}, branchName : {}", | ||
defaultApplicationId, | ||
branchName); | ||
return Mono.just(FALSE); | ||
}); | ||
} | ||
|
||
@Override | ||
public Mono<Boolean> isClientMigrationRequired(PageDTO pageDTO) { | ||
return dslMigrationUtils | ||
.getLatestDslVersion() | ||
.map(latestDslVersion -> { | ||
// ensuring that the page has only one layout, as we don't support multiple layouts yet | ||
// when multiple layouts are supported, this code will have to be updated | ||
assert pageDTO.getLayouts().size() == 1; | ||
Layout layout = pageDTO.getLayouts().get(0); | ||
JSONObject layoutDsl = layout.getDsl(); | ||
return GitUtils.isMigrationRequired(layoutDsl, latestDslVersion); | ||
}) | ||
.onErrorResume(error -> { | ||
log.debug("Error fetching latest DSL version"); | ||
return Mono.just(Boolean.FALSE); | ||
}); | ||
} | ||
|
||
@Override | ||
public Mono<AutoCommitTriggerDTO> isAutoCommitRequired( | ||
String workspaceId, GitArtifactMetadata gitArtifactMetadata, PageDTO pageDTO) { | ||
String defaultApplicationId = gitArtifactMetadata.getDefaultArtifactId(); | ||
String branchName = gitArtifactMetadata.getBranchName(); | ||
|
||
Mono<Boolean> isClientAutocommitRequiredMono = | ||
isClientMigrationRequired(pageDTO).defaultIfEmpty(FALSE); | ||
|
||
Mono<Boolean> isServerAutocommitRequiredMono = isServerAutoCommitRequired(workspaceId, gitArtifactMetadata) | ||
.defaultIfEmpty(FALSE) | ||
.onErrorResume(error -> { | ||
log.debug( | ||
"Error in checking server migration for application id : {} branch name : {}", | ||
defaultApplicationId, | ||
branchName); | ||
return Mono.just(Boolean.FALSE); | ||
}); | ||
|
||
return isServerAutocommitRequiredMono | ||
.zipWith(isClientAutocommitRequiredMono) | ||
.map(tuple2 -> { | ||
Boolean serverFlag = tuple2.getT1(); | ||
Boolean clientFlag = tuple2.getT2(); | ||
|
||
AutoCommitTriggerDTO autoCommitTriggerDTO = new AutoCommitTriggerDTO(); | ||
autoCommitTriggerDTO.setIsClientAutoCommitRequired(TRUE.equals(clientFlag)); | ||
autoCommitTriggerDTO.setIsServerAutoCommitRequired(TRUE.equals(serverFlag)); | ||
autoCommitTriggerDTO.setIsAutoCommitRequired((TRUE.equals(serverFlag) || TRUE.equals(clientFlag))); | ||
return autoCommitTriggerDTO; | ||
}); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...r/src/main/java/com/appsmith/server/helpers/ce/autocommit/AutoCommitEligibiltyHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.appsmith.server.helpers.ce.autocommit; | ||
|
||
import com.appsmith.server.domains.GitArtifactMetadata; | ||
import com.appsmith.server.dtos.PageDTO; | ||
import reactor.core.publisher.Mono; | ||
|
||
public interface AutoCommitEligibiltyHelper { | ||
|
||
Mono<Boolean> isServerAutoCommitRequired(String workspaceId, GitArtifactMetadata gitMetadata); | ||
|
||
Mono<Boolean> isClientMigrationRequired(PageDTO pageDTO); | ||
|
||
Mono<AutoCommitTriggerDTO> isAutoCommitRequired( | ||
String workspaceId, GitArtifactMetadata gitArtifactMetadata, PageDTO pageDTO); | ||
} |
13 changes: 13 additions & 0 deletions
13
...-server/src/main/java/com/appsmith/server/helpers/ce/autocommit/AutoCommitTriggerDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.appsmith.server.helpers.ce.autocommit; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class AutoCommitTriggerDTO { | ||
|
||
private Boolean isAutoCommitRequired; | ||
|
||
private Boolean isClientAutoCommitRequired; | ||
|
||
private Boolean isServerAutoCommitRequired; | ||
} |
18 changes: 18 additions & 0 deletions
18
...h-server/src/main/java/com/appsmith/server/helpers/ce/autocommit/GitAutoCommitHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.appsmith.server.helpers.ce.autocommit; | ||
|
||
import com.appsmith.server.dtos.AutoCommitProgressDTO; | ||
import reactor.core.publisher.Mono; | ||
|
||
public interface GitAutoCommitHelper { | ||
|
||
Mono<Boolean> autoCommitApplication(String defaultApplicationId, String branchName, Boolean isClientMigration); | ||
|
||
Mono<AutoCommitProgressDTO> getAutoCommitProgress(String applicationId); | ||
|
||
Mono<Boolean> autoCommitClientMigration(String defaultApplicationId, String branchName); | ||
|
||
Mono<Boolean> autoCommitServerMigration(String defaultApplicationId, String branchName); | ||
|
||
Mono<Boolean> triggerAutoCommit( | ||
AutoCommitTriggerDTO autoCommitTriggerDTO, String defaultApplicationId, String branchName); | ||
} |
36 changes: 36 additions & 0 deletions
36
.../main/java/com/appsmith/server/helpers/ce/autocommit/GitAutoCommitHelperFallbackImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.appsmith.server.helpers.ce.autocommit; | ||
|
||
import com.appsmith.server.dtos.AutoCommitProgressDTO; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
public class GitAutoCommitHelperFallbackImpl implements GitAutoCommitHelper { | ||
|
||
@Override | ||
public Mono<Boolean> autoCommitClientMigration(String defaultApplicationId, String branchName) { | ||
return Mono.just(Boolean.FALSE); | ||
} | ||
|
||
@Override | ||
public Mono<Boolean> autoCommitServerMigration(String defaultApplicationId, String branchName) { | ||
return Mono.just(Boolean.FALSE); | ||
} | ||
|
||
@Override | ||
public Mono<Boolean> autoCommitApplication( | ||
String defaultApplicationId, String branchName, Boolean isClientMigration) { | ||
return Mono.just(Boolean.FALSE); | ||
} | ||
|
||
@Override | ||
public Mono<AutoCommitProgressDTO> getAutoCommitProgress(String applicationId) { | ||
return Mono.empty(); | ||
} | ||
|
||
@Override | ||
public Mono<Boolean> triggerAutoCommit( | ||
AutoCommitTriggerDTO autoCommitTriggerDTO, String defaultApplicationId, String branchName) { | ||
return Mono.just(Boolean.FALSE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.