Skip to content

Commit

Permalink
added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sondermanish committed Jan 22, 2025
1 parent b14669e commit 00232d7
Show file tree
Hide file tree
Showing 15 changed files with 389 additions and 288 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ public Integer getFileFormatVersion(Object metadata) {
if (metadata == null) {
return 1;
}

JsonNode json = objectMapper.valueToTree(metadata);
int fileFormatVersion = json.get(CommonConstants.FILE_FORMAT_VERSION).asInt();
return fileFormatVersion;
return json.get(CommonConstants.FILE_FORMAT_VERSION).asInt();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,13 @@ public Mono<Boolean> checkoutToBranch(Path repoSuffix, String branchName) {
return Mono.using(
() -> Git.open(createRepoPath(repoSuffix).toFile()),
git -> Mono.fromCallable(() -> {
log.debug(Thread.currentThread().getName() + ": Switching to the branch "
+ branchName);
log.info(
"{}: Switching to the branch {}",
Thread.currentThread().getName(),
branchName);

// We can safely assume that repo has been already initialised either in commit or
// clone flow and
// can directly
// open the repo
// clone flow and can directly open the repo
if (StringUtils.equalsIgnoreCase(
branchName, git.getRepository().getBranch())) {
return TRUE;
Expand Down Expand Up @@ -611,8 +612,12 @@ public Mono<GitStatusDTO> getStatus(Path repoPath, String branchName) {
return Mono.using(
() -> Git.open(repoPath.toFile()),
git -> Mono.fromCallable(() -> {
log.debug(Thread.currentThread().getName() + ": Get status for repo " + repoPath
+ ", branch " + branchName);
log.info(
"{}: Get status for repo {}, {}",
Thread.currentThread().getName(),
repoPath,
branchName);

Status status = git.status().call();
GitStatusDTO response = new GitStatusDTO();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class GitConstantsCE {
public static final String ACTION_LIST = "actionList";
public static final String ACTION_COLLECTION_LIST = "actionCollectionList";

public static final String README_FILE_NAME = "README.md";

public static final String DEFAULT_COMMIT_MESSAGE = "System generated commit, ";
public static final String EMPTY_COMMIT_ERROR_MESSAGE = "On current branch nothing to commit, working tree clean";
public static final String MERGE_CONFLICT_BRANCH_NAME = "_mergeConflict";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
import static com.appsmith.git.constants.CommonConstants.JSON_EXTENSION;
import static com.appsmith.git.constants.CommonConstants.MAIN_CONTAINER;
import static com.appsmith.git.constants.CommonConstants.WIDGETS;
import static com.appsmith.git.constants.ce.CommonConstantsCE.FILE_FORMAT_VERSION;
import static com.appsmith.git.constants.ce.CommonConstantsCE.fileFormatVersion;
import static com.appsmith.git.constants.ce.GitDirectoriesCE.PAGE_DIRECTORY;
import static com.appsmith.server.constants.FieldName.ACTION_COLLECTION_LIST;
import static com.appsmith.server.constants.FieldName.ACTION_LIST;
Expand Down Expand Up @@ -189,6 +191,10 @@ public void setArtifactDependentResources(
copyProperties(applicationJson, applicationMetadata, keys);
final String metadataFilePath = CommonConstants.METADATA + JSON_EXTENSION;
ObjectNode metadata = objectMapper.valueToTree(applicationMetadata);

// put file format version;
metadata.put(FILE_FORMAT_VERSION, fileFormatVersion);

GitResourceIdentity metadataIdentity =
new GitResourceIdentity(GitResourceType.ROOT_CONFIG, metadataFilePath, metadataFilePath);
resourceMap.put(metadataIdentity, metadata);
Expand Down Expand Up @@ -717,7 +723,6 @@ public void setArtifactDependentPropertiesInJson(
artifactExchangeJson.setContextList(pageList);

// widgets

pageList.parallelStream().forEach(newPage -> {
Map<String, org.json.JSONObject> widgetsData = resourceMap.entrySet().stream()
.filter(entry -> {
Expand All @@ -730,13 +735,23 @@ public void setArtifactDependentPropertiesInJson(
.getFilePath()
.replaceFirst(
PAGE_DIRECTORY
+ DELIMITER_PATH
+ newPage.getUnpublishedPage()
.getName()
+ DELIMITER_PATH
+ WIDGETS
+ DELIMITER_PATH,
MAIN_CONTAINER + DELIMITER_PATH),
entry -> (org.json.JSONObject) entry.getValue()));
entry -> {
try {
return new org.json.JSONObject(objectMapper.writeValueAsString(entry.getValue()));
} catch (JsonProcessingException jsonProcessingException) {
log.error(
"Error while deserializing widget with file path {}",
entry.getKey().getFilePath());
throw new RuntimeException(jsonProcessingException);
}
}));

Layout layout = newPage.getUnpublishedPage().getLayouts().get(0);
org.json.JSONObject mainContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import static com.appsmith.server.constants.FieldName.PUBLISHED;
import static com.appsmith.server.constants.FieldName.UNPUBLISHED;
import static com.appsmith.server.helpers.ImportExportUtils.setPropertiesToExistingApplication;
import static com.appsmith.server.helpers.ImportExportUtils.setPublishedApplicationProperties;
import static org.springframework.util.StringUtils.hasText;
Expand Down Expand Up @@ -361,11 +363,18 @@ public Mono<Application> updateAndSaveArtifactInContext(
application.setWorkspaceId(importingMetaDTO.getWorkspaceId());
application.setIsPublic(null);
application.setPolicies(null);
Map<String, List<ApplicationPage>> mapOfApplicationPageList = Map.of(
FieldName.PUBLISHED,
application.getPublishedPages(),
FieldName.UNPUBLISHED,
application.getPages());

List<ApplicationPage> unPublishedPages = CollectionUtils.isEmpty(application.getPages())
? new ArrayList<>()
: application.getPages();

List<ApplicationPage> publishedPages = CollectionUtils.isEmpty(application.getPublishedPages())
? new ArrayList<>()
: application.getPublishedPages();

Map<String, List<ApplicationPage>> mapOfApplicationPageList =
Map.of(PUBLISHED, publishedPages, UNPUBLISHED, unPublishedPages);

mappedImportableResourcesDTO
.getResourceStoreFromArtifactExchangeJson()
.putAll(mapOfApplicationPageList);
Expand Down
Loading

0 comments on commit 00232d7

Please sign in to comment.