diff options
author | Artur Signell <artur@vaadin.com> | 2016-03-01 20:03:16 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-03-08 15:37:10 +0000 |
commit | 9a5643bf3b9e5a5f4578b702fab894ee9c715152 (patch) | |
tree | 1ea1c49cd6a8a3d50b8b6342c2ef5c857be963ec /server | |
parent | aaf0420be5ec30ba8562d9b111b6f6b907aa6619 (diff) | |
download | vaadin-framework-9a5643bf3b9e5a5f4578b702fab894ee9c715152.tar.gz vaadin-framework-9a5643bf3b9e5a5f4578b702fab894ee9c715152.zip |
Try to detect Liferay 7 requests correctly (#19645)
Change-Id: I5bc616b216e3ecadc76b8f0ef542e74eb4493bda
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortlet.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 043f95fd7b..5c91b6669c 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -180,6 +180,14 @@ public class VaadinPortlet extends GenericPortlet implements Constants, */ public static class VaadinLiferayRequest extends VaadinHttpAndPortletRequest { + /** + * The PortalUtil class to use. Set to either + * {@link #LIFERAY_6_PORTAL_UTIL} or {@link #LIFERAY_7_PORTAL_UTIL} the + * first time it is needed. + */ + private static String portalUtilClass = null; + private static final String LIFERAY_6_PORTAL_UTIL = "com.liferay.portal.util.PortalUtil"; + private static final String LIFERAY_7_PORTAL_UTIL = "com.liferay.portal.kernel.util.PortalUtil"; public VaadinLiferayRequest(PortletRequest request, VaadinPortletService vaadinService) { @@ -247,19 +255,28 @@ public class VaadinPortlet extends GenericPortlet implements Constants, @Override protected HttpServletRequest getServletRequest(PortletRequest request) { + if (portalUtilClass == null) { + try { + invokeStaticLiferayMethod(LIFERAY_7_PORTAL_UTIL, + "getHttpServletRequest", request, + "javax.portlet.PortletRequest"); + portalUtilClass = LIFERAY_7_PORTAL_UTIL; + } catch (Exception e) { + // Liferay 6 or older + portalUtilClass = LIFERAY_6_PORTAL_UTIL; + } + } try { // httpRequest = PortalUtil.getHttpServletRequest(request); HttpServletRequest httpRequest = (HttpServletRequest) invokeStaticLiferayMethod( - "com.liferay.portal.util.PortalUtil", - "getHttpServletRequest", request, + portalUtilClass, "getHttpServletRequest", request, "javax.portlet.PortletRequest"); // httpRequest = // PortalUtil.getOriginalServletRequest(httpRequest); httpRequest = (HttpServletRequest) invokeStaticLiferayMethod( - "com.liferay.portal.util.PortalUtil", - "getOriginalServletRequest", httpRequest, - "javax.servlet.http.HttpServletRequest"); + portalUtilClass, "getOriginalServletRequest", + httpRequest, "javax.servlet.http.HttpServletRequest"); return httpRequest; } catch (Exception e) { throw new IllegalStateException("Liferay request not detected", |