Skip to content

Commit

Permalink
LPS-132769 Use request i18n error path attribute, if present, to buil…
Browse files Browse the repository at this point in the history
…d error forward redirect with properly i18n locale.
  • Loading branch information
lfbesada authored and brianchandotcom committed Jun 23, 2021
1 parent d6b61ef commit 70bb903
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions portal-impl/src/com/liferay/portal/util/PortalImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -6732,13 +6732,17 @@ else if (_log.isWarnEnabled()) {
Validator.isNotNull(
PropsValues.SITES_FRIENDLY_URL_PAGE_NOT_FOUND)) {

redirect = PropsValues.SITES_FRIENDLY_URL_PAGE_NOT_FOUND;
redirect = _get18nErrorRedirect(
httpServletRequest,
PropsValues.SITES_FRIENDLY_URL_PAGE_NOT_FOUND);
}
else if ((exception instanceof NoSuchLayoutException) &&
Validator.isNotNull(
PropsValues.LAYOUT_FRIENDLY_URL_PAGE_NOT_FOUND)) {

redirect = PropsValues.LAYOUT_FRIENDLY_URL_PAGE_NOT_FOUND;
redirect = _get18nErrorRedirect(
httpServletRequest,
PropsValues.LAYOUT_FRIENDLY_URL_PAGE_NOT_FOUND);

httpServletRequest.setAttribute(
NoSuchLayoutException.class.getName(), Boolean.TRUE);
Expand Down Expand Up @@ -8247,6 +8251,19 @@ private boolean _containsHostname(
return false;
}

private String _get18nErrorRedirect(
HttpServletRequest httpServletRequest, String redirect) {

String i18nErrorPath = GetterUtil.getString(
httpServletRequest.getAttribute(WebKeys.I18N_ERROR_PATH));

if (Validator.isNull(i18nErrorPath)) {
return redirect;
}

return i18nErrorPath.concat(redirect);
}

private Map<Locale, String> _getAlternateURLs(
String canonicalURL, ThemeDisplay themeDisplay, Layout layout,
Set<Locale> availableLocales)
Expand Down

0 comments on commit 70bb903

Please sign in to comment.