Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberrolandvaltech committed Jul 19, 2018
2 parents 8f8283d + 2e51121 commit 3f849ab
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 104 deletions.
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>0.9</version>
<version>1.0.0</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
21 changes: 19 additions & 2 deletions 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>0.9</version>
<version>1.0.0</version>
</parent>

<artifactId>aecu.bundle</artifactId>
Expand Down Expand Up @@ -51,14 +51,25 @@
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>
<embeddedTarget>/apps/valtech/aecu-bundle/install/</embeddedTarget>
<filters>
<filter>
<root>/apps/valtech/aecu-bundle</root>
</filter>
</filters>
<verbose>true</verbose>
<failOnError>true</failOnError>
<group>Valtech</group>
<subPackages>
<subPackage>
<groupId>com.icfolson.aem.groovy.console</groupId>
<artifactId>aem-groovy-console</artifactId>
<filter>true</filter>
</subPackage>
<subPackage>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.apps</artifactId>
<filter>true</filter>
</subPackage>
</subPackages>
</configuration>
Expand All @@ -77,5 +88,11 @@
<artifactId>aem-groovy-console</artifactId>
<type>zip</type>
</dependency>
<dependency>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu.ui.apps</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
</dependencies>
</project>
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>0.9</version>
<version>1.0.0</version>
</parent>

<artifactId>aecu.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package de.valtech.aecu.core.groovy.console.bindings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.ResourceResolver;
import org.scribe.utils.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;
import de.valtech.aecu.core.groovy.console.bindings.actions.PrintPath;
import de.valtech.aecu.core.groovy.console.bindings.actions.multivalue.AddMultiValues;
Expand All @@ -35,6 +22,19 @@
import de.valtech.aecu.core.groovy.console.bindings.traversers.ForResources;
import de.valtech.aecu.core.groovy.console.bindings.traversers.TraversData;

import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.ResourceResolver;
import org.scribe.utils.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

public class ContentUpgrade {

private static Logger LOG = LoggerFactory.getLogger(ContentUpgrade.class);
Expand Down Expand Up @@ -205,9 +205,7 @@ public StringBuffer dryRun() throws PersistenceException {
private StringBuffer run(boolean dryRun) throws PersistenceException {
StringBuffer stringBuffer = new StringBuffer("Running content upgrade " + (dryRun ? "DRY" : "") + "...\n");
for (TraversData traversal : traversals) {
for (Action action : actions) {
traversal.traverse(resourceResolver, filter, action, stringBuffer, dryRun);
}
traversal.traverse(resourceResolver, filter, actions, stringBuffer, dryRun);
}
return stringBuffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
Expand Down Expand Up @@ -49,19 +50,27 @@ public CopyPropertyToRelativePath(@Nonnull String name, String newName, @Nonnull
public String doAction(@Nonnull Resource resource) {
ValueMap sourceProperties = resource.adaptTo(ValueMap.class);

Resource destinationResource = resourceResolver.getResource(resource, relativeResourcePath);// TODO
// null
// check!!!!
ModifiableValueMap destinationProperties = destinationResource.adaptTo(ModifiableValueMap.class);// TODO
// null
// check!!!!
if (sourceProperties != null) {
Resource destinationResource = resourceResolver.getResource(resource, relativeResourcePath);

Object propValue = sourceProperties.get(name);
String key = (newName != null) ? newName : name;
destinationProperties.put(key, propValue);
if (destinationResource != null) {
ModifiableValueMap destinationProperties = destinationResource.adaptTo(ModifiableValueMap.class);

return "Coping property " + name + " from " + resource.getPath() + " to resource " + destinationResource.getPath()
+ " as " + key;
if (destinationProperties != null) {
Object propValue = sourceProperties.get(name);
String key = (newName != null && StringUtils.isNotBlank(newName)) ? newName : name;
destinationProperties.put(key, propValue);

return "Coping property " + name + " from " + resource.getPath() + " to resource " + destinationResource.getPath() + " as " + key;

} else {
return "WARNING: could not get ModifiableValueMap for resource " + destinationResource.getPath();
}
} else {
return "WARNING: could not read copy destination resource " + relativeResourcePath;
}
}
return "WARNING: could not read properties of resource " + resource.getPath();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

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

import javax.annotation.Nonnull;

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

import javax.annotation.Nonnull;

/**
* @author Roxana Muresan
*/
Expand All @@ -39,7 +39,10 @@ public DeleteProperty(@Nonnull String name) {
@Override
public String doAction(@Nonnull Resource resource) {
ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class);
properties.remove(name);
return "Deleting property " + name + " for resource " + resource.getPath();
if (properties != null) {
properties.remove(name);
return "Deleting property " + name + " for resource " + resource.getPath();
}
return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
Expand Down Expand Up @@ -48,16 +49,28 @@ public MovePropertyToRelativePath(@Nonnull String name, String newName, @Nonnull
public String doAction(@Nonnull Resource resource) {
ModifiableValueMap sourceProperties = resource.adaptTo(ModifiableValueMap.class);

Resource targetResource = resourceResolver.getResource(resource, relativeResourcePath);
ModifiableValueMap targetProperties = targetResource.adaptTo(ModifiableValueMap.class);
if (sourceProperties != null) {
Resource destinationResource = resourceResolver.getResource(resource, relativeResourcePath);

Object propValue = sourceProperties.get(name);
String key = (newName != null) ? newName : name;
targetProperties.put(key, propValue);
sourceProperties.remove(name);
if (destinationResource != null) {
ModifiableValueMap destinationProperties = destinationResource.adaptTo(ModifiableValueMap.class);

return "Moving property " + name + " from " + resource.getPath() + " to resource " + targetResource.getPath() + " as "
+ key;
if (destinationProperties != null) {
Object propValue = sourceProperties.get(name);
String key = (newName != null && StringUtils.isNotBlank(newName)) ? newName : name;
destinationProperties.put(key, propValue);
sourceProperties.remove(name);

return "Moving property " + name + " from " + resource.getPath() + " to resource " + destinationResource.getPath() + " as " + key;

} else {
return "WARNING: could not get ModifiableValueMap for resource " + destinationResource.getPath();
}
} else {
return "WARNING: could not read move destination resource " + relativeResourcePath;
}
}
return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

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

import javax.annotation.Nonnull;

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

import javax.annotation.Nonnull;

/**
* @author Roxana Muresan
*/
Expand All @@ -41,8 +41,11 @@ public RenameProperty(@Nonnull String oldName, @Nonnull String newName) {
@Override
public String doAction(@Nonnull Resource resource) {
ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class);
Object value = properties.remove(oldName);
properties.put(newName, value);
return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath();
if (properties != null) {
Object value = properties.remove(oldName);
properties.put(newName, value);
return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath();
}
return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public SetProperty(@Nonnull String name, Object value) {
@Override
public String doAction(@Nonnull Resource resource) {
ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class);
properties.put(name, value);
return "Setting " + value.getClass().getSimpleName() + " property " + name + "=" + value + " for resource "
+ resource.getPath();
if (properties != null) {
properties.put(name, value);
return "Setting " + value.getClass().getSimpleName() + " property " + name + "=" + value + " for resource " + resource.getPath();
}
return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public CopyResourceToRelativePath(@Nonnull String relativePath, @Nonnull Resourc
@Override
public String doAction(@Nonnull Resource resource) throws PersistenceException {
Resource destinationResource = resourceResolver.getResource(resource, relativePath);
String sourceAbsPAth = resource.getPath();
String destinationAsPath = destinationResource.getPath();
resourceResolver.copy(sourceAbsPAth, destinationAsPath);

return "Copied " + sourceAbsPAth + " to path " + destinationAsPath;
if (destinationResource != null) {
String sourceAbsPAth = resource.getPath();
String destinationAsPath = destinationResource.getPath();
resourceResolver.copy(sourceAbsPAth, destinationAsPath);

return "Copied " + sourceAbsPAth + " to path " + destinationAsPath;
}
return "WARNING: could not read copy destination resource " + relativePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public MoveResourceToRelativePath(@Nonnull String relativePath, @Nonnull Resourc
@Override
public String doAction(@Nonnull Resource resource) throws PersistenceException {
Resource destinationResource = resourceResolver.getResource(resource, relativePath);
String sourceAbsPAth = resource.getPath();
String destinationAsPath = destinationResource.getPath();
resourceResolver.move(sourceAbsPAth, destinationAsPath);

return "Moved " + sourceAbsPAth + " to path " + destinationAsPath;
if (destinationResource != null) {
String sourceAbsPAth = resource.getPath();
String destinationAsPath = destinationResource.getPath();
resourceResolver.move(sourceAbsPAth, destinationAsPath);

return "Moved " + sourceAbsPAth + " to path " + destinationAsPath;
}
return "WARNING: could not read move destination resource " + relativePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

import javax.annotation.Nonnull;

import java.util.Iterator;
import java.util.List;

import javax.annotation.Nonnull;

/**
* @author Roxana Muresan
Expand All @@ -42,15 +43,17 @@ public ForChildResourcesOf(@Nonnull String path) {


@Override
public void traverse(@Nonnull ResourceResolver resourceResolver, FilterBy filter, @Nonnull Action action,
public void traverse(@Nonnull ResourceResolver resourceResolver, FilterBy filter, @Nonnull List<Action> actions,
@Nonnull StringBuffer stringBuffer, boolean dryRun) throws PersistenceException {
Resource parentResource = resourceResolver.getResource(path);
if (parentResource != null) {
Iterator<Resource> resourceIterator = resourceResolver.listChildren(parentResource);
while (resourceIterator.hasNext()) {
Resource resource = resourceIterator.next();
if (filter == null || filter.filter(resource)) {
stringBuffer.append(action.doAction(resource) + "\n");
for (Action action : actions) {
stringBuffer.append(action.doAction(resource) + "\n");
}
}
}
if (!dryRun) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

import javax.annotation.Nonnull;

import java.util.Iterator;
import java.util.List;

import javax.annotation.Nonnull;

/**
* @author Roxana Muresan
Expand All @@ -42,24 +43,26 @@ public ForDescendantResourcesOf(@Nonnull String path) {


@Override
public void traverse(@Nonnull ResourceResolver resourceResolver, FilterBy filter, @Nonnull Action action,
@Nonnull StringBuffer stringBuffer, boolean dryRun) throws PersistenceException {
public void traverse(@Nonnull ResourceResolver resourceResolver, FilterBy filter, @Nonnull List<Action> actions,
@Nonnull StringBuffer stringBuffer, boolean dryRun) throws PersistenceException {
Resource parentResource = resourceResolver.getResource(path);
if (parentResource != null) {
traverseChildResourcesRecursive(resourceResolver, parentResource, filter, action, stringBuffer, dryRun);
traverseChildResourcesRecursive(resourceResolver, parentResource, filter, actions, stringBuffer, dryRun);
}
}

private void traverseChildResourcesRecursive(ResourceResolver resourceResolver, Resource resource, FilterBy filter,
Action action, StringBuffer stringBuffer, boolean dryRun) throws PersistenceException {
List<Action> actions, StringBuffer stringBuffer, boolean dryRun) throws PersistenceException {
if (resource != null && resource.hasChildren()) {
Iterator<Resource> childResources = resource.listChildren();
while (childResources.hasNext()) {
Resource child = childResources.next();
if (filter == null || filter.filter(child)) {
stringBuffer.append(action.doAction(child) + "\n");
for (Action action : actions) {
stringBuffer.append(action.doAction(child) + "\n");
}
}
traverseChildResourcesRecursive(resourceResolver, child, filter, action, stringBuffer, dryRun);
traverseChildResourcesRecursive(resourceResolver, child, filter, actions, stringBuffer, dryRun);
}
if (!dryRun) {
resourceResolver.commit();
Expand Down
Loading

0 comments on commit 3f849ab

Please sign in to comment.