]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #5423 Warns serverside if widgetset does not match vaadin version
authorMarc Englund <marc.englund@itmill.com>
Tue, 26 Apr 2011 12:00:55 +0000 (12:00 +0000)
committerMarc Englund <marc.englund@itmill.com>
Tue, 26 Apr 2011 12:00:55 +0000 (12:00 +0000)
svn changeset:18464/svn branch:6.6

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
src/com/vaadin/terminal/gwt/server/Constants.java

index 3d2bd950ac327bb48d1270bb21e3a11a05ece149..d5d9578bd9b83ec37b5ac21c1f0755c25ce35d76 100755 (executable)
@@ -352,6 +352,7 @@ public class ApplicationConnection {
         int screenHeight = BrowserInfo.get().getScreenHeight();
         int tzOffset = BrowserInfo.get().getTimezoneOffset();
         int rtzOffset = BrowserInfo.get().getRawTimezoneOffset();
+        String widgetsetVersion = ApplicationConfiguration.VERSION;
 
         String token = History.getToken();
 
@@ -361,7 +362,8 @@ public class ApplicationConnection {
         String parameters = "repaintAll=1&" + "sh=" + screenHeight + "&sw="
                 + screenWidth + "&cw=" + clientWidth + "&ch=" + clientHeight
                 + "&vw=" + offsetWidth + "&vh=" + offsetHeight + "&fr=" + token
-                + "&tzo=" + tzOffset + "&rtzo=" + rtzOffset;
+                + "&tzo=" + tzOffset + "&rtzo=" + rtzOffset + "&wsver="
+                + widgetsetVersion;
         return parameters;
     }
 
index 8717a080b83ae9e373d4f1c639380e99f7fe3910..ed7ba10ec4a3d0ac76d5ce93249eccc2b12ecf63 100644 (file)
@@ -127,6 +127,21 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
         }
     }
 
+    /**
+     * Checks that the version reported by the client (widgetset) matches that
+     * of the server.
+     * 
+     * @param request
+     */
+    private void checkWidgetsetVersion(PortletRequest request) {
+        if (!AbstractApplicationServlet.VERSION.equals(getHTTPRequestParameter(
+                request, "wsver"))) {
+            logger.warning(String.format(WIDGETSET_MISMATCH_INFO,
+                    AbstractApplicationServlet.VERSION,
+                    getHTTPRequestParameter(request, "wsver")));
+        }
+    }
+
     private void checkProductionMode() {
         // Check if the application is in production mode.
         // We are in production mode if Debug=false or productionMode=true
@@ -431,6 +446,10 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
                     return;
                 } else if (requestType == RequestType.UIDL) {
                     // Handles AJAX UIDL requests
+                    if (isRepaintAll(request)) {
+                        // warn if versions do not match
+                        checkWidgetsetVersion(request);
+                    }
                     applicationManager.handleUidlRequest(
                             (ResourceRequest) request,
                             (ResourceResponse) response, this, window);
index 73b493ed417fe590018ad26422be00e1c756ea12..6752f6013bf4c2fc2015d9c3bd0c42ad7aafdb4b 100644 (file)
@@ -236,6 +236,19 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
         }
     }
 
+    /**
+     * Checks that the version reported by the client (widgetset) matches that
+     * of the server.
+     * 
+     * @param request
+     */
+    private void checkWidgetsetVersion(HttpServletRequest request) {
+        if (!VERSION.equals(request.getParameter("wsver"))) {
+            logger.warning(String.format(WIDGETSET_MISMATCH_INFO, VERSION,
+                    request.getParameter("wsver")));
+        }
+    }
+
     private void checkProductionMode() {
         // Check if the application is in production mode.
         // We are in production mode if Debug=false or productionMode=true
@@ -399,6 +412,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
             return;
         }
 
+        if (isRepaintAll(request)) {
+            // warn if versions do not match
+            checkWidgetsetVersion(request);
+        }
+
         Application application = null;
         boolean transactionStarted = false;
         boolean requestStarted = false;
index b23a9c1284fcec5143d750abff71220ac6ce7002..d60d723e2457ec58f0f3901b47be86d538365037 100644 (file)
@@ -29,6 +29,15 @@ public interface Constants {
             + "in web.xml. The default of 1h will be used.\n"
             + "===========================================================";
 
+    static final String WIDGETSET_MISMATCH_INFO = "\n"
+            + "=================================================================\n"
+            + "The widgetset in use does not seem to be built for the Vaadin\n"
+            + "version in use. This might cause strange problems - a\n"
+            + "recompile/deploy is strongly recommended.\n"
+            + " Vaadin version: %s\n"
+            + " Widgetset version: %s\n"
+            + "=================================================================";
+
     static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication";
     static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication";
     static final String URL_PARAMETER_REPAINT_ALL = "repaintAll";