Skip to content

Commit

Permalink
Merge branch 'release/1.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberrolandvaltech committed Jan 16, 2019
2 parents 5d6bb01 + 5e5924c commit a07fd17
Show file tree
Hide file tree
Showing 32 changed files with 971 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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 -B
- mvn test javadoc:javadoc -B
- sonar-scanner

cache:
Expand Down
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019-01-16 1.8.0
- Groovy Console binding:
- Path renaming via regex
- Replace substrings in properties

2018-12-20 1.7.0
- Full-text search possibility with Omnisearch (magnifying glass in header)
- Groovy Console binding:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Valtech GmbH
Copyright (c) 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
Expand Down
33 changes: 33 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ You can click on any run to see the full details. This will show the status for

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

## Search History

AECU maintains a full-text search index for the history entries. You can search for script names and their output.

Simply click on the magnifying glass in header to open the search bar:

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

Now you can enter a search term and will see the runs that contain this text. Click on the link to see the full history entry.

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

<a name="groovy"></a>

# Extension to Groovy Console
Expand Down Expand Up @@ -337,13 +349,33 @@ println aecu.contentUpgradeBuilder()
.run()
```

### Replace Property Content
You can replace the content of String properties. This also supports multi-value properties.

* doReplaceValueInAllProperties(String oldValue, String newValue): replaces the substring "oldValue" with "newValue". Applies to all String properties
* doReplaceValueInProperties(String oldValue, String newValue, String[] propertyNames): replaces the substring "oldValue" with "newValue". Applies to all specified String properties
* doReplaceValueInAllPropertiesRegex(String searchRegex, String replacement): checks if the property value(s) match the search pattern and replaces it with "replacement". Applies to all String properties. You can use group references such as $1 (hint: "$" needs to be escaped with "\" in Groovy).
* doReplaceValueInPropertiesRegex(String searchRegex, String replacement, String[] propertyNames): checks if the property value(s) match the search pattern and replaces it with "replacement". Applies to specified String properties. You can use group references such as $1 (hint: "$" needs to be escaped with "\" in Groovy).

```java
println aecu.contentUpgradeBuilder()
.forChildResourcesOf("/content/we-retail/ca/en")
.filterByNodeName("jcr:content")
.doReplaceValueInAllProperties("old", "new")
.doReplaceValueInProperties("old", "new", (String[]) ["propertyName1", "propertyName2"])
.doReplaceValueInAllPropertiesRegex("/content/([^/]+)/(.*)", "/content/newSub/\$2")
.doReplaceValueInPropertiesRegex("/content/([^/]+)/(.*)", "/content/newSub/\$2", (String[]) ["propertyName1", "propertyName2"])
.run()
```

### Copy and Move Nodes

The matching nodes can be copied/moved to a new location. You can use ".." if you want to step back in path.

* doRename(String newName): renames the resource to the given name
* doCopyResourceToRelativePath(String relativePath): copies the node to the given target path
* doMoveResourceToRelativePath(String relativePath): moves the node to the given target path
* doMoveResourceToPathRegex(String matchPattern, String replacementExpr): moves a resource if its path matches the pattern to the target path obtained by applying the replacement expression. You can use group references such as $1 (hint: "$" needs to be escaped with "\" in Groovy).

```java
println aecu.contentUpgradeBuilder()
Expand All @@ -353,6 +385,7 @@ println aecu.contentUpgradeBuilder()
.doCopyResourceToRelativePath("subNode")
.doCopyResourceToRelativePath("../subNode")
.doMoveResourceToRelativePath("subNode")
.doMoveResourceToPathRegex("/content/we-retail/(\\w+)/(\\w+)/(\\w+)", "/content/somewhere/\$1/and/\$2")
.run()
```

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>1.7.0</version>
<version>1.8.0</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* 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,
Expand Down Expand Up @@ -30,6 +30,7 @@
* This class provides the builder methods to perform a content upgrade.
*
* @author Roxana Muresan
* @author Roland Gruber
*/
@ProviderType
public interface ContentUpgrade {
Expand Down Expand Up @@ -215,6 +216,48 @@ public interface ContentUpgrade {
*/
ContentUpgrade doReplaceValuesOfMultiValueProperty(String name, String[] oldValues, String[] newValues);

/**
* Replaces a substring in all properties of the matching resource. Only applies to String
* properties.
*
* @param oldValue old value
* @param newValue new value
* @return upgrade object
*/
ContentUpgrade doReplaceValueInAllProperties(String oldValue, String newValue);

/**
* Replaces a substring in specific properties of the matching resource. Only applies to String
* properties.
*
* @param oldValue old value
* @param newValue new value
* @param propertyNames property names that should be checked
* @return upgrade object
*/
ContentUpgrade doReplaceValueInProperties(String oldValue, String newValue, String[] propertyNames);

/**
* Replaces a substring in all properties of the matching resource using a regular expression.
* Only applies to String properties.
*
* @param searchRegex regex to match old value
* @param replacement new value, may contain matcher groups (e.g. $1)
* @return upgrade object
*/
ContentUpgrade doReplaceValueInAllPropertiesRegex(String searchRegex, String replacement);

/**
* Replaces a substring in specific properties of the matching resource using a regular
* expression. Only applies to String properties.
*
* @param searchRegex regex to match old value
* @param replacement new value, may contain matcher groups (e.g. $1)
* @param propertyNames property names that should be checked
* @return upgrade object
*/
ContentUpgrade doReplaceValueInPropertiesRegex(String searchRegex, String replacement, String[] propertyNames);

/**
* Renames a resource to the given name.
*
Expand All @@ -239,6 +282,17 @@ public interface ContentUpgrade {
*/
ContentUpgrade doMoveResourceToRelativePath(String relativePath);

/**
* Moves a resource if its path matches the pattern to the path obtained by applying the
* replacement expression
*
* @param matchPattern regular expression for matching the resource path
* @param targetPathExpr expression to calculate the target path, can contain matched group
* references $1, $2, ...
* @return upgrade object
*/
ContentUpgrade doMoveResourceToPathRegex(String matchPattern, String targetPathExpr);

/**
* Deletes the resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author Roxana Muresan
*/
@Version("2.0.1")
@Version("2.1.0")
package de.valtech.aecu.api.groovy.console.bindings;

import org.osgi.annotation.versioning.Version;
2 changes: 1 addition & 1 deletion bundle/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>1.7.0</version>
<version>1.8.0</version>
</parent>

<artifactId>aecu.bundle</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>1.7.0</version>
<version>1.8.0</version>
</parent>

<artifactId>aecu.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class AddPageTagsAction implements Action {
* Constructor
*
* @param context binding context
* @param tags tag names
*/
public AddPageTagsAction(BindingContext context, String... tags) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class RemovePageTagsAction implements Action {
* Constructor
*
* @param context binding context
* @param tags tag names
*/
public RemovePageTagsAction(BindingContext context, String... tags) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public class RenderPageAction implements Action {
/**
* Constructor
*
* @param context binding context
* @param context binding context
* @param statusCode expected status code
* @param textPresent text that must be present
* @param textNotPresent text that must not be present
*/
public RenderPageAction(BindingContext context, int statusCode, String textPresent, String textNotPresent) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class SetPageTagsAction implements Action {
* Constructor
*
* @param context binding context
* @param tags tag names
*/
public SetPageTagsAction(BindingContext context, String... tags) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2018 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.actions.resource;

import javax.annotation.Nonnull;

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

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

/**
* Action class for moving resources via regex
*
* @author Roxana Muresan
*/
public class MoveResourceToPathRegex implements Action {

private ResourceResolver resourceResolver;
private String matchPattern;
private String targetPathExpr;

/**
* Constructor
*
* @param matchPattern regex pattern
* @param targetPathExpr target regex
* @param resourceResolver resolver
*/
public MoveResourceToPathRegex(@Nonnull String matchPattern, @Nonnull String targetPathExpr,
@Nonnull ResourceResolver resourceResolver) {
this.resourceResolver = resourceResolver;
this.matchPattern = matchPattern;
this.targetPathExpr = targetPathExpr;
}

@Override
public String doAction(@Nonnull Resource resource) throws PersistenceException {
String resourcePath = resource.getPath();
if (resourcePath.matches(matchPattern)) {
String targetPath = resourcePath.replaceAll(matchPattern, targetPathExpr);
Resource destinationResource = resourceResolver.getResource(targetPath);

if (destinationResource != null) {
resourceResolver.move(resourcePath, targetPath);

return "Moved " + resourcePath + " to path " + targetPath;
}
return "WARNING: could not read move destination resource " + targetPath;
}
return "INFO: resource " + resourcePath + " does not match path regex " + matchPattern + ", skipping";
}
}
Loading

0 comments on commit a07fd17

Please sign in to comment.