summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2010-04-08 08:32:28 +0000
committerHenri Sara <henri.sara@itmill.com>2010-04-08 08:32:28 +0000
commitb3510e3bd466385f472e209f68142fb88ffbc465 (patch)
tree09580a434fdf400c8ce6925c4ce7d727c8d0194d /src
parent970b2e15f026b541e8a6abdddd8cf64fe4f71495 (diff)
downloadvaadin-framework-b3510e3bd466385f472e209f68142fb88ffbc465.tar.gz
vaadin-framework-b3510e3bd466385f472e209f68142fb88ffbc465.zip
#4160 restartApplication support for portlet 2.0 in Liferay and GateIn
svn changeset:12380/svn branch:6.3
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java72
1 files changed, 68 insertions, 4 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 7e5b2159e3..9951f1af8e 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -41,8 +41,11 @@ import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.ResourceURL;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
+import com.liferay.portal.kernel.util.PortalClassInvoker;
import com.liferay.portal.kernel.util.PropsUtil;
import com.vaadin.Application;
import com.vaadin.Application.SystemMessages;
@@ -764,10 +767,10 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
* user not specifically requested to close or restart it.
*/
- final boolean restartApplication = (request
- .getParameter(URL_PARAMETER_RESTART_APPLICATION) != null);
- final boolean closeApplication = (request
- .getParameter(URL_PARAMETER_CLOSE_APPLICATION) != null);
+ final boolean restartApplication = (getHTTPRequestParameter(
+ request, URL_PARAMETER_RESTART_APPLICATION) != null);
+ final boolean closeApplication = (getHTTPRequestParameter(request,
+ URL_PARAMETER_CLOSE_APPLICATION) != null);
if (restartApplication) {
closeApplication(application, request.getPortletSession(false));
@@ -1422,4 +1425,65 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
return value;
}
+ /**
+ * Try to get the value of a HTTP request parameter from a portlet request
+ * using portal specific APIs. It is not possible to get the HTTP request
+ * parameters using the official Portlet 2.0 API.
+ *
+ * @param name
+ * HTTP request parameter name
+ * @return the value of the parameter (empty string if parameter defined
+ * without a value, null if the parameter is not present or
+ * retrieving it failed)
+ */
+ private static String getHTTPRequestParameter(PortletRequest request,
+ String name) {
+ String value = request.getParameter(name);
+ if (value == null) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ if (portalInfo.contains("liferay")) {
+ value = getLiferayHTTPRequestParameter(request, name);
+ } else if (portalInfo.contains("gatein")) {
+ value = getGateInHTTPRequestParameter(request, name);
+ }
+ }
+ return value;
+ }
+
+ private static String getGateInHTTPRequestParameter(PortletRequest request,
+ String name) {
+ String value = null;
+ try {
+ Method getRealReq = request.getClass().getMethod("getRealRequest");
+ HttpServletRequestWrapper origRequest = (HttpServletRequestWrapper) getRealReq
+ .invoke(request);
+ value = origRequest.getParameter(name);
+ } catch (Exception e) {
+ // do nothing - not on GateIn simple-portal
+ }
+ return value;
+ }
+
+ private static String getLiferayHTTPRequestParameter(PortletRequest request, String name) {
+ try {
+ // httpRequest = PortalUtil.getHttpServletRequest(request);
+ HttpServletRequest httpRequest = (HttpServletRequest) PortalClassInvoker
+ .invoke("com.liferay.portal.util.PortalUtil",
+ "getHttpServletRequest", request);
+
+ // httpRequest =
+ // PortalUtil.getOriginalServletRequest(httpRequest);
+ httpRequest = (HttpServletRequest) PortalClassInvoker.invoke(
+ "com.liferay.portal.util.PortalUtil",
+ "getOriginalServletRequest", httpRequest);
+ if (httpRequest != null) {
+ return httpRequest.getParameter(name);
+ }
+ } catch (Exception e) {
+ // ignore and return null - unable to get the original request
+ }
+ return null;
+ }
+
}