diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java index c488bd6c9b44..624dabcebab8 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java @@ -379,7 +379,7 @@ public Mono createAndCheckoutReference(Path repoSuffix, GitRefDTO gitRef refName, repoSuffix); - if (RefType.TAG.equals(refType)) { + if (RefType.tag.equals(refType)) { return createTag(git, gitRefDTO); } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java index 28fb9762f201..4d368e600fb8 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java @@ -1,6 +1,6 @@ package com.appsmith.external.git.constants.ce; public enum RefType { - BRANCH, - TAG + branch, + tag } 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 e067733a8094..ebd105707146 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 @@ -152,5 +152,5 @@ public void nullifyStorageReplicaFields() { this.setMessages(null); } - public static class Fields extends BranchAwareDomain.Fields {} + public static class Fields extends RefAwareDomain.Fields {} } 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/RefAwareDomain.java similarity index 53% rename from app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BranchAwareDomain.java rename to app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/RefAwareDomain.java index 8b3a9524a068..16b40bd91f50 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/RefAwareDomain.java @@ -1,5 +1,6 @@ package com.appsmith.external.models; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.views.Views; import com.fasterxml.jackson.annotation.JsonView; import lombok.Getter; @@ -9,7 +10,7 @@ @Setter @Getter @FieldNameConstants -public abstract class BranchAwareDomain extends GitSyncedDomain { +public abstract class RefAwareDomain extends GitSyncedDomain { @JsonView(Views.Public.class) String baseId; @@ -17,6 +18,34 @@ public abstract class BranchAwareDomain extends GitSyncedDomain { @JsonView(Views.Internal.class) String branchName; + @JsonView(Views.Internal.class) + RefType refType; + + @JsonView(Views.Internal.class) + String refName; + + public RefType getRefType() { + if (refType == null) { + if (this.getRefName() != null) { + return RefType.branch; + } else { + return null; + } + } + return refType; + } + + public String getRefName() { + return refName == null ? branchName : refName; + } + + public void setRefName(String refName) { + this.refName = refName; + if (this.getRefType() == RefType.branch) { + this.branchName = refName; + } + } + @JsonView(Views.Internal.class) public String getBaseIdOrFallback() { return baseId == null ? this.getId() : baseId; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java index dcd2639ec34a..fa6f2c4905a5 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java @@ -4,6 +4,7 @@ import com.appsmith.external.dtos.DslExecutableDTO; import com.appsmith.external.dtos.LayoutExecutableUpdateDTO; import com.appsmith.external.exceptions.ErrorDTO; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.helpers.Identifiable; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.CreatorContextType; @@ -172,7 +173,11 @@ public class ActionCE_DTO implements Identifiable, Executable { @Transient @JsonView({Views.Internal.class}) - private String branchName; + private RefType refType; + + @Transient + @JsonView({Views.Internal.class}) + private String refName; // TODO Abhijeet: Remove this method once we have migrated all the usages of policies to policyMap /** diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java index 7f44a12aea7b..8b70562597f2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java @@ -26,14 +26,9 @@ Flux findAllByApplicationIdAndViewMode( Flux saveAll(List collections); - Mono findByBaseIdAndBranchName(String id, String branchName); - Flux getPopulatedActionCollectionsByViewMode( MultiValueMap params, Boolean viewMode); - Flux getPopulatedActionCollectionsByViewMode( - MultiValueMap params, Boolean viewMode, String branchName); - Mono populateActionCollectionByViewMode( ActionCollectionDTO actionCollectionDTO1, Boolean viewMode); @@ -70,9 +65,6 @@ Flux getCollectionsByPageIdAndViewMode( Mono archiveById(String id); - Mono findByBranchNameAndBaseCollectionId( - String branchName, String baseCollectionId, AclPermission permission); - Mono> archiveActionCollectionByApplicationId(String applicationId, AclPermission permission); Flux findAllActionCollectionsByContextIdAndContextTypeAndViewMode( diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java index f87bc9af4ea1..207a8ff04446 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java @@ -26,7 +26,6 @@ import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort; -import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import reactor.core.observability.micrometer.Micrometer; @@ -127,12 +126,6 @@ public Flux saveAll(List collections) { return repository.saveAll(collections); } - @Override - public Mono findByBaseIdAndBranchName(String id, String branchName) { - // TODO sanitise response for default IDs - return this.findByBranchNameAndBaseCollectionId(branchName, id, actionPermission.getReadPermission()); - } - @Override public Flux getPopulatedActionCollectionsByViewMode( MultiValueMap params, Boolean viewMode) { @@ -140,16 +133,6 @@ public Flux getPopulatedActionCollectionsByViewMode( .flatMap(actionCollectionDTO -> this.populateActionCollectionByViewMode(actionCollectionDTO, viewMode)); } - @Override - public Flux getPopulatedActionCollectionsByViewMode( - MultiValueMap params, Boolean viewMode, String branchName) { - MultiValueMap updatedMap = new LinkedMultiValueMap<>(params); - if (StringUtils.hasLength(branchName)) { - updatedMap.add(FieldName.BRANCH_NAME, branchName); - } - return this.getPopulatedActionCollectionsByViewMode(updatedMap, viewMode); - } - @Override public Mono populateActionCollectionByViewMode( ActionCollectionDTO actionCollectionDTO1, Boolean viewMode) { @@ -459,23 +442,6 @@ protected Mono archiveGivenActionCollection(ActionCollection a deletedActionCollection, getAnalyticsProperties(deletedActionCollection))); } - @Override - public Mono findByBranchNameAndBaseCollectionId( - String branchName, String baseCollectionId, AclPermission permission) { - - if (StringUtils.isEmpty(baseCollectionId)) { - return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.COLLECTION_ID)); - } else if (StringUtils.isEmpty(branchName)) { - return this.findById(baseCollectionId, permission) - .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.NO_RESOURCE_FOUND, FieldName.ACTION_COLLECTION, baseCollectionId))); - } - return repository - .findByBranchNameAndBaseCollectionId(branchName, baseCollectionId, permission) - .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.ACTION_COLLECTION, baseCollectionId))); - } - @Override public Map getAnalyticsProperties(ActionCollection savedActionCollection) { final ActionCollectionDTO unpublishedCollection = savedActionCollection.getUnpublishedCollection(); @@ -546,7 +512,8 @@ protected Mono createJsAction(ActionCollection actionCollection, Acti newAction.setPolicies(actionCollectionPolicies); newActionService.setCommonFieldsFromActionDTOIntoNewAction(action, newAction); - newAction.setBranchName(actionCollection.getBranchName()); + newAction.setRefType(actionCollection.getRefType()); + newAction.setRefName(actionCollection.getRefName()); Mono sendAnalyticsMono = analyticsService.sendCreateEvent(newAction, newActionService.getAnalyticsProperties(newAction)); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java index 5586e16eb3ad..0fb942013c19 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/ActionCollectionImportableServiceCEImpl.java @@ -346,7 +346,8 @@ private void updateExistingCollection( populateDomainMappedReferences(mappedImportableResourcesDTO, existingActionCollection); // Update branchName - existingActionCollection.setBranchName(importingMetaDTO.getBranchName()); + existingActionCollection.setRefType(importingMetaDTO.getRefType()); + existingActionCollection.setRefName(importingMetaDTO.getRefName()); // Recover the deleted state present in DB from imported actionCollection existingActionCollection .getUnpublishedCollection() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/applications/ActionCollectionApplicationImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/applications/ActionCollectionApplicationImportableServiceCEImpl.java index fd077fa62da3..0595b5abee0e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/applications/ActionCollectionApplicationImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/importable/applications/ActionCollectionApplicationImportableServiceCEImpl.java @@ -102,7 +102,8 @@ public void createNewResource( // create or update base id for the action // values already set to base id are kept unchanged actionCollection.setBaseId(actionCollection.getBaseIdOrFallback()); - actionCollection.setBranchName(importingMetaDTO.getBranchName()); + actionCollection.setRefType(importingMetaDTO.getRefType()); + actionCollection.setRefName(importingMetaDTO.getRefName()); // generate gitSyncId if it's not present if (actionCollection.getGitSyncId() == null) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java index afd1ad6335a6..84112ee414ee 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java @@ -308,10 +308,10 @@ public Mono update(String id, Application application) { Mono applicationIdMono; GitArtifactMetadata gitData = application.getGitApplicationMetadata(); if (gitData != null - && !StringUtils.isEmpty(gitData.getBranchName()) + && !StringUtils.isEmpty(gitData.getRefName()) && !StringUtils.isEmpty(gitData.getDefaultArtifactId())) { applicationIdMono = this.findByBranchNameAndBaseApplicationId( - gitData.getBranchName(), + gitData.getRefName(), gitData.getDefaultArtifactId(), applicationPermission.getEditPermission()) .map(Application::getId); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java index 8b15d289ee26..0219547cd849 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java @@ -120,7 +120,7 @@ public Mono getSshKeys(String baseArtifactId) { @Override public Mono createNewArtifactForCheckout(Artifact sourceArtifact, String branchName) { GitArtifactMetadata sourceBranchGitData = sourceArtifact.getGitArtifactMetadata(); - sourceBranchGitData.setBranchName(branchName); + sourceBranchGitData.setRefName(branchName); sourceBranchGitData.setIsRepoPrivate(null); // Save new artifact in DB and update from the parent branch application sourceBranchGitData.setGitAuth(null); @@ -260,7 +260,8 @@ public Mono disconnectEntitiesOfBaseArtifact(Artifact baseArtifact) .flatMap(page -> newPageService.findById(page.getId(), null)) .map(newPage -> { newPage.setBaseId(newPage.getId()); - newPage.setBranchName(null); + newPage.setRefType(null); + newPage.setRefName(null); return newPage; }) .collectList() @@ -272,7 +273,8 @@ public Mono disconnectEntitiesOfBaseArtifact(Artifact baseArtifact) .findByPageId(newPage.getId(), Optional.empty()) .map(newAction -> { newAction.setBaseId(newAction.getId()); - newAction.setBranchName(null); + newAction.setRefType(null); + newAction.setRefName(null); return newAction; }) .collectList() @@ -284,7 +286,8 @@ public Mono disconnectEntitiesOfBaseArtifact(Artifact baseArtifact) .findByPageId(newPage.getId()) .map(actionCollection -> { actionCollection.setBaseId(actionCollection.getId()); - actionCollection.setBranchName(null); + actionCollection.setRefType(null); + actionCollection.setRefName(null); return actionCollection; }) .collectList() @@ -334,7 +337,7 @@ public Mono publishArtifactPostRefCreation( Artifact artifact, RefType refType, Boolean isPublishedManually) { // TODO: create publish for ref type creation. Application application = (Application) artifact; - if (RefType.TAG.equals(refType)) { + if (RefType.tag.equals(refType)) { return Mono.just(application); } 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 3d0703c82582..1ab22bc3d8f5 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 @@ -460,12 +460,6 @@ public Mono updateAndSaveArtifactInContext( } } return importApplicationMono - .doOnNext(application -> { - if (application.getGitArtifactMetadata() != null) { - importingMetaDTO.setBranchName( - application.getGitArtifactMetadata().getBranchName()); - } - }) .elapsed() .map(tuples -> { log.debug("time to create or update application object: {}", tuples.getT1()); @@ -654,14 +648,13 @@ public Mono migrateArtifactExchangeJson( return applicationService.findById(branchedArtifactId).flatMap(application -> { String baseArtifactId = application.getBaseId(); - String branchName = null; + String refName = null; if (application.getGitArtifactMetadata() != null) { - branchName = application.getGitArtifactMetadata().getBranchName(); + refName = application.getGitArtifactMetadata().getRefName(); } - return jsonSchemaMigration.migrateApplicationJsonToLatestSchema( - applicationJson, baseArtifactId, branchName); + return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, baseArtifactId, refName); }); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ConsolidatedAPIController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ConsolidatedAPIController.java index ee2b15db4504..67eea1fc09c0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ConsolidatedAPIController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ConsolidatedAPIController.java @@ -1,5 +1,6 @@ package com.appsmith.server.controllers; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.views.Views; import com.appsmith.server.constants.FieldName; import com.appsmith.server.constants.Url; @@ -11,6 +12,7 @@ import io.micrometer.observation.ObservationRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @@ -47,22 +49,30 @@ public ConsolidatedAPIController( public Mono> getAllDataForFirstPageLoadForEditMode( @RequestParam(name = FieldName.APPLICATION_ID, required = false) String baseApplicationId, @RequestParam(name = "defaultPageId", required = false) String basePageId, + @RequestHeader(required = false, defaultValue = "branch") RefType refType, + @RequestHeader(required = false) String refName, @RequestHeader(required = false) String branchName) { + + if (!StringUtils.hasLength(refName)) { + refName = branchName; + } log.debug( - "Going to fetch consolidatedAPI response for baseApplicationId: {}, basePageId: {}, branchName: {}, " + "Going to fetch consolidatedAPI response for baseApplicationId: {}, basePageId: {}, {}: {}, " + "mode: {}", baseApplicationId, basePageId, - branchName, + refType, + refName, ApplicationMode.EDIT); return consolidatedAPIService - .getConsolidatedInfoForPageLoad(basePageId, baseApplicationId, branchName, ApplicationMode.EDIT) + .getConsolidatedInfoForPageLoad(basePageId, baseApplicationId, refType, refName, ApplicationMode.EDIT) .map(consolidatedAPIResponseDTO -> new ResponseDTO<>(HttpStatus.OK.value(), consolidatedAPIResponseDTO, null)) .tag("pageId", Objects.toString(basePageId)) .tag("applicationId", Objects.toString(baseApplicationId)) - .tag("branchName", Objects.toString(branchName)) + .tag("refType", Objects.toString(refType)) + .tag("refName", Objects.toString(refName)) .name(CONSOLIDATED_API_ROOT_EDIT) .tap(Micrometer.observation(observationRegistry)); } @@ -72,22 +82,31 @@ public Mono> getAllDataForFirstPageLoadF public Mono> getAllDataForFirstPageLoadForViewMode( @RequestParam(required = false) String applicationId, @RequestParam(required = false) String defaultPageId, - @RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) { + @RequestHeader(required = false, defaultValue = "branch") RefType refType, + @RequestHeader(required = false) String refName, + @RequestHeader(required = false) String branchName) { + + if (!StringUtils.hasLength(refName)) { + refName = branchName; + } log.debug( - "Going to fetch consolidatedAPI response for applicationId: {}, defaultPageId: {}, branchName: {}, " + "Going to fetch consolidatedAPI response for applicationId: {}, defaultPageId: {}, {}: {}, " + "mode: {}", applicationId, defaultPageId, - branchName, + refType, + refName, ApplicationMode.PUBLISHED); return consolidatedAPIService - .getConsolidatedInfoForPageLoad(defaultPageId, applicationId, branchName, ApplicationMode.PUBLISHED) + .getConsolidatedInfoForPageLoad( + defaultPageId, applicationId, refType, refName, ApplicationMode.PUBLISHED) .map(consolidatedAPIResponseDTO -> new ResponseDTO<>(HttpStatus.OK.value(), consolidatedAPIResponseDTO, null)) .tag("pageId", Objects.toString(defaultPageId)) .tag("applicationId", Objects.toString(applicationId)) - .tag("branchName", Objects.toString(branchName)) + .tag("refType", Objects.toString(refType)) + .tag("refName", Objects.toString(refName)) .name(CONSOLIDATED_API_ROOT_VIEW) .tap(Micrometer.observation(observationRegistry)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/PageControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/PageControllerCE.java index 16f0f321f5c2..1985ce71d9dc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/PageControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/PageControllerCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.controllers.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.views.Views; import com.appsmith.server.constants.FieldName; import com.appsmith.server.constants.Url; @@ -189,7 +190,7 @@ public Mono> updateDependencyMap( @RequestBody(required = false) Map> dependencyMap, @RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) { return newPageService - .updateDependencyMap(defaultPageId, dependencyMap, branchName) + .updateDependencyMap(defaultPageId, dependencyMap, RefType.branch, branchName) .map(updatedResource -> new ResponseDTO<>(HttpStatus.OK.value(), updatedResource, null)); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Context.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Context.java index 7536e1b10102..cffae91dd329 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Context.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Context.java @@ -1,5 +1,7 @@ package com.appsmith.server.domains; +import com.appsmith.external.git.constants.ce.RefType; + public interface Context { String getId(); @@ -8,7 +10,9 @@ public interface Context { Layout getLayout(); - String getBranchName(); + RefType getRefType(); + + String getRefName(); String getUnpublishedName(); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/NewPage.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/NewPage.java index dec5d5239005..8b050a6db5a5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/NewPage.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/NewPage.java @@ -1,6 +1,6 @@ package com.appsmith.server.domains; -import com.appsmith.external.models.BranchAwareDomain; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; import com.appsmith.server.dtos.PageDTO; @@ -18,7 +18,7 @@ @NoArgsConstructor @Document @FieldNameConstants -public class NewPage extends BranchAwareDomain implements Context { +public class NewPage extends RefAwareDomain implements Context { @JsonView(Views.Public.class) String applicationId; @@ -66,7 +66,7 @@ public String getUnpublishedName() { return this.getUnpublishedPage().getName(); } - public static class Fields extends BranchAwareDomain.Fields { + public static class Fields extends RefAwareDomain.Fields { public static String unpublishedPage_layouts = unpublishedPage + "." + PageDTO.Fields.layouts; public static String unpublishedPage_name = unpublishedPage + "." + PageDTO.Fields.name; public static String unpublishedPage_icon = unpublishedPage + "." + PageDTO.Fields.icon; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ActionCollectionCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ActionCollectionCE.java index 7eb005d1efc2..0540f0b937e8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ActionCollectionCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ActionCollectionCE.java @@ -1,7 +1,7 @@ package com.appsmith.server.domains.ce; -import com.appsmith.external.models.BranchAwareDomain; import com.appsmith.external.models.CreatorContextType; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; import com.appsmith.server.dtos.ActionCollectionDTO; @@ -21,8 +21,8 @@ @Setter @ToString @FieldNameConstants -public class ActionCollectionCE extends BranchAwareDomain { - // Default resources from BranchAwareDomain will be used to store branchName, defaultApplicationId and +public class ActionCollectionCE extends RefAwareDomain { + // Default resources from RefAwareDomain will be used to store branchName, defaultApplicationId and // defaultActionCollectionId @JsonView(Views.Public.class) String applicationId; @@ -52,7 +52,7 @@ public void sanitiseToExportDBObject() { super.sanitiseToExportDBObject(); } - public static class Fields extends BranchAwareDomain.Fields { + public static class Fields extends RefAwareDomain.Fields { public static final String publishedCollection_name = dotted(publishedCollection, ActionCollectionDTO.Fields.name); public static final String unpublishedCollection_name = 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 428f96f1cd87..2b76aabbda79 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,7 +1,7 @@ package com.appsmith.server.domains.ce; import com.appsmith.external.models.BaseDomain; -import com.appsmith.external.models.BranchAwareDomain; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; import com.appsmith.server.helpers.CollectionUtils; @@ -124,5 +124,5 @@ public void sanitiseToExportDBObject() { this.setUpdatedAt(null); } - public static class Fields extends BranchAwareDomain.Fields {} + public static class Fields extends RefAwareDomain.Fields {} } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java index f0988e8956c8..546e60d033b5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java @@ -21,19 +21,16 @@ @Data @FieldNameConstants public class GitArtifactMetadataCE implements AppsmithDomain { + // Git branch corresponding to this application, we have one to one mapping for application in DB with git-branch @JsonView(Views.Public.class) String branchName; - // TODO: make this public view and remove transient annotation once implmentation completes - @Transient @JsonView(Views.Internal.class) - String refName; + RefType refType; - // TODO: make this public view and remove transient annotation once implementation completes - @Transient @JsonView(Views.Internal.class) - RefType refType; + String refName; // Git default branch corresponding to the remote git repo to which the application is connected to @JsonView(Views.Public.class) @@ -130,16 +127,21 @@ public void setDefaultApplicationId(String defaultApplicationId) { this.defaultArtifactId = defaultApplicationId; } + public RefType getRefType() { + return refType == null ? RefType.branch : refType; + } + /** * this returns the branchName instead of reference name * @return returns the ref name. */ public String getRefName() { - return this.getBranchName(); + return this.refName == null ? this.branchName : this.refName; } public void setRefName(String refName) { this.branchName = refName; + this.refName = refName; } public static class Fields {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java index 8751c3c335f5..f4dfd4823d23 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java @@ -2,10 +2,10 @@ import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; -import com.appsmith.external.models.BranchAwareDomain; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.Documentation; import com.appsmith.external.models.PluginType; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; import com.fasterxml.jackson.annotation.JsonView; @@ -20,7 +20,7 @@ @Setter @ToString @FieldNameConstants -public class NewActionCE extends BranchAwareDomain { +public class NewActionCE extends RefAwareDomain { // Fields in action that are not allowed to change between published and unpublished versions @JsonView(Views.Public.class) @@ -61,7 +61,7 @@ public void sanitiseToExportDBObject() { super.sanitiseToExportDBObject(); } - public static class Fields extends BranchAwareDomain.Fields { + public static class Fields extends RefAwareDomain.Fields { public static final String unpublishedAction_datasource_id = dotted(unpublishedAction, ActionDTO.Fields.datasource, Datasource.Fields.id); public static final String unpublishedAction_name = dotted(unpublishedAction, ActionDTO.Fields.name); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ClonePageMetaDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ClonePageMetaDTO.java index b8d37d15e8f4..fb1fad9ee0ef 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ClonePageMetaDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ClonePageMetaDTO.java @@ -1,5 +1,6 @@ package com.appsmith.server.dtos; +import com.appsmith.external.git.constants.ce.RefType; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -15,6 +16,7 @@ public class ClonePageMetaDTO { String branchedSourcePageId; PageDTO clonedPageDTO; - String branchName; + RefType refType; + String refName; Map oldToNewCollectionIds = new HashMap<>(); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExportingMetaDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExportingMetaDTO.java index c37a8ec24f12..84ded5d71d47 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExportingMetaDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ExportingMetaDTO.java @@ -15,7 +15,7 @@ public class ExportingMetaDTO { String artifactType; String artifactId; - String branchName; + String refName; Boolean isGitSync; Boolean exportWithConfiguration; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java index b706e23c0bae..4b231ef5c074 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ImportingMetaDTO.java @@ -1,5 +1,6 @@ package com.appsmith.server.dtos; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.helpers.ImportArtifactPermissionProvider; import lombok.AllArgsConstructor; import lombok.Builder; @@ -22,7 +23,9 @@ public class ImportingMetaDTO { */ String artifactId; - String branchName; + RefType refType; + + String refName; List branchedArtifactIds; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/PageDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/PageDTO.java index 816f82b28689..7bd8d3d0f6de 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/PageDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/PageDTO.java @@ -1,5 +1,6 @@ package com.appsmith.server.dtos; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.Policy; import com.appsmith.external.views.Git; import com.appsmith.external.views.Views; @@ -78,7 +79,11 @@ public class PageDTO { @Transient @JsonView({Views.Internal.class}) - String branchName; + RefType refType; + + @Transient + @JsonView({Views.Internal.class}) + String refName; @JsonView(Views.Public.class) Map> dependencyMap; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/IntegrationCE_DTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/IntegrationCE_DTO.java index 9066ffc268db..5bc8e9a93370 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/IntegrationCE_DTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/IntegrationCE_DTO.java @@ -1,5 +1,6 @@ package com.appsmith.server.dtos.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.AuthenticationResponse; import com.appsmith.external.models.CreatorContextType; import com.fasterxml.jackson.annotation.JsonProperty; @@ -38,7 +39,9 @@ public class IntegrationCE_DTO { String redirectionDomain; - String branch; + RefType refType; + + String refName; String importForGit; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/ExportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/ExportServiceCEImpl.java index b430db8c64f3..7da363b55e5e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/ExportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/ExportServiceCEImpl.java @@ -135,7 +135,7 @@ public Mono exportByExportableArtifactIdAndBranc // from here exportingMetaDTO.setArtifactType(artifactContextConstantMap.get(ARTIFACT_CONTEXT)); exportingMetaDTO.setArtifactId(transactionArtifact.getId()); - exportingMetaDTO.setBranchName(null); + exportingMetaDTO.setRefName(null); exportingMetaDTO.setIsGitSync(isGitSync); exportingMetaDTO.setExportWithConfiguration(exportWithConfiguration); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/partial/PartialExportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/partial/PartialExportServiceCEImpl.java index 2fd276dc31d8..05325c77e904 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/partial/PartialExportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exports/internal/partial/PartialExportServiceCEImpl.java @@ -72,7 +72,7 @@ public Mono getPartialExportResources( exportingMetaDTO.setArtifactType(FieldName.APPLICATION); exportingMetaDTO.setArtifactId(branchedApplicationId); - exportingMetaDTO.setBranchName(null); + exportingMetaDTO.setRefName(null); exportingMetaDTO.setIsGitSync(false); exportingMetaDTO.setExportWithConfiguration(false); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/fork/internal/ApplicationForkingServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/fork/internal/ApplicationForkingServiceCEImpl.java index 48b66a44e1b8..62fc9d9bdec4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/fork/internal/ApplicationForkingServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/fork/internal/ApplicationForkingServiceCEImpl.java @@ -268,7 +268,8 @@ public Mono> forkApplications( newAction.getId()); action.setPageId(savedPage.getId()); action.setBaseId(null); - action.setBranchName(null); + action.setRefType(null); + action.setRefName(null); return newAction; }) .flatMap(newAction -> { @@ -505,7 +506,7 @@ public Mono forkApplicationToWorkspace( if ((application.getGitApplicationMetadata() == null) || application .getGitApplicationMetadata() - .getBranchName() + .getRefName() .equals(application .getGitApplicationMetadata() .getDefaultBranchName())) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java index 5115c99f08fd..4713c8401779 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java @@ -82,9 +82,9 @@ public Mono autoCommitApplication(String branchedApplicat String workspaceId = branchedApplication.getWorkspaceId(); GitArtifactMetadata branchedGitMetadata = branchedApplication.getGitArtifactMetadata(); final String baseApplicationId = branchedGitMetadata.getDefaultArtifactId(); - final String branchName = branchedGitMetadata.getBranchName(); + final String refName = branchedGitMetadata.getRefName(); - if (!hasText(branchName)) { + if (!hasText(refName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); } @@ -92,14 +92,14 @@ public Mono autoCommitApplication(String branchedApplicat autoCommitEligibilityHelper.isAutoCommitRequired(workspaceId, branchedGitMetadata, pageDTO); Mono autoCommitProgressDTOMono = - gitAutoCommitHelper.getAutoCommitProgress(baseApplicationId, branchName); + gitAutoCommitHelper.getAutoCommitProgress(baseApplicationId, refName); return autoCommitProgressDTOMono.flatMap(autoCommitProgressDTO -> { if (Set.of(LOCKED, IN_PROGRESS).contains(autoCommitProgressDTO.getAutoCommitResponse())) { log.info( "application with id: {}, has requested auto-commit for branch name: {}, however an event for branch name: {} is already in progress", baseApplicationId, - branchName, + refName, autoCommitProgressDTO.getBranchName()); autoCommitResponseDTO.setAutoCommitResponse(autoCommitProgressDTO.getAutoCommitResponse()); autoCommitResponseDTO.setProgress(autoCommitProgressDTO.getProgress()); @@ -112,7 +112,7 @@ public Mono autoCommitApplication(String branchedApplicat log.info( "application with id: {}, and branch name: {} is not eligible for autocommit", baseApplicationId, - branchName); + refName); autoCommitResponseDTO.setAutoCommitResponse(IDLE); return Mono.just(autoCommitResponseDTO); } @@ -121,15 +121,15 @@ public Mono autoCommitApplication(String branchedApplicat log.info( "application with id: {}, and branch name: {} is eligible for autocommit", baseApplicationId, - branchName); + refName); return gitAutoCommitHelper - .publishAutoCommitEvent(autoCommitTriggerDTO, baseApplicationId, branchName) + .publishAutoCommitEvent(autoCommitTriggerDTO, baseApplicationId, refName) .map(isEventPublished -> { if (TRUE.equals(isEventPublished)) { log.info( "autocommit event for application with id: {}, and branch name: {} is published", baseApplicationId, - branchName); + refName); autoCommitResponseDTO.setAutoCommitResponse(PUBLISHED); return autoCommitResponseDTO; } @@ -137,7 +137,7 @@ public Mono autoCommitApplication(String branchedApplicat log.info( "application with id: {}, and branch name: {} does not fulfil the prerequisite for autocommit", baseApplicationId, - branchName); + refName); autoCommitResponseDTO.setAutoCommitResponse(REQUIRED); return autoCommitResponseDTO; }); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java index c8958c5c4ae2..2c18be3b1702 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java @@ -36,7 +36,7 @@ public class AutoCommitEligibilityHelperImpl implements AutoCommitEligibilityHel public Mono isServerAutoCommitRequired(String workspaceId, GitArtifactMetadata gitMetadata) { String defaultApplicationId = gitMetadata.getDefaultArtifactId(); - String branchName = gitMetadata.getBranchName(); + String refName = gitMetadata.getRefName(); Mono isServerMigrationRequiredMonoCached = commonGitFileUtils .getMetadataServerSchemaMigrationVersion(workspaceId, gitMetadata, FALSE, APPLICATION) @@ -44,7 +44,7 @@ public Mono isServerAutoCommitRequired(String workspaceId, GitArtifactM log.info( "server schema for application id : {} and branch name : {} is : {}", defaultApplicationId, - branchName, + refName, serverSchemaVersion); return jsonSchemaVersions.getServerVersion() > serverSchemaVersion ? TRUE : FALSE; }) @@ -53,9 +53,9 @@ public Mono isServerAutoCommitRequired(String workspaceId, GitArtifactM return Mono.defer(() -> isServerMigrationRequiredMonoCached).onErrorResume(error -> { log.debug( - "error while retrieving the metadata for defaultApplicationId : {}, branchName : {} error : {}", + "error while retrieving the metadata for defaultApplicationId : {}, refName : {} error : {}", defaultApplicationId, - branchName, + refName, error.getMessage()); return Mono.just(FALSE); }); @@ -93,7 +93,7 @@ public Mono isClientMigrationRequired(PageDTO pageDTO) { public Mono isClientMigrationRequiredFSOps( String workspaceId, GitArtifactMetadata gitMetadata, PageDTO pageDTO) { String defaultApplicationId = gitMetadata.getDefaultArtifactId(); - String branchName = gitMetadata.getBranchName(); + String refName = gitMetadata.getRefName(); Mono latestDslVersionMono = dslMigrationUtils.getLatestDslVersion(); @@ -111,10 +111,10 @@ public Mono isClientMigrationRequiredFSOps( return Mono.defer(() -> isClientMigrationRequired).onErrorResume(error -> { log.debug( - "error while fetching the dsl version for page : {}, defaultApplicationId : {}, branchName : {} error : {}", + "error while fetching the dsl version for page : {}, defaultApplicationId : {}, refName : {} error : {}", pageDTO.getName(), defaultApplicationId, - branchName, + refName, error.getMessage()); return Mono.just(FALSE); }); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java index 460be19c7813..e765af02f3d7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java @@ -208,7 +208,7 @@ public Mono importArtifactFromGit( gitArtifactMetadata.setGitAuth(gitAuth); gitArtifactMetadata.setDefaultArtifactId(artifact.getId()); gitArtifactMetadata.setDefaultBranchName(defaultBranch); - gitArtifactMetadata.setBranchName(defaultBranch); + gitArtifactMetadata.setRefName(defaultBranch); gitArtifactMetadata.setRepoName(repoName); gitArtifactMetadata.setIsRepoPrivate(isRepoPrivate); gitArtifactMetadata.setLastCommittedAt(Instant.now()); @@ -236,7 +236,7 @@ public Mono importArtifactFromGit( jsonMorphDTO.setBaseArtifactId(artifact.getId()); jsonMorphDTO.setArtifactType(artifactType); jsonMorphDTO.setRepoName(gitArtifactMetadata.getRepoName()); - jsonMorphDTO.setRefType(RefType.BRANCH); + jsonMorphDTO.setRefType(RefType.branch); jsonMorphDTO.setRefName(defaultBranch); Mono artifactExchangeJsonMono = gitHandlingService @@ -487,7 +487,7 @@ private Mono checkoutRemoteReference( final String repoName = baseGitMetadata.getRepoName(); final String baseArtifactId = baseGitMetadata.getDefaultArtifactId(); - final String baseBranchName = baseGitMetadata.getBranchName(); + final String baseRefName = baseGitMetadata.getRefName(); final String workspaceId = baseArtifact.getWorkspaceId(); final String finalRemoteRefName = gitRefDTO.getRefName().replaceFirst(ORIGIN, REMOTE_NAME_REPLACEMENT); @@ -500,7 +500,7 @@ private Mono checkoutRemoteReference( jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); Mono artifactMono; - if (baseBranchName.equals(finalRemoteRefName)) { + if (baseRefName.equals(finalRemoteRefName)) { /* in this case, user deleted the initial default branch and now wants to check out to that branch. as we didn't delete the application object but only the branch from git repo, @@ -694,7 +694,7 @@ protected Mono createReference( protected Mono isValidationForRefCreationComplete( Artifact baseArtifact, Artifact parentArtifact, GitType gitType, RefType refType) { - if (RefType.BRANCH.equals(refType)) { + if (RefType.branch.equals(refType)) { return Mono.just(TRUE); } @@ -1006,7 +1006,7 @@ public Mono connectArtifactToGit( GitArtifactMetadata gitArtifactMetadata = artifact.getGitArtifactMetadata(); gitArtifactMetadata.setDefaultArtifactId(artifactId); - gitArtifactMetadata.setBranchName(defaultBranch); + gitArtifactMetadata.setRefName(defaultBranch); gitArtifactMetadata.setDefaultBranchName(defaultBranch); gitArtifactMetadata.setRepoName(repoName); gitArtifactMetadata.setIsRepoPrivate(isRepoPrivate); @@ -1204,7 +1204,7 @@ private Mono commitArtifact( return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR)); } - final String branchName = branchedGitMetadata.getBranchName(); + final String branchName = branchedGitMetadata.getRefName(); if (!hasText(branchName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); } @@ -1264,7 +1264,7 @@ private Mono commitArtifact( }) .flatMap(artifact -> { String errorEntity = ""; - if (!StringUtils.hasText(branchedGitMetadata.getBranchName())) { + if (!StringUtils.hasText(branchedGitMetadata.getRefName())) { errorEntity = "branch name"; } else if (!StringUtils.hasText(branchedGitMetadata.getDefaultArtifactId())) { errorEntity = "default artifact"; @@ -1282,14 +1282,14 @@ private Mono commitArtifact( }) .flatMap(artifactExchangeJson -> { ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(baseArtifact.getId()); jsonTransformationDTO.setRepoName( branchedArtifact.getGitArtifactMetadata().getRepoName()); jsonTransformationDTO.setArtifactType(artifactExchangeJson.getArtifactJsonType()); jsonTransformationDTO.setRefName( - branchedArtifact.getGitArtifactMetadata().getBranchName()); + branchedArtifact.getGitArtifactMetadata().getRefName()); return gitHandlingService .prepareChangesToBeCommitted(jsonTransformationDTO, artifactExchangeJson) @@ -1298,12 +1298,12 @@ private Mono commitArtifact( .flatMap(updatedBranchedArtifact -> { GitArtifactMetadata gitArtifactMetadata = updatedBranchedArtifact.getGitArtifactMetadata(); ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(updatedBranchedArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(gitArtifactMetadata.getDefaultArtifactId()); jsonTransformationDTO.setRepoName(gitArtifactMetadata.getRepoName()); jsonTransformationDTO.setArtifactType(branchedArtifact.getArtifactType()); - jsonTransformationDTO.setRefName(gitArtifactMetadata.getBranchName()); + jsonTransformationDTO.setRefName(gitArtifactMetadata.getRefName()); return gitHandlingService .commitArtifact(updatedBranchedArtifact, commitDTO, jsonTransformationDTO) @@ -1349,7 +1349,7 @@ private Mono commitArtifact( log.error( "An error occurred while committing changes to artifact with base id: {} and branch: {}", branchedGitMetadata.getDefaultArtifactId(), - branchedGitMetadata.getBranchName()); + branchedGitMetadata.getRefName()); return gitRedisUtils .releaseFileLock(branchedGitMetadata.getDefaultArtifactId(), TRUE) @@ -1391,12 +1391,12 @@ public Mono detachRemote( GitArtifactMetadata gitArtifactMetadata = baseArtifact.getGitArtifactMetadata(); ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(gitArtifactMetadata.getDefaultArtifactId()); jsonTransformationDTO.setRepoName(gitArtifactMetadata.getRepoName()); jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); - jsonTransformationDTO.setRefName(gitArtifactMetadata.getBranchName()); + jsonTransformationDTO.setRefName(gitArtifactMetadata.getRefName()); // Remove the git contents from file system return Mono.zip(gitHandlingService.listBranches(jsonTransformationDTO), Mono.just(baseArtifact)); @@ -1410,12 +1410,12 @@ public Mono detachRemote( GitArtifactMetadata gitArtifactMetadata = baseArtifact.getGitArtifactMetadata(); ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(gitArtifactMetadata.getDefaultArtifactId()); jsonTransformationDTO.setRepoName(gitArtifactMetadata.getRepoName()); jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); - jsonTransformationDTO.setRefName(gitArtifactMetadata.getBranchName()); + jsonTransformationDTO.setRefName(gitArtifactMetadata.getRefName()); // Remove the parent application branch name from the list Mono removeRepoMono = gitHandlingService.removeRepository(jsonTransformationDTO); @@ -1502,7 +1502,7 @@ protected Mono getStatus( GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); branchedGitMetadata.setGitAuth(baseGitMetadata.getGitAuth()); - final String finalBranchName = branchedGitMetadata.getBranchName(); + final String finalBranchName = branchedGitMetadata.getRefName(); if (!StringUtils.hasText(finalBranchName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); @@ -1519,7 +1519,7 @@ protected Mono getStatus( }) .flatMap(artifactExchangeJson -> { ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(baseArtifact.getId()); jsonTransformationDTO.setRepoName( @@ -1533,7 +1533,7 @@ protected Mono getStatus( if (compareRemote) { fetchRemoteMono = Mono.defer( - () -> fetchRemoteChanges(baseArtifact, branchedArtifact, FALSE, gitType, RefType.BRANCH) + () -> fetchRemoteChanges(baseArtifact, branchedArtifact, FALSE, gitType, RefType.branch) .onErrorResume(error -> Mono.error(new AppsmithException( AppsmithError.GIT_GENERIC_ERROR, error.getMessage())))); } else { @@ -1648,7 +1648,7 @@ protected Mono pullArtifact(Artifact baseArtifact, Artifact branched log.error( "An error occurred while trying to pull the artifact with base id: {} and branchName: {}", branchedGitMetadata.getDefaultArtifactId(), - branchedGitMetadata.getBranchName()); + branchedGitMetadata.getRefName()); return gitRedisUtils .releaseFileLock(branchedGitMetadata.getDefaultArtifactId(), TRUE) @@ -1692,11 +1692,11 @@ private Mono pullAndRehydrateArtifact( final String workspaceId = branchedArtifact.getWorkspaceId(); final String baseArtifactId = branchedGitMetadata.getDefaultArtifactId(); final String repoName = branchedGitMetadata.getRepoName(); - final String branchName = branchedGitMetadata.getBranchName(); + final String branchName = branchedGitMetadata.getRefName(); ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); jsonTransformationDTO.setRepoName(repoName); - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setRefName(branchName); jsonTransformationDTO.setWorkspaceId(workspaceId); jsonTransformationDTO.setBaseArtifactId(baseArtifactId); @@ -1976,7 +1976,7 @@ protected Mono discardChanges(Artifact branchedArtifact, Git ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); jsonTransformationDTO.setArtifactType(branchedArtifact.getArtifactType()); // Because this operation is only valid for branches - jsonTransformationDTO.setRefType(RefType.BRANCH); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setWorkspaceId(branchedArtifact.getWorkspaceId()); jsonTransformationDTO.setBaseArtifactId(branchedGitData.getDefaultArtifactId()); jsonTransformationDTO.setRefName(branchedGitData.getRefName()); @@ -2001,7 +2001,7 @@ protected Mono discardChanges(Artifact branchedArtifact, Git branchedArtifact.getWorkspaceId(), branchedArtifact.getId(), artifactExchangeJson, - branchedGitData.getBranchName())) + branchedGitData.getRefName())) // Update the last deployed status after the rebase .flatMap(importedArtifact -> gitArtifactHelper.publishArtifact(importedArtifact, true)) .flatMap(publishedArtifact -> { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java index 4e71a75088a4..e82280ace665 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java @@ -229,7 +229,7 @@ protected Mono> getCommitHistory(Artifact branchedArtifact) { GitArtifactMetadata gitData = branchedArtifact.getGitArtifactMetadata(); if (gitData == null || StringUtils.isEmptyOrNull( - branchedArtifact.getGitArtifactMetadata().getBranchName())) { + branchedArtifact.getGitArtifactMetadata().getRefName())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR)); } @@ -238,7 +238,7 @@ protected Mono> getCommitHistory(Artifact branchedArtifact) { branchedArtifact.getWorkspaceId(), gitData.getDefaultArtifactId(), gitData.getRepoName()); Mono> commitHistoryMono = gitExecutor - .checkoutToBranch(baseRepoSuffix, gitData.getBranchName()) + .checkoutToBranch(baseRepoSuffix, gitData.getRefName()) .onErrorResume(e -> Mono.error(new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "checkout", e.getMessage()))) .then(gitExecutor @@ -272,7 +272,7 @@ protected Mono getStatus( GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); branchedGitMetadata.setGitAuth(baseGitMetadata.getGitAuth()); - final String finalBranchName = branchedGitMetadata.getBranchName(); + final String finalBranchName = branchedGitMetadata.getRefName(); if (StringUtils.isEmptyOrNull(finalBranchName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); @@ -393,11 +393,11 @@ public Mono fetchRemoteChanges( String baseArtifactId = baseGitData.getDefaultArtifactId(); - if (branchedGitData == null || !hasText(branchedGitData.getBranchName())) { + if (branchedGitData == null || !hasText(branchedGitData.getRefName())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, BRANCH_NAME)); } - final String finalBranchName = branchedArtifact.getGitArtifactMetadata().getBranchName(); + final String finalBranchName = branchedArtifact.getGitArtifactMetadata().getRefName(); GitArtifactHelper artifactGitHelper = getArtifactGitService(baseArtifact.getArtifactType()); Mono currUserMono = sessionUserService.getCurrentUser().cache(); // will be used to send analytics event @@ -516,7 +516,7 @@ private Mono sendUnitExecutionTimeAnalyticsEvent( "appId", gitArtifactMetadata.getDefaultArtifactId(), FieldName.BRANCH_NAME, - gitArtifactMetadata.getBranchName(), + gitArtifactMetadata.getRefName(), "organizationId", artifact.getWorkspaceId(), "repoUrl", @@ -723,7 +723,7 @@ public Mono connectArtifactToGit( } else { GitArtifactMetadata gitArtifactMetadata = artifact.getGitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(artifactId); - gitArtifactMetadata.setBranchName(defaultBranch); + gitArtifactMetadata.setRefName(defaultBranch); gitArtifactMetadata.setDefaultBranchName(defaultBranch); gitArtifactMetadata.setRemoteUrl(gitConnectDTO.getRemoteUrl()); gitArtifactMetadata.setRepoName(repoName); @@ -926,7 +926,7 @@ private Mono commitArtifact( return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR)); } - final String branchName = branchedGitMetadata.getBranchName(); + final String branchName = branchedGitMetadata.getRefName(); if (!hasText(branchName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); @@ -989,7 +989,7 @@ private Mono commitArtifact( }) .flatMap(artifact -> { String errorEntity = ""; - if (StringUtils.isEmptyOrNull(branchedGitMetadata.getBranchName())) { + if (StringUtils.isEmptyOrNull(branchedGitMetadata.getRefName())) { errorEntity = "branch name"; } else if (StringUtils.isEmptyOrNull(branchedGitMetadata.getDefaultArtifactId())) { // TODO: make this artifact @@ -1192,7 +1192,7 @@ protected Mono pushArtifact(Artifact branchedArtifact, boolean doPublish GitArtifactMetadata gitData = artifact.getGitArtifactMetadata(); if (gitData == null - || StringUtils.isEmptyOrNull(gitData.getBranchName()) + || StringUtils.isEmptyOrNull(gitData.getRefName()) || StringUtils.isEmptyOrNull(gitData.getDefaultArtifactId()) || StringUtils.isEmptyOrNull(gitData.getGitAuth().getPrivateKey())) { @@ -1207,14 +1207,14 @@ protected Mono pushArtifact(Artifact branchedArtifact, boolean doPublish return gitExecutor .checkoutToBranch( baseRepoSuffix, - artifact.getGitArtifactMetadata().getBranchName()) + artifact.getGitArtifactMetadata().getRefName()) .then(Mono.defer(() -> gitExecutor .pushApplication( baseRepoSuffix, gitData.getRemoteUrl(), gitAuth.getPublicKey(), gitAuth.getPrivateKey(), - gitData.getBranchName()) + gitData.getRefName()) .zipWith(Mono.just(artifact)))) .onErrorResume(error -> addAnalyticsForGitOperation( AnalyticsEvents.GIT_PUSH, @@ -1300,12 +1300,12 @@ private Mono pushArtifactErrorRecovery(String pushResult, Artifact artif artifact.getWorkspaceId(), gitMetadata.getDefaultArtifactId(), gitMetadata.getRepoName()); return gitExecutor - .resetHard(path, gitMetadata.getBranchName()) + .resetHard(path, gitMetadata.getRefName()) .then(Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, "push", "Unable to push changes as pre-receive hook declined. Please make sure that you don't have any rules enabled on the branch " - + gitMetadata.getBranchName()))); + + gitMetadata.getRefName()))); } return Mono.just(pushResult); } @@ -1416,7 +1416,7 @@ private Mono checkoutRemoteBranch(Artifact baseArtifact, Str final String repoName = baseGitMetadata.getRepoName(); final String baseArtifactId = baseGitMetadata.getDefaultArtifactId(); - final String baseBranchName = baseGitMetadata.getBranchName(); + final String baseBranchName = baseGitMetadata.getRefName(); final String workspaceId = baseArtifact.getWorkspaceId(); final String finalRemoteBranchName = remoteBranchName.replaceFirst(ORIGIN, REMOTE_NAME_REPLACEMENT); @@ -1540,7 +1540,7 @@ public Mono detachRemote(String branchedArtifactId, Artifact Path repoSuffix = gitArtifactHelper.getRepoSuffixPath( baseArtifact.getWorkspaceId(), baseGitMetadata.getDefaultArtifactId(), repoName); - String baseApplicationBranchName = baseGitMetadata.getBranchName(); + String baseApplicationBranchName = baseGitMetadata.getRefName(); return Mono.zip( gitExecutor.listBranches(repoSuffix), Mono.just(baseArtifact), @@ -1626,19 +1626,18 @@ public Mono createBranch( // Create a new branch from the parent checked out branch return addFileLock(baseGitMetadata.getDefaultArtifactId(), GitCommandConstants.CREATE_BRANCH) - .flatMap(status -> - gitExecutor.checkoutToBranch(repoSuffix, parentGitMetadata.getBranchName())) + .flatMap(status -> gitExecutor.checkoutToBranch(repoSuffix, parentGitMetadata.getRefName())) .onErrorResume(error -> Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, "checkout", - "Unable to find " + parentGitMetadata.getBranchName()))) + "Unable to find " + parentGitMetadata.getRefName()))) .zipWhen(isCheckedOut -> gitExecutor .fetchRemote( repoSuffix, baseGitAuth.getPublicKey(), baseGitAuth.getPrivateKey(), false, - parentGitMetadata.getBranchName(), + parentGitMetadata.getRefName(), true) .onErrorResume(error -> Mono.error( new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "fetch", error)))) @@ -1690,7 +1689,7 @@ public Mono createBranch( GitCommitDTO commitDTO = new GitCommitDTO(); commitDTO.setCommitMessage(DEFAULT_COMMIT_MESSAGE + GitDefaultCommitMessage.BRANCH_CREATED.getReason() - + branchedGitMetadata.getBranchName()); + + branchedGitMetadata.getRefName()); commitDTO.setDoPush(true); return commitArtifact( commitDTO, importedBranchedArtifact.getId(), false, false, artifactType) @@ -1802,7 +1801,7 @@ private Mono pullAndRehydrateArtifact(Artifact baseArtifact, Artifac final String workspaceId = branchedArtifact.getWorkspaceId(); final String baseArtifactId = branchedGitMetadata.getDefaultArtifactId(); final String repoName = branchedGitMetadata.getRepoName(); - final String branchName = branchedGitMetadata.getBranchName(); + final String branchName = branchedGitMetadata.getRefName(); Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName); @@ -2059,7 +2058,7 @@ private Mono addAnalyticsForGitOperation( Boolean isMergeable) { String branchName = artifact.getGitArtifactMetadata() != null - ? artifact.getGitArtifactMetadata().getBranchName() + ? artifact.getGitArtifactMetadata().getRefName() : null; return addAnalyticsForGitOperation( event, artifact, errorType, errorMessage, isRepoPrivate, isSystemGenerated, isMergeable, branchName); @@ -2147,7 +2146,7 @@ public Mono deleteBranch(String baseArtifactId, String branc GitArtifactMetadata baseGitMetadata = baseArtifact.getGitArtifactMetadata(); GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); - final String finalBranchName = branchedGitMetadata.getBranchName(); + final String finalBranchName = branchedGitMetadata.getRefName(); return gitPrivateRepoHelper .isBranchProtected(baseGitMetadata, finalBranchName) @@ -2170,7 +2169,7 @@ public Mono deleteBranch(String baseArtifactId, String branc GitArtifactMetadata baseGitMetadata = baseArtifact.getGitArtifactMetadata(); GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); - final String finalBranchName = branchedGitMetadata.getBranchName(); + final String finalBranchName = branchedGitMetadata.getRefName(); Path repoPath = gitArtifactHelper.getRepoSuffixPath( baseArtifact.getWorkspaceId(), @@ -2265,7 +2264,7 @@ public Mono discardChanges(String branchedArtifactId, Artifa }) .flatMap(branchedArtifact -> { GitArtifactMetadata branchedGitData = branchedArtifact.getGitArtifactMetadata(); - final String branchName = branchedGitData.getBranchName(); + final String branchName = branchedGitData.getRefName(); final String defaultArtifactId = branchedGitData.getDefaultArtifactId(); final String repoName = branchedGitData.getRepoName(); final String workspaceId = branchedArtifact.getWorkspaceId(); @@ -2341,7 +2340,7 @@ public Mono mergeBranch( Mono destinationArtifactMono = baseAndBranchedArtifactsMono.flatMap(artifactTuples -> { Artifact baseArtifact = artifactTuples.getT1(); - if (destinationBranch.equals(baseArtifact.getGitArtifactMetadata().getBranchName())) { + if (destinationBranch.equals(baseArtifact.getGitArtifactMetadata().getRefName())) { return Mono.just(baseArtifact); } @@ -2525,7 +2524,7 @@ public Mono isBranchMergeable( Mono destinationArtifactMono = baseAndBranchedArtifactsMono.flatMap(artifactTuples -> { Artifact baseArtifact = artifactTuples.getT1(); - if (destinationBranch.equals(baseArtifact.getGitArtifactMetadata().getBranchName())) { + if (destinationBranch.equals(baseArtifact.getGitArtifactMetadata().getRefName())) { return Mono.just(baseArtifact); } @@ -2779,7 +2778,7 @@ protected Mono> getBranchList( final String workspaceId = baseArtifact.getWorkspaceId(); final String baseArtifactId = baseGitData.getDefaultArtifactId(); final String repoName = baseGitData.getRepoName(); - final String currentBranch = branchedGitData.getBranchName(); + final String currentBranch = branchedGitData.getRefName(); if (!hasText(baseArtifactId) || !hasText(repoName) || !hasText(currentBranch)) { log.error( @@ -2907,7 +2906,7 @@ private Mono> handleRepoNotFoundException(String baseArtifact // remove origin/ prefix from the remote branch name String branchName = gitBranchDTO.getBranchName().replace("origin/", ""); // The root defaultArtifact is always there, no need to check out it again - if (!branchName.equals(gitArtifactMetadata.getBranchName())) { + if (!branchName.equals(gitArtifactMetadata.getRefName())) { branchesToCheckout.add(branchName); } } else if (gitBranchDTO @@ -3267,7 +3266,7 @@ public Mono importArtifactFromGit( GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setGitAuth(gitAuth); gitArtifactMetadata.setDefaultApplicationId(artifact.getId()); - gitArtifactMetadata.setBranchName(defaultBranch); + gitArtifactMetadata.setRefName(defaultBranch); gitArtifactMetadata.setDefaultBranchName(defaultBranch); gitArtifactMetadata.setRemoteUrl(gitConnectDTO.getRemoteUrl()); gitArtifactMetadata.setRepoName(repoName); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java index 84f772930dc6..dd439c49f912 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java @@ -296,7 +296,7 @@ public Mono> listBranches( @Override public Mono> listReferences( ArtifactJsonTransformationDTO artifactJsonTransformationDTO, Boolean checkRemoteReferences) { - if (RefType.BRANCH.equals(artifactJsonTransformationDTO.getRefType())) { + if (RefType.branch.equals(artifactJsonTransformationDTO.getRefType())) { return listBranches(artifactJsonTransformationDTO, checkRemoteReferences); } @@ -487,7 +487,7 @@ protected Mono pushArtifact(Artifact branchedArtifact, boolean isFileLoc GitArtifactMetadata gitData = artifact.getGitArtifactMetadata(); if (gitData == null - || !StringUtils.hasText(gitData.getBranchName()) + || !StringUtils.hasText(gitData.getRefName()) || !StringUtils.hasText(gitData.getDefaultArtifactId()) || !StringUtils.hasText(gitData.getGitAuth().getPrivateKey())) { @@ -502,14 +502,14 @@ protected Mono pushArtifact(Artifact branchedArtifact, boolean isFileLoc return fsGitHandler .checkoutToBranch( baseRepoSuffix, - artifact.getGitArtifactMetadata().getBranchName()) + artifact.getGitArtifactMetadata().getRefName()) .then(Mono.defer(() -> fsGitHandler .pushApplication( baseRepoSuffix, gitData.getRemoteUrl(), gitAuth.getPublicKey(), gitAuth.getPrivateKey(), - gitData.getBranchName()) + gitData.getRefName()) .zipWith(Mono.just(artifact)))) .onErrorResume(error -> gitAnalyticsUtils .addAnalyticsForGitOperation( @@ -589,12 +589,12 @@ private Mono pushArtifactErrorRecovery(String pushResult, Artifact artif artifact.getWorkspaceId(), gitMetadata.getDefaultArtifactId(), gitMetadata.getRepoName()); return fsGitHandler - .resetHard(path, gitMetadata.getBranchName()) + .resetHard(path, gitMetadata.getRefName()) .then(Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, "push", "Unable to push changes as pre-receive hook declined. Please make sure that you don't have any rules enabled on the branch " - + gitMetadata.getBranchName()))); + + gitMetadata.getRefName()))); } return Mono.just(pushResult); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/utils/GitAnalyticsUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/utils/GitAnalyticsUtils.java index a75e8f6a1ded..bc8f8922db3d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/utils/GitAnalyticsUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/utils/GitAnalyticsUtils.java @@ -73,7 +73,7 @@ public Mono addAnalyticsForGitOperation( Boolean isMergeable) { String branchName = artifact.getGitArtifactMetadata() != null - ? artifact.getGitArtifactMetadata().getBranchName() + ? artifact.getGitArtifactMetadata().getRefName() : null; return addAnalyticsForGitOperation( event, artifact, errorType, errorMessage, isRepoPrivate, isSystemGenerated, isMergeable, branchName); @@ -141,7 +141,7 @@ public Mono sendUnitExecutionTimeAnalyticsEvent( "appId", gitArtifactMetadata.getDefaultArtifactId(), FieldName.BRANCH_NAME, - gitArtifactMetadata.getBranchName(), + gitArtifactMetadata.getRefName(), "organizationId", artifact.getWorkspaceId(), "repoUrl", diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java index ce2d1eac9654..8c6762c13a14 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java @@ -136,7 +136,7 @@ public static String getGitProviderName(String sshUrl) { public static String getDefaultBranchName(GitArtifactMetadata gitArtifactMetadata) { return StringUtils.isEmptyOrNull(gitArtifactMetadata.getDefaultBranchName()) - ? gitArtifactMetadata.getBranchName() + ? gitArtifactMetadata.getRefName() : gitArtifactMetadata.getDefaultBranchName(); } @@ -149,8 +149,8 @@ public static String getDefaultBranchName(GitArtifactMetadata gitArtifactMetadat public static boolean isDefaultBranchedApplication(Application application) { GitArtifactMetadata metadata = application.getGitApplicationMetadata(); return isApplicationConnectedToGit(application) - && !StringUtils.isEmptyOrNull(metadata.getBranchName()) - && metadata.getBranchName().equals(metadata.getDefaultBranchName()); + && !StringUtils.isEmptyOrNull(metadata.getRefName()) + && metadata.getRefName().equals(metadata.getDefaultBranchName()); } /** diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java index 486406d6422b..5349f788df6b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java @@ -696,7 +696,7 @@ public Mono getMetadataServerSchemaMigrationVersion( ArtifactType artifactType) { String defaultArtifactId = gitArtifactMetadata.getDefaultArtifactId(); - String branchName = gitArtifactMetadata.getBranchName(); + String refName = gitArtifactMetadata.getRefName(); String repoName = gitArtifactMetadata.getRepoName(); if (!hasText(workspaceId)) { @@ -707,7 +707,7 @@ public Mono getMetadataServerSchemaMigrationVersion( return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ARTIFACT_ID)); } - if (!hasText(branchName)) { + if (!hasText(refName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); } @@ -716,7 +716,7 @@ public Mono getMetadataServerSchemaMigrationVersion( } Mono serverSchemaNumberMono = reconstructMetadataFromRepo( - workspaceId, defaultArtifactId, repoName, branchName, isResetToLastCommitRequired, artifactType) + workspaceId, defaultArtifactId, repoName, refName, isResetToLastCommitRequired, artifactType) .map(metadataMap -> { return metadataMap.getOrDefault( CommonConstants.SERVER_SCHEMA_VERSION, jsonSchemaVersions.getServerVersion()); @@ -743,7 +743,7 @@ public Mono getPageDslVersionNumber( ArtifactType artifactType) { String defaultArtifactId = gitArtifactMetadata.getDefaultArtifactId(); - String branchName = gitArtifactMetadata.getBranchName(); + String refName = gitArtifactMetadata.getRefName(); String repoName = gitArtifactMetadata.getRepoName(); if (!hasText(workspaceId)) { @@ -754,7 +754,7 @@ public Mono getPageDslVersionNumber( return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ARTIFACT_ID)); } - if (!hasText(branchName)) { + if (!hasText(refName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); } @@ -770,7 +770,7 @@ public Mono getPageDslVersionNumber( Path baseRepoSuffix = artifactGitFileUtils.getRepoSuffixPath(workspaceId, defaultArtifactId, repoName); Mono jsonObjectMono = fileUtils - .reconstructPageFromGitRepo(pageDTO.getName(), branchName, baseRepoSuffix, isResetToLastCommitRequired) + .reconstructPageFromGitRepo(pageDTO.getName(), refName, baseRepoSuffix, isResetToLastCommitRequired) .onErrorResume(error -> Mono.error( new AppsmithException(AppsmithError.GIT_ACTION_FAILED, RECONSTRUCT_PAGE, error.getMessage()))) .map(pageJson -> { 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 6d62d19a786a..663fe760ca62 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,8 +1,8 @@ package com.appsmith.server.imports.importable.artifactbased; import com.appsmith.external.models.BaseDomain; -import com.appsmith.external.models.BranchAwareDomain; import com.appsmith.external.models.GitSyncedDomain; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.server.domains.Artifact; import com.appsmith.server.domains.Context; import com.appsmith.server.dtos.ImportingMetaDTO; @@ -27,15 +27,16 @@ Context updateContextInResource( Object dtoObject, Map contextMap, String fallbackBaseContextId); default void populateBaseId(ImportingMetaDTO importingMetaDTO, Artifact artifact, T branchedResource, T resource) { - BranchAwareDomain branchAwareResource = (BranchAwareDomain) resource; - BranchAwareDomain branchAwareBranchedResource = (BranchAwareDomain) branchedResource; + RefAwareDomain refAwareResource = (RefAwareDomain) resource; + RefAwareDomain refAwareRefResource = (RefAwareDomain) branchedResource; - branchAwareResource.setBranchName(importingMetaDTO.getBranchName()); + refAwareResource.setRefType(importingMetaDTO.getRefType()); + refAwareResource.setRefName(importingMetaDTO.getRefName()); if (artifact.getGitArtifactMetadata() != null && branchedResource != null) { - branchAwareResource.setBaseId(branchAwareBranchedResource.getBaseId()); + refAwareResource.setBaseId(refAwareRefResource.getBaseId()); } else { - branchAwareResource.setBaseId(branchAwareResource.getBaseIdOrFallback()); + refAwareResource.setBaseId(refAwareResource.getBaseIdOrFallback()); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java index 28353b7d1fd7..66a3d8c73e4c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java @@ -9,6 +9,7 @@ import com.appsmith.server.converters.ArtifactExchangeJsonAdapter; import com.appsmith.server.domains.Application; import com.appsmith.server.domains.Artifact; +import com.appsmith.server.domains.GitArtifactMetadata; import com.appsmith.server.domains.Plugin; import com.appsmith.server.domains.User; import com.appsmith.server.domains.Workspace; @@ -443,6 +444,7 @@ private Mono importArtifactInWorkspace( artifactContextString, branchedArtifactId, null, + null, new ArrayList<>(), appendToArtifact, false, @@ -493,6 +495,13 @@ private Mono importArtifactInWorkspace( .then(Mono.defer(() -> Mono.when(branchedArtifactIdsMono, artifactSpecificImportableEntities))) .then(Mono.defer(() -> artifactBasedImportService.updateAndSaveArtifactInContext( importedDoc.getArtifact(), importingMetaDTO, mappedImportableResourcesDTO, currUserMono))) + .doOnNext(artifact -> { + GitArtifactMetadata gitArtifactMetadata = artifact.getGitArtifactMetadata(); + if (gitArtifactMetadata != null) { + importingMetaDTO.setRefType(gitArtifactMetadata.getRefType()); + importingMetaDTO.setRefName(gitArtifactMetadata.getRefName()); + } + }) .cache(); final Mono importMono = importableArtifactMono diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java index c29638d3f2bf..7cdca44ee288 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java @@ -177,6 +177,7 @@ private Mono importResourceInPage( FieldName.APPLICATION, branchedApplicationId, null, + null, new ArrayList<>(), false, true, @@ -200,7 +201,8 @@ private Mono importResourceInPage( return newPageService .findById(branchedPageId, AclPermission.MANAGE_PAGES) .flatMap(page -> { - importingMetaDTO.setBranchName(page.getBranchName()); + importingMetaDTO.setRefType(page.getRefType()); + importingMetaDTO.setRefName(page.getRefName()); Layout layout = page.getUnpublishedPage().getLayouts().get(0); return refactoringService.getAllExistingEntitiesMono( diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration057MoveDRToBaseIds.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration057MoveDRToBaseIds.java index 2a926cd26113..f4cbfc50a399 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration057MoveDRToBaseIds.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration057MoveDRToBaseIds.java @@ -1,7 +1,7 @@ package com.appsmith.server.migrations.db.ce; import com.appsmith.external.models.BaseDomain; -import com.appsmith.external.models.BranchAwareDomain; +import com.appsmith.external.models.RefAwareDomain; import com.appsmith.server.domains.ActionCollection; import com.appsmith.server.domains.NewAction; import com.appsmith.server.domains.NewPage; @@ -37,10 +37,8 @@ public void rollbackExecution() {} @Execution public void executeMigration() { - Query findQuery = query(where(BaseDomain.Fields.deletedAt) - .isNull() - .and(BranchAwareDomain.Fields.branchName) - .exists(false)); + Query findQuery = query( + where(BaseDomain.Fields.deletedAt).isNull().and("branchName").exists(false)); // NewPage AggregationUpdate moveNewPageDRUpdateQuery = getUpdateDefinition("defaultResources.pageId"); @@ -72,9 +70,9 @@ public void executeMigration() { @NotNull private AggregationUpdate getUpdateDefinition(String oldBaseIdPath) { return AggregationUpdate.update() - .set(BranchAwareDomain.Fields.baseId) + .set(RefAwareDomain.Fields.baseId) .toValueOf(Fields.field(oldBaseIdPath)) - .set(BranchAwareDomain.Fields.branchName) + .set("branchName") .toValueOf(Fields.field("defaultResources.branchName")); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java index a2cf04bbd120..662ceac8e451 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java @@ -1,9 +1,8 @@ package com.appsmith.server.newactions.base; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.CreatorContextType; -import com.appsmith.external.models.Executable; -import com.appsmith.external.models.MustacheBindingToken; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.NewAction; import com.appsmith.server.domains.NewPage; @@ -11,7 +10,6 @@ import com.appsmith.server.dtos.ImportActionCollectionResultDTO; import com.appsmith.server.dtos.ImportActionResultDTO; import com.appsmith.server.dtos.ImportedActionAndCollectionMapsDTO; -import com.appsmith.server.dtos.LayoutExecutableUpdateDTO; import com.appsmith.server.dtos.PluginTypeAndCountDTO; import com.appsmith.server.services.CrudService; import org.springframework.data.domain.Sort; @@ -23,14 +21,11 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; public interface NewActionServiceCE extends CrudService { void setCommonFieldsFromActionDTOIntoNewAction(ActionDTO action, NewAction newAction); - Mono findByIdAndBranchName(String id, String branchName); - ActionDTO generateActionByViewMode(NewAction newAction, Boolean viewMode); void generateAndSetActionPolicies(NewPage page, NewAction action); @@ -58,8 +53,6 @@ Mono> updateUnpublishedActionWithoutAnalytics( Flux findUnpublishedOnLoadActionsExplicitSetByUserInPage(String pageId); - Flux findUnpublishedActionsInPageByNames(Set names, String pageId); - Mono findById(String id); Flux findAllById(Iterable id); @@ -91,13 +84,13 @@ Flux findAllByApplicationIdAndViewMode( Flux getUnpublishedActions(MultiValueMap params, Boolean includeJsActions); Flux getUnpublishedActions( - MultiValueMap params, String branchName, Boolean includeJsActions); + MultiValueMap params, RefType refType, String refName, Boolean includeJsActions); Flux getUnpublishedActions(MultiValueMap params); Flux getUnpublishedActionsByPageId(String pageId, AclPermission permission); - Flux getUnpublishedActions(MultiValueMap params, String branchName); + Flux getUnpublishedActions(MultiValueMap params, RefType refType, String refName); Mono deleteGivenNewAction(NewAction toDelete); @@ -117,24 +110,8 @@ Flux getUnpublishedActions( Mono> archiveActionsByApplicationId(String applicationId, AclPermission permission); - List extractMustacheKeysInOrder(String query); - - String replaceMustacheWithQuestionMark(String query, List mustacheBindings); - - Mono updateActionsExecuteOnLoad( - List executables, - String pageId, - List actionUpdates, - List messages); - Flux getUnpublishedActionsExceptJs(MultiValueMap params); - Mono findByBranchNameAndBaseActionId( - String branchName, String baseActionId, Boolean viewMode, AclPermission permission); - - Mono findBranchedIdByBranchNameAndBaseActionId( - String branchName, String baseActionId, AclPermission permission); - Mono sanitizeAction(NewAction action); Mono fillSelfReferencingDataPaths(ActionDTO actionDTO); @@ -149,8 +126,6 @@ Mono updateActionsWithImportedCollectionIds( Flux countActionsByPluginType(String applicationId); - Flux findByPageIds(List unpublishedPages, Optional optionalPermission); - Flux findByPageIdsForExport(List unpublishedPages, Optional optionalPermission); Flux findAllActionsByContextIdAndContextTypeAndViewMode( diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java index 12b787c4dfb8..8c8a227f3a2e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java @@ -2,13 +2,13 @@ import com.appsmith.external.dtos.ExecutePluginDTO; import com.appsmith.external.dtos.RemoteDatasourceDTO; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.helpers.MustacheHelper; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceConfiguration; -import com.appsmith.external.models.Executable; import com.appsmith.external.models.MustacheBindingToken; import com.appsmith.external.models.PluginType; import com.appsmith.external.models.Policy; @@ -55,7 +55,6 @@ import org.apache.commons.lang3.ObjectUtils; import org.springframework.data.domain.Sort; import org.springframework.util.CollectionUtils; -import org.springframework.util.LinkedCaseInsensitiveMap; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -69,13 +68,11 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; import java.util.stream.Collectors; import static com.appsmith.external.constants.spans.ActionSpan.GET_ACTION_REPOSITORY_CALL; @@ -173,7 +170,8 @@ protected void setCommonFieldsFromNewActionIntoAction(NewAction newAction, Actio action.setId(newAction.getId()); action.setBaseId(newAction.getBaseIdOrFallback()); - action.setBranchName(newAction.getBranchName()); + action.setRefType(newAction.getRefType()); + action.setRefName(newAction.getRefName()); action.setUserPermissions(newAction.getUserPermissions()); action.setPolicies(newAction.getPolicies()); /* @@ -197,12 +195,8 @@ public void setCommonFieldsFromActionDTOIntoNewAction(ActionDTO action, NewActio newAction.setDocumentation(action.getDocumentation()); newAction.setApplicationId(action.getApplicationId()); newAction.setBaseId(action.getBaseId()); - newAction.setBranchName(action.getBranchName()); - } - - @Override - public Mono findByIdAndBranchName(String id, String branchName) { - return this.findByBranchNameAndBaseActionId(branchName, id, false, actionPermission.getReadPermission()); + newAction.setRefType(action.getRefType()); + newAction.setRefName(action.getRefName()); } @Override @@ -685,20 +679,6 @@ public Flux findUnpublishedOnLoadActionsExplicitSetByUserInPage(Strin .flatMap(this::sanitizeAction); } - /** - * Given a list of names of actions and pageId, find all the actions matching this criteria of names and pageId - * - * @param names Set of Action names. The returned list of actions will be a subset of the actioned named in this set. - * @param pageId Id of the Page within which to look for Actions. - * @return A Flux of Actions that are identified to be executed on page-load. - */ - @Override - public Flux findUnpublishedActionsInPageByNames(Set names, String pageId) { - return repository - .findUnpublishedActionsByNameInAndPageId(names, pageId, actionPermission.getEditPermission()) - .flatMap(this::sanitizeAction); - } - @Override public Mono findById(String id) { return repository.findById(id).flatMap(this::sanitizeAction); @@ -1005,20 +985,18 @@ protected Flux getUnpublishedActionsFromRepo( @Override public Flux getUnpublishedActions( - MultiValueMap params, String branchName, Boolean includeJsActions) { + MultiValueMap params, RefType refType, String refName, Boolean includeJsActions) { MultiValueMap updatedParams = new LinkedMultiValueMap<>(params); // Get branched applicationId and pageId Mono branchedPageMono = !StringUtils.hasLength(params.getFirst(FieldName.PAGE_ID)) ? Mono.just(new NewPage()) - : newPageService.findByBranchNameAndBasePageId( - branchName, params.getFirst(FieldName.PAGE_ID), pagePermission.getReadPermission(), null); + : newPageService.findByRefTypeAndRefNameAndBasePageId( + refType, refName, params.getFirst(FieldName.PAGE_ID), pagePermission.getReadPermission(), null); Mono branchedApplicationMono = !StringUtils.hasLength(params.getFirst(FieldName.APPLICATION_ID)) ? Mono.just(new Application()) : applicationService.findByBranchNameAndBaseApplicationId( - branchName, - params.getFirst(FieldName.APPLICATION_ID), - applicationPermission.getReadPermission()); + refName, params.getFirst(FieldName.APPLICATION_ID), applicationPermission.getReadPermission()); return Mono.zip(branchedApplicationMono, branchedPageMono).flatMapMany(tuple -> { String applicationId = tuple.getT1().getId(); @@ -1049,8 +1027,9 @@ public Flux getUnpublishedActionsByPageId(String pageId, AclPermissio } @Override - public Flux getUnpublishedActions(MultiValueMap params, String branchName) { - return getUnpublishedActions(params, branchName, TRUE); + public Flux getUnpublishedActions( + MultiValueMap params, RefType refType, String refName) { + return getUnpublishedActions(params, refType, refName, TRUE); } @Override @@ -1271,130 +1250,6 @@ public Flux findByPageId(String pageId) { return repository.findByPageId(pageId).flatMap(this::sanitizeAction); } - /** - * !!!WARNING!!! This function edits the parameters actionUpdates and messages which are eventually returned back to - * the caller with the updates values. - * - * @param onLoadActions : All the actions which have been found to be on page load - * @param pageId - * @param actionUpdates : Empty array list which would be set in this function with all the page actions whose - * execute on load setting has changed (whether flipped from true to false, or vice versa) - * @param messages : Empty array list which would be set in this function with all the messages that should be - * displayed to the developer user communicating the action executeOnLoad changes. - * @return - */ - @Override - public Mono updateActionsExecuteOnLoad( - List onLoadActions, - String pageId, - List actionUpdates, - List messages) { - - List toUpdateActions = new ArrayList<>(); - - MultiValueMap params = - CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)); - params.add(FieldName.PAGE_ID, pageId); - - // Fetch all the actions which exist in this page. - Flux pageActionsFlux = this.getUnpublishedActions(params).cache(); - - // Before we update the actions, fetch all the actions which are currently set to execute on load. - Mono> existingOnPageLoadActionsMono = pageActionsFlux - .flatMap(action -> { - if (TRUE.equals(action.getExecuteOnLoad())) { - return Mono.just(action); - } - return Mono.empty(); - }) - .collectList(); - - return existingOnPageLoadActionsMono - .zipWith(pageActionsFlux.collectList()) - .flatMap(tuple -> { - List existingOnPageLoadActions = tuple.getT1(); - List pageActions = tuple.getT2(); - - // There are no actions in this page. No need to proceed further since no actions would get updated - if (pageActions.isEmpty()) { - return Mono.just(FALSE); - } - - // No actions require an update if no actions have been found as page load actions as well as - // existing on load page actions are empty - if (existingOnPageLoadActions.isEmpty() && (onLoadActions == null || onLoadActions.isEmpty())) { - return Mono.just(FALSE); - } - - // Extract names of existing page load actions and new page load actions for quick lookup. - Set existingOnPageLoadActionNames = existingOnPageLoadActions.stream() - .map(ActionDTO::getValidName) - .collect(Collectors.toSet()); - - Set newOnLoadActionNames = - onLoadActions.stream().map(Executable::getValidName).collect(Collectors.toSet()); - - // Calculate the actions which would need to be updated from execute on load TRUE to FALSE. - Set turnedOffActionNames = new HashSet<>(); - turnedOffActionNames.addAll(existingOnPageLoadActionNames); - turnedOffActionNames.removeAll(newOnLoadActionNames); - - // Calculate the actions which would need to be updated from execute on load FALSE to TRUE - Set turnedOnActionNames = new HashSet<>(); - turnedOnActionNames.addAll(newOnLoadActionNames); - turnedOnActionNames.removeAll(existingOnPageLoadActionNames); - - for (ActionDTO action : pageActions) { - - String actionName = action.getValidName(); - // If a user has ever set execute on load, this field can not be changed automatically. It has - // to be - // explicitly changed by the user again. Add the action to update only if this condition is - // false. - if (FALSE.equals(action.getUserSetOnLoad())) { - - // If this action is no longer an onload action, turn the execute on load to false - if (turnedOffActionNames.contains(actionName)) { - action.setExecuteOnLoad(FALSE); - toUpdateActions.add(action); - } - - // If this action is newly found to be on load, turn execute on load to true - if (turnedOnActionNames.contains(actionName)) { - action.setExecuteOnLoad(TRUE); - toUpdateActions.add(action); - } - } else { - // Remove the action name from either of the lists (if present) because this action should - // not be updated - turnedOnActionNames.remove(actionName); - turnedOffActionNames.remove(actionName); - } - } - - // Add newly turned on page actions to report back to the caller - actionUpdates.addAll(addActionUpdatesForActionNames(pageActions, turnedOnActionNames)); - - // Add newly turned off page actions to report back to the caller - actionUpdates.addAll(addActionUpdatesForActionNames(pageActions, turnedOffActionNames)); - - // Now add messages that would eventually be displayed to the developer user informing them - // about the action setting change. - if (!turnedOffActionNames.isEmpty()) { - messages.add(turnedOffActionNames.toString() + " will no longer be executed on page load"); - } - - if (!turnedOnActionNames.isEmpty()) { - messages.add(turnedOnActionNames.toString() + " will be executed automatically on page load"); - } - - // Finally update the actions which require an update - return Flux.fromIterable(toUpdateActions) - .flatMap(actionDTO -> updateUnpublishedAction(actionDTO.getId(), actionDTO)) - .then(Mono.just(TRUE)); - }); - } - private List addActionUpdatesForActionNames( List pageActions, Set actionNames) { @@ -1462,23 +1317,6 @@ public Mono> archiveActionsByApplicationId(String applicationId, .collectList(); } - public List extractMustacheKeysInOrder(String query) { - return MustacheHelper.extractMustacheKeysInOrder(query); - } - - @Override - public String replaceMustacheWithQuestionMark(String query, List mustacheBindings) { - - ActionConfiguration actionConfiguration = new ActionConfiguration(); - actionConfiguration.setBody(query); - Map replaceParamsMap = - mustacheBindings.stream().collect(Collectors.toMap(Function.identity(), v -> "?")); - - ActionConfiguration updatedActionConfiguration = - MustacheHelper.renderFieldValues(actionConfiguration, replaceParamsMap); - return updatedActionConfiguration.getBody(); - } - private Mono updateDatasourcePolicyForPublicAction(NewAction action, Datasource datasource) { if (datasource.getId() == null) { // This seems to be a nested datasource. Return as is. @@ -1524,34 +1362,6 @@ private Mono updateDatasourcePolicyForPublicAction(NewAction action, }); } - public Mono findByBranchNameAndBaseActionId( - String branchName, String baseActionId, Boolean viewMode, AclPermission permission) { - log.debug("Going to find action based on branchName and defaultActionId with id: {} ", baseActionId); - if (!StringUtils.hasLength(branchName)) { - return repository - .findById(baseActionId, permission) - .switchIfEmpty(Mono.error( - new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.ACTION, baseActionId))); - } - return repository - .findByBranchNameAndBaseActionId(branchName, baseActionId, viewMode, permission) - .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.NO_RESOURCE_FOUND, FieldName.ACTION, baseActionId + "," + branchName))) - .flatMap(this::sanitizeAction); - } - - public Mono findBranchedIdByBranchNameAndBaseActionId( - String branchName, String baseActionId, AclPermission permission) { - if (!StringUtils.hasLength(branchName)) { - return Mono.just(baseActionId); - } - return repository - .findByBranchNameAndBaseActionId(branchName, baseActionId, false, permission) - .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.ACTION, baseActionId + "," + branchName))) - .map(NewAction::getId); - } - private Map getAnalyticsProperties(NewAction savedAction, Datasource datasource) { final Datasource embeddedDatasource = savedAction.getUnpublishedAction().getDatasource(); embeddedDatasource.setIsMock(datasource.getIsMock()); @@ -1677,11 +1487,6 @@ public Flux countActionsByPluginType(String applicationId return repository.countActionsByPluginType(applicationId); } - @Override - public Flux findByPageIds(List unpublishedPages, Optional optionalPermission) { - return repository.findByPageIds(unpublishedPages, optionalPermission); - } - @Override public Flux findByPageIdsForExport( List unpublishedPages, Optional optionalPermission) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/clonepage/ActionClonePageServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/clonepage/ActionClonePageServiceCEImpl.java index 91990d715288..0729fda7f9bc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/clonepage/ActionClonePageServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/clonepage/ActionClonePageServiceCEImpl.java @@ -32,7 +32,8 @@ public Mono cloneEntities(ClonePageMetaDTO clonePageMetaDTO) { .flatMap(action -> { // Set new page id in the actionDTO ActionDTO actionDTO = action.getUnpublishedAction(); - actionDTO.setBranchName(clonePageMetaDTO.getBranchName()); + actionDTO.setRefType(clonePageMetaDTO.getRefType()); + actionDTO.setRefName(clonePageMetaDTO.getRefName()); actionDTO.setPageId(clonePageMetaDTO.getClonedPageDTO().getId()); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java index 3755272f84c6..f96d0200e0fc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java @@ -361,11 +361,7 @@ private Mono createImportNewActionsMono( actionsInCurrentArtifact, newAction); - updateExistingAction( - existingAction, - newAction, - importingMetaDTO.getBranchName(), - importingMetaDTO.getPermissionProvider()); + updateExistingAction(existingAction, newAction, importingMetaDTO); // Add it to actions list that'll be updated in bulk existingNewActionList.add(existingAction); @@ -510,10 +506,8 @@ protected void populateDomainMappedReferences( } private void updateExistingAction( - NewAction existingAction, - NewAction actionToImport, - String branchName, - ImportArtifactPermissionProvider permissionProvider) { + NewAction existingAction, NewAction actionToImport, ImportingMetaDTO importingMetaDTO) { + ImportArtifactPermissionProvider permissionProvider = importingMetaDTO.getPermissionProvider(); // Since the resource is already present in DB, just update resource if (!permissionProvider.hasEditPermission(existingAction)) { log.error("User does not have permission to edit action with id: {}", existingAction.getId()); @@ -524,8 +518,9 @@ private void updateExistingAction( updateImportableActionFromExistingAction(existingAction, actionToImport); copyNestedNonNullProperties(actionToImport, existingAction); - // Update branchName - existingAction.setBranchName(branchName); + // Update ref name + existingAction.setRefType(importingMetaDTO.getRefType()); + existingAction.setRefName(importingMetaDTO.getRefName()); // Recover the deleted state present in DB from imported action existingAction .getUnpublishedAction() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/applications/NewActionApplicationImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/applications/NewActionApplicationImportableServiceCEImpl.java index 19212302fa8b..5a36460e3510 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/applications/NewActionApplicationImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/applications/NewActionApplicationImportableServiceCEImpl.java @@ -102,7 +102,8 @@ public void createNewResource(ImportingMetaDTO importingMetaDTO, NewAction newAc // create or update base id for the action // values already set to base id are kept unchanged newAction.setBaseId(newAction.getBaseIdOrFallback()); - newAction.setBranchName(importingMetaDTO.getBranchName()); + newAction.setRefType(importingMetaDTO.getRefType()); + newAction.setRefName(importingMetaDTO.getRefName()); // generate gitSyncId if it's not present if (newAction.getGitSyncId() == null) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java index b669c91a4142..b981ce2516a1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.newpages.base; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.Application; import com.appsmith.server.domains.ApplicationMode; @@ -69,13 +70,17 @@ Mono findByNameAndApplicationIdAndViewMode( Mono getNameByPageId(String pageId, boolean isPublishedName); - Mono findByBranchNameAndBasePageId( - String branchName, String defaultPageId, AclPermission permission, List projectedFieldNames); + Mono findByRefTypeAndRefNameAndBasePageId( + RefType refType, + String refName, + String defaultPageId, + AclPermission permission, + List projectedFieldNames); - Mono findByBranchNameAndBasePageIdAndApplicationMode( - String branchName, String basePageId, ApplicationMode mode); + Mono findByRefTypeAndRefNameAndBasePageIdAndApplicationMode( + RefType refType, String refName, String basePageId, ApplicationMode mode); - Mono findBranchedPageId(String branchName, String basePageId, AclPermission permission); + Mono findRefPageId(RefType refType, String refName, String basePageId, AclPermission permission); Mono publishPages(Collection pageIds, AclPermission permission); @@ -86,7 +91,8 @@ Mono findByBranchNameAndBasePageIdAndApplicationMode( Mono createApplicationPagesDTO( Application branchedApplication, List newPages, boolean viewMode, boolean isRecentlyAccessed); - Mono updateDependencyMap(String pageId, Map> dependencyMap, String branchName); + Mono updateDependencyMap( + String pageId, Map> dependencyMap, RefType refType, String refName); Flux findByApplicationIdAndApplicationMode( String applicationId, AclPermission permission, ApplicationMode applicationMode); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java index 594e94d033e8..28a291853f2e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.newpages.base; import com.appsmith.external.enums.WorkspaceResourceContext; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.applications.base.ApplicationService; import com.appsmith.server.constants.FieldName; @@ -163,7 +164,8 @@ public Mono createDefault(PageDTO object) { newPage.setGitSyncId(newPage.getApplicationId() + "_" + UUID.randomUUID()); } newPage.setBaseId(object.getId()); - newPage.setBranchName(object.getBranchName()); + newPage.setRefType(object.getRefType()); + newPage.setRefName(object.getRefName()); // Save page and update the defaultPageId after insertion return super.create(newPage) @@ -506,12 +508,16 @@ public Mono getNameByPageId(String pageId, boolean isPublishedName) { } @Override - public Mono findByBranchNameAndBasePageId( - String branchName, String basePageId, AclPermission permission, List projectedFieldNames) { + public Mono findByRefTypeAndRefNameAndBasePageId( + RefType refType, + String refName, + String basePageId, + AclPermission permission, + List projectedFieldNames) { if (!StringUtils.hasText(basePageId)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID)); - } else if (!StringUtils.hasText(branchName)) { + } else if (!StringUtils.hasText(refName)) { return repository .findById(basePageId, permission, projectedFieldNames) .name(GET_PAGE_WITHOUT_BRANCH) @@ -520,16 +526,16 @@ public Mono findByBranchNameAndBasePageId( new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE, basePageId))); } return repository - .findPageByBranchNameAndBasePageId(branchName, basePageId, permission, projectedFieldNames) + .findPageByRefTypeAndRefNameAndBasePageId(refType, refName, basePageId, permission, projectedFieldNames) .name(GET_PAGE_WITH_BRANCH) .tap(Micrometer.observation(observationRegistry)) .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE, basePageId + ", " + branchName))); + AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE, basePageId + ", " + refName))); } @Override - public Mono findByBranchNameAndBasePageIdAndApplicationMode( - String branchName, String basePageId, ApplicationMode mode) { + public Mono findByRefTypeAndRefNameAndBasePageIdAndApplicationMode( + RefType refType, String refName, String basePageId, ApplicationMode mode) { AclPermission permission; if (ApplicationMode.EDIT.equals(mode)) { @@ -538,15 +544,19 @@ public Mono findByBranchNameAndBasePageIdAndApplicationMode( permission = pagePermission.getReadPermission(); } - return this.findByBranchNameAndBasePageId( - branchName, basePageId, permission, List.of(NewPage.Fields.id, NewPage.Fields.applicationId)) + return this.findByRefTypeAndRefNameAndBasePageId( + refType, + refName, + basePageId, + permission, + List.of(NewPage.Fields.id, NewPage.Fields.applicationId)) .name(getQualifiedSpanName(GET_PAGE, mode)) .tap(Micrometer.observation(observationRegistry)); } @Override - public Mono findBranchedPageId(String branchName, String basePageId, AclPermission permission) { - if (!StringUtils.hasText(branchName)) { + public Mono findRefPageId(RefType refType, String refName, String basePageId, AclPermission permission) { + if (!StringUtils.hasText(refName)) { if (!StringUtils.hasText(basePageId)) { return Mono.error( new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID, basePageId)); @@ -554,9 +564,9 @@ public Mono findBranchedPageId(String branchName, String basePageId, Acl return Mono.just(basePageId); } return repository - .findPageByBranchNameAndBasePageId(branchName, basePageId, permission, null) + .findPageByRefTypeAndRefNameAndBasePageId(refType, refName, basePageId, permission, null) .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE_ID, basePageId + ", " + branchName))) + AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE_ID, basePageId + ", " + refName))) .map(NewPage::getId); } @@ -616,11 +626,12 @@ public Flux findAllByApplicationIds(List applicationIds, List updateDependencyMap(String pageId, Map> dependencyMap, String branchName) { + public Mono updateDependencyMap( + String pageId, Map> dependencyMap, RefType refType, String refName) { Mono updateResult; - if (branchName != null) { - updateResult = findBranchedPageId(branchName, pageId, AclPermission.MANAGE_PAGES) - .flatMap(branchPageId -> repository.updateDependencyMap(branchPageId, dependencyMap)); + if (refName != null) { + updateResult = findRefPageId(refType, refName, pageId, AclPermission.MANAGE_PAGES) + .flatMap(refPageId -> repository.updateDependencyMap(refPageId, dependencyMap)); } else { updateResult = repository.updateDependencyMap(pageId, dependencyMap); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/importable/NewPageImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/importable/NewPageImportableServiceCEImpl.java index d49690e2d2a3..eef9bbfe748a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/importable/NewPageImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/importable/NewPageImportableServiceCEImpl.java @@ -126,7 +126,8 @@ public Mono updateImportedEntities( .toList(); return Flux.fromIterable(newPages) .flatMap(newPage -> { - newPage.setBranchName(importingMetaDTO.getBranchName()); + newPage.setRefType(importingMetaDTO.getRefType()); + newPage.setRefName(importingMetaDTO.getRefName()); return mapActionAndCollectionIdWithPageLayout( newPage, importActionResultDTO.getActionIdMap(), @@ -452,7 +453,8 @@ private Flux importAndSavePages( Set existingPagePolicy = existingPage.getPolicies(); copyNestedNonNullProperties(newPage, existingPage); // Update branchName - existingPage.setBranchName(importingMetaDTO.getBranchName()); + existingPage.setRefType(importingMetaDTO.getRefType()); + existingPage.setRefName(importingMetaDTO.getRefName()); // Recover the deleted state present in DB from imported page existingPage .getUnpublishedPage() @@ -474,12 +476,13 @@ private Flux importAndSavePages( if (application.getGitApplicationMetadata() != null) { if (!pagesFromOtherBranches.containsKey(newPage.getGitSyncId())) { - return saveNewPageAndUpdateBaseId(newPage, importingMetaDTO.getBranchName()); + return saveNewPageAndUpdateBaseId(newPage, importingMetaDTO); } NewPage branchedPage = pagesFromOtherBranches.get(newPage.getGitSyncId()); newPage.setBaseId(branchedPage.getBaseId()); - newPage.setBranchName(importingMetaDTO.getBranchName()); + newPage.setRefType(importingMetaDTO.getRefType()); + newPage.setRefName(importingMetaDTO.getRefName()); newPage.getUnpublishedPage() .setDeletedAt(branchedPage .getUnpublishedPage() @@ -489,7 +492,7 @@ private Flux importAndSavePages( newPage.setPolicies(branchedPage.getPolicies()); return newPageService.save(newPage); } - return saveNewPageAndUpdateBaseId(newPage, importingMetaDTO.getBranchName()); + return saveNewPageAndUpdateBaseId(newPage, importingMetaDTO); } }); }) @@ -499,9 +502,10 @@ private Flux importAndSavePages( }); } - private Mono saveNewPageAndUpdateBaseId(NewPage newPage, String branchName) { + private Mono saveNewPageAndUpdateBaseId(NewPage newPage, ImportingMetaDTO importingMetaDTO) { NewPage update = new NewPage(); - newPage.setBranchName(branchName); + newPage.setRefType(importingMetaDTO.getRefType()); + newPage.setRefName(importingMetaDTO.getRefName()); return newPageService.save(newPage).flatMap(page -> { if (StringUtils.isEmpty(page.getBaseId())) { update.setBaseId(page.getId()); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java index 4da3cdc325ab..173ea95a818a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java @@ -6,7 +6,6 @@ import com.appsmith.server.repositories.AppsmithRepository; import org.springframework.data.domain.Sort; import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; import java.util.List; import java.util.Optional; @@ -25,9 +24,6 @@ Flux findNonComposedByApplicationIdAndViewMode( Flux findByPageId(String pageId); - Mono findByBranchNameAndBaseCollectionId( - String branchName, String baseCollectionId, AclPermission permission); - Flux findByPageIds(List pageIds, AclPermission permission); Flux findAllByApplicationIds(List applicationIds, List includeFields); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java index 2c845414323e..10a9d9c9d649 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java @@ -9,7 +9,6 @@ import com.appsmith.server.repositories.BaseAppsmithRepositoryImpl; import org.springframework.data.domain.Sort; import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; import java.util.List; import java.util.Optional; @@ -84,16 +83,6 @@ public Flux findByPageId(String pageId) { return this.findByPageId(pageId, null); } - @Override - public Mono findByBranchNameAndBaseCollectionId( - String branchName, String baseCollectionId, AclPermission permission) { - final BridgeQuery bq = Bridge.equal( - ActionCollection.Fields.baseId, baseCollectionId) - .equal(ActionCollection.Fields.branchName, branchName); - - return queryBuilder().criteria(bq).permission(permission).one(); - } - @Override public Flux findByPageIds(List pageIds, AclPermission permission) { BridgeQuery pageIdCriteria = diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java index debbd0b8b5d9..7076da23aed5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java @@ -50,9 +50,6 @@ Flux findByApplicationId( Mono countByDatasourceId(String datasourceId); - Mono findByBranchNameAndBaseActionId( - String branchName, String baseActionId, Boolean viewMode, AclPermission permission); - Flux findByPageIds(List pageIds, AclPermission permission); Flux findByPageIds(List pageIds, Optional permission); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java index 33d511dd0990..60ab2e1c0eda 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java @@ -275,21 +275,6 @@ public Mono countByDatasourceId(String datasourceId) { return queryBuilder().criteria(q).count(); } - @Override - public Mono findByBranchNameAndBaseActionId( - String branchName, String baseActionId, Boolean viewMode, AclPermission permission) { - final BridgeQuery q = Bridge.equal(NewAction.Fields.baseId, baseActionId) - .equal(NewAction.Fields.branchName, branchName); - - if (Boolean.FALSE.equals(viewMode)) { - // In case an action has been deleted in edit mode, but still exists in deployed mode, NewAction object - // would exist. To handle this, only fetch non-deleted actions - q.isNull(NewAction.Fields.unpublishedAction_deletedAt); - } - - return queryBuilder().criteria(q).permission(permission).one(); - } - @Override public Flux findByPageIds(List pageIds, AclPermission permission) { return queryBuilder() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCE.java index e2fa493346aa..4f901e9fa30c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.NewPage; import com.appsmith.server.repositories.AppsmithRepository; @@ -32,8 +33,12 @@ Mono findByNameAndApplicationIdAndViewMode( Mono getNameByPageId(String pageId, boolean isPublishedName); - Mono findPageByBranchNameAndBasePageId( - String branchName, String basePageId, AclPermission permission, List projectedFieldNames); + Mono findPageByRefTypeAndRefNameAndBasePageId( + RefType refType, + String refName, + String basePageId, + AclPermission permission, + List projectedFieldNames); Flux findAllByApplicationIds(List branchedArtifactIds, List includedFields); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCEImpl.java index 0fd9514d73c9..5f6bec3f82e8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryCEImpl.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Layout; @@ -8,7 +9,6 @@ import com.appsmith.server.helpers.ce.bridge.Bridge; import com.appsmith.server.helpers.ce.bridge.BridgeQuery; import com.appsmith.server.helpers.ce.bridge.BridgeUpdate; -import com.appsmith.server.projections.IdOnly; import com.appsmith.server.repositories.BaseAppsmithRepositoryImpl; import io.micrometer.observation.ObservationRegistry; import lombok.RequiredArgsConstructor; @@ -131,6 +131,8 @@ public Flux findAllPageDTOsByIds(List ids, AclPermission aclPer NewPage.Fields.applicationId, NewPage.Fields.baseId, NewPage.Fields.branchName, + NewPage.Fields.refType, + NewPage.Fields.refName, NewPage.Fields.policyMap, NewPage.Fields.unpublishedPage_name, NewPage.Fields.unpublishedPage_icon, @@ -169,18 +171,27 @@ public Mono getNameByPageId(String pageId, boolean isPublishedName) { } @Override - public Mono findPageByBranchNameAndBasePageId( - String branchName, String basePageId, AclPermission permission, List projectedFieldNames) { + public Mono findPageByRefTypeAndRefNameAndBasePageId( + RefType refType, + String refName, + String basePageId, + AclPermission permission, + List projectedFieldNames) { final BridgeQuery q = // defaultPageIdCriteria Bridge.equal(NewPage.Fields.baseId, basePageId); - if (branchName != null) { + if (refName != null) { // branchCriteria - q.equal(NewPage.Fields.branchName, branchName); + BridgeQuery refQuery = Bridge.or( + Bridge.equal(NewPage.Fields.branchName, refName), + Bridge.and( + Bridge.equal(NewPage.Fields.refName, refName), + Bridge.equal(NewPage.Fields.refType, refType))); + q.and(refQuery); } else { - q.isNull(NewPage.Fields.branchName); + q.and(Bridge.and(Bridge.isNull(NewPage.Fields.branchName), Bridge.isNull(NewPage.Fields.refName))); } return queryBuilder() @@ -192,19 +203,6 @@ public Mono findPageByBranchNameAndBasePageId( .tap(Micrometer.observation(observationRegistry)); } - public Mono findBranchedPageId(String branchName, String defaultPageId, AclPermission permission) { - final BridgeQuery q = - // defaultPageIdCriteria - Bridge.equal(NewPage.Fields.baseId, defaultPageId); - q.equal(NewPage.Fields.branchName, branchName); - - return queryBuilder() - .criteria(q) - .permission(permission) - .one(IdOnly.class) - .map(IdOnly::id); - } - @Override public Flux findAllByApplicationIds(List applicationIds, List includedFields) { return queryBuilder() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java index 1536ba67a357..0ccded931494 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.services.ce; import com.appsmith.external.constants.AnalyticsEvents; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.Datasource; @@ -166,7 +167,8 @@ public Mono createPage(PageDTO page) { Mono pageMono = applicationMono.map(application -> { generateAndSetPagePolicies(application, page); if (application.getGitArtifactMetadata() != null) { - page.setBranchName(application.getGitArtifactMetadata().getBranchName()); + page.setRefType(application.getGitArtifactMetadata().getRefType()); + page.setRefName(application.getGitArtifactMetadata().getRefName()); } return page; }); @@ -309,11 +311,12 @@ public Mono getPageDTOAfterMigratingDSL(NewPage newPage, boolean viewMo @Override public Mono getPageAndMigrateDslByBranchAndBasePageId( - String defaultPageId, String branchName, boolean viewMode, boolean migrateDsl) { + String defaultPageId, String refName, boolean viewMode, boolean migrateDsl) { ApplicationMode applicationMode = viewMode ? ApplicationMode.PUBLISHED : ApplicationMode.EDIT; // Fetch the page with read permission in both editor and in viewer. return newPageService - .findByBranchNameAndBasePageId(branchName, defaultPageId, pagePermission.getReadPermission(), null) + .findByRefTypeAndRefNameAndBasePageId( + RefType.branch, refName, defaultPageId, pagePermission.getReadPermission(), null) .flatMap(newPage -> getPageDTOAfterMigratingDSL(newPage, viewMode, migrateDsl) .name(getQualifiedSpanName(MIGRATE_DSL, applicationMode)) .tap(Micrometer.observation(observationRegistry))); @@ -576,7 +579,8 @@ public Mono clonePage(String pageId) { .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.ACTION_IS_NOT_AUTHORIZED, "Clone Page"))) .flatMap(page -> { ClonePageMetaDTO clonePageMetaDTO = new ClonePageMetaDTO(); - clonePageMetaDTO.setBranchName(page.getBranchName()); + clonePageMetaDTO.setRefType(page.getRefType()); + clonePageMetaDTO.setRefName(page.getRefName()); return applicationService .saveLastEditInformation(page.getApplicationId()) .then(clonePageGivenApplicationId( @@ -651,7 +655,7 @@ protected Mono clonePageGivenApplicationId( page.setApplicationId(applicationId); GitArtifactMetadata gitData = application.getGitApplicationMetadata(); if (gitData != null) { - page.setBranchName(gitData.getBranchName()); + page.setRefName(gitData.getRefName()); } return newPageService.createDefault(page); }); @@ -738,7 +742,7 @@ public Mono cloneApplication(String branchedApplicationId) { if (application.getGitApplicationMetadata() == null || application .getGitApplicationMetadata() - .getBranchName() + .getRefName() .equals(application .getGitApplicationMetadata() .getDefaultBranchName())) { @@ -1278,7 +1282,7 @@ public Mono reorderPage(String branchedApplicationId, Strin return applicationRepository .setPages(application.getId(), pages) .flatMap(ignored -> sendPageOrderAnalyticsEvent( - application, branchedPageId, order, branchedPage.getBranchName())) + application, branchedPageId, order, branchedPage.getRefName())) .then(newPageService.findApplicationPagesByBranchedApplicationIdAndViewMode( application.getId(), Boolean.FALSE, false)); }); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCE.java index 4e7c427fe249..697664f8f01d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.services.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.server.domains.ApplicationMode; import com.appsmith.server.dtos.ConsolidatedAPIResponseDTO; import reactor.core.publisher.Mono; @@ -7,5 +8,5 @@ public interface ConsolidatedAPIServiceCE { Mono getConsolidatedInfoForPageLoad( - String defaultPageId, String applicationId, String branchName, ApplicationMode mode); + String defaultPageId, String applicationId, RefType refType, String refName, ApplicationMode mode); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java index 18e0b23294e0..7872f46995fe 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.services.ce; import com.appsmith.external.exceptions.ErrorDTO; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.server.actioncollections.base.ActionCollectionService; @@ -138,7 +139,7 @@ protected Mono> toResponseDTO(Mono mono) { */ @Override public Mono getConsolidatedInfoForPageLoad( - String basePageId, String baseApplicationId, String branchName, ApplicationMode mode) { + String basePageId, String baseApplicationId, RefType refType, String refName, ApplicationMode mode) { /* if either of pageId or defaultApplicationId are provided then application mode must also be provided */ if (mode == null && (!isBlank(basePageId) || !isBlank(baseApplicationId))) { @@ -149,7 +150,7 @@ public Mono getConsolidatedInfoForPageLoad( ConsolidatedAPIResponseDTO consolidatedAPIResponseDTO = new ConsolidatedAPIResponseDTO(); List> fetches = - getAllFetchableMonos(consolidatedAPIResponseDTO, basePageId, baseApplicationId, branchName, mode); + getAllFetchableMonos(consolidatedAPIResponseDTO, basePageId, baseApplicationId, refType, refName, mode); return Mono.when(fetches).thenReturn(consolidatedAPIResponseDTO); } @@ -158,7 +159,8 @@ protected List> getAllFetchableMonos( ConsolidatedAPIResponseDTO consolidatedAPIResponseDTO, String basePageId, String baseApplicationId, - String branchName, + RefType refType, + String refName, ApplicationMode mode) { final List> fetches = new ArrayList<>(); @@ -222,7 +224,7 @@ protected List> getAllFetchableMonos( Mono baseApplicationIdMono = getBaseApplicationIdMono(basePageId, baseApplicationId, mode, isViewMode); Mono> applicationAndPageTupleMono = - getApplicationAndPageTupleMono(basePageId, branchName, mode, baseApplicationIdMono, isViewMode); + getApplicationAndPageTupleMono(basePageId, refType, refName, mode, baseApplicationIdMono, isViewMode); Mono branchedPageMonoCached = applicationAndPageTupleMono.map(Tuple2::getT2).cache(); @@ -499,7 +501,8 @@ protected Mono getBranchedApplicationMono( protected Mono> getApplicationAndPageTupleMono( String basePageId, - String branchName, + RefType refType, + String refName, ApplicationMode mode, Mono baseApplicationIdMono, boolean isViewMode) { @@ -509,13 +512,13 @@ protected Mono> getApplicationAndPageTupleMono( Mono branchedPageMonoCached; branchedPageMonoCached = newPageService - .findByBranchNameAndBasePageIdAndApplicationMode(branchName, basePageId, mode) + .findByRefTypeAndRefNameAndBasePageIdAndApplicationMode(refType, refName, basePageId, mode) .cache(); if (StringUtils.hasText(cachedBaseApplicationId)) { // Handle non-empty baseApplicationId applicationMono = applicationService.findByBaseIdBranchNameAndApplicationMode( - cachedBaseApplicationId, branchName, mode); + cachedBaseApplicationId, refName, mode); } else { // Handle empty or null baseApplicationId applicationMono = branchedPageMonoCached.flatMap(branchedPage -> @@ -538,7 +541,7 @@ protected Mono> getApplicationAndPageTupleMono( })); } - if (StringUtils.hasText(branchName)) { + if (StringUtils.hasText(refName)) { // If in case the application is a non git connected application and the branch name url param // is present, then we must default to the app without any branches. @@ -548,16 +551,16 @@ protected Mono> getApplicationAndPageTupleMono( // called errors out on empty returns. log.info( - "application or page has for base pageId {} and branchName {} has not been found.", + "application or page has for base pageId {} and refName {} has not been found.", basePageId, - branchName); + refName); if (error instanceof AppsmithException) { Mono basePageMono = - newPageService.findByBranchNameAndBasePageIdAndApplicationMode( - null, basePageId, mode); + newPageService.findByRefTypeAndRefNameAndBasePageIdAndApplicationMode( + null, null, basePageId, mode); return basePageMono.flatMap(basePage -> { - if (StringUtils.hasText(basePage.getBranchName())) { + if (StringUtils.hasText(basePage.getRefName())) { // If the branch name is present then the application is git connected // the error should be thrown. // TODO: verify if branch name could be residue from old git connection @@ -571,7 +574,7 @@ protected Mono> getApplicationAndPageTupleMono( .zipWith(basePageMono) .map(tuple2 -> { log.info( - "The branchName url param should not be associated with application {} as this is not a git connected application", + "The refName url param should not be associated with application {} as this is not a git connected application", tuple2.getT1().getId()); return tuple2; }); @@ -592,7 +595,7 @@ protected Mono> getApplicationAndPageTupleMono( boolean isDefaultBranchNameAbsent = isNotAGitApp || !StringUtils.hasText(gitMetadata.getDefaultBranchName()); boolean isBranchDefault = !isDefaultBranchNameAbsent - && gitMetadata.getDefaultBranchName().equals(gitMetadata.getBranchName()); + && gitMetadata.getDefaultBranchName().equals(gitMetadata.getRefName()); // This last check is specially for view mode, when a queried page which is not present // in default branch, and cacheable repository refers to the base application @@ -619,8 +622,8 @@ protected Mono> getApplicationAndPageTupleMono( return applicationService .findByBaseIdBranchNameAndApplicationMode(application.getId(), defaultBranchName, mode) - .zipWith(newPageService.findByBranchNameAndBasePageIdAndApplicationMode( - defaultBranchName, basePageId, mode)); + .zipWith(newPageService.findByRefTypeAndRefNameAndBasePageIdAndApplicationMode( + RefType.branch, defaultBranchName, basePageId, mode)); }); }) .cache(); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java index d4a473ae650e..b15c60793b3a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/CurlImporterServiceCEImpl.java @@ -7,7 +7,6 @@ import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.Property; import com.appsmith.server.constants.FieldName; -import com.appsmith.server.domains.NewPage; import com.appsmith.server.domains.Plugin; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; @@ -105,13 +104,6 @@ public Mono importAction( .flatMap(action2 -> layoutActionService.createSingleAction(action2)); } - protected Mono getBranchedContextId(CreatorContextType contextType, String contextId, String branchName) { - return newPageService - .findByBranchNameAndBasePageId( - branchName, contextId, pagePermission.getActionCreatePermission(), List.of(NewPage.Fields.id)) - .map(NewPage::getId); - } - protected Mono associateContextIdToActionDTO( ActionDTO actionDTO, CreatorContextType contextType, String contextId) { actionDTO.setPageId(contextId); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java index 6eef236d4def..0539352ff1fc 100755 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java @@ -347,7 +347,8 @@ public Mono createSingleAction(ActionDTO actionDTO, Boolean isJsActio .switchIfEmpty(Mono.error( new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.PAGE, actionDTO.getPageId()))) .flatMap(newPage -> { - actionDTO.setBranchName(newPage.getBranchName()); + actionDTO.setRefType(newPage.getRefType()); + actionDTO.setRefName(newPage.getRefName()); AppsmithEventContext eventContext = new AppsmithEventContext(AppsmithEventContextType.DEFAULT); CreateActionMetaDTO createActionMetaDTO = new CreateActionMetaDTO(); createActionMetaDTO.setIsJsAction(isJsAction); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java index e644b9f7ea64..cc2533c1375c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java @@ -157,7 +157,8 @@ protected Mono validateAndCreateActionCollectionDomain(ActionC return newPageService .findById(collectionDTO.getPageId(), pagePermission.getActionCreatePermission()) .map(branchedPage -> { - actionCollection.setBranchName(branchedPage.getBranchName()); + actionCollection.setRefType(branchedPage.getRefType()); + actionCollection.setRefName(branchedPage.getRefName()); actionCollectionService.generateAndSetPolicies(branchedPage, actionCollection); actionCollection.setUnpublishedCollection(collectionDTO); @@ -342,7 +343,8 @@ public Mono updateUnpublishedActionCollection( actionCollectionDTO.getName() + "." + actionDTO.getName()); actionDTO.setPluginType(actionCollectionDTO.getPluginType()); actionDTO.setPluginId(actionCollectionDTO.getPluginId()); - actionDTO.setBranchName(branchedActionCollection.getBranchName()); + actionDTO.setRefType(branchedActionCollection.getRefType()); + actionDTO.setRefName(branchedActionCollection.getRefName()); // actionCollectionService is a new action, we need to create one if (duplicateNames.contains(actionDTO.getName())) { @@ -380,9 +382,10 @@ public Mono updateUnpublishedActionCollection( // return an empty action so that the filter can remove it from the list .onErrorResume(throwable -> { log.debug( - "Failed to delete action with id {}, branch {} for collection: {}", + "Failed to delete action with id {}, {} {} for collection: {}", x.getBaseId(), - x.getBranchName(), + x.getRefType(), + x.getRefName(), actionCollectionDTO.getName()); log.error(throwable.getMessage()); return Mono.empty(); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java index eec29d9169db..8d4909cc4b8f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AuthenticationServiceCEImpl.java @@ -4,6 +4,7 @@ import com.appsmith.external.exceptions.BaseException; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.helpers.SSLHelper; import com.appsmith.external.helpers.restApiUtils.helpers.OAuth2Utils; import com.appsmith.external.models.AuthenticationDTO; @@ -147,17 +148,19 @@ public Mono getAuthorizationCodeURLForGenericOAuth2( String workspaceId = tuple2.getT2().getT1(); String trueEnvironmentId = tuple2.getT2().getT2(); NewPage branchedPage = tuple2.getT2().getT3(); - String branchName = null; + String refName = null; + RefType refType = null; - if (hasText(branchedPage.getBranchName())) { - branchName = branchedPage.getBranchName(); + if (hasText(branchedPage.getRefName())) { + refType = branchedPage.getRefType(); + refName = branchedPage.getRefName(); } String basePageId = branchedPage.getBaseIdOrFallback(); OAuth2 oAuth2 = (OAuth2) datasourceStorage.getDatasourceConfiguration().getAuthentication(); final String redirectUri = redirectHelper.getRedirectDomain(httpRequest.getHeaders()); - final String state = StringUtils.hasText(branchName) + final String state = StringUtils.hasText(refName) ? String.join( ",", basePageId, @@ -165,7 +168,8 @@ public Mono getAuthorizationCodeURLForGenericOAuth2( trueEnvironmentId, redirectUri, workspaceId, - branchName) + refType.name(), + refName) : String.join(",", basePageId, datasourceId, trueEnvironmentId, redirectUri, workspaceId); // Adding basic uri components UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString( @@ -354,7 +358,7 @@ private Mono getPageRedirectUrl(String state, String error) { final String environmentId = splitState[2]; final String redirectOrigin = splitState[3]; final String workspaceId = splitState[4]; - final String branchName = splitState.length == 6 ? splitState[5] : null; + final String refName = splitState.length == 7 ? splitState[6] : null; String response = SUCCESS; if (error != null) { response = error; @@ -374,7 +378,7 @@ private Mono getPageRedirectUrl(String state, String error) { + responseStatus + "&view_mode=true" + (StringUtils.hasText(workspaceId) ? "&workspaceId=" + workspaceId : "") - + (StringUtils.hasText(branchName) ? "&branch=" + branchName : ""); + + (StringUtils.hasText(refName) ? "&branch=" + refName : ""); }) .onErrorResume(e -> Mono.just(redirectOrigin + Entity.SLASH + Entity.APPLICATIONS + "?response_status=" @@ -549,8 +553,9 @@ protected Mono getContext(String branchedContextId, Creato pageRedirectionDTO.setId(basePage.getId()); pageRedirectionDTO.setBaseId(basePage.getBaseId()); pageRedirectionDTO.setApplicationId(basePage.getApplicationId()); - // the branch name should come from the branched page as it is required for redirecting - pageRedirectionDTO.setBranchName(branchedPage.getBranchName()); + // the ref name should come from the ref page as it is required for redirecting + pageRedirectionDTO.setRefName(branchedPage.getRefName()); + pageRedirectionDTO.setRefType(branchedPage.getRefType()); return pageRedirectionDTO; }); }); @@ -562,8 +567,9 @@ protected IntegrationDTO associateIntegrationDTOWithContext( integrationDTO.setPageId(pageRedirectionDTO.getBaseIdOrFallback()); integrationDTO.setApplicationId(pageRedirectionDTO.getApplicationId()); - if (hasText(pageRedirectionDTO.getBranchName())) { - integrationDTO.setBranch(pageRedirectionDTO.getBranchName()); + if (hasText(pageRedirectionDTO.getRefName())) { + integrationDTO.setRefType(pageRedirectionDTO.getRefType()); + integrationDTO.setRefName(pageRedirectionDTO.getRefName()); } return integrationDTO; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java index 00dba526a9c8..da73e86a08bc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java @@ -396,7 +396,10 @@ public Mono createPageFromDBTable( .filter(newAction -> StringUtils.equalsIgnoreCase( newAction.getUnpublishedAction().getPageId(), plugin.getGenerateCRUDPageComponent())) - .peek(newAction -> newAction.setBranchName(page.getBranchName())) + .peek(newAction -> { + newAction.setRefType(page.getRefType()); + newAction.setRefName(page.getRefName()); + }) .collect(Collectors.toList()); List templateUnpublishedActionConfigList = templateActionList.stream() @@ -523,9 +526,9 @@ private Mono getOrCreatePage(String branchedApplicationId, String branc page.setApplicationId(applicationId); page.setName(pageName); if (branchedApplication.getGitArtifactMetadata() != null) { - page.setBranchName(branchedApplication + page.setRefName(branchedApplication .getGitArtifactMetadata() - .getBranchName()); + .getRefName()); } return applicationPageService.createPage(page); })) @@ -610,7 +613,8 @@ private Flux cloneActionsFromTemplateApplication( actionDTO.setDatasource(datasourceService.createDatasourceFromDatasourceStorage(datasourceStorage)); actionDTO.setPageId(pageId); actionDTO.setName(templateAction.getUnpublishedAction().getName()); - actionDTO.setBranchName(templateAction.getBranchName()); + actionDTO.setRefType(templateAction.getRefType()); + actionDTO.setRefName(templateAction.getRefName()); // Indicates that source of action creation is generate-crud-page actionDTO.setSource(ActionCreationSourceTypeEnum.GENERATE_PAGE); diff --git a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesIT.java b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesIT.java index a20345d049d4..cba8496fd85e 100644 --- a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesIT.java +++ b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesIT.java @@ -189,7 +189,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(artifactMetadata.getBranchName()); + assertThat(branch).isEqualTo(artifactMetadata.getRefName()); // Assert only single system generated commit exists on FS Iterable commits = git.log().call(); @@ -231,7 +231,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc // Now there should be two commits in the git log response try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(artifactMetadata.getBranchName()); + assertThat(branch).isEqualTo(artifactMetadata.getRefName()); Iterable commits = git.log().call(); Iterator commitIterator = commits.iterator(); @@ -248,7 +248,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc } // Assert that the initialized branch is set as default - assertThat(artifactMetadata.getBranchName()).isEqualTo(artifactMetadata.getDefaultBranchName()); + assertThat(artifactMetadata.getRefName()).isEqualTo(artifactMetadata.getDefaultBranchName()); // Assert that the branch is not protected by default assertThat(artifactMetadata.getBranchProtectionRules()).isNullOrEmpty(); @@ -276,7 +276,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc // Check that the previous attempt didn't actually go through try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(artifactMetadata.getBranchName()); + assertThat(branch).isEqualTo(artifactMetadata.getRefName()); Iterable commits = git.log().call(); assertThat(commits.iterator().next().getId()).isEqualTo(topOfCommits); @@ -307,7 +307,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(artifactMetadata.getBranchName()); + assertThat(branch).isEqualTo(artifactMetadata.getRefName()); Iterable commits = git.log().call(); Iterator commitIterator = commits.iterator(); @@ -358,11 +358,11 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc String fooArtifactId = fooArtifact.getId(); GitArtifactMetadata fooMetadata = fooArtifact.getGitArtifactMetadata(); - assertThat(fooMetadata.getBranchName()).isEqualTo("foo"); + assertThat(fooMetadata.getRefName()).isEqualTo("foo"); try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(fooMetadata.getBranchName()); + assertThat(branch).isEqualTo(fooMetadata.getRefName()); Iterable commits = git.log().call(); Iterator commitIterator = commits.iterator(); @@ -389,11 +389,11 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc String barArtifactId = barArtifact.getId(); GitArtifactMetadata barMetadata = barArtifact.getGitArtifactMetadata(); - assertThat(barMetadata.getBranchName()).isEqualTo("bar"); + assertThat(barMetadata.getRefName()).isEqualTo("bar"); try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(barMetadata.getBranchName()); + assertThat(branch).isEqualTo(barMetadata.getRefName()); Iterable commits = git.log().call(); Iterator commitIterator = commits.iterator(); @@ -417,12 +417,12 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc .collectList() .block(); assertThat(branchList).containsExactlyInAnyOrder( - artifactMetadata.getBranchName(), - "origin/" + artifactMetadata.getBranchName(), - fooMetadata.getBranchName(), - "origin/" + fooMetadata.getBranchName(), - barMetadata.getBranchName(), - "origin/" + barMetadata.getBranchName()); + artifactMetadata.getRefName(), + "origin/" + artifactMetadata.getRefName(), + fooMetadata.getRefName(), + "origin/" + fooMetadata.getRefName(), + barMetadata.getRefName(), + "origin/" + barMetadata.getRefName()); Mono deleteBranchAttemptMono = commonGitService.deleteBranch(artifactId, "foo", artifactType); StepVerifier @@ -445,11 +445,11 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc .collectList() .block(); assertThat(branchList2).containsExactlyInAnyOrder( - artifactMetadata.getBranchName(), - "origin/" + artifactMetadata.getBranchName(), - "origin/" + fooMetadata.getBranchName(), - barMetadata.getBranchName(), - "origin/" + barMetadata.getBranchName()); + artifactMetadata.getRefName(), + "origin/" + artifactMetadata.getRefName(), + "origin/" + fooMetadata.getRefName(), + barMetadata.getRefName(), + "origin/" + barMetadata.getRefName()); Artifact checkedOutFooArtifact = commonGitService.checkoutBranch(artifactId, "origin/foo", true, artifactType).block(); @@ -460,17 +460,17 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc .collectList() .block(); assertThat(branchList3).containsExactlyInAnyOrder( - artifactMetadata.getBranchName(), - "origin/" + artifactMetadata.getBranchName(), - fooMetadata.getBranchName(), - "origin/" + fooMetadata.getBranchName(), - barMetadata.getBranchName(), - "origin/" + barMetadata.getBranchName()); + artifactMetadata.getRefName(), + "origin/" + artifactMetadata.getRefName(), + fooMetadata.getRefName(), + "origin/" + fooMetadata.getRefName(), + barMetadata.getRefName(), + "origin/" + barMetadata.getRefName()); // Verify latest commit on foo should be same as changes made on foo previously try (Git git = Git.open(path.toFile())) { branch = git.log().getRepository().getBranch(); - assertThat(branch).isEqualTo(fooMetadata.getBranchName()); + assertThat(branch).isEqualTo(fooMetadata.getRefName()); Iterable commits = git.log().call(); Iterator commitIterator = commits.iterator(); @@ -578,7 +578,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc } private AutoCommitResponseDTO.AutoCommitResponse getAutocommitProgress(String artifactId, Artifact artifact, GitArtifactMetadata artifactMetadata) { - AutoCommitResponseDTO autoCommitProgress = commonGitService.getAutoCommitProgress(artifactId, artifactMetadata.getBranchName(), artifact.getArtifactType()).block(); + AutoCommitResponseDTO autoCommitProgress = commonGitService.getAutoCommitProgress(artifactId, artifactMetadata.getRefName(), artifact.getArtifactType()).block(); assertThat(autoCommitProgress).isNotNull(); return autoCommitProgress.getAutoCommitResponse(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java index 025e3d11f9c7..834a4b7e3ade 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java @@ -831,7 +831,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService @@ -867,7 +867,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour ArtifactType.APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson) .flatMap(applicationJson -> importService.importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()))) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()))) .map(importableArtifact -> (Application) importableArtifact) .cache(); @@ -886,7 +886,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour List actionList = tuple.getT3(); final String branchName = - application.getGitApplicationMetadata().getBranchName(); + application.getGitApplicationMetadata().getRefName(); pageList.forEach(page -> { assertThat(page.getBranchName()).isEqualTo(branchName); }); @@ -939,7 +939,7 @@ public void importUpdatedApplicationIntoWorkspaceFromFile_publicApplication_visi testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); testApplication.setGitApplicationMetadata(gitData); Application application = applicationPageService @@ -1423,7 +1423,7 @@ public void exportApplication_withReadOnlyAccess_exportedWithDecryptedFields() { testApplication.getUnpublishedApplicationDetail().setNavigationSetting(appNavigationSetting); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService .createApplication(testApplication, workspaceId) @@ -1442,7 +1442,7 @@ public void exportApplication_withReadOnlyAccess_exportedWithDecryptedFields() { applicationJson.getExportedApplication().setPublishedApplicationDetail(null); return importService .importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()) .map(importableArtifact -> (Application) importableArtifact); }); @@ -1482,7 +1482,7 @@ public void importApplicationInWorkspaceFromGit_WithAppLayoutInEditMode_Imported testApplication.setUnpublishedAppLayout(new Application.AppLayout(Application.AppLayout.Type.DESKTOP)); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService .createApplication(testApplication, workspaceId) @@ -1501,7 +1501,7 @@ public void importApplicationInWorkspaceFromGit_WithAppLayoutInEditMode_Imported applicationJson.getExportedApplication().setPublishedAppLayout(null); return importService .importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()) .map(importableArtifact -> (Application) importableArtifact); }); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/fork/ApplicationForkingServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/fork/ApplicationForkingServiceTests.java index e303be7d492c..fb84d7ea6cb1 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/fork/ApplicationForkingServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/fork/ApplicationForkingServiceTests.java @@ -1001,7 +1001,7 @@ public void forkGitConnectedApplication_defaultBranchUpdated_forkDefaultBranchAp theme.setDisplayName("theme_" + uniqueString); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(createdSrcApplication.getId()); - gitArtifactMetadata.setBranchName("master"); + gitArtifactMetadata.setRefName("master"); gitArtifactMetadata.setDefaultBranchName("feature1"); gitArtifactMetadata.setIsRepoPrivate(false); gitArtifactMetadata.setRepoName("testRepo"); @@ -1023,7 +1023,7 @@ public void forkGitConnectedApplication_defaultBranchUpdated_forkDefaultBranchAp GitArtifactMetadata gitArtifactMetadata1 = new GitArtifactMetadata(); gitArtifactMetadata1.setDefaultApplicationId(createdSrcApplication.getId()); - gitArtifactMetadata1.setBranchName("feature1"); + gitArtifactMetadata1.setRefName("feature1"); gitArtifactMetadata1.setDefaultBranchName("feature1"); gitArtifactMetadata1.setIsRepoPrivate(false); gitArtifactMetadata1.setRepoName("testRepo"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java index 307014c1735a..8963aba9e620 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java @@ -4,6 +4,7 @@ import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.GitExecutor; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Datasource; @@ -690,7 +691,7 @@ public void connectArtifactToGit_WithEmptyPublishedPages_CloneSuccess() throws I .assertNext(application -> { GitArtifactMetadata gitArtifactMetadata1 = application.getGitApplicationMetadata(); assertThat(gitArtifactMetadata1.getRemoteUrl()).isEqualTo(gitConnectDTO.getRemoteUrl()); - assertThat(gitArtifactMetadata1.getBranchName()).isEqualTo("defaultBranchName"); + assertThat(gitArtifactMetadata1.getRefName()).isEqualTo("defaultBranchName"); assertThat(gitArtifactMetadata1.getGitAuth().getPrivateKey()) .isNotNull(); assertThat(gitArtifactMetadata1.getGitAuth().getPublicKey()).isNotNull(); @@ -769,7 +770,7 @@ public void connectArtifactToGit_WithoutGitProfileUsingDefaultProfile_CloneSucce .assertNext(application -> { GitArtifactMetadata gitArtifactMetadata1 = application.getGitApplicationMetadata(); assertThat(gitArtifactMetadata1.getRemoteUrl()).isEqualTo(gitConnectDTO.getRemoteUrl()); - assertThat(gitArtifactMetadata1.getBranchName()).isEqualTo("defaultBranchName"); + assertThat(gitArtifactMetadata1.getRefName()).isEqualTo("defaultBranchName"); }) .verifyComplete(); } @@ -792,7 +793,7 @@ public void connectArtifactToGit_WithoutGitProfileUsingLocalProfile_ThrowAuthorN gitAuth.setDocUrl("docUrl"); gitArtifactMetadata.setGitAuth(gitAuth); gitArtifactMetadata.setRemoteUrl("git@github.com:test/testRepo.git"); - gitArtifactMetadata.setBranchName("defaultBranchNameFromRemote"); + gitArtifactMetadata.setRefName("defaultBranchNameFromRemote"); gitArtifactMetadata.setRepoName("testRepo"); testApplication.setGitApplicationMetadata(gitArtifactMetadata); testApplication.setName("localGitProfile"); @@ -880,7 +881,7 @@ public void connectArtifactToGit_WithNonEmptyPublishedPages_CloneSuccess() throw .assertNext(application -> { GitArtifactMetadata gitArtifactMetadata1 = application.getGitApplicationMetadata(); assertThat(gitArtifactMetadata1.getRemoteUrl()).isEqualTo(gitConnectDTO.getRemoteUrl()); - assertThat(gitArtifactMetadata1.getBranchName()).isEqualTo("defaultBranchName"); + assertThat(gitArtifactMetadata1.getRefName()).isEqualTo("defaultBranchName"); assertThat(gitArtifactMetadata1.getGitAuth().getPrivateKey()) .isNotNull(); assertThat(gitArtifactMetadata1.getGitAuth().getPublicKey()).isNotNull(); @@ -1087,7 +1088,7 @@ public void connectArtifactToGit_WithValidCustomGitDomain_CloneSuccess() throws .assertNext(application -> { GitArtifactMetadata gitArtifactMetadata1 = application.getGitApplicationMetadata(); assertThat(gitArtifactMetadata1.getRemoteUrl()).isEqualTo(gitConnectDTO.getRemoteUrl()); - assertThat(gitArtifactMetadata1.getBranchName()).isEqualTo("defaultBranchName"); + assertThat(gitArtifactMetadata1.getRefName()).isEqualTo("defaultBranchName"); assertThat(gitArtifactMetadata1.getGitAuth().getPrivateKey()) .isNotNull(); assertThat(gitArtifactMetadata1.getGitAuth().getPublicKey()).isNotNull(); @@ -1187,7 +1188,7 @@ public void detachRemote_applicationWithActionAndActionCollection_Success() { gitArtifactMetadata.setRepoName("repoName"); gitArtifactMetadata.setDefaultApplicationId("TestId"); gitArtifactMetadata.setDefaultBranchName("defaultBranchFromRemote"); - gitArtifactMetadata.setBranchName("defaultBranch"); + gitArtifactMetadata.setRefName("defaultBranch"); testApplication.setGitApplicationMetadata(gitArtifactMetadata); testApplication.setName("detachRemote_validData"); testApplication.setWorkspaceId(workspaceId); @@ -1224,7 +1225,8 @@ public void detachRemote_applicationWithActionAndActionCollection_Success() { action.setDatasource(datasource); action.setBaseId("branchedActionId"); - action.setBranchName("testBranch"); + action.setRefType(RefType.branch); + action.setRefName("testBranch"); ObjectMapper objectMapper = new ObjectMapper(); JSONObject parentDsl = null; @@ -1489,7 +1491,7 @@ public void listBranchForArtifact_defaultBranchChangesInRemoteExistsInDB_Success .assertNext(application -> { assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("feature1"); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); }) .verifyComplete(); @@ -1555,7 +1557,7 @@ public void listBranchForArtifact_defaultBranchChangesInRemoteDoesNotExistsInDB_ .assertNext(application -> { assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("feature1"); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); }) .verifyComplete(); @@ -1727,8 +1729,8 @@ public void isBranchMergeable_nonConflictingChanges_canBeMerged() throws IOExcep application1 = applicationService.save(application1).block(); GitMergeDTO gitMergeDTO = new GitMergeDTO(); - gitMergeDTO.setSourceBranch(application1.getGitApplicationMetadata().getBranchName()); - gitMergeDTO.setDestinationBranch(application.getGitApplicationMetadata().getBranchName()); + gitMergeDTO.setSourceBranch(application1.getGitApplicationMetadata().getRefName()); + gitMergeDTO.setDestinationBranch(application.getGitApplicationMetadata().getRefName()); MergeStatusDTO mergeStatus = new MergeStatusDTO(); mergeStatus.setMergeAble(true); @@ -1775,7 +1777,7 @@ public void isBranchMergeable_conflictingChanges_canNotBeMerged() throws IOExcep applicationService.save(application).block(); GitMergeDTO gitMergeDTO = new GitMergeDTO(); - gitMergeDTO.setSourceBranch(application.getGitApplicationMetadata().getBranchName()); + gitMergeDTO.setSourceBranch(application.getGitApplicationMetadata().getRefName()); gitMergeDTO.setDestinationBranch(DEFAULT_BRANCH); MergeStatusDTO mergeStatus = new MergeStatusDTO(); @@ -1823,7 +1825,7 @@ public void isBranchMergeable_remoteAhead_remoteAheadErrorMessage() throws IOExc applicationService.save(application1).block(); GitMergeDTO gitMergeDTO = new GitMergeDTO(); - gitMergeDTO.setSourceBranch(application1.getGitApplicationMetadata().getBranchName()); + gitMergeDTO.setSourceBranch(application1.getGitApplicationMetadata().getRefName()); gitMergeDTO.setDestinationBranch(DEFAULT_BRANCH); GitStatusDTO gitStatusDTO = new GitStatusDTO(); @@ -1920,7 +1922,7 @@ public void checkoutRemoteBranch_notPresentInLocal_newApplicationCreated() throw StepVerifier.create(applicationMono) .assertNext(application1 -> { - assertThat(application1.getGitApplicationMetadata().getBranchName()) + assertThat(application1.getGitApplicationMetadata().getRefName()) .isEqualTo("branchNotInLocal"); assertThat(application1.getGitApplicationMetadata().getDefaultArtifactId()) .isEqualTo(gitConnectedApplication.getId()); @@ -2627,7 +2629,7 @@ public void createBranch_validCreateBranchRequest_newApplicationCreated() throws assertThat(application).isNotNull(); assertThat(application.getId()).isNotEqualTo(gitData.getDefaultArtifactId()); assertThat(gitData.getDefaultArtifactId()).isEqualTo(parentApplication.getId()); - assertThat(gitData.getBranchName()).isEqualTo(createGitBranchDTO.getBranchName()); + assertThat(gitData.getRefName()).isEqualTo(createGitBranchDTO.getBranchName()); assertThat(gitData.getDefaultBranchName()).isNotEmpty(); assertThat(gitData.getRemoteUrl()).isNotEmpty(); assertThat(gitData.getBrowserSupportedRemoteUrl()).isNotEmpty(); @@ -2981,9 +2983,9 @@ public void createBranch_BranchDeleteLogo_SrcLogoRemainsUnchanged() throws GitAP Application branchedApplication = applicationTuple.getT1(); Application application = applicationTuple.getT2(); String srcBranchName = - application.getGitApplicationMetadata().getBranchName(); + application.getGitApplicationMetadata().getRefName(); String otherBranchName = - branchedApplication.getGitApplicationMetadata().getBranchName(); + branchedApplication.getGitApplicationMetadata().getRefName(); String defaultApplicationId = branchedApplication.getGitApplicationMetadata().getDefaultArtifactId(); @@ -3062,9 +3064,9 @@ public void createBranch_BranchSetPageIcon_SrcBranchPageIconRemainsNull() throws Application branchedApplication = applicationTuple.getT1(); Application application = applicationTuple.getT2(); String srcBranchName = - application.getGitApplicationMetadata().getBranchName(); + application.getGitApplicationMetadata().getRefName(); String otherBranchName = - branchedApplication.getGitApplicationMetadata().getBranchName(); + branchedApplication.getGitApplicationMetadata().getRefName(); String defaultApplicationId = branchedApplication.getGitApplicationMetadata().getDefaultArtifactId(); @@ -3289,7 +3291,7 @@ public void createBranch_cancelledMidway_newApplicationCreated() throws GitAPIEx assertThat(application).isNotNull(); assertThat(application.getId()).isNotEqualTo(gitData.getDefaultArtifactId()); assertThat(gitData.getDefaultArtifactId()).isEqualTo(application1.getId()); - assertThat(gitData.getBranchName()).isEqualTo(createGitBranchDTO.getBranchName()); + assertThat(gitData.getRefName()).isEqualTo(createGitBranchDTO.getBranchName()); assertThat(gitData.getDefaultBranchName()).isNotEmpty(); assertThat(gitData.getRemoteUrl()).isNotEmpty(); assertThat(gitData.getBrowserSupportedRemoteUrl()).isNotEmpty(); @@ -3480,7 +3482,7 @@ public void importArtifactFromGit_validRequest_Success() { Application application = applicationImportDTO.getApplication(); assertThat(application.getName()).isEqualTo("testRepo"); assertThat(application.getGitApplicationMetadata()).isNotNull(); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("defaultBranch"); @@ -3533,7 +3535,7 @@ public void importArtifactFromGit_validRequestWithDuplicateApplicationName_Succe Application application = applicationImportDTO.getApplication(); assertThat(application.getName()).isEqualTo("testGitRepo (1)"); assertThat(application.getGitApplicationMetadata()).isNotNull(); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("defaultBranch"); @@ -3601,7 +3603,7 @@ public void importArtifactFromGit_validRequestWithDuplicateDatasourceOfSameType_ Application application = applicationImportDTO.getApplication(); assertThat(application.getName()).isEqualTo("testGitImportRepo"); assertThat(application.getGitApplicationMetadata()).isNotNull(); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("defaultBranch"); @@ -3687,7 +3689,7 @@ public void importArtifactFromGit_validRequestWithDuplicateDatasourceOfSameTypeC .assertNext(application -> { assertThat(application.getName()).isEqualTo("testGitImportRepoCancelledMidway"); assertThat(application.getGitApplicationMetadata()).isNotNull(); - assertThat(application.getGitApplicationMetadata().getBranchName()) + assertThat(application.getGitApplicationMetadata().getRefName()) .isEqualTo("defaultBranch"); assertThat(application.getGitApplicationMetadata().getDefaultBranchName()) .isEqualTo("defaultBranch"); @@ -3847,7 +3849,7 @@ public void deleteBranch_branchDoesNotExist_ThrowError() throws IOException, Git Mockito.when(gitExecutor.deleteBranch(any(Path.class), Mockito.anyString())) .thenReturn(Mono.just(false)); - application.getGitApplicationMetadata().setBranchName("not-present-branch"); + application.getGitApplicationMetadata().setRefName("not-present-branch"); Mockito.doReturn(Mono.just(application)) .when(applicationService) .findByBranchNameAndBaseApplicationId(anyString(), anyString(), any(AclPermission.class)); @@ -4067,7 +4069,7 @@ public void deleteBranch_cancelledMidway_success() throws GitAPIException, IOExc .assertNext(applicationList -> { Set branchNames = new HashSet<>(); applicationList.forEach(application1 -> branchNames.add( - application1.getGitApplicationMetadata().getBranchName())); + application1.getGitApplicationMetadata().getRefName())); assertThat(branchNames).doesNotContain(TO_BE_DELETED_BRANCH); }) .verifyComplete(); @@ -4189,7 +4191,7 @@ public void checkoutRemoteBranch_WhenApplicationObjectIsPresent_NewAppNotCreated String appName = "app_" + UUID.randomUUID().toString(); Application application = createApplicationConnectedToGit(appName, "develop"); - assertThat(application.getGitApplicationMetadata().getBranchName()).isEqualTo("develop"); + assertThat(application.getGitApplicationMetadata().getRefName()).isEqualTo("develop"); assertThat(application.getId()) .isEqualTo(application.getGitApplicationMetadata().getDefaultArtifactId()); @@ -4223,7 +4225,7 @@ public void checkoutRemoteBranch_WhenApplicationObjectIsPresent_NewAppNotCreated StepVerifier.create(checkoutBranchMono) .assertNext(app -> { assertThat(app.getId()).isEqualTo(application.getId()); - assertThat(app.getGitApplicationMetadata().getBranchName()).isEqualTo("develop"); + assertThat(app.getGitApplicationMetadata().getRefName()).isEqualTo("develop"); assertThat(app.getGitApplicationMetadata().getGitAuth()).isNotNull(); }) .verifyComplete(); @@ -4366,7 +4368,7 @@ private String createBranchedApplication(List branchList) { // set the git app meta data GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); - gitArtifactMetadata.setBranchName(s); + gitArtifactMetadata.setRefName(s); gitArtifactMetadata.setDefaultBranchName(defaultBranchName); gitArtifactMetadata.setDefaultApplicationId(defaultAppId); createdApp.setGitApplicationMetadata(gitArtifactMetadata); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java index 3a7e5f53c350..39a4287537c5 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java @@ -141,7 +141,7 @@ private Application createApplication() { application.setPages(List.of(applicationPage)); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); - gitArtifactMetadata.setBranchName(BRANCH_NAME); + gitArtifactMetadata.setRefName(BRANCH_NAME); gitArtifactMetadata.setDefaultBranchName(DEFAULT_BRANCH_NAME); gitArtifactMetadata.setRepoName(REPO_NAME); gitArtifactMetadata.setDefaultApplicationId(DEFAULT_APP_ID); @@ -647,7 +647,7 @@ public void testAutoCommit_whenServerIsRunningMigrationCallsAutocommitAgainOnDif .isEqualTo(AutoCommitResponseDTO.AutoCommitResponse.PUBLISHED)) .verifyComplete(); - testApplication.getGitApplicationMetadata().setBranchName("another-branch-name"); + testApplication.getGitApplicationMetadata().setRefName("another-branch-name"); // redis-utils fixing Mockito.when(redisUtils.getRunningAutoCommitBranchName(DEFAULT_APP_ID)).thenReturn(Mono.just(BRANCH_NAME)); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java index c6e08c5bb4a4..c77a12b55028 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java @@ -65,7 +65,7 @@ private GitArtifactMetadata createGitMetadata() { GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(DEFAULT_APPLICATION_ID); gitArtifactMetadata.setRepoName(REPO_NAME); - gitArtifactMetadata.setBranchName(BRANCH_NAME); + gitArtifactMetadata.setRefName(BRANCH_NAME); return gitArtifactMetadata; } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java index 80f0f122c5ae..f7d10aab1d82 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java @@ -287,7 +287,7 @@ public void autoCommitApplication_WhenServerRequiresMigration_successIfEverythin GitArtifactMetadata metaData = new GitArtifactMetadata(); metaData.setRepoName("test-repo-name"); metaData.setDefaultApplicationId(defaultApplicationId); - metaData.setBranchName(branchName); + metaData.setRefName(branchName); GitAuth gitAuth = new GitAuth(); gitAuth.setPrivateKey("private-key"); @@ -333,7 +333,7 @@ public void autoCommitApplication_WhenServerDoesNotRequireMigration_returnFalse( GitArtifactMetadata metaData = new GitArtifactMetadata(); metaData.setRepoName("test-repo-name"); metaData.setDefaultApplicationId(defaultApplicationId); - metaData.setBranchName(branchName); + metaData.setRefName(branchName); GitAuth gitAuth = new GitAuth(); gitAuth.setPrivateKey("private-key"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/ops/GitConnectTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/ops/GitConnectTests.java index d1d576bbcad8..9d848250e358 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/ops/GitConnectTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/ops/GitConnectTests.java @@ -332,7 +332,7 @@ public void connectArtifactToGit_whenUsingGlobalProfile_completesSuccessfully() .assertNext(application -> { GitArtifactMetadata gitArtifactMetadata1 = application.getGitApplicationMetadata(); assertThat(gitArtifactMetadata1.getRemoteUrl()).isEqualTo(gitConnectDTO.getRemoteUrl()); - assertThat(gitArtifactMetadata1.getBranchName()).isEqualTo("defaultBranchName"); + assertThat(gitArtifactMetadata1.getRefName()).isEqualTo("defaultBranchName"); }) .verifyComplete(); } @@ -361,7 +361,7 @@ public void connectArtifactToGit_whenUsingIncompleteLocalProfile_throwsAuthorNam gitAuth.setDocUrl("docUrl"); gitArtifactMetadata.setGitAuth(gitAuth); gitArtifactMetadata.setRemoteUrl("git@github.com:test/testRepo.git"); - gitArtifactMetadata.setBranchName("defaultBranchNameFromRemote"); + gitArtifactMetadata.setRefName("defaultBranchNameFromRemote"); gitArtifactMetadata.setRepoName("testRepo"); testApplication.setGitApplicationMetadata(gitArtifactMetadata); testApplication.setName("localGitProfile"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitUtilsTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitUtilsTest.java index 551253497455..c0fe33b94d1c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitUtilsTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitUtilsTest.java @@ -268,7 +268,7 @@ public void testIsDefaultBranchedApplication_DefaultBranch() { GitArtifactMetadata metadata = new GitArtifactMetadata(); metadata.setDefaultApplicationId(UUID.randomUUID().toString()); metadata.setRemoteUrl("https://git.example.com/repo.git"); - metadata.setBranchName("main"); + metadata.setRefName("main"); metadata.setDefaultBranchName("main"); defaultBranchApplication.setGitApplicationMetadata(metadata); @@ -282,7 +282,7 @@ public void testIsDefaultBranchedApplication_NotDefaultBranch() { GitArtifactMetadata metadata = new GitArtifactMetadata(); metadata.setDefaultApplicationId(UUID.randomUUID().toString()); metadata.setRemoteUrl("https://git.example.com/repo.git"); - metadata.setBranchName("feature-branch"); + metadata.setRefName("feature-branch"); metadata.setDefaultBranchName("main"); nonDefaultBranchApplication.setGitApplicationMetadata(metadata); @@ -313,7 +313,7 @@ public void testIsDefaultBranchedApplication_NullBranchName() { GitArtifactMetadata metadata = new GitArtifactMetadata(); metadata.setDefaultApplicationId(UUID.randomUUID().toString()); metadata.setRemoteUrl("https://git.example.com/repo.git"); - metadata.setBranchName(null); + metadata.setRefName(null); metadata.setDefaultBranchName("main"); nullBranchNameApplication.setGitApplicationMetadata(metadata); @@ -327,7 +327,7 @@ public void testIsDefaultBranchedApplication_NullDefaultBranchName() { GitArtifactMetadata metadata = new GitArtifactMetadata(); metadata.setDefaultApplicationId(UUID.randomUUID().toString()); metadata.setRemoteUrl("https://git.example.com/repo.git"); - metadata.setBranchName("main"); + metadata.setRefName("main"); metadata.setDefaultBranchName(null); nullDefaultBranchNameApplication.setGitApplicationMetadata(metadata); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java index 38337a84be5a..cfc76f867793 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java @@ -1,6 +1,7 @@ package com.appsmith.server.imports.internal; import com.appsmith.external.dtos.ModifiedResources; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.helpers.AppsmithBeanUtils; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; @@ -329,6 +330,7 @@ private Flux getActionsInApplication(Application application) { .findByApplicationId(application.getId(), READ_PAGES, false) .flatMap(page -> newActionService.getUnpublishedActions( new LinkedMultiValueMap<>(Map.of(FieldName.PAGE_ID, Collections.singletonList(page.getId()))), + RefType.branch, "")); } @@ -1365,7 +1367,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService @@ -1398,7 +1400,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour .exportByArtifactId(savedApplication.getId(), VERSION_CONTROL, APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson) .flatMap(applicationJson -> importService.importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()))) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()))) .map(importableArtifact -> (Application) importableArtifact) .cache(); @@ -1417,7 +1419,7 @@ public void exportImportApplication_importWithBranchName_updateApplicationResour List actionList = tuple.getT3(); final String branchName = - application.getGitApplicationMetadata().getBranchName(); + application.getGitApplicationMetadata().getRefName(); pageList.forEach(page -> { assertThat(page.getBranchName()).isEqualTo(branchName); }); @@ -1581,7 +1583,7 @@ public void importArtifactIntoWorkspace_pageRemovedAndUpdatedDefaultPageNameInBr testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); testApplication.setGitApplicationMetadata(gitData); Application application = applicationPageService @@ -1655,7 +1657,7 @@ public void importArtifactIntoWorkspace_pageAddedInBranchApplication_Success() { testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); testApplication.setGitApplicationMetadata(gitData); Application application = applicationPageService @@ -1753,7 +1755,7 @@ public void importUpdatedApplicationIntoWorkspaceFromFile_publicApplication_visi testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); testApplication.setGitApplicationMetadata(gitData); Application application = applicationPageService @@ -3275,7 +3277,7 @@ public void importApplication_datasourceWithSameNameAndPlugin_importedWithValidA testApplication.getUnpublishedApplicationDetail().setNavigationSetting(appNavigationSetting); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService .createApplication(testApplication, workspaceId) @@ -3293,7 +3295,7 @@ public void importApplication_datasourceWithSameNameAndPlugin_importedWithValidA applicationJson.getExportedApplication().setPublishedApplicationDetail(null); return importService .importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()) .map(importableArtifact -> (Application) importableArtifact); }); @@ -3333,7 +3335,7 @@ public void importApplicationInWorkspaceFromGit_WithAppLayoutInEditMode_Imported testApplication.setUnpublishedAppLayout(new Application.AppLayout(Application.AppLayout.Type.DESKTOP)); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); testApplication.setGitApplicationMetadata(gitData); Application savedApplication = applicationPageService .createApplication(testApplication, workspaceId) @@ -3351,7 +3353,7 @@ public void importApplicationInWorkspaceFromGit_WithAppLayoutInEditMode_Imported applicationJson.getExportedApplication().setPublishedAppLayout(null); return importService .importArtifactInWorkspaceFromGit( - workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName()) + workspaceId, savedApplication.getId(), applicationJson, gitData.getRefName()) .map(importableArtifact -> (Application) importableArtifact); }); @@ -3841,7 +3843,7 @@ public void mergeApplication_gitConnectedApplication_pageAddedSuccessfully() { testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -3932,7 +3934,7 @@ public void mergeApplication_gitConnectedApplicationChildBranch_pageAddedSuccess testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -3953,7 +3955,7 @@ public void mergeApplication_gitConnectedApplicationChildBranch_pageAddedSuccess testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData1 = new GitArtifactMetadata(); - gitData1.setBranchName("feature"); + gitData1.setRefName("feature"); gitData1.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData1); @@ -4042,7 +4044,7 @@ public void mergeApplication_gitConnectedApplicationSelectedSpecificPages_select testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -4064,7 +4066,7 @@ public void mergeApplication_gitConnectedApplicationSelectedSpecificPages_select testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData1 = new GitArtifactMetadata(); - gitData1.setBranchName("feature"); + gitData1.setRefName("feature"); gitData1.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData1); @@ -4153,7 +4155,7 @@ public void mergeApplication_gitConnectedApplicationSelectedAllPages_selectedPag testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -4175,7 +4177,7 @@ public void mergeApplication_gitConnectedApplicationSelectedAllPages_selectedPag testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData1 = new GitArtifactMetadata(); - gitData1.setBranchName("feature"); + gitData1.setRefName("feature"); gitData1.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData1); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java index 739c4b997da8..6570ca2da9ac 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java @@ -207,20 +207,19 @@ public void setup() { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("actionServiceTest"); + gitData.setRefName("actionServiceTest"); newApp.setGitApplicationMetadata(gitData); gitConnectedApp = applicationPageService .createApplication(newApp, workspaceId) .flatMap(application1 -> { application1.getGitApplicationMetadata().setDefaultApplicationId(application1.getId()); return applicationService.save(application1).zipWhen(application11 -> exportService - .exportByArtifactIdAndBranchName( - application11.getId(), gitData.getBranchName(), APPLICATION) + .exportByArtifactIdAndBranchName(application11.getId(), gitData.getRefName(), APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -228,7 +227,7 @@ public void setup() { .findPageById(gitConnectedApp.getPages().get(0).getId(), READ_PAGES, false) .block(); - branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); workspaceId = workspace.getId(); datasource = new Datasource(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceTest.java index 28e8b18141de..9010de1a0e58 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceTest.java @@ -187,7 +187,7 @@ public void setup() { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("actionServiceTest"); + gitData.setRefName("actionServiceTest"); newApp.setGitApplicationMetadata(gitData); gitConnectedApp = applicationPageService .createApplication(newApp, workspaceId) @@ -196,11 +196,11 @@ public void setup() { return applicationService .save(application1) .zipWhen(application11 -> exportService.exportByArtifactIdAndBranchName( - application11.getId(), gitData.getBranchName(), APPLICATION)); + application11.getId(), gitData.getRefName(), APPLICATION)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -208,7 +208,7 @@ public void setup() { .findPageById(gitConnectedApp.getPages().get(0).getId(), READ_PAGES, false) .block(); - branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); workspaceId = workspace.getId(); datasource = new Datasource(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java index 71da2c690722..0f5fadf984ce 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java @@ -100,8 +100,8 @@ void publishPages_WhenIdMatches_Published() { @Test void findPageWithoutBranchName() { - StepVerifier.create(newPageRepository.findPageByBranchNameAndBasePageId( - null, "pageId", AclPermission.PAGE_CREATE_PAGE_ACTIONS, null)) + StepVerifier.create(newPageRepository.findPageByRefTypeAndRefNameAndBasePageId( + null, null, "pageId", AclPermission.PAGE_CREATE_PAGE_ACTIONS, null)) .verifyComplete(); } } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java index f67e350bd86b..5f7d38a1d223 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/searchentities/SearchEntitySolutionCETest.java @@ -248,7 +248,7 @@ private static Application mockGitConnectedApplication( application.setName(searchString + "_application"); application.setWorkspaceId(workspace.getId()); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); - gitArtifactMetadata.setBranchName(branchName); + gitArtifactMetadata.setRefName(branchName); gitArtifactMetadata.setDefaultBranchName(defaultBranchName); gitArtifactMetadata.setRemoteUrl("git@test.com:user/testRepo.git"); application.setGitApplicationMetadata(gitArtifactMetadata); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceImplTest.java index 43b0d91a0850..41b452a91bce 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceImplTest.java @@ -52,6 +52,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; @ExtendWith(SpringExtension.class) @Slf4j @@ -200,8 +201,8 @@ public void testCreateCollection_withRepeatedActionName_throwsError() throws IOE final NewPage newPage = objectMapper.convertValue(jsonNode.get("newPage"), NewPage.class); Mockito.when(newPageService.findById(Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); - Mockito.when(newPageService.findByBranchNameAndBasePageId( - Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) + Mockito.when(newPageService.findByRefTypeAndRefNameAndBasePageId( + any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(false)); @@ -234,8 +235,8 @@ public void testCreateCollection_createActionFailure_returnsWithIncompleteCollec Mockito.when(newPageService.findById(Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); - Mockito.when(newPageService.findByBranchNameAndBasePageId( - Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) + Mockito.when(newPageService.findByRefTypeAndRefNameAndBasePageId( + any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(true)); @@ -292,8 +293,8 @@ public void testCreateCollection_validCollection_returnsPopulatedCollection() th Mockito.when(newPageService.findById(Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); - Mockito.when(newPageService.findByBranchNameAndBasePageId( - Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) + Mockito.when(newPageService.findByRefTypeAndRefNameAndBasePageId( + any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); Mockito.when(refactoringService.isNameAllowed(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(true)); @@ -388,8 +389,8 @@ public void testUpdateUnpublishedActionCollection_withInvalidId_throwsError() th Mockito.when(actionCollectionRepository.findById(Mockito.anyString(), Mockito.any())) .thenReturn(Mono.empty()); - Mockito.when(newPageService.findByBranchNameAndBasePageId( - Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) + Mockito.when(newPageService.findByRefTypeAndRefNameAndBasePageId( + any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) .thenReturn(Mono.just(newPage)); Mockito.when(newPageService.findById(Mockito.any(), Mockito.any())) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java index 9260c2672ec1..364e3ee7209c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java @@ -384,7 +384,7 @@ public void createOrUpdateSuffixedApplication_GitConnectedAppExistsWithSameName_ Application application = new Application(); application.setName(appName); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); - gitArtifactMetadata.setBranchName("branch1"); + gitArtifactMetadata.setRefName("branch1"); application.setGitApplicationMetadata(gitArtifactMetadata); Mono importAppMono = applicationPageService @@ -395,7 +395,7 @@ public void createOrUpdateSuffixedApplication_GitConnectedAppExistsWithSameName_ }) .flatMap(createdApp -> { createdApp.setId(null); - createdApp.getGitApplicationMetadata().setBranchName("branch2"); + createdApp.getGitApplicationMetadata().setRefName("branch2"); // just duplicate the app, we're not considering the pages, they remain same in both apps return applicationRepository.save(createdApp); }) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java index 99aaf6bba8c9..6538471c394e 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java @@ -149,7 +149,7 @@ public void createApplicationSnapshot_WhenGitBranchExists_SnapshotCreatedWithBra // this app will have default app id=testDefaultAppId and branch name=test branch name GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(testDefaultAppId); - gitArtifactMetadata.setBranchName(testBranchName); + gitArtifactMetadata.setRefName(testBranchName); testApplication.setGitApplicationMetadata(gitArtifactMetadata); Mono> tuple2Mono = applicationPageService .createApplication(testApplication) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java index cf8fdec1cca4..bacca9f82e67 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java @@ -467,17 +467,10 @@ public void importValidCurlCommand() { curlImporterService.importAction(command, null, page.getId(), "actionName", workspaceId)) .cache(); - // As importAction updates the ids with the defaultIds before sending the response to client we have to again - // fetch branched action - Mono branchedSavedActionMono = - branchedResultMono.flatMap(actionDTO -> newActionService.findByBranchNameAndBaseActionId( - "testBranch", actionDTO.getId(), false, AclPermission.MANAGE_ACTIONS)); - - StepVerifier.create(Mono.zip(branchedResultMono, branchedPageMono, branchedSavedActionMono)) + StepVerifier.create(Mono.zip(branchedResultMono, branchedPageMono, branchedResultMono)) .assertNext(tuple -> { ActionDTO action1 = tuple.getT1(); - NewPage newPage = tuple.getT2(); - NewAction newAction = tuple.getT3(); + ActionDTO actionDTO = tuple.getT3(); assertThat(action1).isNotNull(); assertThat(action1.getDatasource()).isNotNull(); @@ -494,9 +487,9 @@ public void importValidCurlCommand() { assertThat(action1.getActionConfiguration().getHttpMethod()).isEqualTo(HttpMethod.GET); assertThat(action1.getActionConfiguration().getBody()).isEqualTo("{someJson}"); - assertThat(newAction.getBaseId()).isEqualTo(newAction.getId()); + assertThat(actionDTO.getBaseId()).isEqualTo(actionDTO.getId()); - assertThat(newAction.getBranchName()).isEqualTo("testBranch"); + assertThat(actionDTO.getRefName()).isEqualTo("testBranch"); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java index ecda5e353fd8..4ad9cf33c936 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java @@ -213,7 +213,7 @@ public void setup() { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("actionServiceTest"); + gitData.setRefName("actionServiceTest"); newApp.setGitApplicationMetadata(gitData); gitConnectedApp = applicationPageService .createApplication(newApp, workspaceId) @@ -221,12 +221,12 @@ public void setup() { application1.getGitApplicationMetadata().setDefaultApplicationId(application1.getId()); return applicationService.save(application1).zipWhen(application11 -> exportService .exportByArtifactIdAndBranchName( - application11.getId(), gitData.getBranchName(), ArtifactType.APPLICATION) + application11.getId(), gitData.getRefName(), ArtifactType.APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -234,7 +234,7 @@ public void setup() { .findPageById(gitConnectedApp.getPages().get(0).getId(), READ_PAGES, false) .block(); - branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); workspaceId = workspace.getId(); datasource = new Datasource(); @@ -1103,7 +1103,8 @@ void testExecuteOnPageLoadOrderWhenAllActionsAreOnlyExplicitlySetToExecute() thr createdAction1.setExecuteOnLoad(true); // this can only be set to true post action creation. NewAction newAction1 = new NewAction(); newAction1.setUnpublishedAction(createdAction1); - newAction1.setBranchName(createdAction1.getBranchName()); + newAction1.setRefType(createdAction1.getRefType()); + newAction1.setRefName(createdAction1.getRefName()); newAction1.setBaseId(createdAction1.getBaseId()); newAction1.setPluginId(installed_plugin.getId()); newAction1.setPluginType(installed_plugin.getType()); @@ -1114,7 +1115,8 @@ void testExecuteOnPageLoadOrderWhenAllActionsAreOnlyExplicitlySetToExecute() thr createdAction2.setExecuteOnLoad(true); // this can only be set to true post action creation. NewAction newAction2 = new NewAction(); newAction2.setUnpublishedAction(createdAction2); - newAction2.setBranchName(createdAction2.getBranchName()); + newAction2.setRefType(createdAction2.getRefType()); + newAction2.setRefName(createdAction2.getRefName()); newAction2.setBaseId(createdAction2.getBaseId()); newAction2.setPluginId(installed_plugin.getId()); newAction2.setPluginType(installed_plugin.getType()); @@ -1188,7 +1190,8 @@ void updateLayout_WhenPageLoadActionSetBothWaysExplicitlyAndImplicitlyViaWidget_ createdAction1.setUserSetOnLoad(true); NewAction newAction1 = new NewAction(); newAction1.setUnpublishedAction(createdAction1); - newAction1.setBranchName(createdAction1.getBranchName()); + newAction1.setRefType(createdAction1.getRefType()); + newAction1.setRefName(createdAction1.getRefName()); newAction1.setBaseId(createdAction1.getBaseId()); newAction1.setPluginId(installed_plugin.getId()); newAction1.setPluginType(installed_plugin.getType()); 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 11237328ac62..b89277c7012a 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 @@ -1,5 +1,6 @@ package com.appsmith.server.services; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.Policy; import com.appsmith.server.applications.base.ApplicationService; import com.appsmith.server.domains.Application; @@ -426,7 +427,7 @@ public void updateDependencyMap_NotNullValue_shouldUpdateDependencyMap() { dependencyMap.put("key2", List.of("val1", "val2")); dependencyMap.put("key3", List.of("val1", "val2")); return newPageService - .updateDependencyMap(pageDTO.getId(), dependencyMap, null) + .updateDependencyMap(pageDTO.getId(), dependencyMap, RefType.branch, null) .then(newPageService.findById(pageDTO.getId(), null)); }); @@ -462,7 +463,7 @@ public void updateDependencyMap_NotNullValueAndPublishApplication_shouldUpdateDe dependencyMap.put("key2", List.of("val1", "val2")); dependencyMap.put("key3", List.of("val1", "val2")); return newPageService - .updateDependencyMap(pageDTO.getId(), dependencyMap, null) + .updateDependencyMap(pageDTO.getId(), dependencyMap, RefType.branch, null) .flatMap(page -> applicationPageService.publish(application.getId(), false)) .then(newPageService.findById(pageDTO.getId(), null)); }); @@ -499,7 +500,7 @@ public void updateDependencyMap_nullValue_shouldUpdateDependencyMap() { return applicationPageService.createPage(pageDTO); }) .flatMap(pageDTO -> newPageService - .updateDependencyMap(pageDTO.getId(), null, null) + .updateDependencyMap(pageDTO.getId(), null, RefType.branch, null) .then(newPageService.findById(pageDTO.getId(), null))); StepVerifier.create(newPageMono) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java index 3ec766f804c9..0822fc81098c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java @@ -1,5 +1,6 @@ package com.appsmith.server.services; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Datasource; @@ -174,7 +175,7 @@ private Application setupGitConnectedTestApplication(String uniquePrefix) { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName(uniquePrefix + "_pageServiceTest"); + gitData.setRefName(uniquePrefix + "_pageServiceTest"); newApp.setGitApplicationMetadata(gitData); return applicationPageService .createApplication(newApp, workspaceId) @@ -182,12 +183,12 @@ private Application setupGitConnectedTestApplication(String uniquePrefix) { application.getGitApplicationMetadata().setDefaultApplicationId(application.getId()); return applicationService.save(application).zipWhen(application1 -> exportService .exportByArtifactIdAndBranchName( - application1.getId(), gitData.getBranchName(), ArtifactType.APPLICATION) + application1.getId(), gitData.getRefName(), ArtifactType.APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(artifactExchangeJson -> (Application) artifactExchangeJson) .block(); } @@ -790,7 +791,7 @@ public void clonePage_whenPageCloned_defaultIdsRetained() { gitConnectedApplication = setupGitConnectedTestApplication("clonePage"); final String pageId = gitConnectedApplication.getPages().get(0).getId(); final String branchName = - gitConnectedApplication.getGitApplicationMetadata().getBranchName(); + gitConnectedApplication.getGitApplicationMetadata().getRefName(); final PageDTO page = newPageService.findPageById(pageId, READ_PAGES, false).block(); @@ -862,8 +863,8 @@ public void clonePage_whenPageCloned_defaultIdsRetained() { final Mono pageMono = applicationPageService .clonePage(page.getId()) - .flatMap(pageDTO -> - newPageService.findByBranchNameAndBasePageId(branchName, pageDTO.getId(), MANAGE_PAGES, null)) + .flatMap(pageDTO -> newPageService.findByRefTypeAndRefNameAndBasePageId( + RefType.branch, branchName, pageDTO.getId(), MANAGE_PAGES, null)) .cache(); Mono> actionsMono = pageMono.flatMapMany( @@ -1150,7 +1151,7 @@ public void reorderPage_pageReordered_success() { gitConnectedApplication = setupGitConnectedTestApplication("reorderPage"); final String branchName = - gitConnectedApplication.getGitApplicationMetadata().getBranchName(); + gitConnectedApplication.getGitApplicationMetadata().getRefName(); final ApplicationPage[] pageIds = new ApplicationPage[4]; PageDTO testPage1 = new PageDTO(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java index 9b496524358c..3c46097d5755 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java @@ -250,7 +250,7 @@ public void setup() { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("actionServiceTest"); + gitData.setRefName("actionServiceTest"); newApp.setGitApplicationMetadata(gitData); gitConnectedApp = applicationPageService .createApplication(newApp, workspaceId) @@ -258,12 +258,12 @@ public void setup() { application2.getGitApplicationMetadata().setDefaultApplicationId(application2.getId()); return applicationService.save(application2).zipWhen(application1 -> exportService .exportByArtifactIdAndBranchName( - application1.getId(), gitData.getBranchName(), ArtifactType.APPLICATION) + application1.getId(), gitData.getRefName(), ArtifactType.APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -271,7 +271,7 @@ public void setup() { .findPageById(gitConnectedApp.getPages().get(0).getId(), READ_PAGES, false) .block(); - branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); datasource = new Datasource(); datasource.setName("Default Database"); @@ -307,15 +307,12 @@ public void findByIdAndBranchName_forGitConnectedAction_getBranchedAction() { action.setActionConfiguration(actionConfiguration); action.setDatasource(datasource); - Mono actionMono = layoutActionService - .createSingleAction(action) - .flatMap(createdAction -> newActionService.findByBranchNameAndBaseActionId( - branchName, createdAction.getId(), false, READ_ACTIONS)); + Mono actionMono = layoutActionService.createSingleAction(action); StepVerifier.create(actionMono) - .assertNext(newAction -> { - assertThat(newAction.getUnpublishedAction().getPageId()).isEqualTo(gitConnectedPage.getId()); - assertThat(newAction.getBaseId()).isEqualTo(newAction.getId()); + .assertNext(actionDTO -> { + assertThat(actionDTO.getPageId()).isEqualTo(gitConnectedPage.getId()); + assertThat(actionDTO.getBaseId()).isEqualTo(actionDTO.getId()); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java index 89c9a9adabd4..6093222abbb7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java @@ -1,5 +1,6 @@ package com.appsmith.server.services.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.BaseDomain; @@ -339,7 +340,7 @@ public void setup() { Application gitConnectedApp1 = new Application(); gitConnectedApp1.setWorkspaceId(workspaceId); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("testBranch"); + gitData.setRefName("testBranch"); gitData.setDefaultBranchName("testBranch"); gitData.setRepoName("testRepo"); gitData.setRemoteUrl("git@test.com:user/testRepo.git"); @@ -357,12 +358,12 @@ public void setup() { // Assign the branchName to all the resources connected to the application ApplicationJson gitConnectedApplicationJson = exportService - .exportByArtifactIdAndBranchName(newGitConnectedApp.getId(), gitData.getBranchName(), APPLICATION) + .exportByArtifactIdAndBranchName(newGitConnectedApp.getId(), gitData.getRefName(), APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson) .block(); gitConnectedApp = importService .importArtifactInWorkspaceFromGit( - workspaceId, newGitConnectedApp.getId(), gitConnectedApplicationJson, gitData.getBranchName()) + workspaceId, newGitConnectedApp.getId(), gitConnectedApplicationJson, gitData.getRefName()) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -710,9 +711,9 @@ public void getApplicationsByBranchName_validBranchName_success() { StepVerifier.create(getApplication) .assertNext(t -> { assertThat(t).isNotNull(); - assertThat(t.getGitApplicationMetadata().getBranchName()) + assertThat(t.getGitApplicationMetadata().getRefName()) .isEqualTo( - gitConnectedApp.getGitApplicationMetadata().getBranchName()); + gitConnectedApp.getGitApplicationMetadata().getRefName()); assertThat(t.getId()).isEqualTo(gitConnectedApp.getId()); }) .verifyComplete(); @@ -836,7 +837,7 @@ public void updateApplicationByIdAndBranchName_validBranchName_success() { .flatMap(t -> { GitArtifactMetadata gitData = t.getGitApplicationMetadata(); return applicationService.findByBranchNameAndBaseApplicationId( - gitData.getBranchName(), gitData.getDefaultApplicationId(), READ_APPLICATIONS); + gitData.getRefName(), gitData.getDefaultApplicationId(), READ_APPLICATIONS); }); StepVerifier.create(updateApplication) @@ -1106,7 +1107,7 @@ public void makeApplicationPublic_applicationWithGitMetadata_success() { testApplication.setWorkspaceId(workspaceId); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(gitConnectedApp.getId()); - gitArtifactMetadata.setBranchName("test"); + gitArtifactMetadata.setRefName("test"); testApplication.setGitApplicationMetadata(gitArtifactMetadata); Application application = applicationPageService.createApplication(testApplication).block(); @@ -1253,7 +1254,7 @@ public void makeApplicationPrivate_applicationWithGitMetadata_success() { testApplication.setWorkspaceId(workspaceId); GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(gitConnectedApp.getId()); - gitArtifactMetadata.setBranchName("test2"); + gitArtifactMetadata.setRefName("test2"); testApplication.setGitApplicationMetadata(gitArtifactMetadata); Application application = applicationPageService.createApplication(testApplication).block(); @@ -1606,7 +1607,7 @@ public void validMakeApplicationPublicWithActions() { @WithUserDetails(value = "api_user") public void cloneApplication_applicationWithGitMetadata_success() { - final String branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + final String branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); Mono clonedApplicationMono = applicationPageService.cloneApplication(gitConnectedApp.getId()).cache(); @@ -1720,8 +1721,8 @@ public void cloneApplication_applicationWithGitMetadata_success() { .collectList(); Mono> srcNewPageListMono = Flux.fromIterable(gitConnectedApp.getPages()) - .flatMap(applicationPage -> newPageService.findByBranchNameAndBasePageId( - branchName, applicationPage.getDefaultPageId(), READ_PAGES, null)) + .flatMap(applicationPage -> newPageService.findByRefTypeAndRefNameAndBasePageId( + RefType.branch, branchName, applicationPage.getDefaultPageId(), READ_PAGES, null)) .collectList(); StepVerifier.create(Mono.zip(clonedNewPageListMono, srcNewPageListMono)) @@ -1776,7 +1777,7 @@ public void cloneApplication_applicationWithGitMetadata_success() { @WithUserDetails(value = "api_user") public void cloneApplication_applicationWithGitMetadataAndActions_success() { - final String branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + final String branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); Mono workspaceResponse = workspaceService.findById(workspaceId, READ_WORKSPACES); @@ -2478,7 +2479,7 @@ public void cloneGitConnectedApplication_withUpdatedDefaultBranch_sucess() { .flatMap(application1 -> { GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(application1.getId()); - gitArtifactMetadata.setBranchName("master"); + gitArtifactMetadata.setRefName("master"); gitArtifactMetadata.setDefaultBranchName("feature1"); gitArtifactMetadata.setIsRepoPrivate(false); gitArtifactMetadata.setRepoName("testRepo"); @@ -2500,7 +2501,7 @@ public void cloneGitConnectedApplication_withUpdatedDefaultBranch_sucess() { .flatMap(application1 -> { GitArtifactMetadata gitArtifactMetadata = new GitArtifactMetadata(); gitArtifactMetadata.setDefaultApplicationId(application1.getId()); - gitArtifactMetadata.setBranchName("feature1"); + gitArtifactMetadata.setRefName("feature1"); gitArtifactMetadata.setDefaultBranchName("feature1"); gitArtifactMetadata.setIsRepoPrivate(false); gitArtifactMetadata.setRepoName("testRepo"); @@ -2742,7 +2743,7 @@ public void publishApplication_withGitConnectedApp_success() { .update(gitConnectedApp.getId(), gitConnectedApp) .flatMap(updatedApp -> applicationPageService.publish(updatedApp.getId(), true)) .flatMap(application -> applicationService.findByBranchNameAndBaseApplicationId( - gitData.getBranchName(), gitData.getDefaultApplicationId(), MANAGE_APPLICATIONS)) + gitData.getRefName(), gitData.getDefaultApplicationId(), MANAGE_APPLICATIONS)) .cache(); Mono> applicationPagesMono = applicationMono @@ -2893,7 +2894,7 @@ public void deleteUnpublishedPageFromApplication() { @WithUserDetails(value = "api_user") public void deleteUnpublishedPage_FromApplicationConnectedToGit_success() { - final String branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + final String branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); PageDTO page = new PageDTO(); page.setName("Test delete unPublish page test"); page.setApplicationId(gitConnectedApp.getId()); @@ -3794,16 +3795,16 @@ public void getApplicationConnectedToGit_defaultBranchUpdated_returnBranchSpecif testApplication.setName("getApplicationConnectedToGit_defaultBranchUpdated_returnBranchSpecificApplication"); testApplication.setWorkspaceId(workspaceId); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("release"); + gitData.setRefName("release"); gitData.setDefaultApplicationId(gitConnectedApp.getId()); testApplication.setGitApplicationMetadata(gitData); Application application = applicationPageService .createApplication(testApplication) .flatMap(application1 -> exportService - .exportByArtifactIdAndBranchName(gitConnectedApp.getId(), gitData.getBranchName(), APPLICATION) + .exportByArtifactIdAndBranchName(gitConnectedApp.getId(), gitData.getRefName(), APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson) .flatMap(applicationJson -> importService.importArtifactInWorkspaceFromGit( - workspaceId, application1.getId(), applicationJson, gitData.getBranchName()))) + workspaceId, application1.getId(), applicationJson, gitData.getRefName()))) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -3811,11 +3812,11 @@ public void getApplicationConnectedToGit_defaultBranchUpdated_returnBranchSpecif StepVerifier.create(getApplication) .assertNext(application1 -> { assertThat(application1).isNotNull(); - assertThat(application1.getGitApplicationMetadata().getBranchName()) + assertThat(application1.getGitApplicationMetadata().getRefName()) .isNotEqualTo( - gitConnectedApp.getGitApplicationMetadata().getBranchName()); - assertThat(application1.getGitApplicationMetadata().getBranchName()) - .isEqualTo(application.getGitApplicationMetadata().getBranchName()); + gitConnectedApp.getGitApplicationMetadata().getRefName()); + assertThat(application1.getGitApplicationMetadata().getRefName()) + .isEqualTo(application.getGitApplicationMetadata().getRefName()); assertThat(application1.getGitArtifactMetadata().getDefaultArtifactId()) .isEqualTo(gitConnectedApp.getId()); assertThat(application1.getName()).isEqualTo(application.getName()); @@ -4466,7 +4467,7 @@ public void testCacheEviction_whenPagesDeletedInEditModeFollowedByAppPublish_sho // Step 7: Call the consolidated API to force cache update consolidatedAPIService - .getConsolidatedInfoForPageLoad(basePageId1Ref.get(), null, null, ApplicationMode.PUBLISHED) + .getConsolidatedInfoForPageLoad(basePageId1Ref.get(), null, null, null, ApplicationMode.PUBLISHED) .block(); // Step 8: Verify basePageId1 is now cached after the consolidated API call @@ -4483,7 +4484,7 @@ public void testCacheEviction_whenPagesDeletedInEditModeFollowedByAppPublish_sho // Step 10: Call the consolidated API to force cache update for basePageId2 consolidatedAPIService - .getConsolidatedInfoForPageLoad(basePageId2Ref.get(), null, null, ApplicationMode.PUBLISHED) + .getConsolidatedInfoForPageLoad(basePageId2Ref.get(), null, null, null, ApplicationMode.PUBLISHED) .block(); // Step 11: Verify basePageId2 is now cached after the consolidated API call diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java index ccc70eb9315a..bdeea2812344 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java @@ -1,5 +1,6 @@ package com.appsmith.server.services.ce; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Datasource; import com.appsmith.server.acl.AclPermission; @@ -48,6 +49,7 @@ import com.appsmith.server.services.UserService; import com.appsmith.server.themes.base.ThemeService; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -141,7 +143,7 @@ public class ConsolidatedAPIServiceImplTest { @Test public void testErrorWhenModeIsNullAndPageIdAvailable() { Mono consolidatedInfoForPageLoad = - consolidatedAPIService.getConsolidatedInfoForPageLoad("pageId", null, null, null); + consolidatedAPIService.getConsolidatedInfoForPageLoad("pageId", null, null, null, null); StepVerifier.create(consolidatedInfoForPageLoad).verifyErrorSatisfies(error -> { assertThat(error).isInstanceOf(AppsmithException.class); assertEquals("Please enter a valid parameter appMode.", error.getMessage()); @@ -172,7 +174,7 @@ public void testPageLoadResponseWhenPageIdAndApplicationIdMissing() { Mono consolidatedInfoForPageLoad = consolidatedAPIService.getConsolidatedInfoForPageLoad( - "pageId", "appId", "branch", ApplicationMode.PUBLISHED); + "pageId", "appId", RefType.branch, "branch", ApplicationMode.PUBLISHED); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getUserProfile()); @@ -245,7 +247,7 @@ public void testPageLoadResponseForViewMode() { mockNewPage.setBranchName("branch"); doReturn(Mono.just(mockNewPage)) .when(spyNewPageService) - .findByBranchNameAndBasePageId(anyString(), anyString(), any(), any()); + .findByRefTypeAndRefNameAndBasePageId(any(), anyString(), anyString(), any(), any()); doReturn(Mono.just(List.of(mockNewPage))) .when(spyApplicationPageService) @@ -284,7 +286,7 @@ public void testPageLoadResponseForViewMode() { Mono consolidatedInfoForPageLoad = consolidatedAPIService.getConsolidatedInfoForPageLoad( - "pageId123", null, "branch", ApplicationMode.PUBLISHED); + "pageId123", null, RefType.branch, "branch", ApplicationMode.PUBLISHED); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getPublishedActions()); @@ -432,7 +434,7 @@ public void testPageLoadResponseForEditMode() { mockNewPage.setApplicationId("mockApplicationId"); doReturn(Mono.just(mockNewPage)) .when(spyNewPageService) - .findByBranchNameAndBasePageId(anyString(), anyString(), any(), any()); + .findByRefTypeAndRefNameAndBasePageId(any(), anyString(), anyString(), any(), any()); doReturn(Mono.just(List.of(mockNewPage))) .when(spyApplicationPageService) @@ -524,7 +526,8 @@ public void testPageLoadResponseForEditMode() { when(mockMockDataService.getMockDataSet()).thenReturn(Mono.just(sampleMockDataDTO)); Mono consolidatedInfoForPageLoad = - consolidatedAPIService.getConsolidatedInfoForPageLoad("pageId", null, "branch", ApplicationMode.EDIT); + consolidatedAPIService.getConsolidatedInfoForPageLoad( + "pageId", null, RefType.branch, "branch", ApplicationMode.EDIT); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getUserProfile()); @@ -737,15 +740,16 @@ public void testErrorResponseWhenAnonymousUserAccessPrivateApp() { when(mockProductAlertService.getSingleApplicableMessage()) .thenReturn(Mono.just(List.of(sampleProductAlertResponseDTO))); - when(mockNewPageRepository.findPageByBranchNameAndBasePageId(anyString(), anyString(), any(), any())) - .thenReturn(Mono.empty()); + Mockito.doReturn(Mono.empty()) + .when(mockNewPageRepository) + .findPageByRefTypeAndRefNameAndBasePageId(any(), anyString(), anyString(), any(), any()); doReturn(Mono.empty()) .when(spyApplicationRepository) .getApplicationByGitBranchAndBaseApplicationId(anyString(), anyString(), any(AclPermission.class)); Mono consolidatedInfoForPageLoad = consolidatedAPIService.getConsolidatedInfoForPageLoad( - "pageId", "appId", "branch", ApplicationMode.PUBLISHED); + "pageId", "appId", RefType.branch, "branch", ApplicationMode.PUBLISHED); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getUserProfile()); @@ -923,7 +927,7 @@ public void testPageLoadResponseForViewMode_whenBranchNameIsPresentInNonGitApp() doReturn(Mono.just(mockNewPage)) .when(spyNewPageService) - .findByBranchNameAndBasePageId(eq(null), eq("mockPageId"), any(), any()); + .findByRefTypeAndRefNameAndBasePageId(any(), eq(null), eq("mockPageId"), any(), any()); doReturn(Mono.just(List.of(mockNewPage))) .when(spyApplicationPageService) @@ -962,7 +966,7 @@ public void testPageLoadResponseForViewMode_whenBranchNameIsPresentInNonGitApp() Mono consolidatedInfoForPageLoad = consolidatedAPIService.getConsolidatedInfoForPageLoad( - "mockPageId", null, "branch", ApplicationMode.PUBLISHED); + "mockPageId", null, RefType.branch, "branch", ApplicationMode.PUBLISHED); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getPublishedActions()); @@ -1105,7 +1109,7 @@ public void testPageLoadResponseForEditModeWhenDefaultBranchIsDifferentFromDefau Application mockApplicationBaseBranch = new Application(); GitArtifactMetadata baseMetadata = new GitArtifactMetadata(); - baseMetadata.setBranchName("master"); + baseMetadata.setRefName("master"); baseMetadata.setDefaultBranchName("newDefaultBranch"); baseMetadata.setDefaultApplicationId("mockBaseId"); mockApplicationBaseBranch.setGitArtifactMetadata(baseMetadata); @@ -1121,7 +1125,7 @@ public void testPageLoadResponseForEditModeWhenDefaultBranchIsDifferentFromDefau Application mockDefaultApplication = new Application(); GitArtifactMetadata defaultMetadata = new GitArtifactMetadata(); - defaultMetadata.setBranchName("newDefaultBranch"); + defaultMetadata.setRefName("newDefaultBranch"); defaultMetadata.setDefaultApplicationId("mockBaseId"); mockDefaultApplication.setGitArtifactMetadata(defaultMetadata); mockDefaultApplication.setId("defaultApplicationId"); @@ -1143,11 +1147,11 @@ public void testPageLoadResponseForEditModeWhenDefaultBranchIsDifferentFromDefau doReturn(Mono.just(basePage)) .when(spyNewPageService) - .findByBranchNameAndBasePageId(eq(null), anyString(), any(), any()); + .findByRefTypeAndRefNameAndBasePageId(any(), eq(null), anyString(), any(), any()); doReturn(Mono.just(defaultAppDefaultPage)) .when(spyNewPageService) - .findByBranchNameAndBasePageId(anyString(), anyString(), any(), any()); + .findByRefTypeAndRefNameAndBasePageId(any(), anyString(), anyString(), any(), any()); doReturn(Mono.just(List.of(defaultAppDefaultPage))) .when(spyApplicationPageService) @@ -1235,7 +1239,7 @@ public void testPageLoadResponseForEditModeWhenDefaultBranchIsDifferentFromDefau when(mockMockDataService.getMockDataSet()).thenReturn(Mono.just(sampleMockDataDTO)); Mono consolidatedInfoForPageLoad = - consolidatedAPIService.getConsolidatedInfoForPageLoad("pageId", null, null, ApplicationMode.EDIT); + consolidatedAPIService.getConsolidatedInfoForPageLoad("pageId", null, null, null, ApplicationMode.EDIT); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO.getUserProfile()); @@ -1459,7 +1463,7 @@ public void testPageLoadWhenPageFromFeatureBranchAndCacheableRepositoryReturnsBa // base metadata GitArtifactMetadata baseMetadata = new GitArtifactMetadata(); - baseMetadata.setBranchName(BASE_BRANCH); + baseMetadata.setRefName(BASE_BRANCH); baseMetadata.setDefaultBranchName(DEFAULT_BRANCH); baseMetadata.setDefaultApplicationId(DEFAULT_APPLICATION_ID); @@ -1483,7 +1487,7 @@ public void testPageLoadWhenPageFromFeatureBranchAndCacheableRepositoryReturnsBa // default metadata GitArtifactMetadata defaultMetadata = new GitArtifactMetadata(); - defaultMetadata.setBranchName(DEFAULT_BRANCH); + defaultMetadata.setRefName(DEFAULT_BRANCH); defaultMetadata.setDefaultBranchName(DEFAULT_BRANCH); defaultMetadata.setDefaultApplicationId(DEFAULT_APPLICATION_ID); @@ -1504,7 +1508,7 @@ public void testPageLoadWhenPageFromFeatureBranchAndCacheableRepositoryReturnsBa doReturn(Mono.just(featureBranchPage)) .when(spyNewPageService) - .findByBranchNameAndBasePageIdAndApplicationMode(eq(null), eq(FEATURE_PAGE_ID), any()); + .findByRefTypeAndRefNameAndBasePageIdAndApplicationMode(any(), eq(null), eq(FEATURE_PAGE_ID), any()); doReturn(Mono.just(new PageDTO())) .when(spyApplicationPageService) @@ -1589,7 +1593,7 @@ public void testPageLoadWhenPageFromFeatureBranchAndCacheableRepositoryReturnsBa Mono consolidatedInfoForPageLoad = consolidatedAPIService.getConsolidatedInfoForPageLoad( - FEATURE_PAGE_ID, null, null, ApplicationMode.PUBLISHED); + FEATURE_PAGE_ID, null, null, null, ApplicationMode.PUBLISHED); StepVerifier.create(consolidatedInfoForPageLoad) .assertNext(consolidatedAPIResponseDTO -> { assertNotNull(consolidatedAPIResponseDTO); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/AuthenticationServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/AuthenticationServiceTest.java index 2538f7925daa..7e2eb4825594 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/AuthenticationServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/AuthenticationServiceTest.java @@ -1,5 +1,6 @@ package com.appsmith.server.solutions; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceConfiguration; @@ -288,7 +289,7 @@ public void testGetAuthorizationCodeURL_validDatasourceAndBranchName() { PageDTO testPage = new PageDTO(); testPage.setName("Test-Page-oauth2-git-redirection"); - testPage.setBranchName(branchName); + testPage.setRefName(branchName); Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); @@ -355,6 +356,7 @@ public void testGetAuthorizationCodeURL_validDatasourceAndBranchName() { defaultEnvironmentId, "https://mock.origin.com", workspaceId, + RefType.branch.name(), branchName) + "&scope=Scope\\d%20Scope\\d" + "&key=value")); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java index 5ebba1803e6a..f409d5e809f9 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java @@ -1,5 +1,6 @@ package com.appsmith.server.solutions; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Datasource; @@ -340,7 +341,7 @@ public void createPage_withValidBranch_validDefaultIds() { Application gitConnectedApp = new Application(); gitConnectedApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("crudTestBranch"); + gitData.setRefName("crudTestBranch"); gitConnectedApp.setGitApplicationMetadata(gitData); applicationPageService .createApplication(gitConnectedApp, testWorkspace.getId()) @@ -348,12 +349,12 @@ public void createPage_withValidBranch_validDefaultIds() { application.getGitApplicationMetadata().setDefaultApplicationId(application.getId()); gitData.setDefaultApplicationId(application.getId()); return applicationService.save(application).zipWhen(application1 -> exportService - .exportByArtifactIdAndBranchName(application1.getId(), gitData.getBranchName(), APPLICATION) + .exportByArtifactIdAndBranchName(application1.getId(), gitData.getRefName(), APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - testWorkspace.getId(), tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + testWorkspace.getId(), tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -366,8 +367,12 @@ public void createPage_withValidBranch_validDefaultIds() { .createPage(newPage) .flatMap(savedPage -> solution.createPageFromDBTable(savedPage.getId(), resource, testDefaultEnvironmentId)) - .flatMap(crudPageResponseDTO -> newPageService.findByBranchNameAndBasePageId( - gitData.getBranchName(), crudPageResponseDTO.getPage().getId(), READ_PAGES, null)); + .flatMap(crudPageResponseDTO -> newPageService.findByRefTypeAndRefNameAndBasePageId( + RefType.branch, + gitData.getRefName(), + crudPageResponseDTO.getPage().getId(), + READ_PAGES, + null)); StepVerifier.create(resultMono.zipWhen(newPage1 -> getActions(newPage1.getId()))) .assertNext(tuple -> { @@ -378,14 +383,14 @@ public void createPage_withValidBranch_validDefaultIds() { Layout layout = page.getLayouts().get(0); assertThat(page.getName()).isEqualTo("crud-admin-page-with-git-connected-app"); - assertThat(newPage1.getBranchName()).isEqualTo(gitData.getBranchName()); + assertThat(newPage1.getBranchName()).isEqualTo(gitData.getRefName()); assertThat(newPage1.getBaseId()).isEqualTo(newPage1.getId()); assertThat(actionList).hasSize(4); NewAction newAction = actionList.get(0); assertThat(newAction.getBaseId()) .isEqualTo(actionList.get(0).getId()); - assertThat(newAction.getBranchName()).isEqualTo(gitData.getBranchName()); + assertThat(newAction.getBranchName()).isEqualTo(gitData.getRefName()); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java index 2ff253c45125..0ba451f58822 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java @@ -1,5 +1,6 @@ package com.appsmith.server.solutions; +import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.DBAuth; @@ -220,7 +221,7 @@ private Application createGitConnectedApp(String applicationName) { testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -289,7 +290,7 @@ public void testGetPartialExport_gitConnectedApp_branchResourceExported() { PageDTO savedPage = new PageDTO(); savedPage.setName("Page 2"); savedPage.setApplicationId(application.getId()); - savedPage.setBranchName("master"); + savedPage.setRefName("master"); savedPage = applicationPageService.createPage(savedPage).block(); // Create Action @@ -349,7 +350,7 @@ public void testGetPartialExport_gitConnectedApp_featureBranchResourceExported() PageDTO savedPage = new PageDTO(); savedPage.setName("Page 2"); savedPage.setApplicationId(application.getId()); - savedPage.setBranchName("master"); + savedPage.setRefName("master"); savedPage = applicationPageService.createPage(savedPage).block(); // Create Action @@ -362,7 +363,8 @@ public void testGetPartialExport_gitConnectedApp_featureBranchResourceExported() actionConfiguration.setTimeoutInMillisecond("6000"); action.setActionConfiguration(actionConfiguration); action.setDatasource(datasourceMap.get("DS1")); - action.setBranchName("master"); + action.setRefType(RefType.branch); + action.setRefName("master"); ActionDTO savedAction = layoutActionService.createSingleAction(action, Boolean.FALSE).block(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java index 218269a72ec7..1169d8742880 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java @@ -239,7 +239,7 @@ private Application createGitConnectedApp(String applicationName) { testApplication.setModifiedBy("some-user"); testApplication.setGitApplicationMetadata(new GitArtifactMetadata()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("master"); + gitData.setRefName("master"); gitData.setDefaultBranchName("master"); testApplication.setGitApplicationMetadata(gitData); @@ -331,7 +331,7 @@ public void testPartialImport_gitConnectedAppDefaultBranch_success() { PageDTO savedPage = new PageDTO(); savedPage.setName("Page 2"); savedPage.setApplicationId(application.getId()); - savedPage.setBranchName("master"); + savedPage.setRefName("master"); savedPage = applicationPageService.createPage(savedPage).block(); Part filePart = createFilePart("test_assets/ImportExportServiceTest/partial-export-valid-without-widget.json"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCETest.java index e8bb6bc39db5..43cf663f943c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCETest.java @@ -252,7 +252,7 @@ public void setup() { Application newApp = new Application(); newApp.setName(UUID.randomUUID().toString()); GitArtifactMetadata gitData = new GitArtifactMetadata(); - gitData.setBranchName("actionServiceTest"); + gitData.setRefName("actionServiceTest"); newApp.setGitApplicationMetadata(gitData); gitConnectedApp = applicationPageService .createApplication(newApp, workspaceId) @@ -260,12 +260,12 @@ public void setup() { application1.getGitApplicationMetadata().setDefaultApplicationId(application1.getId()); return applicationService.save(application1).zipWhen(application11 -> exportService .exportByArtifactIdAndBranchName( - application11.getId(), gitData.getBranchName(), ArtifactType.APPLICATION) + application11.getId(), gitData.getRefName(), ArtifactType.APPLICATION) .map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)); }) // Assign the branchName to all the resources connected to the application .flatMap(tuple -> importService.importArtifactInWorkspaceFromGit( - workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getBranchName())) + workspaceId, tuple.getT1().getId(), tuple.getT2(), gitData.getRefName())) .map(importableArtifact -> (Application) importableArtifact) .block(); @@ -273,7 +273,7 @@ public void setup() { .findPageById(gitConnectedApp.getPages().get(0).getId(), READ_PAGES, false) .block(); - branchName = gitConnectedApp.getGitApplicationMetadata().getBranchName(); + branchName = gitConnectedApp.getGitApplicationMetadata().getRefName(); datasource = new Datasource(); datasource.setName("Default Database");