Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3471 #3488

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,11 +11,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)
## Unreleased ([details][unreleased changes details])

### Fixed

- #3471 - Make MailTemplateManager interface public so it can be used by other bundles, and add onprem jar to the
all.zip.
- #3479 - Fixed Configurations Model for Redirect Manager after change in "redirect" resource as "sling:Folder"

## 6.9.6 - 2024-11-20

### Fixed

- #3473 - Fix Broken Styling when the notification is active
- #3474 - Fixed reintroduction of dependency to outdated Apache Commons Collections 3

@@ -34,11 +38,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)
## 6.9.0 - 2024-10-29

### Fixed

- #3459 - Top level properties in parameterized include are now respected.
- #3460 - Fixes issue where double parameters were not working for the parameterized include
- #3443 - Content Sync: don't drill down into content tree if recursion is off

### Changed

- #3385 Made nesting parameterized includes inside a multi-field (ignored resource types) possible

## 6.8.0 - 2024-10-17
9 changes: 8 additions & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ====================================================================== -->
<!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
@@ -204,6 +205,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>acs-aem-commons-bundle-onprem</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>acs-aem-commons-ui.apps</artifactId>
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@

import javax.mail.MessagingException;

import com.adobe.acs.commons.email.MailTemplateManager;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.osgi.service.component.annotations.Component;
@@ -35,8 +36,8 @@ public class MailTemplateManagerImpl implements MailTemplateManager {

@Override
public <T extends Email> T getEmail(final MailTemplate template,
final Map<String, String> params,
final Class<T> mailType)
final Map<String, String> params,
final Class<T> mailType)
throws IOException, EmailException, MessagingException {
return template.getEmail(params, mailType);
}
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@

import javax.mail.MessagingException;

import com.adobe.acs.commons.email.MailTemplateManager;
import org.apache.commons.lang.text.StrLookup;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
@@ -36,8 +37,8 @@ public class MailTemplateManagerImpl implements MailTemplateManager {

@Override
public <T extends Email> T getEmail(final MailTemplate template,
final Map<String, String> params,
final Class<T> mailType)
final Map<String, String> params,
final Class<T> mailType)
throws IOException, EmailException, MessagingException {
return template.getEmail(StrLookup.mapLookup(params), mailType);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*-
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2024 Adobe
* %%
/*
* ACS AEM Commons
*
* Copyright (C) 2013 - 2024 Adobe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -15,9 +14,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.email.impl;
package com.adobe.acs.commons.email;

import java.io.IOException;
import java.util.Map;
@@ -36,15 +34,16 @@ public interface MailTemplateManager {

/**
* Get the email from the template
* @param <T> The email type
*
* @param <T> The email type
* @param template The email template
* @param params Optional parameters used inside the template
* @param params Optional parameters used inside the template
* @param mailType The email type
* @return The email object
* @throws IOException If an error occurs handling the text template.
* @throws MessagingException If an error occurs during building the email message.
* @throws EmailException If an error occurs during building the email.
*/
<T extends Email> T getEmail(MailTemplate template, final Map<String, String> params, Class<T> mailType)
throws IOException, EmailException, MessagingException;
throws IOException, EmailException, MessagingException;
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

import com.adobe.acs.commons.email.EmailService;
import com.adobe.acs.commons.email.EmailServiceConstants;
import com.adobe.acs.commons.email.MailTemplateManager;
import com.day.cq.commons.mail.MailTemplate;
import com.day.cq.mailer.MessageGateway;
import com.day.cq.mailer.MessageGatewayService;
@@ -52,18 +53,18 @@
/**
* ACS AEM Commons - E-mail Service
* A Generic Email service that sends an email to a given list of recipients.
*
* <p>
* The mailType is set to HTMLEmail by default if there are any attachments. Since we are using
* the template to determine the mailType, the template name has to be *.html.
*
* <p>
* Here is an example to send an email with attachments:
*
* String attachment1 = "This text should be in the attache txt file."
* Map<String, DataSource> attachments = new HashMap<>();
* attachments.put("attachment1.txt", new ByteArrayDataSource(attachment1, "text/plain"));
* ...
* ...
* List<String> participantList = emailService.sendEmail(htmlEmailTemplatePath, emailParams, attachments, key);
* <p>
* String attachment1 = "This text should be in the attache txt file."
* Map<String, DataSource> attachments = new HashMap<>();
* attachments.put("attachment1.txt", new ByteArrayDataSource(attachment1, "text/plain"));
* ...
* ...
* List<String> participantList = emailService.sendEmail(htmlEmailTemplatePath, emailParams, attachments, key);
*/
@Component(metatype = true, label = "ACS AEM Commons - Email Service", description = "ACS AEM Commons - Email Service")
@Service
@@ -269,7 +270,7 @@ private Class<? extends Email> getMailType(String templatePath) {
private MailTemplate getMailTemplate(String templatePath) throws IllegalArgumentException {
MailTemplate mailTemplate = null;
Map<String, Object> authInfo = Collections.singletonMap(ResourceResolverFactory.SUBSERVICE, (Object) SERVICE_NAME);
try (ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(authInfo) ){
try (ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(authInfo)) {
mailTemplate = MailTemplate.create(templatePath, resourceResolver.adaptTo(Session.class));

if (mailTemplate == null) {
Original file line number Diff line number Diff line change
@@ -18,5 +18,5 @@
/**
* Email Service.
*/
@org.osgi.annotation.versioning.Version("1.3.0")
@org.osgi.annotation.versioning.Version("1.4.0")
package com.adobe.acs.commons.email;
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
*/
package com.adobe.acs.commons.hc.impl;

import com.adobe.acs.commons.email.impl.MailTemplateManager;
import com.adobe.acs.commons.email.MailTemplateManager;
import com.adobe.acs.commons.util.RequireAem;
import com.day.cq.commons.mail.MailTemplate;
import com.day.cq.mailer.MessageGateway;
@@ -46,7 +46,6 @@
import javax.mail.internet.InternetAddress;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
*/
package com.adobe.acs.commons.email.impl;

import com.adobe.acs.commons.email.MailTemplateManager;
import com.day.cq.commons.mail.MailTemplate;
import com.day.cq.mailer.MessageGateway;
import com.day.cq.mailer.MessageGatewayService;
@@ -85,7 +86,7 @@ public class EmailServiceImplTest {
private static final String EMAIL_TEMPLATE_ATTACHMENT = "emailTemplateAttachment.html";

@Before
public final void setUp() throws Exception {
public final void setUp() throws Exception {
context.load().binaryFile(this.getClass().getResourceAsStream(EMAIL_TEMPLATE), emailTemplatePath);
context.load().binaryFile(this.getClass().getResourceAsStream(EMAIL_TEMPLATE_ATTACHMENT), emailTemplateAttachmentPath);

@@ -96,8 +97,8 @@ public final void setUp() throws Exception {
context.registerService(MailTemplateManager.class, new MailTemplateManager() {
@Override
public <T extends Email> T getEmail(MailTemplate template, Map<String, String> params, Class<T> mailType)
throws IOException, EmailException, MessagingException {
return template.getEmail(StrLookup.mapLookup(params), mailType) ;
throws IOException, EmailException, MessagingException {
return template.getEmail(StrLookup.mapLookup(params), mailType);
}
});
context.registerInjectActivateService(emailService);
@@ -118,10 +119,10 @@ public final void testSendEmailMultipleRecipients() {
params.put("senderName", expectedSenderName);
params.put("senderEmailAddress", expectedSenderEmailAddress);

final String[] recipients = new String[] {"[email protected]",
"[email protected]",
"[email protected]"
};
final String[] recipients = new String[]{"[email protected]",
"[email protected]",
"[email protected]"
};
ArgumentCaptor<SimpleEmail> captor = ArgumentCaptor.forClass(SimpleEmail.class);

final List<String> failureList = emailService.sendEmail(emailTemplatePath, params, recipients);
@@ -154,7 +155,7 @@ public final void testSendEmailSingleRecipient() {
params.put("senderName", expectedSenderName);
params.put("senderEmailAddress", expectedSenderEmailAddress);

final String recipient = "[email protected]";
final String recipient = "[email protected]";

ArgumentCaptor<SimpleEmail> captor = ArgumentCaptor.forClass(SimpleEmail.class);

@@ -187,7 +188,7 @@ public final void testSendEmailAttachment() throws Exception {
params.put("senderName", expectedSenderName);
params.put("senderEmailAddress", expectedSenderEmailAddress);

final String recipient = "[email protected]";
final String recipient = "[email protected]";

Map<String, DataSource> attachments = new HashMap();
attachments.put(attachmentName, new ByteArrayDataSource(attachment, "text/plain"));
@@ -216,7 +217,7 @@ public final void testSendEmailAttachment() throws Exception {
public final void testSendEmailNoRecipients() {
final String templatePath = emailTemplatePath;
final Map<String, String> params = new HashMap<String, String>();
final String[] recipients = new String[] {};
final String[] recipients = new String[]{};

thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Invalid Recipients");
@@ -225,29 +226,29 @@ public final void testSendEmailNoRecipients() {
}


@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public final void testBlankTemplatePath() {
final String templatePath = null;
final Map<String, String> params = new HashMap<String, String>();
final String recipient = "[email protected]";
final String recipient = "[email protected]";

emailService.sendEmail(templatePath, params, recipient);
}
}

@Test
public final void testInValidTemplatePath() {
final String templatePath = "/invalidTemplatePath.txt";
final Map<String, String> params = new HashMap<String, String>();
final String recipient = "[email protected]";
final String recipient = "[email protected]";
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Mail template path [ /invalidTemplatePath.txt ] could not resolve to a valid template");

emailService.sendEmail(templatePath, params, recipient);
}
}

@Test
public void testDefaultTimeouts() {
context.registerInjectActivateService(emailService,Collections.emptyMap());
context.registerInjectActivateService(emailService, Collections.emptyMap());
SimpleEmail email = sendTestEmail();
assertEquals(30000, email.getSocketConnectionTimeout());
assertEquals(30000, email.getSocketTimeout());
@@ -270,7 +271,7 @@ private SimpleEmail sendTestEmail() {
params.put("senderName", "John Smith");
params.put("senderEmailAddress", "[email protected]");

final String recipient = "[email protected]";
final String recipient = "[email protected]";

ArgumentCaptor<SimpleEmail> captor = ArgumentCaptor.forClass(SimpleEmail.class);

@@ -288,7 +289,7 @@ public final void testSubjectSetting() {
final Map<String, String> params = new HashMap<String, String>();
params.put("subject", expectedSubject);

final String recipient = "[email protected]";
final String recipient = "[email protected]";

ArgumentCaptor<SimpleEmail> captor = ArgumentCaptor.forClass(SimpleEmail.class);

@@ -305,7 +306,7 @@ public final void testBounceAddress() throws Exception {
final Map<String, String> params = new HashMap<String, String>();
params.put("bounceAddress", expectedBounceAddress);

final String recipient = "[email protected]";
final String recipient = "[email protected]";

ArgumentCaptor<SimpleEmail> captor = ArgumentCaptor.forClass(SimpleEmail.class);

Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@

import javax.mail.MessagingException;

import com.adobe.acs.commons.email.impl.MailTemplateManager;
import com.adobe.acs.commons.email.MailTemplateManager;
import com.adobe.acs.commons.util.RequireAem;
import com.adobe.acs.commons.util.impl.RequireAemImpl;
import com.day.cq.commons.mail.MailTemplate;
@@ -36,7 +36,6 @@
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
import org.apache.poi.ss.formula.functions.T;
import org.apache.sling.hc.api.HealthCheck;
import org.apache.sling.hc.api.Result;
import org.junit.Before;
@@ -66,8 +65,8 @@ public void setUp() {
ctx.registerService(MailTemplateManager.class, new MailTemplateManager() {
@Override
public <T extends Email> T getEmail(MailTemplate template, Map<String, String> params, Class<T> mailType)
throws IOException, EmailException, MessagingException {
return template.getEmail(StrLookup.mapLookup(params), mailType) ;
throws IOException, EmailException, MessagingException {
return template.getEmail(StrLookup.mapLookup(params), mailType);
}
});
}