Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save point #26430

Merged
merged 20 commits into from Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven-cicd-pipeline.yml
Expand Up @@ -292,7 +292,7 @@ jobs:
echo "${DOTCMS_LICENSE_KEY}" > ${DOTCMS_LICENSE_PATH}/license.dat
echo "DOTCMS_LICENSE_FILE=${DOTCMS_LICENSE_PATH}/license.dat" >> "$GITHUB_ENV"
- name: Build
run: eval ./mvnw -Dprod $JVM_TEST_MAVEN_OPTS -Dtestcontainers.docker.image=${{ needs.build-jdk11.outputs.docker-tag }} -pl :dotcms-api-data-model,:dotcms-cli test ${{ matrix.java.maven_args}}
run: eval ./mvnw -Dprod $JVM_TEST_MAVEN_OPTS -Dtestcontainers.docker.image=${{ needs.build-jdk11.outputs.docker-tag }} -pl :dotcms-api-data-model,:dotcms-cli verify ${{ matrix.java.maven_args}}
- name: Prepare reports archive (if maven failed)
if: failure()
shell: bash
Expand Down
Expand Up @@ -2,10 +2,10 @@

import com.dotcms.model.asset.AssetView;
import com.dotcms.model.asset.FolderView;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* A node in a hierarchical tree representation of a file system directory. Each node represents a
Expand All @@ -16,8 +16,8 @@
*/
public class TreeNode {

private final FolderView folder;
private List<TreeNode> children;
private FolderView folder;
private final List<TreeNode> children;
private List<AssetView> assets;

/**
Expand All @@ -38,18 +38,25 @@ public TreeNode(final FolderView folder) {
* ({@code false})
*/
public TreeNode(final FolderView folder, final boolean ignoreAssets) {

this.folder = folder;
this.children = new ArrayList<>();
this.assets = new ArrayList<>();

if (!ignoreAssets) {
if (folder.assets() != null) {
this.assets.addAll(folder.assets().versions());
}
if (!ignoreAssets && null != folder.assets()) {
this.assets.addAll(folder.assets().versions());
fabrizzio-dotCMS marked this conversation as resolved.
Show resolved Hide resolved
}
}

/**
* Mutators are evil, but we really need to update the status of the folder
* @param mark the delete mark
*/
public void markForDelete(boolean mark) {
this.folder = FolderView.builder().from(this.folder)
.markForDelete(mark)
//Here only for compatibility with the actual code will be removed later
.build();
}

/**
* Returns the folder represented by this TreeNode.
*/
Expand All @@ -64,6 +71,17 @@ public List<TreeNode> children() {
return this.children;
}

/**
* Returns a list of child nodes of this TreeNode
* Given that this is a recursive structure, this method returns a flattened list of all the
* @return the list of child nodes
*/
public Stream<TreeNode> flattened() {
return Stream.concat(
Stream.of(this),
children.stream().flatMap(TreeNode::flattened));
}

/**
* Returns a list of assets contained within the folder represented by this {@code TreeNode}.
*
Expand Down Expand Up @@ -119,7 +137,7 @@ public TreeNode cloneAndFilterAssets(final boolean live, final String language,
boolean includeAssets = includeAssets();
if (includeAssets && this.assets != null) {
List<AssetView> filteredAssets = this.assets.stream()
.filter((asset) -> {
.filter(asset -> {
spbolton marked this conversation as resolved.
Show resolved Hide resolved

if (live) {
return asset.live() && asset.lang().equalsIgnoreCase(language);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import org.immutables.value.Value.Auxiliary;

@ValueType
@Value.Immutable
Expand Down
Expand Up @@ -4,12 +4,11 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;

import javax.annotation.Nullable;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import org.immutables.value.Value;

@ValueType
@Value.Immutable
Expand Down Expand Up @@ -79,8 +78,4 @@ default boolean implicitGlobInclude() {

Optional<Boolean> markForDelete();

Optional<String> localStatus();

Optional<String> localLanguage();

}
@@ -1,20 +1,20 @@
package com.dotcms.api.client.files;

import com.dotcms.api.client.files.PushServiceImpl.TraverseResult;
import com.dotcms.api.traversal.TreeNode;
import com.dotcms.api.traversal.TreeNodePushInfo;
import com.dotcms.cli.common.OutputOptionMixin;
import com.dotcms.common.AssetsUtils;
import org.apache.commons.lang3.tuple.Triple;

import java.io.File;
import java.util.List;

public interface PushService {

/**
* Traverses the local folders and retrieves the hierarchical tree representation of their contents with the push
* related information for each file and folder.
* Each folder is represented as a pair of its local path structure and the corresponding tree node.
* Traverses the local folders and retrieves the hierarchical tree representation of their
* contents with the push related information for each file and folder. Each folder is
* represented as a TraverseResult with the corresponding local path structure and tree node.
*
* @param output the output option mixin
* @param source the source to traverse
Expand All @@ -23,12 +23,12 @@ public interface PushService {
* @param removeFolders true to allow remove folders, false otherwise
* @param ignoreEmptyFolders true to ignore empty folders, false otherwise
* @param failFast true to fail fast, false to continue on error
* @return a list of Triple, where each Triple contains a list of exceptions, the folder's local path structure
* and its corresponding root node of the hierarchical tree
* @throws IllegalArgumentException if the source path or workspace path does not exist, or if the source path is
* outside the workspace
* @return a list of Triple, where each Triple contains a list of exceptions, the folder's local
* path structure and its corresponding root node of the hierarchical tree
* @throws IllegalArgumentException if the source path or workspace path does not exist, or if
* the source path is outside the workspace
*/
List<Triple<List<Exception>, AssetsUtils.LocalPathStructure, TreeNode>> traverseLocalFolders(
List<TraverseResult> traverseLocalFolders(
OutputOptionMixin output, File workspace, File source, boolean removeAssets, boolean removeFolders,
boolean ignoreEmptyFolders, final boolean failFast);

Expand Down