Skip to content

Commit

Permalink
Merge branch 'release/6.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nhirrle committed Dec 7, 2023
2 parents dce5302 + 44e16b2 commit 8e2d7a5
Show file tree
Hide file tree
Showing 40 changed files with 240 additions and 330 deletions.
7 changes: 7 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2023-12-07 6.5.0
- Move of aecu.ui.content to /apps/settings to avoid overwrite of the configured weekly operations window (#225)
- New filter method: filterByPropertyIsMultiple() (#
- Documentation update for filter concatenation semantics with regards of AND/OR (#212)
- Documentation update for re-execute logic of groovy scripts installed through InstallHook
- Documentation update for filterWith

2023-03-20 6.4.0
- Resource Action: New actions to add / remove mixins (#209)
- AEMaaCS doesn't start AECU Migration, due to wrong check in AecuCloudStartupService (#210)
Expand Down
44 changes: 37 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,21 @@ AECU requires Java 8 and AEM 6.5 or AEM Cloud. For older AEM versions see below.

| AEM Version | Groovy Console | AECU |
| ------------- | -------------- | --------- |
| 6.5 (>=6.5.3)<br/>Cloud | included | 6.x, 5.x |
| 6.5 (>=6.5.13)<br/>Cloud | included | 6.x, 5.x |
| 6.5 (>=6.5.3 && < 6.5.13) | included | 6.0.1, 5.x |


## Older AEM versions
For AEM 6.3/6.4 please see here what versions are compatible. Groovy Console can be installed manually if [bundle install](#bundleInstall) is not used.

| AEM Version | Groovy Console | AECU |
| ------------- | -------------- | --------- |
| 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 |
| AEM Version | Groovy Console | AECU |
| ------------- | -------------- | --------- |
| 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 |

### AEM 6.5 and Java 11
For AEM 6.5 and Java 11 make sure to edit the sling.properties file and add `org.osgi.framework.bootdelegation=sun.*,com.sun.*,jdk.internal.reflect,jdk.internal.reflect.*` to avoid a NoClassDefFoundError, see [FELIX-6184](https://issues.apache.org/jira/browse/FELIX-6184) & [Adobe Documantation](https://experienceleague.adobe.com/docs/experience-manager-65/deploying/deploying/troubleshooting.html?lang=en#the-website-does-not-load-or-fails-intermittently-with-java11) for details.

<a name="installation"></a>

Expand Down Expand Up @@ -233,6 +238,10 @@ You can add the install hook by adding de.valtech.aecu.core.installhook.AecuInst
</plugin>
```

The Groovy scripts must be covered by the filter, i.e. must be imported into the repository during installation.

By default each Groovy script is only executed once (if it does not end with suffix `.always.groovy`). It will be re-executed though in case any of the Groovy scripts have been modified (through the package installation) or in case the previous execution was not successful.

<a name="manualExecution"></a>

## Manual Execution
Expand Down Expand Up @@ -325,7 +334,7 @@ aecu.contentUpgradeBuilder()
<a name="binding_filter"></a>

### Filter Options
These methods can be used to filter the nodes that were collected above. Multiple filters can be applied for one run.
These methods can be used to filter the nodes that were collected above. Multiple filters can be applied for one run (they are combined with `AND` logic, i.e. all filters must match)

#### Filter by Properties

Expand All @@ -334,6 +343,7 @@ Filters the resources by property values.
* filterByHasProperty: matches all nodes that have the given property. The value of the property is not relevant.
* filterByNotHasProperty: matches all nodes that do not have the given property. The value of the property is not relevant.
* filterByProperty: matches all nodes that have the given attribute value. Filter does not match if attribute is not present. By using a value of "null" you can search if an attribute is not present.
* filterByPropertyIsMultiple: matches all nodes where a given property is a multi-value property (such as an array or list) and contains a specific value or values. The filter does not match if the attribute does not exist, or if it exists but is not a multi-value property or does not contain the specified value or values.
* filterByNotProperty: matches all nodes that do not have the given attribute value. Filter matches if attribute is not present.
* filterByProperties: use this to filter by a list of property values (e.g. sling:resourceType). All properties in the map are required to to match. Filter does not match if attribute does not exist.
* filterByNotProperties: use this to filter by a list of property values (e.g. sling:resourceType) is not matching. If any property in the map does not match the filter matches. Filter matches if attribute does not exist.
Expand Down Expand Up @@ -463,6 +473,26 @@ aecu.contentUpgradeBuilder()
.run()
```

#### Filter with custom FilterBy implementation

To filter by complex conditions that are not covered by existing `filterBy...()` presets you can use `filterWith()` that takes a custom `FilterBy` implementation as shown in the example below:

```java
aecu.contentUpgradeBuilder()
.forDescendantResourcesOf("/content/we-retail/ca/en", false)
.filterWith(new FilterBy(){
public boolean filter(Resource resource, StringBuilder output) {
ValueMap properties = resource.valueMap
Calendar lastModified = properties.get("cq:lastModified", Calendar.class)
Calendar cal = Calendar.instance
cal.add(Calendar.YEAR, -5)
return lastModified.time.before(cal.time)
}
})
.doSetProperty("old", true) // mark pages that weren't modified in the past 5 years
.run()
```

<a name="binding_execute"></a>

### Execute Options
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>6.4.0</version>
<version>6.5.0</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ public interface ContentUpgrade {
*/
ContentUpgrade filterByNotProperty(String name, Object value);

/**
* Filters by matching a single property using a regular expression for the value. This is
* intended for single value properties.
*
* @param name property name
* @param value attribute value
* @return upgrade object
*/
ContentUpgrade filterByPropertyIsMultiple(String name, Object value);

/**
* Filters by matching a single property using a regular expression for the value. This is
* intended for single value properties.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2018 - 2019 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.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;

import de.valtech.aecu.api.groovy.console.bindings.GStringConverter;


/**
* Filters resources by a given property. The filter only matches if the attribute exists and has
* the exact given value and the property is an array or a list.
*
* @author Michiel Spiritus
*/
public class FilterByPropertyIsMultiple implements FilterBy {

private String name;
private Object value;

/**
* Constructor
*
* @param name attribute name
* @param value attribute value
*/
public FilterByPropertyIsMultiple(@Nonnull String name, Object value) {
this.name = name;
this.value = GStringConverter.convert(value);
}

@Override
public boolean filter(@Nonnull Resource resource, StringBuilder output) {
ValueMap properties = resource.getValueMap();
Object attrValue = properties.get(name);

// Check if the property is an array or a list
if (attrValue instanceof Object[] || attrValue instanceof java.util.List) {
return ((value == null) && (attrValue == null)) || ((value != null) && value.equals(attrValue));
}

return false;
}


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

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2023 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.core.groovy.console.bindings.filters;

import org.apache.sling.api.resource.ValueMap;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
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 de.valtech.aecu.api.groovy.console.bindings.filters.FilterByPropertyIsMultiple;

import java.util.Arrays;
import java.util.List;

/**
* Tests FilterByPropertyIsMultiple
*
* @author Roland Gruber
*/
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class FilterByPropertyIsMultipleTest {

private static final String NAME = "name";
private static final List<String> MULTIPLE_VALUE = Arrays.asList("value1", "value2");

@Mock
private Resource resource;

@Mock
ValueMap values;

@Mock
ValueMap valueMap;

@BeforeEach
public void setup() {
when(resource.getValueMap()).thenReturn(values);
}

@Test
void filterAttributeArray() {
Object[] attrArray = new Object[]{"value1", "value2", "value3"};
when(resource.getValueMap()).thenReturn(valueMap);
when(valueMap.get("name")).thenReturn(attrArray);

FilterByPropertyIsMultiple filter = new FilterByPropertyIsMultiple("name", attrArray);

assertTrue(filter.filter(resource, new StringBuilder()));
}



@Test
public void filterAttributeList() {
FilterByPropertyIsMultiple filter = new FilterByPropertyIsMultiple(NAME, MULTIPLE_VALUE);
when(values.get(NAME)).thenReturn(MULTIPLE_VALUE);

assertTrue(filter.filter(resource, new StringBuilder()));
}

@Test
public void filterAttributeNonMultiple() {
FilterByPropertyIsMultiple filter = new FilterByPropertyIsMultiple(NAME, "value");
when(values.get(NAME)).thenReturn("value");

assertFalse(filter.filter(resource, new StringBuilder()));
}

}
2 changes: 1 addition & 1 deletion 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.4.0</version>
<version>6.5.0</version>
</parent>

<artifactId>aecu.cloud.startup.hook</artifactId>
Expand Down
12 changes: 1 addition & 11 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.4.0</version>
<version>6.5.0</version>
</parent>

<artifactId>aecu.complete.cloud</artifactId>
Expand Down Expand Up @@ -58,10 +58,6 @@
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.apps</artifactId>
</embedded>
<embedded>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.content</artifactId>
</embedded>
</embeddeds>
</configuration>
</plugin>
Expand Down Expand Up @@ -89,12 +85,6 @@
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.content</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.core</artifactId>
Expand Down
13 changes: 1 addition & 12 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.4.0</version>
<version>6.5.0</version>
</parent>

<artifactId>aecu.complete</artifactId>
Expand Down Expand Up @@ -44,11 +44,6 @@
<artifactId>aecu.ui.apps</artifactId>
<filter>true</filter>
</subPackage>
<subPackage>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.content</artifactId>
<filter>true</filter>
</subPackage>
<subPackage>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.oak.index</artifactId>
Expand Down Expand Up @@ -94,12 +89,6 @@
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.content</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.oak.index</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/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.4.0</version>
<version>6.5.0</version>
</parent>

<artifactId>aecu.core</artifactId>
Expand Down
Loading

0 comments on commit 8e2d7a5

Please sign in to comment.