Skip to content

Commit

Permalink
Merge branch 'release/6.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nhirrle committed Feb 23, 2023
2 parents 131f59f + 5cf977c commit 7772c2a
Show file tree
Hide file tree
Showing 29 changed files with 271 additions and 91 deletions.
7 changes: 6 additions & 1 deletion HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2023-02-23 6.2.1
- Upgrade of Orbinson Groovy Console to version 19.0.3 (#205, #208)
- New filter method: filterByNodeRootPaths() (#204)
- AecuService: added new execute(String path, String data) method which accepts a JSON data string to be used within scipts (#204)
- JMX: added that execute(String path, String data) method (#204)

2023-01-27 6.2.0
- Use Orbinson Groovy Console instead of CID15 one

Expand Down Expand Up @@ -156,4 +162,3 @@

2018-07-19 0.9
- initial release

20 changes: 20 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,15 @@ Nodes can also be filtered by their path using a regular expression.

* filterByPathRegex(String regex): process nodes whose path matches the given regular expression
* filterByNotPathRegex(String regex): process nodes whose path does not match the given regular expression
* filterByNodeRootPaths: filters resources that do not meet the given list of root paths.


```java
aecu.contentUpgradeBuilder()
.forChildResourcesOf("/content/we-retail/ca/en")
.filterByPathRegex(".*/jcr:content/.*")
.filterByNotPathRegex(".*/jcr:content/.*")
.filterByNodeRootPaths(Arrays.asList("/content/we-retail/ca/en", "/content/we-retail/be/nl"))
.doSetProperty("name", "value")
.run()
```
Expand Down Expand Up @@ -1046,6 +1049,23 @@ Parameters:
* Start index: starts with 0 (= latest history entry)
* Count: number of entries to print

## Execute with data

Executes a single file or all files of a folder structure. Additionally, you can pass json data for the script context.

Parameters:
* Path: path of script/folder
* Data: Json object string

Example json:
``` json
{
"rootPaths": [
"/content/we-retail"
]
}
```

## GetFiles

This will print all files that are executable for a given path. You can use this to check which scripts of a given folder would be executed.
Expand Down
10 changes: 5 additions & 5 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>6.2.0</version>
<version>6.3.0</version>
</parent>

<artifactId>aecu.api</artifactId>
<packaging>bundle</packaging>
<name>AECU - API</name>
Expand Down Expand Up @@ -74,7 +74,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
</plugin>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -116,8 +116,8 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package de.valtech.aecu.api.groovy.console.bindings;

import java.util.List;
import java.util.Map;

import org.apache.sling.api.resource.PersistenceException;
Expand Down Expand Up @@ -79,7 +80,7 @@ public interface ContentUpgrade {
/**
* Loops over resources found by the SQL2 query generated by the path and properties and the
* default node type "nt:base".
*
*
* @param path search path
* @param conditionProperties properties to generate AND conditions (values containing % will be
* matched using LIKE)
Expand All @@ -89,7 +90,7 @@ public interface ContentUpgrade {

/**
* Loops over resources found by the SQL2 query generated by the nodeType, path and properties.
*
*
* @param path search path
* @param conditionProperties properties to generate AND conditions (values containing % will be
* matched using LIKE)
Expand Down Expand Up @@ -268,6 +269,14 @@ public interface ContentUpgrade {
*/
ContentUpgrade filterByNotPathRegex(String regex);

/**
* Filters by matching the resource path with the rootpaths
*
* @param rootPaths List of rootPaths to be matched
* @return upgrade object
*/
ContentUpgrade filterByNodeRootPaths(List<String> rootPaths);

/**
* Filters by matching the given filter.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.valtech.aecu.api.groovy.console.bindings.filters;

import org.apache.sling.api.resource.Resource;

import javax.annotation.Nonnull;
import java.util.List;

/**
* Filters resources by node root paths. Only resource matching or starting with the root paths are accepted
*
* @author Dries Vanbilloen
*/
public class FilterByNodeRootPaths implements FilterBy {

private List<String> rootPaths;

/**
* Constructor
*
* @param rootPaths list of root paths
*/
public FilterByNodeRootPaths(List<String> rootPaths) {
this.rootPaths = rootPaths;
}

@Override
public boolean filter(@Nonnull Resource resource, @Nonnull StringBuilder output) {
final String currentPath = resource.getPath();
return rootPaths.stream()
.anyMatch(rootPath -> rootPath.equals(currentPath) || (currentPath + "/").startsWith(rootPath));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

/**
* Filters are used in AECU Groovy Console binding to filter matching nodes.
*
*
* @author Roxana Muresan
*/
@Version("3.1.0")
@Version("3.2.0")
package de.valtech.aecu.api.groovy.console.bindings.filters;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

/**
* Contains the classes for the Groovy binding "aecu".
*
*
* @author Roxana Muresan
*/
@Version("4.8.0")
@Version("4.9.0")
package de.valtech.aecu.api.groovy.console.bindings;

import org.osgi.annotation.versioning.Version;
21 changes: 21 additions & 0 deletions api/src/main/java/de/valtech/aecu/api/service/AecuService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public interface AecuService {
*/
ExecutionResult execute(String path) throws AecuException;

/**
* Executes the script at the given position.
*
* @param path path of script
* @param data json object of script
* @return execution result
* @throws AecuException error during execution
*/
ExecutionResult execute(String path, String data) throws AecuException;

/**
* Starts a new history entry.
*
Expand Down Expand Up @@ -146,4 +156,15 @@ public interface AecuService {
*/
HistoryEntry executeWithInstallHookHistory(String path) throws AecuException;

/**
* Executes the script(s) at the given position and taking install hook history into account.
*
* @param path path of script/folder
* @param data data json string of script
* @return execution result
* @throws AecuException error during execution
*/
HistoryEntry executeWithInstallHookHistory(String path, String data) throws AecuException;


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* This package contains the service API for AEM Easy Content Upgrade (AECU). You can use this to
* integrate AECU into your own software. See {@link de.valtech.aecu.api.service.AecuService} for a
* starting point.
*
*
* @author Roland Gruber
*/
@Version("3.0.0")
@Version("3.1.0")
package de.valtech.aecu.api.service;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.valtech.aecu.api.groovy.console.bindings.filters;

import org.apache.sling.api.resource.Resource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class FilterByNodeRootPathsTest {

private static final String TEST_PATH = "/content/my-site/nl/my-page";

@Mock
Resource resource;

@BeforeEach
void setUp() {
when(resource.getPath()).thenReturn(TEST_PATH);
}

@Test
void test_whenRootPathsMatches_filterAccepts() {
boolean accept = new FilterByNodeRootPaths(Arrays.asList("/content/my-site")).filter(resource, new StringBuilder());
assertTrue(accept);
}

@Test
void test_whenRootPathsDontMatch_filterDenies() {
boolean accept = new FilterByNodeRootPaths(Arrays.asList("/content/my-other-site")).filter(resource, new StringBuilder());
assertFalse(accept);
}

}
8 changes: 4 additions & 4 deletions cloud.startup.hook/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>6.2.0</version>
<version>6.3.0</version>
</parent>

<artifactId>aecu.cloud.startup.hook</artifactId>
Expand All @@ -30,7 +30,7 @@
<instructions>
<Import-Package>
javax.annotation;version=0.0.0,
be.orbinson.aem.groovy.console.*;version="[15.1,19)",
be.orbinson.aem.groovy.console.*;version="[19,20)",
*
</Import-Package>
</instructions>
Expand Down Expand Up @@ -76,8 +76,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>be.orbinson.aem</groupId>
Expand Down
12 changes: 6 additions & 6 deletions complete-cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>6.2.0</version>
<version>6.3.0</version>
</parent>

<artifactId>aecu.complete.cloud</artifactId>
Expand All @@ -15,9 +15,9 @@

<build>
<sourceDirectory>src/main/content/jcr_root</sourceDirectory>

<plugins>

<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
Expand Down Expand Up @@ -119,7 +119,7 @@
</dependencies>

<profiles>

<profile>
<id>autoInstallPackageCloud</id>
<activation>
Expand Down Expand Up @@ -176,8 +176,8 @@
</pluginManagement>
</build>
</profile>

</profiles>


</project>
12 changes: 6 additions & 6 deletions complete/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>6.2.0</version>
<version>6.3.0</version>
</parent>

<artifactId>aecu.complete</artifactId>
Expand All @@ -15,7 +15,7 @@

<build>
<sourceDirectory>src/main/content/jcr_root</sourceDirectory>

<plugins>

<plugin>
Expand Down Expand Up @@ -117,9 +117,9 @@
<version>${project.version}</version>
</dependency>
</dependencies>

<profiles>

<profile>
<id>autoInstallPackage</id>
<activation>
Expand Down Expand Up @@ -176,7 +176,7 @@
</pluginManagement>
</build>
</profile>

</profiles>

</project>
Loading

0 comments on commit 7772c2a

Please sign in to comment.