aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2013-09-23 16:51:42 +0300
committerVaadin Code Review <review@vaadin.com>2013-09-27 10:33:10 +0000
commita5795f346e077268eb77edef09d902fba57d5804 (patch)
treec33ff81d236ff3fce1c0f2c93b61a58dda9be917
parent649735f755c51e5c11d5ebe984e7a308fe97552a (diff)
downloadvaadin-framework-a5795f346e077268eb77edef09d902fba57d5804.tar.gz
vaadin-framework-a5795f346e077268eb77edef09d902fba57d5804.zip
Prefixes GET parameters in Liferay with portlet namespace #12602
Change-Id: I9939a7af83482e136ed0d146accdeec0cd9f10ea
-rw-r--r--client/src/com/vaadin/client/ApplicationConfiguration.java17
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java2
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java29
-rw-r--r--server/src/com/vaadin/server/communication/PortletBootstrapHandler.java11
-rw-r--r--shared/src/com/vaadin/shared/ApplicationConstants.java4
5 files changed, 58 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index da8f521799..7a70080c7e 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -246,6 +246,23 @@ public class ApplicationConfiguration implements EntryPoint {
ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER) == Boolean.TRUE;
}
+ /**
+ * Return the name of the parameter used to to send data to the service url.
+ * This method should only be called if {@link #useServiceUrlPathParam()} is
+ * true.
+ *
+ * @since 7.1.6
+ * @return The parameter name, by default <code>v-resourcePath</code>
+ */
+ public String getServiceUrlParameterName() {
+ String prefix = getJsoConfiguration(id).getConfigString(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE);
+ if (prefix == null) {
+ prefix = "";
+ }
+ return prefix + ApplicationConstants.V_RESOURCE_PATH;
+ }
+
public String getRootPanelId() {
return id;
}
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 0d9c859ee8..4314602bc2 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -2994,7 +2994,7 @@ public class ApplicationConnection {
if (!path.startsWith("/")) {
path = '/' + path;
}
- String pathParam = ApplicationConstants.V_RESOURCE_PATH + "="
+ String pathParam = conf.getServiceUrlParameterName() + "="
+ URL.encodeQueryString(path);
serviceUrl = addGetParameters(serviceUrl, pathParam);
uidlUri = serviceUrl;
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index d86e5e6507..093a1c9152 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -422,16 +422,37 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
* @return A wrapped version of the PorletRequest
*/
protected VaadinPortletRequest createVaadinRequest(PortletRequest request) {
- String portalInfo = request.getPortalContext().getPortalInfo()
- .toLowerCase();
- if (portalInfo.contains("liferay")) {
+ if (isLiferay(request)) {
return new VaadinLiferayRequest(request, getService());
- } else if (portalInfo.contains("gatein")) {
+ } else if (isGateIn(request)) {
return new VaadinGateinRequest(request, getService());
} else {
return new VaadinPortletRequest(request, getService());
}
+ }
+ /**
+ * Returns true if the portlet request is from Liferay.
+ *
+ * @param request
+ * @return True if Liferay, false otherwise
+ */
+ private static boolean isLiferay(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("liferay");
+ }
+
+ /**
+ * Returns true if the portlet request if from GateIn
+ *
+ * @param request
+ * @return True if GateIn, false otherwise
+ */
+ private static boolean isGateIn(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("gatein");
}
private VaadinPortletResponse createVaadinResponse(PortletResponse response) {
diff --git a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
index 2458951ada..dd6d3c9283 100644
--- a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
+++ b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
@@ -31,6 +31,7 @@ import org.json.JSONObject;
import com.vaadin.server.BootstrapHandler;
import com.vaadin.server.PaintException;
import com.vaadin.server.VaadinPortlet;
+import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
import com.vaadin.server.VaadinPortletRequest;
import com.vaadin.server.VaadinPortletResponse;
import com.vaadin.server.VaadinRequest;
@@ -98,6 +99,8 @@ public class PortletBootstrapHandler extends BootstrapHandler {
JSONObject parameters = super.getApplicationParameters(context);
VaadinPortletResponse response = (VaadinPortletResponse) context
.getResponse();
+ VaadinPortletRequest request = (VaadinPortletRequest) context
+ .getRequest();
MimeResponse portletResponse = (MimeResponse) response
.getPortletResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
@@ -108,6 +111,14 @@ public class PortletBootstrapHandler extends BootstrapHandler {
parameters
.put(ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER, true);
+ // If we are running in Liferay then we need to prefix all parameters
+ // with the portlet namespace
+ if (request instanceof VaadinLiferayRequest) {
+ parameters.put(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE,
+ response.getPortletResponse().getNamespace());
+ }
+
return parameters;
}
} \ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java
index 104f3047a8..4b5dc9140b 100644
--- a/shared/src/com/vaadin/shared/ApplicationConstants.java
+++ b/shared/src/com/vaadin/shared/ApplicationConstants.java
@@ -49,6 +49,10 @@ public class ApplicationConstants implements Serializable {
public static final String SERVICE_URL_PATH_AS_PARAMETER = "usePathParameter";
+ // Denotes the namespace which parameters should be prefixed with when
+ // passed as GET parameters. Currently only used by Liferay.
+ public static final String SERVICE_URL_PARAMETER_NAMESPACE = "pathParameterNS";
+
// Javadocs in ApplicationConfiguration should be updated if this is changed
public static final String V_RESOURCE_PATH = "v-resourcePath";