Skip to content

Commit

Permalink
save point (#26430)
Browse files Browse the repository at this point in the history
* save point

* #26380

* #26380  this should fix the issue

* #26380

* #26380 fix in pipiline + fix in Test

* #26380 adjusting test to relflect fix

* #26380 playing wiht broken test

* debug info

* testing more scenarios

* #26380 trying fix for test

* #26380 IT

* #26380 undoing refactor saving it for anther PR

* #26380 fixing doc

* #26380 applying feedback provided

* #26380 replacing Abstract Class by the concrete impl
  • Loading branch information
fabrizzio-dotCMS committed Oct 18, 2023
1 parent 9fb2040 commit 3c41b76
Show file tree
Hide file tree
Showing 18 changed files with 635 additions and 375 deletions.
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
8 changes: 4 additions & 4 deletions tools/dotcms-cli/.gitignore
Expand Up @@ -42,8 +42,8 @@ nb-configuration.xml
/cli/.allure/

# Stuff generated by the CLI
content-types/
files/
languages/
sites/
/content-types/
/files/
/languages/
/sites/
.dot-workspace.yml
2 changes: 0 additions & 2 deletions tools/dotcms-cli/api-data-model/pom.xml
Expand Up @@ -50,7 +50,6 @@
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${immutables.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -64,7 +63,6 @@
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${google.findbugs.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
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());
}
}

/**
* 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 -> {

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();

}
8 changes: 4 additions & 4 deletions tools/dotcms-cli/cli/.gitignore
Expand Up @@ -39,8 +39,8 @@ nb-configuration.xml
.env

# Stuff generated by the CLI
content-types/
files/
languages/
sites/
/content-types/
/files/
/languages/
/sites/
.dot-workspace.yml
@@ -1,20 +1,21 @@
package com.dotcms.api.client.files;

import com.dotcms.api.client.files.traversal.AbstractTraverseResult;
import com.dotcms.api.client.files.traversal.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 +24,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

0 comments on commit 3c41b76

Please sign in to comment.