Skip to content

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberrolandvaltech committed Jun 11, 2021
2 parents a07d933 + c7add1c commit 350878f
Show file tree
Hide file tree
Showing 32 changed files with 413 additions and 1,040 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -59,9 +59,8 @@ jobs:
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
- run: |
mvn clean install
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java

jdk:
- openjdk9
- openjdk11

addons:
sonarcloud:
Expand All @@ -10,7 +10,7 @@ addons:
secure: v0L2WG1NtMt4bXGRipEY9X23Glmz5ZldVCw7LaIUbUwKOB2AVghhUttZAsI0FBntsF0jRHJDk3L/4g45UZWSZOMRMl3lPm8NTHZLC4TmeDb00H/JXirh5ZghX+9KDiL1X8IF5xX6HRU8WO2XFnPhNR9kdh6JKSBwM2wEXADl8WNWLP7I8hB4hQ+gBdil1zOcT5vnyhc29zSU5EuBp4uZanlNhjry12tIOp/pZpdDO/pzF6m8T0DvGsgvlkZNWF16a0kazsLVWOYZ7QmjM8YDt6jVCNVQ+cImY/YPoq42OdvbIUfTazxiMS+P68Wel7ulH9FqzfHmz+SYPxQ1TfAQ2ltZO05ubQ5C2TScC+mipUkfbgqRr9RJUPkret+nUJ1WaQdf6+W3oZ6pTvn27s+XZFlWTbj6CcmgTPN8cCL5D+A9huvDOD2wWHkP7cquGSIuqh+Nc33K/EWR/BhY4ec2Xk/bjfoPTIE4tOuVyIZQLf64RxL0sRyitj4dZz+aRqhKiCaVKRtELqh8JoteYon+QPw/MF4UOalq+/QAFWvmgMeCouGxLwh2EPlK+3kXFO5tebRv67zLVesfVFCZgKWshTvUJ02kxKqy8HpocMTmoaIsRUHi2E5ucpbMxzKuJitpetrOHIjMNJQhfi0oW17zeB8i/oDwMIdNUGXPAU2MF1g=

script:
- mvn test javadoc:javadoc -B
- mvn clean install javadoc:javadoc -B
- sonar-scanner

cache:
Expand Down
4 changes: 4 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2021-06-11 4.1.0
- New filter methods: filterByNodeExists() and filterByNodeNotExists()
- Fixed Sonar issues (#156)

2020-12-21 4.0.0
- Update to Groovy Console 16 and require AEM 6.5 (#135)
- Fix for AEM Cloud in manual execution tool
Expand Down
21 changes: 20 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ AECU requires Java 8 and AEM 6.5 or above. For AEM 6.3/6.4 please see below. Gro
| AEM Version | Groovy Console | AECU |
| ------------- | -------------- | --------- |
| AEM Cloud | 16.x <br/>14.x, 13.x | 4.x<br/> 3.x, 2.x |
| 6.5 | 16.x <br/>14.x, 13.x | 4.x<br/> 3.x, 2.x |
| 6.5 (>=6.5.3) | 16.x <br/>14.x, 13.x | 4.x<br/> 3.x, 2.x |
| 6.4 | 14.x, 13.x | 3.x, 2.x |
| 6.3 | 12.x | 1.x |

Expand Down Expand Up @@ -122,6 +122,8 @@ All migration scripts need to be located in /var/groovyconsole/scripts/aecu. The
an unlimited number of folders and files. E.g. organize your files by project or deployment.
The content of the scripts is plain Groovy code that can be run via [Groovy Console](https://github.com/OlsonDigital/aem-groovy-console).

If your package containing the scripts is bundled in another package please make sure that this is done using "subPackages" in pom.xml.

<img src="docs/images/files.png">

There are just a few naming conventions:
Expand Down Expand Up @@ -323,6 +325,23 @@ aecu.contentUpgradeBuilder()
.run()
```

#### Filter by Node Existence

Filters resources by the (non-)existence of relative or absolute node path.

* filterByNodeExists(String path): process if the given subnode or absolute node exists
* filterByNodeNotExists(String path): process if the given subnode or absolute node does not exist

```java
aecu.contentUpgradeBuilder()
.forChildResourcesOf("/content/we-retail/ca/en")
.filterByNodeExists("jcr:content/meta")
.filterByNodeExists("/content")
.filterByNodeNotExists("jcr:content/meta")
.filterByNodeNotExists("/content")
.doSetProperty("name", "value")
.run()
```

#### Combine Multiple Filters
You can combine filters with AND and OR to build more complex filters.
Expand Down
2 changes: 1 addition & 1 deletion api/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>4.0.0</version>
<version>4.1.0</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ public interface ContentUpgrade {
*/
ContentUpgrade filterByNodeName(String nodeName);

/**
* Filters by node/subNode exists.
*
* @param path absolute or relative resource path
* @return upgrade object
*/
ContentUpgrade filterByNodeExists(String path);

/**
* Filters by node/subNode not exists.
*
* @param path absolute or relative resource path
* @return upgrade object
*/
ContentUpgrade filterByNodeNotExists(String path);

/**
* Filters by node name using regular expression.
*
Expand Down Expand Up @@ -191,9 +207,9 @@ public interface ContentUpgrade {
/**
* Joins a property value into a single value using the given separator.
*
* @param name property name
* @param value property value fall back for empty arrays. Use null to delete the property.
* @param name separator (e.g. ",")
* @param name property name
* @param value property value fall back for empty arrays. Use null to delete the property.
* @param separator separator (e.g. ",")
* @return upgrade object
**/
ContentUpgrade doJoinProperty(String name, Object value, String separator);
Expand Down Expand Up @@ -362,6 +378,7 @@ public interface ContentUpgrade {
* Deletes the child resources if supplied. If no children are specified it deletes the resource
* itself.
*
* @param children names of child nodes
* @return upgrade object
*/
ContentUpgrade doDeleteResource(String... children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public interface ValidateAccessRights {
/**
* Fail whole script execution on error. Script will stop after current aecu block. Subsequent
* code will no longer be executed.
*
* @return access right validation builder
*/
ValidateAccessRights failOnError();

Expand All @@ -243,6 +245,7 @@ public interface ValidateAccessRights {
* code will no longer be executed.
*
* @param fail if true fail script execution
* @return access right validation builder
*/
ValidateAccessRights failOnError(boolean fail);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright 2021 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package de.valtech.aecu.api.groovy.console.bindings.filters;


import javax.annotation.Nonnull;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;


/**
* Filters resources by absolute or relative node path. Only resources that (not) exist in the
* repository are accepted.
*
* @author Vugar Aghayev
*/
public class FilterByNodeExistence implements FilterBy {

private String path;
private boolean nodeExists;

/**
* Constructor
*
* @param path absolute or relative resource path
* @param nodeExists node exists option
*/
public FilterByNodeExistence(@Nonnull String path, boolean nodeExists) {
this.path = path;
this.nodeExists = nodeExists;
}

@Override
public boolean filter(@Nonnull Resource resource, StringBuilder output) {
if (StringUtils.isBlank(path)) {
return true;
}

if (isAbsolutePath(path)) {
return (nodeExists && null != resource.getResourceResolver().getResource(path))
|| (!nodeExists && null == resource.getResourceResolver().getResource(path));
} else {
return (nodeExists && null != resource.getChild(path)) || (!nodeExists && null == resource.getChild(path));
}
}

/**
* checks whether given path is absolute or not.
*
* @param path jcr path
* @return true if the given path is the absolute path. Otherwise false.
*/
private boolean isAbsolutePath(String path) {
return path.startsWith("/");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Roxana Muresan
*/
@Version("3.0.0")
@Version("3.1.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 @@ -22,7 +22,7 @@
*
* @author Roxana Muresan
*/
@Version("4.4.0")
@Version("4.5.0")
package de.valtech.aecu.api.groovy.console.bindings;

import org.osgi.annotation.versioning.Version;
Loading

0 comments on commit 350878f

Please sign in to comment.