Skip to content

Commit a414fb3

Browse files
authored
Merge branch 'main' into main
2 parents dbf0306 + d8834a1 commit a414fb3

File tree

28 files changed

+480
-24
lines changed

28 files changed

+480
-24
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ For existing projects, take example from the [AEM Project Archetype](https://git
9191

9292
### System Requirements
9393

94-
Core Components | AEM as a Cloud Service | AEM 6.5 | Java SE | Maven
95-
----------------|------------------------|-----------|---------|---------
96-
[2.27.0+](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Continual | 6.5.21.0+ | 8, <br/>11 | 3.3.9+
94+
Core Components | AEM as a Cloud Service | AEM 6.5 | Java SE | Maven
95+
----------------|------------------------|--------------|-----------|---------
96+
[>= 2.26.x](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Continual | \>= 6.5.21.0 | 11 | \>= 3.3.9
97+
[<= 2.25.x](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.23.4) | Not applicable | \<= 6.5.21.0 | 8 <br/>11 | \<= 3.3.9
98+
9799

98100
For the requirements from previous Core Component releases, see [Historical System Requirements](VERSIONS.md).
99101

VERSIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ See below for a full list of system requirements for historical versions of the
44

55
Core Components | Extension | AEM 6.5 | AEM 6.4 | AEM 6.3 | Java | Maven
66
----------------|-----------|-----------|---------|---------|-------|------
7-
[2.27.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
8-
[2.26.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
7+
[2.27.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 11 | 3.3.9+
8+
[2.26.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.26.0) | - | 6.5.21.0+ | - | - | 11 | 3.3.9+
99
[2.25.4](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.4) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
1010
[2.25.2](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.2) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+
1111
[2.25.0](https://github.com/adobe/aem-core-wcm-components/releases/tag/core.wcm.components.reactor-2.25.0) | - | 6.5.21.0+ | - | - | 8, 11 | 3.3.9+

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/form/TextImpl.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717

1818
import javax.annotation.PostConstruct;
1919

20+
import com.day.cq.wcm.api.designer.Style;
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
2022
import org.apache.sling.api.SlingHttpServletRequest;
2123
import org.apache.sling.api.resource.Resource;
2224
import org.apache.sling.models.annotations.Default;
2325
import org.apache.sling.models.annotations.Exporter;
2426
import org.apache.sling.models.annotations.Model;
25-
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
26-
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
27-
import org.apache.sling.models.annotations.injectorspecific.Self;
28-
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
27+
import org.apache.sling.models.annotations.injectorspecific.*;
2928

3029
import com.adobe.cq.export.json.ComponentExporter;
3130
import com.adobe.cq.export.json.ExporterConstants;
3231
import com.adobe.cq.wcm.core.components.internal.form.FormConstants;
3332
import com.adobe.cq.wcm.core.components.models.form.Text;
3433
import com.day.cq.wcm.foundation.forms.FormStructureHelperFactory;
3534
import com.day.cq.wcm.foundation.forms.FormsHelper;
35+
import org.jetbrains.annotations.Nullable;
3636

3737
@Model(adaptables = SlingHttpServletRequest.class,
3838
adapters = {Text.class, ComponentExporter.class},
@@ -54,6 +54,8 @@ public class TextImpl extends AbstractFieldImpl implements Text, ComponentExport
5454
private static final boolean PROP_USE_PLACEHOLDER_DEFAULT = false;
5555
private static final int PROP_ROWS_DEFAULT = 2;
5656
private static final boolean PROP_HIDE_TITLE_DEFAULT = false;
57+
public static final String PROP_DISPLAY_VALIDATION = "displayValidation";
58+
public static final boolean PROP_DISPLAY_VALIDATION_DEFAULT = false;
5759

5860
@Self
5961
private SlingHttpServletRequest slingRequest;
@@ -103,6 +105,16 @@ public class TextImpl extends AbstractFieldImpl implements Text, ComponentExport
103105
@Default(booleanValues = PROP_HIDE_TITLE_DEFAULT)
104106
private boolean hideTitle;
105107

108+
/**
109+
* The current style for this component.
110+
*/
111+
@ScriptVariable(injectionStrategy = InjectionStrategy.OPTIONAL)
112+
@JsonIgnore
113+
@Nullable
114+
protected Style currentStyle;
115+
116+
private boolean displayValidationMassages;
117+
106118
@PostConstruct
107119
private void initModel() {
108120
slingRequest.setAttribute(FormsHelper.REQ_ATTR_FORM_STRUCTURE_HELPER,
@@ -114,6 +126,10 @@ private void initModel() {
114126
if (usePlaceholder) {
115127
placeholder = helpMessage;
116128
}
129+
130+
if (currentStyle !=null) {
131+
displayValidationMassages = currentStyle.get(PROP_DISPLAY_VALIDATION, PROP_DISPLAY_VALIDATION_DEFAULT);
132+
}
117133
}
118134

119135
@Override
@@ -190,4 +206,8 @@ public boolean hideTitle() {
190206
return hideTitle;
191207
}
192208

209+
@Override
210+
public boolean displayValidation() {
211+
return displayValidationMassages;
212+
}
193213
}

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/ImageImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ private void initNextGenerationDynamicMedia() {
331331
properties = resource.getValueMap();
332332
String fileReference = properties.get("fileReference", String.class);
333333
String smartCrop = properties.get("smartCropRendition", String.class);
334+
String modifiers = properties.get("imageModifiers", String.class);
334335
if (isNgdmImageReference(fileReference)) {
335336
int width = currentStyle.get(PN_DESIGN_RESIZE_WIDTH, DEFAULT_NGDM_ASSET_WIDTH);
336337
NextGenDMImageURIBuilder builder = new NextGenDMImageURIBuilder(nextGenDynamicMediaConfig, fileReference)
@@ -339,6 +340,9 @@ private void initNextGenerationDynamicMedia() {
339340
if(StringUtils.isNotEmpty(smartCrop) && !StringUtils.equals(smartCrop, SMART_CROP_AUTO)) {
340341
builder.withSmartCrop(smartCrop);
341342
}
343+
if (StringUtils.isNotEmpty(modifiers)) {
344+
builder.withImageModifiers(modifiers);
345+
}
342346
src = builder.build();
343347
ngdmImage = true;
344348
hasContent = true;

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/NextGenDMImageURIBuilder.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class NextGenDMImageURIBuilder {
4242
private int height;
4343
private boolean preferWebp = true;
4444

45+
private String modifiers;
46+
4547
public NextGenDMImageURIBuilder(NextGenDynamicMediaConfig config, String fileReference) {
4648
this.config = config;
4749
this.fileReference = fileReference;
@@ -84,6 +86,15 @@ public NextGenDMImageURIBuilder withPreferWebp(boolean preferWebp) {
8486
return this;
8587
}
8688

89+
/**
90+
* Set extra image modifiers.
91+
* @param modifiersStr
92+
*/
93+
public NextGenDMImageURIBuilder withImageModifiers(String modifiersStr) {
94+
this.modifiers = modifiersStr;
95+
return this;
96+
}
97+
8798
/**
8899
* Use this to create a NextGen Dynamic Media Image URI.
89100
* @return a uri.
@@ -124,6 +135,13 @@ public String build() {
124135
}
125136
uriBuilder.deleteCharAt(uriBuilder.length() - 1);
126137
}
138+
if(StringUtils.isNotEmpty(this.modifiers)) {
139+
if (this.modifiers.startsWith("&")) {
140+
uriBuilder.append(this.modifiers);
141+
} else {
142+
uriBuilder.append("&" + this.modifiers);
143+
}
144+
}
127145
return uriBuilder.toString();
128146
}
129147
LOGGER.info("Invalid fileReference or NGDMConfig. fileReference = {}", this.fileReference);

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/CoreFormHandlingServlet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ protected void activate(Configuration configuration) {
110110
@Override
111111
protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull final SlingHttpServletResponse response)
112112
throws ServletException, IOException {
113+
// response will have content type text/html since it is represented by a JSP without another content type set
114+
// JSPs have this content type by default
115+
// So set this content type in advance inside response, in order to avoid breaking request dispatcher contract
116+
// More info https://jakarta.ee/specifications/servlet/4.0/apidocs/javax/servlet/requestdispatcher#include-javax.servlet.ServletRequest-javax.servlet.ServletResponse-
117+
response.setContentType("text/html");
113118
formsHandlingServletHelper.doPost(request, response);
114119
}
115120

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/form/Text.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public interface Text extends Field {
2727

2828
/**
29-
* Checks if the this text field is mandatory.
29+
* Checks if the text field is mandatory.
3030
*
3131
* @return {@code true} if the field must have a input, {@code false} otherwise
3232
* @since com.adobe.cq.wcm.core.components.models.form 13.0.0; marked <code>default</code> in 14.1.0
@@ -107,4 +107,14 @@ default int getRows() {
107107
default boolean hideTitle() {
108108
return false;
109109
}
110+
111+
/**
112+
* Checks if the validation messages should be displayed.
113+
*
114+
* @return {@code true} if the validation messages should be displayed, {@code false} otherwise
115+
* @since com.adobe.cq.wcm.core.components.models.form 14.5.0
116+
*/
117+
default boolean displayValidation() {
118+
return false;
119+
}
110120
}

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/form/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* version, is bound to this proxy component resource type.
3535
* </p>
3636
*/
37-
@Version("14.4.0")
37+
@Version("14.5.0")
3838
package com.adobe.cq.wcm.core.components.models.form;
3939

4040
import org.osgi.annotation.versioning.Version;

bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v1/form/TextImplTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class TextImplTest {
3939
private static final String TEXTINPUT1_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text";
4040
private static final String TEXTINPUT2_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text_185087333";
4141
private static final String TEXTINPUT3_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2";
42+
private static final String TEXTINPUT4_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2-2";
43+
private static final String TEXTINPUT5_PATH = CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text-v2-3";
4244

4345

4446
public final AemContext context = CoreComponentTestContext.newAemContext();
@@ -79,6 +81,7 @@ public void testInputWithCustomDataAndAttributes() {
7981
assertEquals(3, text.getRows());
8082
assertEquals("Custom help/placeholder message", text.getHelpMessage());
8183
assertTrue(text.hideTitle());
84+
assertFalse(text.displayValidation());
8285
Utils.testJSONExport(text, Utils.getTestExporterJSONPath(TEST_BASE, TEXTINPUT2_PATH));
8386
}
8487

@@ -88,6 +91,24 @@ public void testV2JSONExport() {
8891
Utils.testJSONExport(text, Utils.getTestExporterJSONPath(TEST_BASE, TEXTINPUT3_PATH));
8992
}
9093

94+
@Test
95+
public void testInputWithPolicyDisplayValidationFalse() {
96+
context.contentPolicyMapping("core/wcm/components/form/text/v2/text", "displayValidation", false);
97+
Text text = getTextUnderTest(TEXTINPUT4_PATH);
98+
assertEquals("Custom Name", text.getName());
99+
assertEquals("Custom title", text.getTitle());
100+
assertFalse(text.displayValidation());
101+
}
102+
103+
@Test
104+
public void testInputWithPolicyDisplayValidationTrue() {
105+
context.contentPolicyMapping("core/wcm/components/form/text/v2/text", "displayValidation", true);
106+
Text text = getTextUnderTest(TEXTINPUT5_PATH);
107+
assertEquals("Custom Name", text.getName());
108+
assertEquals("Custom title", text.getTitle());
109+
assertTrue(text.displayValidation());
110+
}
111+
91112
private Text getTextUnderTest(String resourcePath) {
92113
context.currentResource(Objects.requireNonNull(context.resourceResolver().getResource(resourcePath)));
93114
return context.request().adaptTo(Text.class);

bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/models/v3/ImageImplTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class ImageImplTest extends com.adobe.cq.wcm.core.components.internal.models.v2.
9696
private static final String PAGE3_IMAGE0_PATH = PAGE3 + "/jcr:content/root/page3_image0";
9797
private static final String NGDM_IMAGE1_PATH = "/content/ngdm_test_page/jcr:content/root/ngdm_test_page_image1";
9898
private static final String NGDM_SMARTCROP_IMAGE_PATH = "/content/ngdm_test_page/jcr:content/root/ngdm_test_page_smartcrop_image";
99+
100+
private static final String NGDM_MODIFIERS_IMAGE_PATH = "/content/ngdm_test_page/jcr:content/root/ngdm_test_page_modifiers_image";
99101
private static final String NGDM_SMARTCROP_AUTO_IMAGE_PATH = "/content/ngdm_test_page/jcr:content/root/ngdm_test_page_smartcrop_image_auto";
100102

101103

@@ -731,6 +733,19 @@ void testNgdmImageWithSmartCropRendition() {
731733
Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, NGDM_SMARTCROP_IMAGE_PATH));
732734
}
733735

736+
@Test
737+
void testNgdmImageWithModifiers() {
738+
MockNextGenDynamicMediaConfig config = new MockNextGenDynamicMediaConfig();
739+
config.setEnabled(true);
740+
config.setRepositoryId("testrepo");
741+
config.setAssetMetadataPath("/adobe/assets/{asset-id}/metadata");
742+
context.registerInjectActivateService(config);
743+
744+
Image image = getImageUnderTest(NGDM_MODIFIERS_IMAGE_PATH);
745+
Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, NGDM_MODIFIERS_IMAGE_PATH));
746+
assertTrue(image.getSrc().contains("&width=100&height=200"));
747+
}
748+
734749
@Test
735750
void testNgdmImageWithAutoSmartCropRendition() throws Exception {
736751
String expectedMetadataAPIResponseJSON = "{\"assetId\":\"urn:aaid:aem:33b6255d-a978-43ad-8e2e-ef5677c64715\",\"repositoryMetadata\":{\"smartcrops\":{\"Large\":{\"height\":\"1200\",\"left\":\"0.0\",\"manualCrop\":\"false\",\"width\":\"800\",\"top\":\"0.16\"},\"Medium\":{\"height\":\"800\",\"left\":\"0.0\",\"manualCrop\":\"false\",\"width\":\"600\",\"top\":\"0.0\"}}}}";

0 commit comments

Comments
 (0)