aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java79
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java81
2 files changed, 83 insertions, 77 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
index bd577bdbd6..d442b1ed17 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
@@ -486,7 +486,8 @@ public class ApplicationServlet extends HttpServlet {
DownloadStream download = null;
// Handles the URI if the application is still running
- download = handleURI(application, window, request, response);
+ download = getApplicationManager(application).handleURI(window,
+ request, response);
// If this is not a download request
if (download == null) {
@@ -1086,82 +1087,6 @@ public class ApplicationServlet extends HttpServlet {
* before any windows URIs are processed and if a DownloadStream is returned
* it is sent to the client.
*
- * @param application
- * the Application owning the URI.
- * @param request
- * the HTTP request instance.
- * @param response
- * the HTTP response to write to.
- * @return boolean <code>true</code> if the request was handled and further
- * processing should be suppressed, <code>false</code> otherwise.
- * @see com.itmill.toolkit.terminal.URIHandler
- */
- private DownloadStream handleURI(Application application, Window window,
- HttpServletRequest request, HttpServletResponse response) {
-
- String uri = request.getPathInfo();
-
- // If no URI is available
- if (uri == null) {
- uri = "";
- } else {
- // Removes the leading /
- while (uri.startsWith("/") && uri.length() > 0) {
- uri = uri.substring(1);
- }
- }
-
- // If using application runner, remove package and class name
- if (isApplicationRunnerServlet) {
- if (uri.contains("/")) {
- uri = uri.replaceFirst(applicationRunnerClassname + "/", "");
- } else {
- uri = "";
- }
- }
-
- // Handles the uri
- try {
- URL context = application.getURL();
- if (window == application.getMainWindow()) {
- DownloadStream stream = null;
- /*
- * Application.handleURI run first. Handles possible
- * ApplicationResources.
- */
- stream = application.handleURI(context, uri);
- if (stream == null) {
- stream = window.handleURI(context, uri);
- }
- return stream;
- } else {
- // Resolve the prefix end inded
- final int index = uri.indexOf('/');
- if (index > 0) {
- String prefix = uri.substring(0, index);
- URL windowContext;
- windowContext = new URL(context, prefix + "/");
- final String windowUri = (uri.length() > prefix.length() + 1) ? uri
- .substring(prefix.length() + 1)
- : "";
- return window.handleURI(windowContext, windowUri);
- } else {
- return null;
- }
- }
-
- } catch (final Throwable t) {
- application.terminalError(new URIHandlerErrorImpl(application, t));
- return null;
- }
- }
-
- /**
- * Handles the requested URI. An application can add handlers to do special
- * processing, when a certain URI is requested. The handlers are invoked
- * before any windows URIs are processed and if a DownloadStream is returned
- * it is sent to the client.
- *
* @param stream
* the download stream.
*
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
index fcdd96dcd9..ced2dd593e 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
@@ -14,6 +14,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.URL;
import java.security.GeneralSecurityException;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
@@ -45,6 +46,7 @@ import com.itmill.toolkit.external.org.apache.commons.fileupload.FileItemStream;
import com.itmill.toolkit.external.org.apache.commons.fileupload.FileUploadException;
import com.itmill.toolkit.external.org.apache.commons.fileupload.ProgressListener;
import com.itmill.toolkit.external.org.apache.commons.fileupload.servlet.ServletFileUpload;
+import com.itmill.toolkit.terminal.DownloadStream;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.Paintable;
import com.itmill.toolkit.terminal.URIHandler;
@@ -1376,4 +1378,83 @@ public class CommunicationManager implements Paintable.RepaintRequestListener {
}
}
+
+ /**
+ * Handles the requested URI. An application can add handlers to do special
+ * processing, when a certain URI is requested. The handlers are invoked
+ * before any windows URIs are processed and if a DownloadStream is returned
+ * it is sent to the client.
+ *
+ * @param application
+ * the Application owning the URI.
+ * @param request
+ * the HTTP request instance.
+ * @param response
+ * the HTTP response to write to.
+ * @return boolean <code>true</code> if the request was handled and further
+ * processing should be suppressed, <code>false</code> otherwise.
+ * @see com.itmill.toolkit.terminal.URIHandler
+ */
+ DownloadStream handleURI(Window window, HttpServletRequest request,
+ HttpServletResponse response) {
+
+ String uri = request.getPathInfo();
+
+ // If no URI is available
+ if (uri == null) {
+ uri = "";
+ } else {
+ // Removes the leading /
+ while (uri.startsWith("/") && uri.length() > 0) {
+ uri = uri.substring(1);
+ }
+ }
+
+ // If using application runner, remove package and class name
+ if (applicationServlet.isApplicationRunnerServlet) {
+ if (uri.contains("/")) {
+ uri = uri
+ .replaceFirst(
+ applicationServlet.applicationRunnerClassname
+ + "/", "");
+ } else {
+ uri = "";
+ }
+ }
+
+ // Handles the uri
+ try {
+ URL context = application.getURL();
+ if (window == application.getMainWindow()) {
+ DownloadStream stream = null;
+ /*
+ * Application.handleURI run first. Handles possible
+ * ApplicationResources.
+ */
+ stream = application.handleURI(context, uri);
+ if (stream == null) {
+ stream = window.handleURI(context, uri);
+ }
+ return stream;
+ } else {
+ // Resolve the prefix end inded
+ final int index = uri.indexOf('/');
+ if (index > 0) {
+ String prefix = uri.substring(0, index);
+ URL windowContext;
+ windowContext = new URL(context, prefix + "/");
+ final String windowUri = (uri.length() > prefix.length() + 1) ? uri
+ .substring(prefix.length() + 1)
+ : "";
+ return window.handleURI(windowContext, windowUri);
+ } else {
+ return null;
+ }
+ }
+
+ } catch (final Throwable t) {
+ application.terminalError(new URIHandlerErrorImpl(application, t));
+ return null;
+ }
+ }
}