summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-07-31 11:41:10 +0300
committerLeif Åstrand <leif@vaadin.com>2012-07-31 11:41:10 +0300
commitaeb7c094e11ab338a800a63602bda9e797752e22 (patch)
tree1607abddb38f5add0245477071a7c6b5d04d5b6e
parent42193afeb27b4722a0d48517d33ea183080bfe59 (diff)
downloadvaadin-framework-aeb7c094e11ab338a800a63602bda9e797752e22.tar.gz
vaadin-framework-aeb7c094e11ab338a800a63602bda9e797752e22.zip
Use constants for magic strings and add / to end of UIDL url (#9168)
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConnection.java23
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java6
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java8
-rw-r--r--src/com/vaadin/terminal/gwt/server/Constants.java2
-rw-r--r--src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java4
5 files changed, 28 insertions, 15 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 9992a6f27d..fb7af1404c 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -78,11 +78,18 @@ import com.vaadin.terminal.gwt.server.AbstractCommunicationManager;
* Entry point classes (widgetsets) define <code>onModuleLoad()</code>.
*/
public class ApplicationConnection {
+ public static final String APP_REQUEST_PATH = "APP/";
+
+ public static final String UIDL_REQUEST_PATH = "UIDL/";
+
+ public static final String APP_PROTOCOL_PREFIX = "app://";
+
public static final String V_RESOURCE_PATH = "v-resourcePath";
- private static final String CONNECTOR_PROTOCOL_PREFIX = "connector://";
+ public static final String CONNECTOR_PROTOCOL_PREFIX = "connector://";
- public static final String CONNECTOR_RESOURCE_PREFIX = "APP/CONNECTOR";
+ public static final String CONNECTOR_RESOURCE_PREFIX = APP_REQUEST_PATH
+ + "CONNECTOR";
// This indicates the whole page is generated by us (not embedded)
public static final String GENERATED_BODY_CLASSNAME = "v-generated-body";
@@ -515,7 +522,7 @@ public class ApplicationConnection {
final String payload = uidlSecurityKey + VAR_BURST_SEPARATOR
+ requestData;
VConsole.log("Making UIDL Request with params: " + payload);
- String uri = translateVaadinUri("app://UIDL");
+ String uri = translateVaadinUri(APP_PROTOCOL_PREFIX + UIDL_REQUEST_PATH);
if (extraParams != null && extraParams.length() > 0) {
uri = addGetParameters(uri, extraParams);
@@ -2301,12 +2308,13 @@ public class ApplicationConnection {
// getAppUri *should* always end with /
// substring *should* always start with / (connector:///foo.bar
// without connector://)
- uidlUri = "app://" + CONNECTOR_RESOURCE_PREFIX
+ uidlUri = APP_PROTOCOL_PREFIX + CONNECTOR_RESOURCE_PREFIX
+ uidlUri.substring(CONNECTOR_PROTOCOL_PREFIX.length());
// Let translation of app:// urls take care of the rest
}
- if (uidlUri.startsWith("app://")) {
- String relativeUrl = uidlUri.substring(6);
+ if (uidlUri.startsWith(APP_PROTOCOL_PREFIX)) {
+ String relativeUrl = uidlUri
+ .substring(APP_PROTOCOL_PREFIX.length());
if (getConfiguration().usePortletURLs()) {
// Should put path in v-resourcePath parameter and append query
// params to base portlet url
@@ -2314,6 +2322,9 @@ public class ApplicationConnection {
String path = parts[0];
String url = getConfiguration().getPortletResourceUrl();
+
+ // If there's a "?" followed by something, append it as a query
+ // string to the base URL
if (parts.length > 1) {
String appUrlParams = parts[1];
url = addGetParameters(url, appUrlParams);
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 3b65c506f5..9a1a2f9c16 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -1284,7 +1284,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
}
- return "connector:///" + name;
+ return ApplicationConnection.CONNECTOR_PROTOCOL_PREFIX + "/" + name;
}
/**
@@ -2340,8 +2340,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
streamVariableToSeckey.put(value, seckey);
}
- return "app://" + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/"
- + seckey;
+ return ApplicationConnection.APP_PROTOCOL_PREFIX
+ + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + seckey;
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java
index 73d45f62b1..3a33621d10 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpSessionBindingListener;
import com.vaadin.Application;
import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.ApplicationResource;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
/**
* Base class for web application contexts (including portlet contexts) that
@@ -180,7 +181,8 @@ public abstract class AbstractWebApplicationContext implements
final String filename = resource.getFilename();
if (filename == null) {
- return "app://APP/" + mapKey + "/";
+ return ApplicationConnection.APP_PROTOCOL_PREFIX
+ + ApplicationConnection.APP_REQUEST_PATH + mapKey + "/";
} else {
// #7738 At least Tomcat and JBoss refuses requests containing
// encoded slashes or backslashes in URLs. Application resource URLs
@@ -188,7 +190,9 @@ public abstract class AbstractWebApplicationContext implements
// in the future.
String encodedFileName = urlEncode(filename).replace("%2F", "/")
.replace("%5C", "\\");
- return "app://APP/" + mapKey + "/" + encodedFileName;
+ return ApplicationConnection.APP_PROTOCOL_PREFIX
+ + ApplicationConnection.APP_REQUEST_PATH + mapKey + "/"
+ + encodedFileName;
}
}
diff --git a/src/com/vaadin/terminal/gwt/server/Constants.java b/src/com/vaadin/terminal/gwt/server/Constants.java
index 9e6b2c775b..7efb0205ac 100644
--- a/src/com/vaadin/terminal/gwt/server/Constants.java
+++ b/src/com/vaadin/terminal/gwt/server/Constants.java
@@ -54,8 +54,6 @@ public interface Constants {
static final int MAX_BUFFER_SIZE = 64 * 1024;
- static final String AJAX_UIDL_URI = "/UIDL";
-
final String THEME_DIRECTORY_PATH = "VAADIN/themes/";
static final int DEFAULT_THEME_CACHETIME = 1000 * 60 * 60 * 24;
diff --git a/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java
index 55f2756604..91d9371d6a 100644
--- a/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java
+++ b/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java
@@ -103,11 +103,11 @@ class ServletPortletHelper implements Serializable {
}
public static boolean isUIDLRequest(WrappedRequest request) {
- return hasPathPrefix(request, Constants.AJAX_UIDL_URI);
+ return hasPathPrefix(request, ApplicationConnection.UIDL_REQUEST_PATH);
}
public static boolean isApplicationResourceRequest(WrappedRequest request) {
- return hasPathPrefix(request, "APP/");
+ return hasPathPrefix(request, ApplicationConnection.APP_REQUEST_PATH);
}
}