Bugfix for ccm-navigation and redirect to language specific URL: If the URL points to a JSP (sitemap.jsp in particular) do no redirect.
git-svn-id: https://svn.libreccm.org/ccm/trunk@5104 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
ae645cb299
commit
c9bf0919b0
|
|
@ -77,67 +77,76 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
||||||
s_log.debug("Resolving " + path);
|
s_log.debug("Resolving " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CMSConfig.getInstanceOf().getUseLanguageExtension()
|
if (!path.endsWith(".jsp")) {
|
||||||
&& path.matches("(.*)/index\\.[a-zA-Z]{2}")) {
|
if (CMSConfig.getInstanceOf().getUseLanguageExtension()
|
||||||
|
&& path.matches("(.*)/index\\.[a-zA-Z]{2}")) {
|
||||||
|
|
||||||
final String lang = path.substring(path.length() - 2);
|
final String lang = path.substring(path.length() - 2);
|
||||||
path = path.substring(0, path.length() - "index.$$".length());
|
path = path.substring(0, path.length() - "index.$$".length());
|
||||||
GlobalizationHelper.setSelectedLocale(lang);
|
GlobalizationHelper.setSelectedLocale(lang);
|
||||||
} else {
|
|
||||||
|
|
||||||
String lang;
|
|
||||||
if (GlobalizationHelper.getSelectedLocale(sreq) == null) {
|
|
||||||
lang = GlobalizationHelper.getNegotiatedLocale().getLanguage();
|
|
||||||
} else {
|
} else {
|
||||||
lang = GlobalizationHelper.getSelectedLocale(sreq).getLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
final StringBuffer redirectTo = new StringBuffer();
|
String lang;
|
||||||
|
if (GlobalizationHelper.getSelectedLocale(sreq) == null) {
|
||||||
redirectTo
|
lang = GlobalizationHelper.getNegotiatedLocale()
|
||||||
.append(DispatcherHelper.getRequest().getScheme())
|
.getLanguage();
|
||||||
.append("://")
|
} else {
|
||||||
.append(DispatcherHelper.getRequest().getServerName());
|
lang = GlobalizationHelper.getSelectedLocale(sreq)
|
||||||
|
.getLanguage();
|
||||||
if (DispatcherHelper.getRequest().getServerPort() != 80
|
|
||||||
&& DispatcherHelper.getRequest().getServerPort() != 443) {
|
|
||||||
redirectTo
|
|
||||||
.append(":")
|
|
||||||
.append(DispatcherHelper.getRequest().getServerPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DispatcherHelper.getWebappContext() != null
|
|
||||||
&& !DispatcherHelper.getWebappContext().trim().isEmpty()) {
|
|
||||||
redirectTo.append(DispatcherHelper.getWebappContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Is category available in lang? If not change lang to default language
|
|
||||||
final Category[] cats = resolvePath(getRootCategory(), path);
|
|
||||||
if (cats == null) {
|
|
||||||
lang = KernelConfig.getConfig().getDefaultLanguage();
|
|
||||||
} else {
|
|
||||||
final CategoryLocalizationCollection langs = cats[cats.length
|
|
||||||
- 1]
|
|
||||||
.getCategoryLocalizationCollection();
|
|
||||||
if (!langs.localizationExists(lang)) {
|
|
||||||
lang = KernelConfig.getConfig().getDefaultLanguage();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
redirectTo
|
final StringBuffer redirectTo = new StringBuffer();
|
||||||
.append("/ccm")
|
|
||||||
.append(app.getPath())
|
|
||||||
.append(path)
|
|
||||||
.append("index.")
|
|
||||||
.append(lang);
|
|
||||||
|
|
||||||
sresp.setHeader("Location", redirectTo.toString());
|
redirectTo
|
||||||
try {
|
.append(DispatcherHelper.getRequest().getScheme())
|
||||||
sresp.sendError(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
.append("://")
|
||||||
} catch (IOException ex) {
|
.append(DispatcherHelper.getRequest().getServerName());
|
||||||
throw new RuntimeException(ex);
|
|
||||||
|
if (DispatcherHelper.getRequest().getServerPort() != 80
|
||||||
|
&& DispatcherHelper.getRequest().getServerPort() != 443) {
|
||||||
|
redirectTo
|
||||||
|
.append(":")
|
||||||
|
.append(DispatcherHelper.getRequest().getServerPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DispatcherHelper.getWebappContext() != null
|
||||||
|
&& !DispatcherHelper.getWebappContext().trim().isEmpty()) {
|
||||||
|
redirectTo.append(DispatcherHelper.getWebappContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Is category available in lang? If not change lang to default language
|
||||||
|
final Category[] cats = resolvePath(getRootCategory(), path);
|
||||||
|
if (cats == null) {
|
||||||
|
lang = KernelConfig.getConfig().getDefaultLanguage();
|
||||||
|
} else {
|
||||||
|
final CategoryLocalizationCollection langs
|
||||||
|
= cats[cats.length
|
||||||
|
- 1]
|
||||||
|
.getCategoryLocalizationCollection();
|
||||||
|
if (!langs.localizationExists(lang)) {
|
||||||
|
lang = KernelConfig.getConfig().getDefaultLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectTo
|
||||||
|
.append("/ccm")
|
||||||
|
.append(app.getPath())
|
||||||
|
.append(path);
|
||||||
|
if (!path.endsWith("/")) {
|
||||||
|
redirectTo.append('/');
|
||||||
|
}
|
||||||
|
redirectTo
|
||||||
|
.append("index.")
|
||||||
|
.append(lang);
|
||||||
|
|
||||||
|
sresp.setHeader("Location", redirectTo.toString());
|
||||||
|
try {
|
||||||
|
sresp.sendError(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.equals("/category.jsp")) {
|
if (path.equals("/category.jsp")) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue