]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use constants for magic strings and add / to end of UIDL url (#9168)
authorLeif Åstrand <leif@vaadin.com>
Tue, 31 Jul 2012 08:41:10 +0000 (11:41 +0300)
committerLeif Åstrand <leif@vaadin.com>
Tue, 31 Jul 2012 08:41:10 +0000 (11:41 +0300)
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java
src/com/vaadin/terminal/gwt/server/Constants.java
src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java

index 9992a6f27d2a6928c81bdedb4ab6392b59bebef5..fb7af1404c0651e5bfe67106b68fea72e854721f 100644 (file)
@@ -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);
index 3b65c506f54ec02eba2720c0a722fbc4ddc2fa3d..9a1a2f9c16c5959e71cd562e8ebc1fb50edaa928 100644 (file)
@@ -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;
 
     }
 
index 73d45f62b10d9d7c4b6fd5b9703a83a2b83d3225..3a33621d108fb23ca5fb792b04d2df10dd553a31 100644 (file)
@@ -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;
         }
 
     }
index 9e6b2c775b980502939c7e1e55ee1728af73cf21..7efb0205acaf2dcb21e0736571a1309d98db46c8 100644 (file)
@@ -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;
index 55f27566047fe664340d66c12f292786529f896b..91d9371d6a9954d529f5410a46eaace5fb48e025 100644 (file)
@@ -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);
     }
 
 }