diff --git a/HISTORY b/HISTORY
index 56419401..fd1a8541 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,3 +1,9 @@
+2022-01-01 6.6.0
+- upgrade groovyconsole to v 19.0.8 for java 21 support (#240)
+- Change AECU cloud startup hook to use sling job for processing scripts to avoid multiple executions (#228)
+- improve logging and don't start aecu migration in case script path is not around (#228)
+- remove limitation in ExecuteDataSource to only execute in paths for the installhooks (#237)
+
2024-09-09 6.5.2
- Fix repoinit script for weekly maintenance jobs (#235)
diff --git a/api/pom.xml b/api/pom.xml
index 329fb463..676807f3 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -4,7 +4,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.api
diff --git a/cloud.startup.hook/pom.xml b/cloud.startup.hook/pom.xml
index 3d4b663c..8c56dacf 100644
--- a/cloud.startup.hook/pom.xml
+++ b/cloud.startup.hook/pom.xml
@@ -4,7 +4,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.cloud.startup.hook
diff --git a/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuCloudStartupService.java b/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuCloudStartupService.java
index a8a3e5c4..a76100ec 100644
--- a/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuCloudStartupService.java
+++ b/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuCloudStartupService.java
@@ -29,6 +29,7 @@
import javax.jcr.Session;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.event.jobs.JobManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
@@ -67,6 +68,9 @@ public class AecuCloudStartupService {
@Reference
private ServiceComponentRuntime serviceComponentRuntime;
+ @Reference
+ private JobManager jobManager;
+
private BundleContext bundleContext;
@Activate
@@ -91,6 +95,10 @@ protected void checkAndRunMigration() {
throw new IllegalStateException("Groovy extension services seem to be not bound");
}
Thread.sleep(1000L * WAIT_PERIOD * 2);
+ if (resourceResolver.getResource(AecuService.AECU_APPS_PATH_PREFIX) == null) {
+ LOGGER.info("AECU apps script path not found, not starting migration.");
+ return;
+ }
startAecuMigration();
} catch (InterruptedException e) {
LOGGER.error("Interrupted", e);
@@ -170,13 +178,7 @@ private boolean servicesAreOk() {
* Starts the AECU migration
*/
void startAecuMigration() {
- try {
- LOGGER.info("AECU migration started");
- aecuService.executeWithInstallHookHistory(AecuService.AECU_APPS_PATH_PREFIX);
- LOGGER.info("AECU migration finished");
- } catch (AecuException ae) {
- LOGGER.error("Error while executing AECU migration", ae);
- }
+ jobManager.addJob(AecuStartupJobConsumer.JOB_TOPIC, null);
}
/**
diff --git a/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuStartupJobConsumer.java b/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuStartupJobConsumer.java
new file mode 100644
index 00000000..47bf3235
--- /dev/null
+++ b/cloud.startup.hook/src/main/java/de/valtech/aecu/startuphook/AecuStartupJobConsumer.java
@@ -0,0 +1,41 @@
+package de.valtech.aecu.startuphook;
+
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import de.valtech.aecu.api.service.AecuException;
+import de.valtech.aecu.api.service.AecuService;
+import de.valtech.aecu.api.service.HistoryEntry;
+
+import org.apache.sling.event.jobs.Job;
+import org.apache.sling.event.jobs.consumer.JobConsumer;
+
+
+@Component(service=JobConsumer.class, property= {
+ JobConsumer.PROPERTY_TOPICS + "=" + AecuStartupJobConsumer.JOB_TOPIC
+})
+public class AecuStartupJobConsumer implements JobConsumer {
+
+ protected static final String JOB_TOPIC = "de/valtech/aecu/cloud/AecuStartupJobTopic";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AecuStartupJobConsumer.class);
+
+ @Reference
+ private AecuService aecuService;
+
+
+ public JobResult process(final Job job) {
+ try {
+ LOGGER.info("AECU migration started");
+ HistoryEntry result = aecuService.executeWithInstallHookHistory(AecuService.AECU_APPS_PATH_PREFIX);
+ LOGGER.info("AECU migration finished with result "+result.getResult());
+ return JobResult.OK;
+ } catch (AecuException ae) {
+ LOGGER.error("Error while executing AECU migration", ae);
+ // Do not retry job, hence status CANCEL (=failed permanently) and not FAILED (=can be retried)
+ return JobResult.CANCEL;
+ }
+ }
+}
\ No newline at end of file
diff --git a/cloud.startup.hook/src/test/java/de/valtech/aecu/startuphook/AecuCloudStartupServiceTest.java b/cloud.startup.hook/src/test/java/de/valtech/aecu/startuphook/AecuCloudStartupServiceTest.java
index fa796061..31ba6173 100644
--- a/cloud.startup.hook/src/test/java/de/valtech/aecu/startuphook/AecuCloudStartupServiceTest.java
+++ b/cloud.startup.hook/src/test/java/de/valtech/aecu/startuphook/AecuCloudStartupServiceTest.java
@@ -36,7 +36,9 @@
import javax.jcr.Session;
+import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.event.jobs.JobManager;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -68,9 +70,16 @@ public class AecuCloudStartupServiceTest {
@Mock
private Session session;
+ @Mock
+ private Resource resource;
+
+
@Mock
private HistoryEntry historyEntry;
+ @Mock
+ private JobManager jobManager;
+
@InjectMocks
@Spy
private AecuCloudStartupService startupService;
@@ -79,6 +88,8 @@ public class AecuCloudStartupServiceTest {
public void setUp() throws Exception {
when(resolverService.getAdminResourceResolver()).thenReturn(resolver);
when(resolver.adaptTo(Session.class)).thenReturn(session);
+ when(resolver.getResource(AecuService.AECU_APPS_PATH_PREFIX)).thenReturn(resource);
+ when(jobManager.addJob(anyString(), any())).thenReturn(null);
doReturn(true).when(session).hasPermission(anyString(), anyString());
doReturn(true).when(startupService).waitForServices();
}
@@ -89,7 +100,7 @@ public void testMigration_compositeNodeStore() throws Exception {
startupService.checkAndRunMigration();
- verify(aecuService, times(1)).executeWithInstallHookHistory(AecuService.AECU_APPS_PATH_PREFIX);
+ verify(jobManager, times(1)).addJob(AecuStartupJobConsumer.JOB_TOPIC, null);
}
@Test
@@ -106,7 +117,7 @@ public void testMigration_noCompositeNodeStore() throws Exception {
startupService.checkAndRunMigration();
- verify(aecuService, never()).executeWithInstallHookHistory(AecuService.AECU_APPS_PATH_PREFIX);
+ verify(jobManager, never()).addJob(AecuStartupJobConsumer.JOB_TOPIC, null);
}
@Test
diff --git a/complete-cloud/pom.xml b/complete-cloud/pom.xml
index 8081bf4f..675973c2 100644
--- a/complete-cloud/pom.xml
+++ b/complete-cloud/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.complete.cloud
diff --git a/complete-cloud/src/main/content/jcr_root/apps/valtech/aecu-complete/config/org.apache.sling.event.jobs.QueueConfiguration~aecu-startup-hook-job-consumer.xml b/complete-cloud/src/main/content/jcr_root/apps/valtech/aecu-complete/config/org.apache.sling.event.jobs.QueueConfiguration~aecu-startup-hook-job-consumer.xml
new file mode 100644
index 00000000..8573f631
--- /dev/null
+++ b/complete-cloud/src/main/content/jcr_root/apps/valtech/aecu-complete/config/org.apache.sling.event.jobs.QueueConfiguration~aecu-startup-hook-job-consumer.xml
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/complete/pom.xml b/complete/pom.xml
index 2f97889f..94ab5432 100644
--- a/complete/pom.xml
+++ b/complete/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.complete
diff --git a/core/pom.xml b/core/pom.xml
index 92485535..00f5bb1b 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -4,7 +4,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.core
diff --git a/core/src/main/java/de/valtech/aecu/core/model/execute/ExecuteDataSource.java b/core/src/main/java/de/valtech/aecu/core/model/execute/ExecuteDataSource.java
index c7c87794..98404ecd 100644
--- a/core/src/main/java/de/valtech/aecu/core/model/execute/ExecuteDataSource.java
+++ b/core/src/main/java/de/valtech/aecu/core/model/execute/ExecuteDataSource.java
@@ -68,8 +68,7 @@ public void setup() throws AecuException {
String path = request.getParameter("searchPath");
List entries = new ArrayList<>();
- if (path != null && StringUtils.isNotEmpty(path) && (path.startsWith(AecuService.AECU_CONF_PATH_PREFIX)
- || path.startsWith(AecuService.AECU_VAR_PATH_PREFIX) || path.startsWith(AecuService.AECU_APPS_PATH_PREFIX))) {
+ if (path != null && StringUtils.isNotEmpty(path) ) {
List allowedScripts = aecuService.getFiles(path);
ResourceResolver resourceResolver = request.getResourceResolver();
for (String scriptPath : allowedScripts) {
diff --git a/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java b/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java
index 0afd0727..772677ba 100644
--- a/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java
+++ b/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java
@@ -114,7 +114,7 @@ private List findCandidates(ResourceResolver resolver, String path) thro
}
Resource resource = resolver.getResource(path);
if (resource == null) {
- throw new AecuException("Path is invalid");
+ throw new AecuException("Path " + path + " is invalid");
}
List candidates = new ArrayList<>();
if (isFolder(resource) && matchesRunmodes(resource.getName())) {
@@ -180,10 +180,10 @@ public ExecutionResult execute(String path, String data) throws AecuException {
try (ResourceResolver resolver = resolverService.getContentMigratorResourceResolver()) {
Resource resource = resolver.getResource(path);
if (resource == null) {
- throw new AecuException("Path is invalid");
+ throw new AecuException("Path " + path + " invalid");
}
if (!isValidScriptName(resource.getName())) {
- throw new AecuException("Invalid script name");
+ throw new AecuException("Invalid script name " + resource.getName());
}
return executeScript(resolver, path, data);
} catch (LoginException e) {
diff --git a/examples-cloud/pom.xml b/examples-cloud/pom.xml
index f51f6584..7969b260 100644
--- a/examples-cloud/pom.xml
+++ b/examples-cloud/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.examples-cloud
diff --git a/examples/pom.xml b/examples/pom.xml
index 36cfc5e7..8f8a7b92 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.examples
diff --git a/oak.index/pom.xml b/oak.index/pom.xml
index dbfd1ec5..ce99a900 100644
--- a/oak.index/pom.xml
+++ b/oak.index/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.oak.index
diff --git a/pom.xml b/pom.xml
index 387ebd37..530a80e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
de.valtech.aecu
aecu
pom
- 6.5.2
+ 6.6.0
AECU
AEM Easy Content Upgrade
https://github.com/valtech/aem-easy-content-upgrade
@@ -527,13 +527,13 @@
org.apache.groovy
groovy
- 4.0.9
+ 4.0.22
provided
be.orbinson.aem
aem-groovy-console-api
- 19.0.4
+ 19.0.8
provided
@@ -546,7 +546,7 @@
be.orbinson.aem
aem-groovy-console-all
- 19.0.3
+ 19.0.8
zip
diff --git a/ui.apps/pom.xml b/ui.apps/pom.xml
index 17de9ea7..723c25fe 100644
--- a/ui.apps/pom.xml
+++ b/ui.apps/pom.xml
@@ -5,7 +5,7 @@
de.valtech.aecu
aecu
- 6.5.2
+ 6.6.0
aecu.ui.apps