diff --git a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/AbstractLocalizedNameProvider.java b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/AbstractLocalizedNameProvider.java index e23c333..7cbc40e 100644 --- a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/AbstractLocalizedNameProvider.java +++ b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/AbstractLocalizedNameProvider.java @@ -1,6 +1,7 @@ package com.merkle.oss.magnolia.powernode; import info.magnolia.cms.i18n.I18nContentSupport; +import info.magnolia.module.site.Site; import info.magnolia.module.site.SiteManager; import java.util.Locale; @@ -13,8 +14,11 @@ public abstract class AbstractLocalizedNameProvider implements LocalizedNameProvider { private final Function, I18nContentSupport> i18nContentSupportProvider; - protected AbstractLocalizedNameProvider(final SiteManager siteManager) { - this.i18nContentSupportProvider = (node) -> node.map(siteManager::getAssignedSite).orElseGet(siteManager::getCurrentSite).getI18n(); + protected AbstractLocalizedNameProvider( + final SiteManager siteManager, + final I18nContentSupport i18nContentSupport + ) { + this.i18nContentSupportProvider = (node) -> node.map(siteManager::getAssignedSite).map(Site::getI18n).orElse(i18nContentSupport); } protected AbstractLocalizedNameProvider(final Function, I18nContentSupport> i18nContentSupportProvider) { diff --git a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProvider.java b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProvider.java index f3be09b..98b6630 100644 --- a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProvider.java +++ b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProvider.java @@ -16,8 +16,11 @@ public class MagnoliaDefaultLocalizedNameProvider extends AbstractLocalizedNameProvider { @Inject - public MagnoliaDefaultLocalizedNameProvider(final SiteManager siteManager) { - super(siteManager); + public MagnoliaDefaultLocalizedNameProvider( + final SiteManager siteManager, + final I18nContentSupport i18nContentSupport + ) { + super(siteManager, i18nContentSupport); } protected MagnoliaDefaultLocalizedNameProvider(final Function, I18nContentSupport> i18nContentSupportProvider) { diff --git a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProvider.java b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProvider.java index 87e5a17..914ea99 100644 --- a/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProvider.java +++ b/powernode-base/src/main/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProvider.java @@ -17,8 +17,11 @@ public class MagnoliaLanguageLocalizedNameProvider extends AbstractLocalizedNameProvider { @Inject - public MagnoliaLanguageLocalizedNameProvider(final SiteManager siteManager) { - super(siteManager); + public MagnoliaLanguageLocalizedNameProvider( + final SiteManager siteManager, + final I18nContentSupport i18nContentSupport + ) { + super(siteManager, i18nContentSupport); } protected MagnoliaLanguageLocalizedNameProvider(final Function, I18nContentSupport> i18nContentSupportProvider) { diff --git a/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProviderTest.java b/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProviderTest.java index f0c24bd..edc3452 100644 --- a/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProviderTest.java +++ b/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaDefaultLocalizedNameProviderTest.java @@ -28,7 +28,7 @@ void setUp() { doReturn(i18nContentSupport).when(site).getI18n(); final SiteManager siteManager = mock(SiteManager.class); doReturn(site).when(siteManager).getAssignedSite(any(Node.class)); - localizedNameProvider = new MagnoliaDefaultLocalizedNameProvider(siteManager); + localizedNameProvider = new MagnoliaDefaultLocalizedNameProvider(siteManager, i18nContentSupport); } @Test diff --git a/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProviderTest.java b/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProviderTest.java index 0d2122d..1b9ab24 100644 --- a/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProviderTest.java +++ b/powernode-base/src/test/java/com/merkle/oss/magnolia/powernode/magnolia/MagnoliaLanguageLocalizedNameProviderTest.java @@ -25,7 +25,7 @@ void setUp() { doReturn(i18nContentSupport).when(site).getI18n(); final SiteManager siteManager = mock(SiteManager.class); doReturn(site).when(siteManager).getCurrentSite(); - localizedNameProvider = new MagnoliaLanguageLocalizedNameProvider(siteManager); + localizedNameProvider = new MagnoliaLanguageLocalizedNameProvider(siteManager, i18nContentSupport); } @Test