diff --git a/modules/apps/client-extension/client-extension-test/src/testIntegration/java/com/liferay/client/extension/internal/event/test/ClientExtensionServicePreActionTest.java b/modules/apps/client-extension/client-extension-test/src/testIntegration/java/com/liferay/client/extension/internal/event/test/ClientExtensionServicePreActionTest.java index e424f8d768e28d..2238c327fe3378 100644 --- a/modules/apps/client-extension/client-extension-test/src/testIntegration/java/com/liferay/client/extension/internal/event/test/ClientExtensionServicePreActionTest.java +++ b/modules/apps/client-extension/client-extension-test/src/testIntegration/java/com/liferay/client/extension/internal/event/test/ClientExtensionServicePreActionTest.java @@ -350,12 +350,10 @@ private void _assertThemeCSSURLs( else { MatcherAssert.assertThat( themeDisplay.getClayCSSURL(), - CoreMatchers.containsString( - "themeId=classic_WAR_classictheme")); + CoreMatchers.startsWith("/o/classic-theme/css/clay.")); MatcherAssert.assertThat( themeDisplay.getMainCSSURL(), - CoreMatchers.containsString( - "themeId=classic_WAR_classictheme")); + CoreMatchers.startsWith("/o/classic-theme/css/main.")); } } diff --git a/modules/apps/frontend-js/frontend-js-web/src/main/java/com/liferay/frontend/js/web/internal/events/FrontendServicePreAction.java b/modules/apps/frontend-js/frontend-js-web/src/main/java/com/liferay/frontend/js/web/internal/events/FrontendServicePreAction.java deleted file mode 100644 index 2bc34202bee53a..00000000000000 --- a/modules/apps/frontend-js/frontend-js-web/src/main/java/com/liferay/frontend/js/web/internal/events/FrontendServicePreAction.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com - * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 - */ - -package com.liferay.frontend.js.web.internal.events; - -import com.liferay.portal.kernel.events.Action; -import com.liferay.portal.kernel.events.ActionException; -import com.liferay.portal.kernel.events.LifecycleAction; -import com.liferay.portal.kernel.frontend.hashed.files.HashedFilesRegistry; -import com.liferay.portal.kernel.model.Theme; -import com.liferay.portal.kernel.theme.ThemeDisplay; -import com.liferay.portal.kernel.util.Portal; -import com.liferay.portal.kernel.util.WebKeys; -import com.liferay.portal.url.builder.AbsolutePortalURLBuilder; -import com.liferay.portal.url.builder.AbsolutePortalURLBuilderFactory; -import com.liferay.portal.url.builder.WebContextScriptAbsolutePortalURLBuilder; -import com.liferay.portal.url.builder.WebContextStylesheetAbsolutePortalURLBuilder; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; - -/** - * @author Iván Zaera Avellón - */ -@Component( - property = "key=servlet.service.events.pre", service = LifecycleAction.class -) -public class FrontendServicePreAction extends Action { - - @Override - public void run( - HttpServletRequest httpServletRequest, - HttpServletResponse httpServletResponse) - throws ActionException { - - ThemeDisplay themeDisplay = - (ThemeDisplay)httpServletRequest.getAttribute( - WebKeys.THEME_DISPLAY); - - if (themeDisplay == null) { - return; - } - - AbsolutePortalURLBuilder absolutePortalURLBuilder = - _absolutePortalURLBuilderFactory.getAbsolutePortalURLBuilder( - httpServletRequest); - - Theme theme = themeDisplay.getTheme(); - boolean rtl = _portal.isRightToLeft(httpServletRequest); - - WebContextStylesheetAbsolutePortalURLBuilder - webContextStylesheetAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextStylesheet( - theme.getServletContextName(), - rtl ? "/css/clay_rtl.css" : "/css/clay.css"); - - themeDisplay.setDefaultClayCSSURL( - webContextStylesheetAbsolutePortalURLBuilder.build()); - - webContextStylesheetAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextStylesheet( - theme.getServletContextName(), - rtl ? "/css/main_rtl.css" : "/css/main.css"); - - themeDisplay.setDefaultMainCSSURL( - webContextStylesheetAbsolutePortalURLBuilder.build()); - - WebContextScriptAbsolutePortalURLBuilder - webContextScriptAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextScript( - theme.getServletContextName(), "/js/main.js"); - - themeDisplay.setDefaultMainJSURL( - webContextScriptAbsolutePortalURLBuilder.build()); - } - - @Reference - private AbsolutePortalURLBuilderFactory _absolutePortalURLBuilderFactory; - - @Reference - private HashedFilesRegistry _hashedFilesRegistry; - - @Reference - private Portal _portal; - -} \ No newline at end of file diff --git a/modules/apps/layout/layout-impl/build.gradle b/modules/apps/layout/layout-impl/build.gradle index 5eebe27065d353..b921c1598434c9 100644 --- a/modules/apps/layout/layout-impl/build.gradle +++ b/modules/apps/layout/layout-impl/build.gradle @@ -44,7 +44,6 @@ dependencies { compileOnly project(":apps:portal-lock:portal-lock-api") compileOnly project(":apps:portal-search:portal-search-api") compileOnly project(":apps:portal-search:portal-search-spi") - compileOnly project(":apps:portal-url-builder:portal-url-builder-api") compileOnly project(":apps:portal-vulcan:portal-vulcan-api") compileOnly project(":apps:portal-workflow:portal-workflow-api") compileOnly project(":apps:portal:portal-json-validator") diff --git a/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/struts/GetPagePreviewStrutsAction.java b/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/struts/GetPagePreviewStrutsAction.java index d421295d5d4016..53fefaa614c7ff 100644 --- a/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/struts/GetPagePreviewStrutsAction.java +++ b/modules/apps/layout/layout-impl/src/main/java/com/liferay/layout/internal/struts/GetPagePreviewStrutsAction.java @@ -45,10 +45,6 @@ import com.liferay.portal.kernel.util.Portal; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; -import com.liferay.portal.url.builder.AbsolutePortalURLBuilder; -import com.liferay.portal.url.builder.AbsolutePortalURLBuilderFactory; -import com.liferay.portal.url.builder.WebContextScriptAbsolutePortalURLBuilder; -import com.liferay.portal.url.builder.WebContextStylesheetAbsolutePortalURLBuilder; import com.liferay.segments.constants.SegmentsWebKeys; import com.liferay.segments.service.SegmentsExperienceLocalService; @@ -142,8 +138,6 @@ public String execute( themeDisplay.setLookAndFeel(theme, layout.getColorScheme()); - _addClayURLs(httpServletRequest, themeDisplay); - themeDisplay.setSignedIn(false); User guestUser = _userLocalService.getGuestUser( @@ -227,42 +221,6 @@ public String execute( return null; } - private void _addClayURLs( - HttpServletRequest httpServletRequest, ThemeDisplay themeDisplay) { - - AbsolutePortalURLBuilder absolutePortalURLBuilder = - _absolutePortalURLBuilderFactory.getAbsolutePortalURLBuilder( - httpServletRequest); - - Theme theme = themeDisplay.getTheme(); - boolean rtl = _portal.isRightToLeft(httpServletRequest); - - WebContextStylesheetAbsolutePortalURLBuilder - webContextStylesheetAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextStylesheet( - theme.getServletContextName(), - rtl ? "/css/clay_rtl.css" : "/css/clay.css"); - - themeDisplay.setDefaultClayCSSURL( - webContextStylesheetAbsolutePortalURLBuilder.build()); - - webContextStylesheetAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextStylesheet( - theme.getServletContextName(), - rtl ? "/css/main_rtl.css" : "/css/main.css"); - - themeDisplay.setDefaultMainCSSURL( - webContextStylesheetAbsolutePortalURLBuilder.build()); - - WebContextScriptAbsolutePortalURLBuilder - webContextScriptAbsolutePortalURLBuilder = - absolutePortalURLBuilder.forWebContextScript( - theme.getServletContextName(), "/js/main.js"); - - themeDisplay.setDefaultMainJSURL( - webContextScriptAbsolutePortalURLBuilder.build()); - } - private void _addLinkedAssetEntryId( String className, long classPK, HttpServletRequest httpServletRequest) { @@ -346,9 +304,6 @@ private void _includeInfoItemObjects( private static final Log _log = LogFactoryUtil.getLog( GetPagePreviewStrutsAction.class); - @Reference - private AbsolutePortalURLBuilderFactory _absolutePortalURLBuilderFactory; - @Reference private InfoItemServiceRegistry _infoItemServiceRegistry; diff --git a/modules/apps/layout/layout-test/src/testIntegration/java/com/liferay/layout/internal/struts/test/GetPagePreviewStrutsActionTest.java b/modules/apps/layout/layout-test/src/testIntegration/java/com/liferay/layout/internal/struts/test/GetPagePreviewStrutsActionTest.java index ee4b597369e559..c27ccd07029376 100644 --- a/modules/apps/layout/layout-test/src/testIntegration/java/com/liferay/layout/internal/struts/test/GetPagePreviewStrutsActionTest.java +++ b/modules/apps/layout/layout-test/src/testIntegration/java/com/liferay/layout/internal/struts/test/GetPagePreviewStrutsActionTest.java @@ -256,7 +256,7 @@ private void _assertContainsContent(String expectedThemeId) Assert.assertThat( content, CoreMatchers.containsString( - "href=\"/o/" + theme.getServletContextName() + "/css/")); + "/o/" + theme.getServletContextName() + "/css/main.")); } private void _setUpThemeDisplay() throws Exception { diff --git a/portal-kernel/src/com/liferay/portal/kernel/theme/ThemeDisplay.java b/portal-kernel/src/com/liferay/portal/kernel/theme/ThemeDisplay.java index 0aaf05e26318d5..c3b6cfd9c760b0 100644 --- a/portal-kernel/src/com/liferay/portal/kernel/theme/ThemeDisplay.java +++ b/portal-kernel/src/com/liferay/portal/kernel/theme/ThemeDisplay.java @@ -13,6 +13,7 @@ import com.liferay.petra.string.StringPool; import com.liferay.portal.kernel.change.tracking.CTCollectionThreadLocal; import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.frontend.hashed.files.HashedFilesRegistryUtil; import com.liferay.portal.kernel.json.JSON; import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.log.Log; @@ -190,8 +191,15 @@ public String getClayCSSURL() { return _clayCSSURL; } - if (Validator.isNotNull(_defaultClayCSSURL)) { - _clayCSSURL = _defaultClayCSSURL; + String hashedFileURI = HashedFilesRegistryUtil.getHashedFileURI( + StringBundler.concat( + PortalUtil.getPathModule(), StringPool.SLASH, + _theme.getServletContextName(), _theme.getCssPath(), + PortalUtil.isRightToLeft(_httpServletRequest) ? + "/clay_rtl.css" : "/clay.css")); + + if (Validator.isNotNull(hashedFileURI)) { + _clayCSSURL = hashedFileURI; } else { _clayCSSURL = PortalUtil.getStaticResourceURL( @@ -564,8 +572,15 @@ public String getMainCSSURL() { return _mainCSSURL; } - if (Validator.isNotNull(_defaultMainCSSURL)) { - _mainCSSURL = _defaultMainCSSURL; + String hashedFileURI = HashedFilesRegistryUtil.getHashedFileURI( + StringBundler.concat( + PortalUtil.getPathModule(), StringPool.SLASH, + _theme.getServletContextName(), _theme.getCssPath(), + PortalUtil.isRightToLeft(_httpServletRequest) ? + "/main_rtl.css" : "/main.css")); + + if (Validator.isNotNull(hashedFileURI)) { + _mainCSSURL = hashedFileURI; } else { _mainCSSURL = PortalUtil.getStaticResourceURL( @@ -580,8 +595,14 @@ public String getMainJSURL() { return _mainJSURL; } - if (Validator.isNotNull(_defaultMainJSURL)) { - _mainJSURL = _defaultMainJSURL; + String hashedFileURI = HashedFilesRegistryUtil.getHashedFileURI( + StringBundler.concat( + PortalUtil.getPathModule(), StringPool.SLASH, + _theme.getServletContextName(), _theme.getJavaScriptPath(), + "/main.js")); + + if (Validator.isNotNull(hashedFileURI)) { + _mainJSURL = hashedFileURI; } else { _mainJSURL = PortalUtil.getStaticResourceURL( @@ -1385,18 +1406,6 @@ public void setContact(Contact contact) { _contact = contact; } - public void setDefaultClayCSSURL(String defaultClayCSSURL) { - _defaultClayCSSURL = defaultClayCSSURL; - } - - public void setDefaultMainCSSURL(String defaultMainCSSURL) { - _defaultMainCSSURL = defaultMainCSSURL; - } - - public void setDefaultMainJSURL(String defaultMainJSURL) { - _defaultMainJSURL = defaultMainJSURL; - } - public void setDevice(Device device) { _device = device; } @@ -2029,9 +2038,6 @@ private int _getLayoutManagePagesInitialChildren() { private Contact _contact; private Group _controlPanelGroup; private Layout _controlPanelLayout; - private String _defaultClayCSSURL; - private String _defaultMainCSSURL; - private String _defaultMainJSURL; private Device _device; private long _doAsGroupId; private String _doAsUserId = StringPool.BLANK; diff --git a/portal-kernel/src/com/liferay/portal/kernel/theme/packageinfo b/portal-kernel/src/com/liferay/portal/kernel/theme/packageinfo index eaa8f17d37438e..b1299c48c49986 100644 --- a/portal-kernel/src/com/liferay/portal/kernel/theme/packageinfo +++ b/portal-kernel/src/com/liferay/portal/kernel/theme/packageinfo @@ -1 +1 @@ -version 13.1.0 \ No newline at end of file +version 14.0.0 \ No newline at end of file