Skip to content

Commit

Permalink
[SITES-21656] OOTB Experience Fragment Localization Issue for /eu/fr …
Browse files Browse the repository at this point in the history
…Site (#2755)

* [SITES-21656] OOTB Experience Fragment Localization Issue for /eu/fr Site

* Remove Java 8 support

* Allow to specify cq:isLanguageRoot=true and jcr:language="fr" on language root resource in order to force correct localization of XF link

---------

Co-authored-by: Alexandru Marian Stancioiu <stancioi@adobe.com>
  • Loading branch information
alexandru-stancioiu and Alexandru Marian Stancioiu committed May 20, 2024
1 parent afb6dda commit d844a0e
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11

# Set up dependency cache
- name: Cache local Maven repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11

# Set up dependency cache
- name: Cache local Maven repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
java: [8, 11]
java: [11]
profile: [ '', '-Pcloud,adobe-public']

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static String getLocalizationRoot(@NotNull Resource resource, @NotNull Re
*/
@Nullable
public static String getLanguageRoot(@NotNull Resource resource, @NotNull LanguageManager languageManager) {
return Optional.ofNullable(languageManager.getLanguageRoot(resource))
return Optional.ofNullable(languageManager.getLanguageRoot(resource, true))
.map(Page::getPath)
.orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ public static AemContext newAemContext() {
.resourceResolverType(ResourceResolverType.JCR_MOCK)
.resourceResolverFactoryActivatorProps(PROPERTIES)
.<AemContext>afterSetUp(context -> {
context.addModelsForClasses(MockResponsiveGrid.class);
context.addModelsForPackage("com.adobe.cq.wcm.core.components.models");
context.addModelsForPackage("com.adobe.cq.wcm.core.components.internal.link");
context.registerService(SlingModelFilter.class, new MockSlingModelFilter() {
private final Set<String> IGNORED_NODE_NAMES = new HashSet<String>() {{
add(NameConstants.NN_RESPONSIVE_CONFIG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ExperienceFragmentImplTest {
private static final String US_EN_PAGE = SITE_ROOT + "/us/en/page";
private static final String CH_MYSITE_FR_PAGE = SITE_ROOT + "/ch/mysite/fr/page";
private static final String CH_FR_PAGE = SITE_ROOT + "/ch_fr/page";
private static final String EU_FR_PAGE = SITE_ROOT + "/eu/fr/page";
private static final String BLUEPRINT_ROOT = "/content/mysite/blueprint";
private static final String BLUEPRINT_PAGE = BLUEPRINT_ROOT + "/page";
private static final String LIVECOPY_ROOT = "/content/mysite/livecopy";
Expand Down Expand Up @@ -555,6 +556,23 @@ void testValidXFInPageWithLocalizationWithDifferentCountry_Language() {
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf41"));
}

/**
* Site with region/language localization
* XF component is defined in the template
* XF component points to a different region/language branch as the page
* and system cannot infer correctly the language root unless page is marked with
* "cq:isLanguageRoot": true
* and
* "jcr:language": "fr"
*/
@Test
void testValidXFInPageWithLocalizationWithDifferentCountry_Language_withLanguageRootMarking() {

ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-23", EU_FR_PAGE);
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf23"));
}

/**
* Site with country_language localization
* XF component is defined in the template
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "experiencefragment-8920b315ce",
"localizedFragmentVariationPath": "/content/experience-fragments/mysite/eu/fr/footer/master/jcr:content",
"configured": false,
"classNames": "aem-xf empty",
":items": {},
":type": "core/wcm/components/experiencefragment/v1/experiencefragment",
":itemsOrder": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
"sling:resourceType": "core/wcm/components/experiencefragment/v1/experiencefragment",
"fragmentVariationPath": "/content/experience-fragments/mysite/us/en/footer/master/undefined"
},
"xf-component-23": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "core/wcm/components/experiencefragment/v1/experiencefragment",
"fragmentVariationPath": "/content/experience-fragments/mysite/language-masters/en/footer/master"
},
"xf-component-30a": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "core/wcm/components/experiencefragment/v1/experiencefragment",
Expand Down Expand Up @@ -147,4 +152,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,36 @@
}
}
},
"eu": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "Europe",
"jcr:created": "Mon APR 08 2019 20:21:55 GMT+0200"
},
"fr": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "Français",
"jcr:created": "Mon APR 08 2019 20:21:55 GMT+0200",
"cq:isLanguageRoot": true,
"jcr:language": "fr"
},
"page": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "Test page",
"jcr:created": "Mon APR 08 2019 20:21:55 GMT+0200",
"cq:template": "/conf/coretest/settings/wcm/templates/product-page",
"root": {
"jcr:primaryType": "nt:unstructured"
}
}
}
}
},
"ch": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
Expand Down Expand Up @@ -303,6 +333,53 @@
"sling:resourceType": "cq/experience-fragments/components/experiencefragment"
}
},
"language-masters": {
"en": {
"jcr:primaryType": "sling:Folder",
"footer": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "English Test Footer",
"jcr:created": "Mon APR 08 2019 20:21:55 GMT+0200",
"sling:resourceType": "cq/experience-fragments/components/experiencefragment"
},
"master": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "English Test Footer Master",
"cq:xfVariantType": "web",
"cq:xfMasterVariation": "true"
}
}
}
}
},
"eu": {
"jcr:primaryType": "sling:Folder",
"fr": {
"jcr:primaryType": "sling:Folder",
"footer": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "English Test Footer",
"jcr:created": "Mon APR 08 2019 20:21:55 GMT+0200",
"sling:resourceType": "cq/experience-fragments/components/experiencefragment"
},
"master": {
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "English Test Footer Master",
"cq:xfVariantType": "web",
"cq:xfMasterVariation": "true"
}
}
}
}
},
"us": {
"jcr:primaryType": "sling:Folder",
"en": {
Expand Down Expand Up @@ -703,4 +780,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ private AmpTestContext() {
public static io.wcm.testing.mock.aem.junit5.AemContext newAemContext() {
return new AemContextBuilder().resourceResolverType(ResourceResolverType.JCR_MOCK)
.<io.wcm.testing.mock.aem.junit5.AemContext>afterSetUp(context -> {
context.addModelsForClasses(MockResponsiveGrid.class);
context.registerService(SlingModelFilter.class, new MockSlingModelFilter() {
private final Set<String> IGNORED_NODE_NAMES = new HashSet<String>() {{
add(NameConstants.NN_RESPONSIVE_CONFIG);
Expand Down
6 changes: 3 additions & 3 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<vault.user>admin</vault.user>
<vault.password>admin</vault.password>
<slf4j.version>1.7.25</slf4j.version>
<aem.java.version>8</aem.java.version>
<aem.java.version>11</aem.java.version>
<jacoco.version>0.8.8</jacoco.version>
<frontend-maven-plugin.version>1.11.3</frontend-maven-plugin.version>
<node.version>v16.13.1</node.version>
Expand Down Expand Up @@ -336,7 +336,7 @@
</requireMavenVersion>
<requireJavaVersion>
<message>Project must be compiled with Java ${aem.java.version} or higher</message>
<version>1.${aem.java.version}</version>
<version>${aem.java.version}</version>
</requireJavaVersion>
</rules>
</configuration>
Expand Down Expand Up @@ -799,7 +799,7 @@
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>5.1.0</version>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion testing/it/e2e-selenium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
</build>

<properties>
<cq.java.version>8</cq.java.version>
<cq.java.version>11</cq.java.version>
<excludedGroups>failing,nested</excludedGroups>
<granite.it.author.url>http://localhost:4502</granite.it.author.url>
<granite.it.publish.url>http://localhost:4503</granite.it.publish.url>
Expand Down
6 changes: 3 additions & 3 deletions testing/it/http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.${cq.java.version}</source>
<target>1.${cq.java.version}</target>
<source>${cq.java.version}</source>
<target>${cq.java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -148,7 +148,7 @@
<granite.it.publish.url>http://localhost:4503</granite.it.publish.url>
<sling.junit.core.version>1.0.28</sling.junit.core.version>
<sling.testing.tools.version>1.0.8</sling.testing.tools.version>
<cq.java.version>8</cq.java.version>
<cq.java.version>11</cq.java.version>
<test.thread.count>30</test.thread.count>
</properties>

Expand Down

0 comments on commit d844a0e

Please sign in to comment.