Skip to content

Commit

Permalink
Merge branch 'release/6.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nhirrle committed Jan 1, 2025
2 parents dee5d6f + 189964d commit 77a12cf
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 27 deletions.
6 changes: 6 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -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)

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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.cloud.startup.hook</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +68,9 @@ public class AecuCloudStartupService {
@Reference
private ServiceComponentRuntime serviceComponentRuntime;

@Reference
private JobManager jobManager;

private BundleContext bundleContext;

@Activate
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.complete.cloud</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"

queue.name="AECU Cloud Startup Job Queue"
queue.priority="NORM"
queue.topics="de/valtech/aecu/cloud/AecuStartupJobTopic"
queue.type="ORDERED"
queue.keepJobs="true"
/>
2 changes: 1 addition & 1 deletion 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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.complete</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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public void setup() throws AecuException {
String path = request.getParameter("searchPath");
List<Resource> 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<String> allowedScripts = aecuService.getFiles(path);
ResourceResolver resourceResolver = request.getResourceResolver();
for (String scriptPath : allowedScripts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private List<String> 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<String> candidates = new ArrayList<>();
if (isFolder(resource) && matchesRunmodes(resource.getName())) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion examples-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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.examples-cloud</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.examples</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion oak.index/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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.oak.index</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<packaging>pom</packaging>
<version>6.5.2</version>
<version>6.6.0</version>
<name>AECU</name>
<description>AEM Easy Content Upgrade</description>
<url>https://github.com/valtech/aem-easy-content-upgrade</url>
Expand Down Expand Up @@ -527,13 +527,13 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.9</version>
<version>4.0.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>be.orbinson.aem</groupId>
<artifactId>aem-groovy-console-api</artifactId>
<version>19.0.4</version>
<version>19.0.8</version>
<scope>provided</scope>
<!-- exclude dependencies -->
<exclusions>
Expand All @@ -546,7 +546,7 @@
<dependency>
<groupId>be.orbinson.aem</groupId>
<artifactId>aem-groovy-console-all</artifactId>
<version>19.0.3</version>
<version>19.0.8</version>
<type>zip</type>
<!-- exclude dependencies -->
<exclusions>
Expand Down
2 changes: 1 addition & 1 deletion ui.apps/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.5.2</version>
<version>6.6.0</version>
</parent>

<artifactId>aecu.ui.apps</artifactId>
Expand Down

0 comments on commit 77a12cf

Please sign in to comment.