From 6335562c72fb193a2835a3a09b617aa6c90efea6 Mon Sep 17 00:00:00 2001
From: Leif Åstrand
true
if a {@link RequestHandler} has
@@ -2406,8 +2406,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
*
* @since 7.0
*/
- protected boolean handleOtherRequest(WrappedRequest request,
- WrappedResponse response) throws IOException {
+ protected boolean handleOtherRequest(VaadinRequest request,
+ VaadinResponse response) throws IOException {
// Use a copy to avoid ConcurrentModificationException
for (RequestHandler handler : new ArrayListtrue
if the same UI instance should be reused e.g.
* when the browser window is refreshed.
*/
- public boolean isPreservedOnRefresh(WrappedRequest request,
+ public boolean isPreservedOnRefresh(VaadinRequest request,
Class extends UI> uiClass);
/**
@@ -51,14 +50,14 @@ public interface UIProvider {
* defined for the UI class.
*
* @param request
- * the wrapped request for which to get a widgetset
+ * the Vaadin request for which to get a widgetset
* @param uiClass
* the UI class to get a widgetset for
* @return the name of the widgetset, or null
if the default
* widgetset should be used
*
*/
- public String getWidgetset(WrappedRequest request,
+ public String getWidgetset(VaadinRequest request,
Class extends UI> uiClass);
/**
@@ -73,8 +72,7 @@ public interface UIProvider {
* should be used
*
*/
- public String getTheme(WrappedRequest request,
- Class extends UI> uiClass);
+ public String getTheme(VaadinRequest request, Class extends UI> uiClass);
/**
* Finds an existing {@link UI} for a request.
@@ -85,14 +83,14 @@ public interface UIProvider {
*
* If no UI provider returns an existing UI, the framework does also check
* the window.name for an existing instance with
- * {@link #isPreservedOnRefresh(WrappedRequest, Class)} before falling back to
- * bootstrapping and creating a new UI instance.
+ * {@link #isPreservedOnRefresh(VaadinRequest, Class)} before falling back
+ * to bootstrapping and creating a new UI instance.
*
* @param request
* the request for which a UI is desired
* @return a UI belonging to the request, or
+ * Either this method or getWriter() may be called to write the response,
+ * not both.
+ *
+ * @return a
+ * Either this method or getOutputStream() may be called to write the
+ * response, not both.
+ *
+ * @return a
- * Either this method or getWriter() may be called to write the response,
- * not both.
- *
- * @return a
- * Either this method or getOutputStream() may be called to write the
- * response, not both.
- *
- * @return a
* When a new UI instance is needed, typically because the user opens a URL in a
* browser window which points to {@link VaadinServlet},
- * {@link VaadinSession#getUIForRequest(WrappedRequest)} is invoked to get a UI.
+ * {@link VaadinSession#getUIForRequest(VaadinRequest)} is invoked to get a UI.
* That method does by default create a UI according to the
* {@value VaadinSession#UI_PARAMETER} parameter from web.xml.
*
* After a UI has been created by the application, it is initialized using
- * {@link #init(WrappedRequest)}. This method is intended to be overridden by
- * the developer to add components to the user interface and initialize
+ * {@link #init(VaadinRequest)}. This method is intended to be overridden by the
+ * developer to add components to the user interface and initialize
* non-component functionality. The component hierarchy is initialized by
* passing a {@link ComponentContainer} with the main layout of the view to
* {@link #setContent(ComponentContainer)}.
*
- * The {@link WrappedRequest} can be used to get information about the
+ * The {@link VaadinRequest} can be used to get information about the
* request that caused this UI to be created. {@link BrowserDetails} will be
* available in the request.
* null
if this UI
* provider doesn't have an existing UI for the request.
*/
- public UI getExistingUI(WrappedRequest request);
+ public UI getExistingUI(VaadinRequest request);
}
diff --git a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
index 38ac14b2d2..8525dc29ca 100644
--- a/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
+++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java
@@ -35,7 +35,7 @@ public class UnsupportedBrowserHandler implements RequestHandler {
@Override
public boolean handleRequest(VaadinSession session,
- WrappedRequest request, WrappedResponse response)
+ VaadinRequest request, VaadinResponse response)
throws IOException {
if (request.getBrowserDetails() != null) {
@@ -62,8 +62,8 @@ public class UnsupportedBrowserHandler implements RequestHandler {
* @param response
* @throws IOException
*/
- protected void writeBrowserTooOldPage(WrappedRequest request,
- WrappedResponse response) throws IOException {
+ protected void writeBrowserTooOldPage(VaadinRequest request,
+ VaadinResponse response) throws IOException {
Writer page = response.getWriter();
WebBrowser b = request.getBrowserDetails().getWebBrowser();
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 2027431f0b..83d152d653 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -88,7 +88,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
@Override
- public String getConfiguredWidgetset(WrappedRequest request) {
+ public String getConfiguredWidgetset(VaadinRequest request) {
String widgetset = getDeploymentConfiguration()
.getApplicationOrSystemProperty(PARAMETER_WIDGETSET, null);
@@ -96,7 +96,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
if (widgetset == null) {
// If no widgetset defined for the application, check the
// portal property
- widgetset = WrappedPortletRequest.cast(request)
+ widgetset = VaadinPortletRequest.cast(request)
.getPortalProperty(PORTAL_PARAMETER_VAADIN_WIDGETSET);
}
@@ -109,10 +109,10 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
@Override
- public String getConfiguredTheme(WrappedRequest request) {
+ public String getConfiguredTheme(VaadinRequest request) {
// is the default theme defined by the portal?
- String themeName = WrappedPortletRequest.cast(request)
+ String themeName = VaadinPortletRequest.cast(request)
.getPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_THEME);
if (themeName == null) {
@@ -124,13 +124,13 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
@Override
- public boolean isStandalone(WrappedRequest request) {
+ public boolean isStandalone(VaadinRequest request) {
return false;
}
@Override
- public String getStaticFileLocation(WrappedRequest request) {
- String staticFileLocation = WrappedPortletRequest.cast(request)
+ public String getStaticFileLocation(VaadinRequest request) {
+ String staticFileLocation = VaadinPortletRequest.cast(request)
.getPortalProperty(
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH);
if (staticFileLocation != null) {
@@ -179,7 +179,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
@Override
- protected boolean requestCanCreateSession(WrappedRequest request) {
+ protected boolean requestCanCreateSession(VaadinRequest request) {
RequestType requestType = getRequestType(request);
if (requestType == RequestType.RENDER) {
// In most cases the first request is a render request that
@@ -205,12 +205,12 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected RequestType getRequestType(WrappedRequest request) {
+ protected RequestType getRequestType(VaadinRequest request) {
RequestType type = (RequestType) request
.getAttribute(RequestType.class.getName());
if (type == null) {
type = getPortlet().getRequestType(
- WrappedPortletRequest.cast(request));
+ VaadinPortletRequest.cast(request));
request.setAttribute(RequestType.class.getName(), type);
}
return type;
@@ -223,9 +223,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
public static PortletRequest getCurrentPortletRequest() {
- WrappedRequest currentRequest = VaadinService.getCurrentRequest();
+ VaadinRequest currentRequest = VaadinService.getCurrentRequest();
try {
- WrappedPortletRequest request = WrappedPortletRequest
+ VaadinPortletRequest request = VaadinPortletRequest
.cast(currentRequest);
if (request != null) {
return request.getPortletRequest();
@@ -237,21 +237,21 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
}
- public static WrappedPortletResponse getCurrentResponse() {
- return (WrappedPortletResponse) VaadinService.getCurrentResponse();
+ public static VaadinPortletResponse getCurrentResponse() {
+ return (VaadinPortletResponse) VaadinService.getCurrentResponse();
}
@Override
- protected VaadinSession createVaadinSession(WrappedRequest request)
+ protected VaadinSession createVaadinSession(VaadinRequest request)
throws ServiceException {
return new VaadinPortletSession();
}
}
- public static class WrappedHttpAndPortletRequest extends
- WrappedPortletRequest {
+ public static class VaadinHttpAndPortletRequest extends
+ VaadinPortletRequest {
- public WrappedHttpAndPortletRequest(PortletRequest request,
+ public VaadinHttpAndPortletRequest(PortletRequest request,
HttpServletRequest originalRequest, PortletService vaadinService) {
super(request, vaadinService);
this.originalRequest = originalRequest;
@@ -292,9 +292,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
}
- public static class WrappedGateinRequest extends
- WrappedHttpAndPortletRequest {
- public WrappedGateinRequest(PortletRequest request,
+ public static class VaadinGateinRequest extends VaadinHttpAndPortletRequest {
+ public VaadinGateinRequest(PortletRequest request,
PortletService vaadinService) {
super(request, getOriginalRequest(request), vaadinService);
}
@@ -314,10 +313,10 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
}
- public static class WrappedLiferayRequest extends
- WrappedHttpAndPortletRequest {
+ public static class VaadinLiferayRequest extends
+ VaadinHttpAndPortletRequest {
- public WrappedLiferayRequest(PortletRequest request,
+ public VaadinLiferayRequest(PortletRequest request,
PortletService vaadinService) {
super(request, getOriginalRequest(request), vaadinService);
}
@@ -358,11 +357,11 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
@Override
- public void criticalNotification(WrappedRequest request,
- WrappedResponse response, String cap, String msg,
+ public void criticalNotification(VaadinRequest request,
+ VaadinResponse response, String cap, String msg,
String details, String outOfSyncURL) throws IOException {
- portlet.criticalNotification(WrappedPortletRequest.cast(request),
- (WrappedPortletResponse) response, cap, msg, details,
+ portlet.criticalNotification(VaadinPortletRequest.cast(request),
+ (VaadinPortletResponse) response, cap, msg, details,
outOfSyncURL);
}
}
@@ -465,30 +464,30 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
/**
- * @param wrappedRequest
+ * @param vaadinRequest
* @return
*
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected RequestType getRequestType(WrappedPortletRequest wrappedRequest) {
- PortletRequest request = wrappedRequest.getPortletRequest();
+ protected RequestType getRequestType(VaadinPortletRequest vaadinRequest) {
+ PortletRequest request = vaadinRequest.getPortletRequest();
if (request instanceof RenderRequest) {
return RequestType.RENDER;
} else if (request instanceof ResourceRequest) {
ResourceRequest resourceRequest = (ResourceRequest) request;
- if (ServletPortletHelper.isUIDLRequest(wrappedRequest)) {
+ if (ServletPortletHelper.isUIDLRequest(vaadinRequest)) {
return RequestType.UIDL;
} else if (isBrowserDetailsRequest(resourceRequest)) {
return RequestType.BROWSER_DETAILS;
- } else if (ServletPortletHelper.isFileUploadRequest(wrappedRequest)) {
+ } else if (ServletPortletHelper.isFileUploadRequest(vaadinRequest)) {
return RequestType.FILE_UPLOAD;
} else if (ServletPortletHelper
- .isConnectorResourceRequest(wrappedRequest)) {
+ .isConnectorResourceRequest(vaadinRequest)) {
return RequestType.CONNECTOR_RESOURCE;
- } else if (ServletPortletHelper.isAppRequest(wrappedRequest)) {
+ } else if (ServletPortletHelper.isAppRequest(vaadinRequest)) {
return RequestType.APP;
- } else if (ServletPortletHelper.isHeartbeatRequest(wrappedRequest)) {
+ } else if (ServletPortletHelper.isHeartbeatRequest(vaadinRequest)) {
return RequestType.HEARTBEAT;
} else if (isDummyRequest(resourceRequest)) {
return RequestType.DUMMY;
@@ -534,15 +533,15 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
AbstractApplicationPortletWrapper portletWrapper = new AbstractApplicationPortletWrapper(
this);
- WrappedPortletRequest wrappedRequest = createWrappedRequest(request);
+ VaadinPortletRequest vaadinRequest = createVaadinRequest(request);
- WrappedPortletResponse wrappedResponse = new WrappedPortletResponse(
+ VaadinPortletResponse vaadinResponse = new VaadinPortletResponse(
response, getVaadinService());
- getVaadinService().setCurrentInstances(wrappedRequest,
- wrappedResponse);
+ getVaadinService().setCurrentInstances(vaadinRequest,
+ vaadinResponse);
- RequestType requestType = getRequestType(wrappedRequest);
+ RequestType requestType = getRequestType(vaadinRequest);
if (requestType == RequestType.UNKNOWN) {
handleUnknownRequest(request, response);
@@ -571,7 +570,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// redirectToApplication??
vaadinSession = (VaadinPortletSession) getVaadinService()
- .findVaadinSession(wrappedRequest);
+ .findVaadinSession(vaadinRequest);
if (vaadinSession == null) {
return;
}
@@ -584,17 +583,17 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
if (requestType == RequestType.CONNECTOR_RESOURCE) {
communicationManager.serveConnectorResource(
- wrappedRequest, wrappedResponse);
+ vaadinRequest, vaadinResponse);
return;
} else if (requestType == RequestType.HEARTBEAT) {
communicationManager.handleHeartbeatRequest(
- wrappedRequest, wrappedResponse, vaadinSession);
+ vaadinRequest, vaadinResponse, vaadinSession);
return;
}
/* Update browser information from request */
vaadinSession.getBrowser().updateRequestDetails(
- wrappedRequest);
+ vaadinRequest);
sessionProcessed = true;
@@ -610,7 +609,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// Both action requests and render requests are ok
// without a UI as they render the initial HTML
// and then do a second request
- uI = vaadinSession.getUIForRequest(wrappedRequest);
+ uI = vaadinSession.getUIForRequest(vaadinRequest);
break;
case BROWSER_DETAILS:
// Should not try to find a UI here as the
@@ -623,7 +622,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// Not related to any UI
break;
default:
- uI = vaadinSession.getUIForRequest(wrappedRequest);
+ uI = vaadinSession.getUIForRequest(vaadinRequest);
}
// if window not found, not a problem - use null
} finally {
@@ -655,19 +654,19 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// UI is resolved in handleFileUpload by
// PortletCommunicationManager
communicationManager.handleFileUpload(vaadinSession,
- wrappedRequest, wrappedResponse);
+ vaadinRequest, vaadinResponse);
return;
} else if (requestType == RequestType.BROWSER_DETAILS) {
communicationManager.handleBrowserDetailsRequest(
- wrappedRequest, wrappedResponse, vaadinSession);
+ vaadinRequest, vaadinResponse, vaadinSession);
return;
} else if (requestType == RequestType.UIDL) {
// Handles AJAX UIDL requests
- communicationManager.handleUidlRequest(wrappedRequest,
- wrappedResponse, portletWrapper, uI);
+ communicationManager.handleUidlRequest(vaadinRequest,
+ vaadinResponse, portletWrapper, uI);
return;
} else {
- handleOtherRequest(wrappedRequest, wrappedResponse,
+ handleOtherRequest(vaadinRequest, vaadinResponse,
requestType, vaadinSession,
communicationManager);
}
@@ -681,7 +680,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
getLogger()
.fine("General security exception, the security key was probably incorrect.");
} catch (final Throwable e) {
- handleServiceException(wrappedRequest, wrappedResponse,
+ handleServiceException(vaadinRequest, vaadinResponse,
vaadinSession, e);
} finally {
@@ -700,22 +699,21 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
}
/**
- * Wraps the request in a (possibly portal specific) wrapped portlet
- * request.
+ * Wraps the request in a (possibly portal specific) Vaadin portlet request.
*
* @param request
* The original PortletRequest
* @return A wrapped version of the PorletRequest
*/
- protected WrappedPortletRequest createWrappedRequest(PortletRequest request) {
+ protected VaadinPortletRequest createVaadinRequest(PortletRequest request) {
String portalInfo = request.getPortalContext().getPortalInfo()
.toLowerCase();
if (portalInfo.contains("liferay")) {
- return new WrappedLiferayRequest(request, getVaadinService());
+ return new VaadinLiferayRequest(request, getVaadinService());
} else if (portalInfo.contains("gatein")) {
- return new WrappedGateinRequest(request, getVaadinService());
+ return new VaadinGateinRequest(request, getVaadinService());
} else {
- return new WrappedPortletRequest(request, getVaadinService());
+ return new VaadinPortletRequest(request, getVaadinService());
}
}
@@ -746,8 +744,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
* @throws IOException
* @throws MalformedURLException
*/
- private void handleOtherRequest(WrappedPortletRequest request,
- WrappedResponse response, RequestType requestType,
+ private void handleOtherRequest(VaadinPortletRequest request,
+ VaadinResponse response, RequestType requestType,
VaadinSession vaadinSession,
PortletCommunicationManager communicationManager)
throws PortletException, IOException, MalformedURLException {
@@ -832,8 +830,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
handleRequest(request, response);
}
- private void handleServiceException(WrappedPortletRequest request,
- WrappedPortletResponse response, VaadinSession vaadinSession,
+ private void handleServiceException(VaadinPortletRequest request,
+ VaadinPortletResponse response, VaadinSession vaadinSession,
Throwable e) throws IOException, PortletException {
// TODO Check that this error handler is working when running inside a
// portlet
@@ -898,8 +896,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- void criticalNotification(WrappedPortletRequest request,
- WrappedPortletResponse response, String caption, String message,
+ void criticalNotification(VaadinPortletRequest request,
+ VaadinPortletResponse response, String caption, String message,
String details, String url) throws IOException {
// clients JS app is still running, but server application either
diff --git a/server/src/com/vaadin/server/VaadinPortletRequest.java b/server/src/com/vaadin/server/VaadinPortletRequest.java
new file mode 100644
index 0000000000..b0a16d01a4
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinPortletRequest.java
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.ClientDataRequest;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.ResourceRequest;
+
+import com.vaadin.server.VaadinPortlet.PortletService;
+import com.vaadin.shared.ApplicationConstants;
+
+/**
+ * Wrapper for {@link PortletRequest} and its subclasses.
+ *
+ * @author Vaadin Ltd.
+ * @since 7.0
+ *
+ * @see VaadinRequest
+ * @see VaadinPortletResponse
+ */
+public class VaadinPortletRequest implements VaadinRequest {
+
+ private final PortletRequest request;
+ private final PortletService vaadinService;
+
+ /**
+ * Wraps a portlet request and an associated vaadin service
+ *
+ * @param request
+ * the portlet request to wrap
+ * @param vaadinService
+ * the associated vaadin service
+ */
+ public VaadinPortletRequest(PortletRequest request,
+ PortletService vaadinService) {
+ this.request = request;
+ this.vaadinService = vaadinService;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ return request.getAttribute(name);
+ }
+
+ @Override
+ public int getContentLength() {
+ try {
+ return ((ClientDataRequest) request).getContentLength();
+ } catch (ClassCastException e) {
+ throw new IllegalStateException(
+ "Content lenght only available for ClientDataRequests");
+ }
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ return ((ClientDataRequest) request).getPortletInputStream();
+ } catch (ClassCastException e) {
+ throw new IllegalStateException(
+ "Input data only available for ClientDataRequests");
+ }
+ }
+
+ @Override
+ public String getParameter(String name) {
+ return request.getParameter(name);
+ }
+
+ @Override
+ public Mapnull
if
+ * the property is not defined
+ */
+ public String getPortalProperty(String name) {
+ return request.getPortalContext().getProperty(name);
+ }
+
+ @Override
+ public PortletService getVaadinService() {
+ return vaadinService;
+ }
+
+ /**
+ * Helper method to get a {@link VaadinPortletRequest} from a
+ * {@link VaadinRequest}. Aside from casting, this method also takes care of
+ * situations where there's another level of wrapping.
+ *
+ * @param request
+ * a Vaadin request
+ * @return a Vaadin portlet request
+ * @throws ClassCastException
+ * if the Vaadin request doesn't wrap a portlet request
+ */
+ public static VaadinPortletRequest cast(VaadinRequest request) {
+ if (request instanceof CombinedRequest) {
+ CombinedRequest combinedRequest = (CombinedRequest) request;
+ request = combinedRequest.getSecondRequest();
+ }
+ return (VaadinPortletRequest) request;
+ }
+}
diff --git a/server/src/com/vaadin/server/VaadinPortletResponse.java b/server/src/com/vaadin/server/VaadinPortletResponse.java
new file mode 100644
index 0000000000..5ca1ba580e
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinPortletResponse.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletResponse;
+import javax.portlet.ResourceResponse;
+
+import com.vaadin.server.VaadinPortlet.PortletService;
+
+/**
+ * Wrapper for {@link PortletResponse} and its subclasses.
+ *
+ * @author Vaadin Ltd.
+ * @since 7.0
+ *
+ * @see VaadinResponse
+ * @see VaadinPortletRequest
+ */
+public class VaadinPortletResponse implements VaadinResponse {
+ private static final DateFormat HTTP_DATE_FORMAT = new SimpleDateFormat(
+ "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
+ static {
+ HTTP_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
+ private final PortletResponse response;
+ private PortletService vaadinService;
+
+ /**
+ * Wraps a portlet response and an associated vaadin service
+ *
+ * @param response
+ * the portlet response to wrap
+ * @param vaadinService
+ * the associated vaadin service
+ */
+ public VaadinPortletResponse(PortletResponse response,
+ PortletService vaadinService) {
+ this.response = response;
+ this.vaadinService = vaadinService;
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ return ((MimeResponse) response).getPortletOutputStream();
+ }
+
+ /**
+ * Gets the original, unwrapped portlet response.
+ *
+ * @return the unwrapped portlet response
+ */
+ public PortletResponse getPortletResponse() {
+ return response;
+ }
+
+ @Override
+ public void setContentType(String type) {
+ ((MimeResponse) response).setContentType(type);
+ }
+
+ @Override
+ public PrintWriter getWriter() throws IOException {
+ return ((MimeResponse) response).getWriter();
+ }
+
+ @Override
+ public void setStatus(int responseStatus) {
+ response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
+ Integer.toString(responseStatus));
+ }
+
+ @Override
+ public void setHeader(String name, String value) {
+ response.setProperty(name, value);
+ }
+
+ @Override
+ public void setDateHeader(String name, long timestamp) {
+ response.setProperty(name, HTTP_DATE_FORMAT.format(new Date(timestamp)));
+ }
+
+ @Override
+ public void setCacheTime(long milliseconds) {
+ VaadinServletResponse.doSetCacheTime(this, milliseconds);
+ }
+
+ @Override
+ public void sendError(int errorCode, String message) throws IOException {
+ setStatus(errorCode);
+ getWriter().write(message);
+ }
+
+ @Override
+ public PortletService getVaadinService() {
+ return vaadinService;
+ }
+}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/VaadinPortletSession.java b/server/src/com/vaadin/server/VaadinPortletSession.java
index bb37bbbcf3..e5b512588d 100644
--- a/server/src/com/vaadin/server/VaadinPortletSession.java
+++ b/server/src/com/vaadin/server/VaadinPortletSession.java
@@ -74,8 +74,8 @@ public class VaadinPortletSession extends VaadinSession {
}
private PortletResponse getCurrentResponse() {
- WrappedPortletResponse currentResponse = (WrappedPortletResponse) CurrentInstance
- .get(WrappedResponse.class);
+ VaadinPortletResponse currentResponse = (VaadinPortletResponse) CurrentInstance
+ .get(VaadinResponse.class);
if (currentResponse != null) {
return currentResponse.getPortletResponse();
@@ -85,8 +85,8 @@ public class VaadinPortletSession extends VaadinSession {
}
public PortletConfig getPortletConfig() {
- WrappedPortletResponse response = (WrappedPortletResponse) CurrentInstance
- .get(WrappedResponse.class);
+ VaadinPortletResponse response = (VaadinPortletResponse) CurrentInstance
+ .get(VaadinResponse.class);
return response.getVaadinService().getPortlet().getPortletConfig();
}
diff --git a/server/src/com/vaadin/server/VaadinRequest.java b/server/src/com/vaadin/server/VaadinRequest.java
new file mode 100644
index 0000000000..0664d53f65
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinRequest.java
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import com.vaadin.ui.UI;
+
+/**
+ * A generic request to the server, wrapping a more specific request type, e.g.
+ * HttpServletReqest or PortletRequest.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public interface VaadinRequest extends Serializable {
+
+ /**
+ * Detailed information extracted from the browser.
+ *
+ * @see VaadinRequest#getBrowserDetails()
+ * @deprecated might be refactored or removed before 7.0.0
+ */
+ @Deprecated
+ public interface BrowserDetails extends Serializable {
+ /**
+ * Gets the URI hash fragment for the request. This is typically used to
+ * encode navigation within an application.
+ *
+ * @return the URI hash fragment
+ */
+ public String getUriFragment();
+
+ /**
+ * Gets the value of window.name from the browser. This can be used to
+ * keep track of the specific window between browser reloads.
+ *
+ * @return the string value of window.name in the browser
+ */
+ public String getWindowName();
+
+ /**
+ * Gets a reference to the {@link WebBrowser} object containing
+ * additional information, e.g. screen size and the time zone offset.
+ *
+ * @return the web browser object
+ */
+ public WebBrowser getWebBrowser();
+ }
+
+ /**
+ * Gets the named request parameter This is typically a HTTP GET or POST
+ * parameter, though other request types might have other ways of
+ * representing parameters.
+ *
+ * @see javax.servlet.ServletRequest#getParameter(String)
+ * @see javax.portlet.PortletRequest#getParameter(String)
+ *
+ * @param parameter
+ * the name of the parameter
+ * @return The paramter value, or null
if no parameter with the
+ * given name is present
+ */
+ public String getParameter(String parameter);
+
+ /**
+ * Gets all the parameters of the request.
+ *
+ * @see #getParameter(String)
+ *
+ * @see javax.servlet.ServletRequest#getParameterMap()
+ * @see javax.portlet.PortletRequest#getParameter(String)
+ *
+ * @return A mapping of parameter names to arrays of parameter values
+ */
+ public Mapnull
if there is no
+ * attribute with the given name
+ *
+ * @see javax.servlet.ServletRequest#getAttribute(String)
+ * @see javax.portlet.PortletRequest#getAttribute(String)
+ */
+ public Object getAttribute(String name);
+
+ /**
+ * Defines a request attribute.
+ *
+ * @param name
+ * the name of the attribute
+ * @param value
+ * the attribute value
+ *
+ * @see javax.servlet.ServletRequest#setAttribute(String, Object)
+ * @see javax.portlet.PortletRequest#setAttribute(String, Object)
+ */
+ public void setAttribute(String name, Object value);
+
+ /**
+ * Gets the path of the requested resource relative to the application. The
+ * path be null
if no path information is available. Does
+ * always start with / if the path isn't null
.
+ *
+ * @return a string with the path relative to the application.
+ *
+ * @see javax.servlet.http.HttpServletRequest#getPathInfo()
+ */
+ public String getRequestPathInfo();
+
+ /**
+ * Gets the session associated with this request, creating a new if there is
+ * no session.
+ *
+ * @see WrappedSession
+ * @see HttpServletRequest#getSession()
+ * @see PortletRequest#getPortletSession()
+ *
+ * @return the wrapped session for this request
+ */
+ public WrappedSession getWrappedSession();
+
+ /**
+ * Gets the session associated with this request, optionally creating a new
+ * if there is no session.
+ *
+ * @param allowSessionCreation
+ * true
to create a new session for this request if
+ * necessary; false
to return null
if
+ * there's no current session
+ *
+ * @see WrappedSession
+ * @see HttpServletRequest#getSession(boolean)
+ * @see PortletRequest#getPortletSession(boolean)
+ *
+ * @return the wrapped session for this request
+ */
+ public WrappedSession getWrappedSession(boolean allowSessionCreation);
+
+ /**
+ * Returns the MIME type of the body of the request, or null if the type is
+ * not known.
+ *
+ * @return a string containing the name of the MIME type of the request, or
+ * null if the type is not known
+ *
+ * @see javax.servlet.ServletRequest#getContentType()
+ * @see javax.portlet.ResourceRequest#getContentType()
+ *
+ */
+ public String getContentType();
+
+ /**
+ * Gets detailed information about the browser from which the request
+ * originated. This consists of information that is not available from
+ * normal HTTP requests, but requires additional information to be extracted
+ * for instance using javascript in the browser.
+ *
+ * This information is only guaranteed to be available in some special
+ * cases, for instance in {@link UI#init(VaadinRequest)}.
+ *
+ * @return the browser details, or null
if details are not
+ * available
+ *
+ * @see BrowserDetails
+ * @deprecated might be refactored or removed before 7.0.0
+ */
+ @Deprecated
+ public BrowserDetails getBrowserDetails();
+
+ /**
+ * Gets locale information from the query, e.g. using the Accept-Language
+ * header.
+ *
+ * @return the preferred Locale
+ *
+ * @see ServletRequest#getLocale()
+ * @see PortletRequest#getLocale()
+ */
+ public Locale getLocale();
+
+ /**
+ * Returns the IP address from which the request came. This might also be
+ * the address of a proxy between the server and the original requester.
+ *
+ * @return a string containing the IP address, or null
if the
+ * address is not available
+ *
+ * @see ServletRequest#getRemoteAddr()
+ */
+ public String getRemoteAddr();
+
+ /**
+ * Checks whether the request was made using a secure channel, e.g. using
+ * https.
+ *
+ * @return a boolean indicating if the request is secure
+ *
+ * @see ServletRequest#isSecure()
+ * @see PortletRequest#isSecure()
+ */
+ public boolean isSecure();
+
+ /**
+ * Gets the value of a request header, e.g. a http header for a
+ * {@link HttpServletRequest}.
+ *
+ * @param headerName
+ * the name of the header
+ * @return the header value, or null
if the header is not
+ * present in the request
+ *
+ * @see HttpServletRequest#getHeader(String)
+ */
+ public String getHeader(String headerName);
+
+ /**
+ * Gets the vaadin service for the context of this request.
+ *
+ * @return the vaadin service
+ *
+ * @see VaadinService
+ */
+ public VaadinService getVaadinService();
+
+}
diff --git a/server/src/com/vaadin/server/VaadinResponse.java b/server/src/com/vaadin/server/VaadinResponse.java
new file mode 100644
index 0000000000..bfa36015a3
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinResponse.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletResponse;
+import javax.portlet.ResourceResponse;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A generic response from the server, wrapping a more specific response type,
+ * e.g. HttpServletResponse or PortletResponse.
+ *
+ * @since 7.0
+ */
+public interface VaadinResponse extends Serializable {
+
+ /**
+ * Sets the (http) status code for the response. If you want to include an
+ * error message along the status code, use {@link #sendError(int, String)}
+ * instead.
+ *
+ * @param statusCode
+ * the status code to set
+ * @see HttpServletResponse#setStatus(int)
+ *
+ * @see ResourceResponse#HTTP_STATUS_CODE
+ */
+ public void setStatus(int statusCode);
+
+ /**
+ * Sets the content type of this response. If the content type including a
+ * charset is set before {@link #getWriter()} is invoked, the returned
+ * PrintWriter will automatically use the defined charset.
+ *
+ * @param contentType
+ * a string specifying the MIME type of the content
+ *
+ * @see ServletResponse#setContentType(String)
+ * @see MimeResponse#setContentType(String)
+ */
+ public void setContentType(String contentType);
+
+ /**
+ * Sets the value of a generic response header. If the header had already
+ * been set, the new value overwrites the previous one.
+ *
+ * @param name
+ * the name of the header
+ * @param value
+ * the header value.
+ *
+ * @see HttpServletResponse#setHeader(String, String)
+ * @see PortletResponse#setProperty(String, String)
+ */
+ public void setHeader(String name, String value);
+
+ /**
+ * Properly formats a timestamp as a date header. If the header had already
+ * been set, the new value overwrites the previous one.
+ *
+ * @param name
+ * the name of the header
+ * @param timestamp
+ * the number of milliseconds since epoch
+ *
+ * @see HttpServletResponse#setDateHeader(String, long)
+ */
+ public void setDateHeader(String name, long timestamp);
+
+ /**
+ * Returns a OutputStream
for writing binary data in the
+ * response.
+ * OutputStream
for writing binary data
+ * @throws IOException
+ * if an input or output exception occurred
+ *
+ * @see #getWriter()
+ * @see ServletResponse#getOutputStream()
+ * @see MimeResponse#getPortletOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException;
+
+ /**
+ * Returns a PrintWriter
object that can send character text to
+ * the client. The PrintWriter uses the character encoding defined using
+ * setContentType.
+ * PrintWriter
for writing character text
+ * @throws IOException
+ * if an input or output exception occurred
+ *
+ * @see #getOutputStream()
+ * @see ServletResponse#getWriter()
+ * @see MimeResponse#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException;
+
+ /**
+ * Sets cache time in milliseconds, -1 means no cache at all. All required
+ * headers related to caching in the response are set based on the time.
+ *
+ * @param milliseconds
+ * Cache time in milliseconds
+ */
+ public void setCacheTime(long milliseconds);
+
+ /**
+ * Sends an error response to the client using the specified status code and
+ * clears the buffer. In some configurations, this can cause a predefined
+ * error page to be displayed.
+ *
+ * @param errorCode
+ * the HTTP status code
+ * @param message
+ * a message to accompany the error
+ * @throws IOException
+ * if an input or output exception occurs
+ *
+ * @see HttpServletResponse#sendError(int, String)
+ */
+ public void sendError(int errorCode, String message) throws IOException;
+
+ /**
+ * Gets the vaadin service for the context of this response.
+ *
+ * @return the vaadin service
+ *
+ * @see VaadinService
+ */
+ public VaadinService getVaadinService();
+}
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 4b176d5f67..766ae47fdb 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -97,7 +97,7 @@ public abstract class VaadinService implements Serializable {
* @return The location of static resources (should contain the VAADIN
* directory). Never ends with a slash (/).
*/
- public abstract String getStaticFileLocation(WrappedRequest request);
+ public abstract String getStaticFileLocation(VaadinRequest request);
/**
* Gets the widgetset that is configured for this deployment, e.g. from a
@@ -107,7 +107,7 @@ public abstract class VaadinService implements Serializable {
* the request for which a widgetset is required
* @return the name of the widgetset
*/
- public abstract String getConfiguredWidgetset(WrappedRequest request);
+ public abstract String getConfiguredWidgetset(VaadinRequest request);
/**
* Gets the theme that is configured for this deployment, e.g. from a portal
@@ -117,7 +117,7 @@ public abstract class VaadinService implements Serializable {
* the request for which a theme is required
* @return the name of the theme
*/
- public abstract String getConfiguredTheme(WrappedRequest request);
+ public abstract String getConfiguredTheme(VaadinRequest request);
/**
* Checks whether the UI will be rendered on its own in the browser or
@@ -129,7 +129,7 @@ public abstract class VaadinService implements Serializable {
* the request for which the UI is loaded
* @return a boolean indicating whether the UI should be standalone
*/
- public abstract boolean isStandalone(WrappedRequest request);
+ public abstract boolean isStandalone(VaadinRequest request);
/**
* Get the class loader to use for loading classes loaded by name, e.g.
@@ -307,7 +307,7 @@ public abstract class VaadinService implements Serializable {
* session is found and this is a request for which a new session
* shouldn't be created.
*/
- public VaadinSession findVaadinSession(WrappedRequest request)
+ public VaadinSession findVaadinSession(VaadinRequest request)
throws ServiceException, SessionExpiredException {
boolean requestCanCreateSession = requestCanCreateSession(request);
@@ -356,7 +356,7 @@ public abstract class VaadinService implements Serializable {
}
- private VaadinSession createAndRegisterSession(WrappedRequest request)
+ private VaadinSession createAndRegisterSession(VaadinRequest request)
throws ServiceException {
VaadinSession session = createVaadinSession(request);
@@ -397,7 +397,7 @@ public abstract class VaadinService implements Serializable {
* @deprecated Only used to support {@link LegacyApplication}.
*/
@Deprecated
- protected URL getApplicationUrl(WrappedRequest request)
+ protected URL getApplicationUrl(VaadinRequest request)
throws MalformedURLException {
return null;
}
@@ -421,10 +421,10 @@ public abstract class VaadinService implements Serializable {
* @throws ServletException
* @throws MalformedURLException
*/
- protected abstract VaadinSession createVaadinSession(WrappedRequest request)
+ protected abstract VaadinSession createVaadinSession(VaadinRequest request)
throws ServiceException;
- private void onVaadinSessionStarted(WrappedRequest request,
+ private void onVaadinSessionStarted(VaadinRequest request,
VaadinSession session) throws ServiceException {
addonContext.fireApplicationStarted(session);
eventRouter.fireEvent(new VaadinSessionInitializeEvent(this, session,
@@ -444,7 +444,7 @@ public abstract class VaadinService implements Serializable {
}
}
- protected VaadinSession getExistingSession(WrappedRequest request,
+ protected VaadinSession getExistingSession(VaadinRequest request,
boolean allowSessionCreation) throws SessionExpiredException {
// Ensures that the session is still valid
@@ -472,7 +472,7 @@ public abstract class VaadinService implements Serializable {
* @return true
if it's valid to create a new Vaadin session
* for the request; else false
*/
- protected abstract boolean requestCanCreateSession(WrappedRequest request);
+ protected abstract boolean requestCanCreateSession(VaadinRequest request);
/**
* Gets the currently used Vaadin service. The current service is
@@ -485,7 +485,7 @@ public abstract class VaadinService implements Serializable {
* @return the current Vaadin service instance if available, otherwise
* null
*
- * @see #setCurrentInstances(WrappedRequest, WrappedResponse)
+ * @see #setCurrentInstances(VaadinRequest, VaadinResponse)
*/
public static VaadinService getCurrent() {
return CurrentInstance.get(VaadinService.class);
@@ -493,7 +493,7 @@ public abstract class VaadinService implements Serializable {
/**
* Sets the this Vaadin service as the current service and also sets the
- * current wrapped request and wrapped response. This method is used by the
+ * current Vaadin request and Vaadin response. This method is used by the
* framework to set the current instances when a request related to the
* service is processed and they are cleared when the request has been
* processed.
@@ -504,51 +504,51 @@ public abstract class VaadinService implements Serializable {
* null
if no request should be set.
* @param response
- * the wrapped response to set as the current response, or
+ * the Vaadin response to set as the current response, or
* null
if no response should be set.
*
* @see #getCurrent()
* @see #getCurrentRequest()
* @see #getCurrentResponse()
*/
- public void setCurrentInstances(WrappedRequest request,
- WrappedResponse response) {
+ public void setCurrentInstances(VaadinRequest request,
+ VaadinResponse response) {
CurrentInstance.setInheritable(VaadinService.class, this);
- CurrentInstance.set(WrappedRequest.class, request);
- CurrentInstance.set(WrappedResponse.class, response);
+ CurrentInstance.set(VaadinRequest.class, request);
+ CurrentInstance.set(VaadinResponse.class, response);
}
/**
- * Gets the currently processed wrapped request. The current request is
+ * Gets the currently processed Vaadin request. The current request is
* automatically defined when the request is started. The current request
* can not be used in e.g. background threads because of the way server
* implementations reuse request instances.
*
- * @return the current wrapped request instance if available, otherwise
+ * @return the current Vaadin request instance if available, otherwise
* null
*
- * @see #setCurrentInstances(WrappedRequest, WrappedResponse)
+ * @see #setCurrentInstances(VaadinRequest, VaadinResponse)
*/
- public static WrappedRequest getCurrentRequest() {
- return CurrentInstance.get(WrappedRequest.class);
+ public static VaadinRequest getCurrentRequest() {
+ return CurrentInstance.get(VaadinRequest.class);
}
/**
- * Gets the currently processed wrapped request. The current request is
+ * Gets the currently processed Vaadin request. The current request is
* automatically defined when the request is started. The current request
* can not be used in e.g. background threads because of the way server
* implementations reuse request instances.
*
- * @return the current wrapped request instance if available, otherwise
+ * @return the current Vaadin request instance if available, otherwise
* null
*
- * @see #setCurrentInstances(WrappedRequest, WrappedResponse)
+ * @see #setCurrentInstances(VaadinRequest, VaadinResponse)
*/
- public static WrappedResponse getCurrentResponse() {
- return CurrentInstance.get(WrappedResponse.class);
+ public static VaadinResponse getCurrentResponse() {
+ return CurrentInstance.get(VaadinResponse.class);
}
}
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 54709b41d1..518d26070b 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -66,8 +66,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
@Override
- public String getStaticFileLocation(WrappedRequest request) {
- HttpServletRequest servletRequest = WrappedHttpServletRequest
+ public String getStaticFileLocation(VaadinRequest request) {
+ HttpServletRequest servletRequest = VaadinServletRequest
.cast(request);
String staticFileLocation;
// if property is defined in configurations, use that
@@ -108,20 +108,20 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
@Override
- public String getConfiguredWidgetset(WrappedRequest request) {
+ public String getConfiguredWidgetset(VaadinRequest request) {
return getDeploymentConfiguration().getApplicationOrSystemProperty(
VaadinServlet.PARAMETER_WIDGETSET,
VaadinServlet.DEFAULT_WIDGETSET);
}
@Override
- public String getConfiguredTheme(WrappedRequest request) {
+ public String getConfiguredTheme(VaadinRequest request) {
// Use the default
return VaadinServlet.getDefaultTheme();
}
@Override
- public boolean isStandalone(WrappedRequest request) {
+ public boolean isStandalone(VaadinRequest request) {
return true;
}
@@ -146,7 +146,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
@Override
- protected boolean requestCanCreateSession(WrappedRequest request) {
+ protected boolean requestCanCreateSession(VaadinRequest request) {
RequestType requestType = getRequestType(request);
if (requestType == RequestType.BROWSER_DETAILS) {
// This is the first request if you are embedding by writing the
@@ -172,22 +172,22 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected RequestType getRequestType(WrappedRequest request) {
+ protected RequestType getRequestType(VaadinRequest request) {
RequestType type = (RequestType) request
.getAttribute(RequestType.class.getName());
if (type == null) {
type = getServlet().getRequestType(
- WrappedHttpServletRequest.cast(request));
+ VaadinServletRequest.cast(request));
request.setAttribute(RequestType.class.getName(), type);
}
return type;
}
@Override
- protected URL getApplicationUrl(WrappedRequest request)
+ protected URL getApplicationUrl(VaadinRequest request)
throws MalformedURLException {
return getServlet().getApplicationUrl(
- WrappedHttpServletRequest.cast(request));
+ VaadinServletRequest.cast(request));
}
@Override
@@ -197,9 +197,9 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
public static HttpServletRequest getCurrentServletRequest() {
- WrappedRequest currentRequest = VaadinService.getCurrentRequest();
+ VaadinRequest currentRequest = VaadinService.getCurrentRequest();
try {
- WrappedHttpServletRequest request = WrappedHttpServletRequest
+ VaadinServletRequest request = VaadinServletRequest
.cast(currentRequest);
if (request != null) {
return request.getHttpServletRequest();
@@ -211,13 +211,12 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
}
- public static WrappedHttpServletResponse getCurrentResponse() {
- return (WrappedHttpServletResponse) VaadinService
- .getCurrentResponse();
+ public static VaadinServletResponse getCurrentResponse() {
+ return (VaadinServletResponse) VaadinService.getCurrentResponse();
}
@Override
- protected VaadinSession createVaadinSession(WrappedRequest request)
+ protected VaadinSession createVaadinSession(VaadinRequest request)
throws ServiceException {
return new VaadinServletSession();
}
@@ -232,12 +231,11 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
@Override
- public void criticalNotification(WrappedRequest request,
- WrappedResponse response, String cap, String msg,
+ public void criticalNotification(VaadinRequest request,
+ VaadinResponse response, String cap, String msg,
String details, String outOfSyncURL) throws IOException {
- servlet.criticalNotification(
- WrappedHttpServletRequest.cast(request),
- ((WrappedHttpServletResponse) response), cap, msg, details,
+ servlet.criticalNotification(VaadinServletRequest.cast(request),
+ ((VaadinServletResponse) response), cap, msg, details,
outOfSyncURL);
}
}
@@ -381,11 +379,11 @@ public class VaadinServlet extends HttpServlet implements Constants {
HttpServletResponse response) throws ServletException, IOException {
CurrentInstance.clearAll();
setCurrent(this);
- service(createWrappedRequest(request), createWrappedResponse(response));
+ service(createVaadinRequest(request), createVaadinResponse(response));
}
- private void service(WrappedHttpServletRequest request,
- WrappedHttpServletResponse response) throws ServletException,
+ private void service(VaadinServletRequest request,
+ VaadinServletResponse response) throws ServletException,
IOException {
RequestTimer requestTimer = new RequestTimer();
requestTimer.start();
@@ -501,24 +499,22 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
}
- private WrappedHttpServletResponse createWrappedResponse(
+ private VaadinServletResponse createVaadinResponse(
HttpServletResponse response) {
- WrappedHttpServletResponse wrappedResponse = new WrappedHttpServletResponse(
- response, getVaadinService());
- return wrappedResponse;
+ return new VaadinServletResponse(response, getVaadinService());
}
/**
- * Create a wrapped request for a http servlet request. This method can be
- * overridden if the wrapped request should have special properties.
+ * Create a Vaadin request for a http servlet request. This method can be
+ * overridden if the Vaadin request should have special properties.
*
* @param request
* the original http servlet request
- * @return a wrapped request for the original request
+ * @return a Vaadin request for the original request
*/
- protected WrappedHttpServletRequest createWrappedRequest(
+ protected VaadinServletRequest createVaadinRequest(
HttpServletRequest request) {
- return new WrappedHttpServletRequest(request, getVaadinService());
+ return new VaadinServletRequest(request, getVaadinService());
}
/**
@@ -545,8 +541,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @throws IOException
*/
private boolean ensureCookiesEnabled(RequestType requestType,
- WrappedHttpServletRequest request,
- WrappedHttpServletResponse response) throws IOException {
+ VaadinServletRequest request, VaadinServletResponse response)
+ throws IOException {
if (requestType == RequestType.UIDL) {
// In all other but the first UIDL request a cookie should be
// returned by the browser.
@@ -592,7 +588,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected void criticalNotification(WrappedHttpServletRequest request,
+ protected void criticalNotification(VaadinServletRequest request,
HttpServletResponse response, String caption, String message,
String details, String url) throws IOException {
@@ -705,8 +701,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
return resultPath;
}
- private void handleServiceException(WrappedHttpServletRequest request,
- WrappedHttpServletResponse response, VaadinSession vaadinSession,
+ private void handleServiceException(VaadinServletRequest request,
+ VaadinServletResponse response, VaadinSession vaadinSession,
Throwable e) throws IOException, ServletException {
// if this was an UIDL request, response UIDL back to client
if (getRequestType(request) == RequestType.UIDL) {
@@ -772,8 +768,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- void handleServiceSessionExpired(WrappedHttpServletRequest request,
- WrappedHttpServletResponse response) throws IOException,
+ void handleServiceSessionExpired(VaadinServletRequest request,
+ VaadinServletResponse response) throws IOException,
ServletException {
if (isOnUnloadRequest(request)) {
@@ -818,9 +814,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
- private void handleServiceSecurityException(
- WrappedHttpServletRequest request,
- WrappedHttpServletResponse response) throws IOException,
+ private void handleServiceSecurityException(VaadinServletRequest request,
+ VaadinServletResponse response) throws IOException,
ServletException {
if (isOnUnloadRequest(request)) {
/*
@@ -1212,7 +1207,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected RequestType getRequestType(WrappedHttpServletRequest request) {
+ protected RequestType getRequestType(VaadinServletRequest request) {
if (ServletPortletHelper.isFileUploadRequest(request)) {
return RequestType.FILE_UPLOAD;
} else if (ServletPortletHelper.isConnectorResourceRequest(request)) {
diff --git a/server/src/com/vaadin/server/VaadinServletRequest.java b/server/src/com/vaadin/server/VaadinServletRequest.java
new file mode 100644
index 0000000000..e9d673a1f3
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinServletRequest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+import com.vaadin.server.VaadinServlet.ServletService;
+
+/**
+ * Wrapper for {@link HttpServletRequest}.
+ *
+ * @author Vaadin Ltd.
+ * @since 7.0
+ *
+ * @see VaadinRequest
+ * @see VaadinServletResponse
+ */
+public class VaadinServletRequest extends HttpServletRequestWrapper implements
+ VaadinRequest {
+
+ private final ServletService vaadinService;
+
+ /**
+ * Wraps a http servlet request and associates with a vaadin service
+ *
+ * @param request
+ * the http servlet request to wrap
+ * @param vaadinService
+ * the associated vaadin service
+ */
+ public VaadinServletRequest(HttpServletRequest request,
+ ServletService vaadinService) {
+ super(request);
+ this.vaadinService = vaadinService;
+ }
+
+ @Override
+ public String getRequestPathInfo() {
+ return getPathInfo();
+ }
+
+ @Override
+ public WrappedSession getWrappedSession() {
+ return getWrappedSession(true);
+ }
+
+ @Override
+ public WrappedSession getWrappedSession(boolean allowSessionCreation) {
+ HttpSession session = getSession(allowSessionCreation);
+ if (session != null) {
+ return new WrappedHttpSession(session);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the original, unwrapped HTTP servlet request.
+ *
+ * @return the servlet request
+ */
+ public HttpServletRequest getHttpServletRequest() {
+ return this;
+ }
+
+ @Override
+ public ServletService getVaadinService() {
+ return vaadinService;
+ }
+
+ @Override
+ public BrowserDetails getBrowserDetails() {
+ return new BrowserDetails() {
+ @Override
+ public String getUriFragment() {
+ return null;
+ }
+
+ @Override
+ public String getWindowName() {
+ return null;
+ }
+
+ @Override
+ public WebBrowser getWebBrowser() {
+ return VaadinSession.getCurrent().getBrowser();
+ }
+ };
+ }
+
+ /**
+ * Helper method to get a {@link VaadinServletRequest} from a
+ * {@link VaadinRequest}. Aside from casting, this method also takes care of
+ * situations where there's another level of wrapping.
+ *
+ * @param request
+ * a Vaadin request
+ * @return a Vaadin http servlet request
+ * @throws ClassCastException
+ * if the Vaadin request doesn't wrap a http servlet request
+ */
+ public static VaadinServletRequest cast(VaadinRequest request) {
+ if (request instanceof CombinedRequest) {
+ CombinedRequest combinedRequest = (CombinedRequest) request;
+ request = combinedRequest.getSecondRequest();
+ }
+ return (VaadinServletRequest) request;
+ }
+
+}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/VaadinServletResponse.java b/server/src/com/vaadin/server/VaadinServletResponse.java
new file mode 100644
index 0000000000..b21ca34249
--- /dev/null
+++ b/server/src/com/vaadin/server/VaadinServletResponse.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.server;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import com.vaadin.server.VaadinServlet.ServletService;
+
+/**
+ * Wrapper for {@link HttpServletResponse}.
+ *
+ * @author Vaadin Ltd.
+ * @since 7.0
+ *
+ * @see VaadinResponse
+ * @see VaadinServletRequest
+ */
+public class VaadinServletResponse extends HttpServletResponseWrapper implements
+ VaadinResponse {
+
+ private ServletService vaadinService;
+
+ /**
+ * Wraps a http servlet response and an associated vaadin service
+ *
+ * @param response
+ * the http servlet response to wrap
+ * @param vaadinService
+ * the associated vaadin service
+ */
+ public VaadinServletResponse(HttpServletResponse response,
+ ServletService vaadinService) {
+ super(response);
+ this.vaadinService = vaadinService;
+ }
+
+ /**
+ * Gets the original unwrapped HttpServletResponse
+ *
+ * @return the unwrapped response
+ */
+ public HttpServletResponse getHttpServletResponse() {
+ return this;
+ }
+
+ @Override
+ public void setCacheTime(long milliseconds) {
+ doSetCacheTime(this, milliseconds);
+ }
+
+ // Implementation shared with VaadinPortletResponse
+ static void doSetCacheTime(VaadinResponse response, long milliseconds) {
+ if (milliseconds <= 0) {
+ response.setHeader("Cache-Control", "no-cache");
+ response.setHeader("Pragma", "no-cache");
+ response.setDateHeader("Expires", 0);
+ } else {
+ response.setHeader("Cache-Control", "max-age=" + milliseconds
+ / 1000);
+ response.setDateHeader("Expires", System.currentTimeMillis()
+ + milliseconds);
+ // Required to apply caching in some Tomcats
+ response.setHeader("Pragma", "cache");
+ }
+ }
+
+ @Override
+ public ServletService getVaadinService() {
+ return vaadinService;
+ }
+}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 8fbc7af335..c3699bacfa 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -42,7 +42,7 @@ import com.vaadin.data.util.converter.Converter;
import com.vaadin.data.util.converter.ConverterFactory;
import com.vaadin.data.util.converter.DefaultConverterFactory;
import com.vaadin.event.EventRouter;
-import com.vaadin.server.WrappedRequest.BrowserDetails;
+import com.vaadin.server.VaadinRequest.BrowserDetails;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Table;
@@ -615,18 +615,18 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* host page is requested.
*
* @param request
- * the wrapped request for which a UI is needed
+ * the Vaadin request for which a UI is needed
* @return a UI instance to use for the request
*
* @see UI
- * @see WrappedRequest#getBrowserDetails()
+ * @see VaadinRequest#getBrowserDetails()
*
* @since 7.0
*
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- public Class extends UI> getUIClass(WrappedRequest request) {
+ public Class extends UI> getUIClass(VaadinRequest request) {
UIProvider uiProvider = getUiProvider(request, null);
return uiProvider.getUIClass(request);
}
@@ -644,7 +644,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* @deprecated might be refactored or removed before 7.0.0
*/
@Deprecated
- protected WrappedHttpServletRequest
from a
- * WrappedRequest
. Aside from casting, this method also takes
- * care of situations where there's another level of wrapping.
- *
- * @param request
- * a wrapped request
- * @return a wrapped http servlet request
- * @throws ClassCastException
- * if the wrapped request doesn't wrap a http servlet request
- */
- public static WrappedHttpServletRequest cast(WrappedRequest request) {
- if (request instanceof CombinedRequest) {
- CombinedRequest combinedRequest = (CombinedRequest) request;
- request = combinedRequest.getSecondRequest();
- }
- return (WrappedHttpServletRequest) request;
- }
-
-}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/WrappedHttpServletResponse.java b/server/src/com/vaadin/server/WrappedHttpServletResponse.java
deleted file mode 100644
index 74a580f874..0000000000
--- a/server/src/com/vaadin/server/WrappedHttpServletResponse.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-
-import com.vaadin.server.VaadinServlet.ServletService;
-
-/**
- * Wrapper for {@link HttpServletResponse}.
- *
- * @author Vaadin Ltd.
- * @since 7.0
- *
- * @see WrappedResponse
- * @see WrappedHttpServletRequest
- */
-public class WrappedHttpServletResponse extends HttpServletResponseWrapper
- implements WrappedResponse {
-
- private ServletService vaadinService;
-
- /**
- * Wraps a http servlet response and an associated vaadin service
- *
- * @param response
- * the http servlet response to wrap
- * @param vaadinService
- * the associated vaadin service
- */
- public WrappedHttpServletResponse(HttpServletResponse response,
- ServletService vaadinService) {
- super(response);
- this.vaadinService = vaadinService;
- }
-
- /**
- * Gets the original unwrapped HttpServletResponse
- *
- * @return the unwrapped response
- */
- public HttpServletResponse getHttpServletResponse() {
- return this;
- }
-
- @Override
- public void setCacheTime(long milliseconds) {
- doSetCacheTime(this, milliseconds);
- }
-
- // Implementation shared with WrappedPortletResponse
- static void doSetCacheTime(WrappedResponse response, long milliseconds) {
- if (milliseconds <= 0) {
- response.setHeader("Cache-Control", "no-cache");
- response.setHeader("Pragma", "no-cache");
- response.setDateHeader("Expires", 0);
- } else {
- response.setHeader("Cache-Control", "max-age=" + milliseconds
- / 1000);
- response.setDateHeader("Expires", System.currentTimeMillis()
- + milliseconds);
- // Required to apply caching in some Tomcats
- response.setHeader("Pragma", "cache");
- }
- }
-
- @Override
- public ServletService getVaadinService() {
- return vaadinService;
- }
-}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/WrappedPortletRequest.java b/server/src/com/vaadin/server/WrappedPortletRequest.java
deleted file mode 100644
index d4670cfd92..0000000000
--- a/server/src/com/vaadin/server/WrappedPortletRequest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.portlet.ClientDataRequest;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.ResourceRequest;
-
-import com.vaadin.server.VaadinPortlet.PortletService;
-import com.vaadin.shared.ApplicationConstants;
-
-/**
- * Wrapper for {@link PortletRequest} and its subclasses.
- *
- * @author Vaadin Ltd.
- * @since 7.0
- *
- * @see WrappedRequest
- * @see WrappedPortletResponse
- */
-public class WrappedPortletRequest implements WrappedRequest {
-
- private final PortletRequest request;
- private final PortletService vaadinService;
-
- /**
- * Wraps a portlet request and an associated vaadin service
- *
- * @param request
- * the portlet request to wrap
- * @param vaadinService
- * the associated vaadin service
- */
- public WrappedPortletRequest(PortletRequest request,
- PortletService vaadinService) {
- this.request = request;
- this.vaadinService = vaadinService;
- }
-
- @Override
- public Object getAttribute(String name) {
- return request.getAttribute(name);
- }
-
- @Override
- public int getContentLength() {
- try {
- return ((ClientDataRequest) request).getContentLength();
- } catch (ClassCastException e) {
- throw new IllegalStateException(
- "Content lenght only available for ClientDataRequests");
- }
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- return ((ClientDataRequest) request).getPortletInputStream();
- } catch (ClassCastException e) {
- throw new IllegalStateException(
- "Input data only available for ClientDataRequests");
- }
- }
-
- @Override
- public String getParameter(String name) {
- return request.getParameter(name);
- }
-
- @Override
- public Mapnull
if
- * the property is not defined
- */
- public String getPortalProperty(String name) {
- return request.getPortalContext().getProperty(name);
- }
-
- @Override
- public PortletService getVaadinService() {
- return vaadinService;
- }
-
- /**
- * Helper method to get a WrappedPortlettRequest
from a
- * WrappedRequest
. Aside from casting, this method also takes
- * care of situations where there's another level of wrapping.
- *
- * @param request
- * a wrapped request
- * @return a wrapped portlet request
- * @throws ClassCastException
- * if the wrapped request doesn't wrap a portlet request
- */
- public static WrappedPortletRequest cast(WrappedRequest request) {
- if (request instanceof CombinedRequest) {
- CombinedRequest combinedRequest = (CombinedRequest) request;
- request = combinedRequest.getSecondRequest();
- }
- return (WrappedPortletRequest) request;
- }
-}
diff --git a/server/src/com/vaadin/server/WrappedPortletResponse.java b/server/src/com/vaadin/server/WrappedPortletResponse.java
deleted file mode 100644
index 5888c33b43..0000000000
--- a/server/src/com/vaadin/server/WrappedPortletResponse.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import javax.portlet.MimeResponse;
-import javax.portlet.PortletResponse;
-import javax.portlet.ResourceResponse;
-
-import com.vaadin.server.VaadinPortlet.PortletService;
-
-/**
- * Wrapper for {@link PortletResponse} and its subclasses.
- *
- * @author Vaadin Ltd.
- * @since 7.0
- *
- * @see WrappedResponse
- * @see WrappedPortletRequest
- */
-public class WrappedPortletResponse implements WrappedResponse {
- private static final DateFormat HTTP_DATE_FORMAT = new SimpleDateFormat(
- "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
- static {
- HTTP_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
-
- private final PortletResponse response;
- private PortletService vaadinService;
-
- /**
- * Wraps a portlet response and an associated vaadin service
- *
- * @param response
- * the portlet response to wrap
- * @param vaadinService
- * the associated vaadin service
- */
- public WrappedPortletResponse(PortletResponse response,
- PortletService vaadinService) {
- this.response = response;
- this.vaadinService = vaadinService;
- }
-
- @Override
- public OutputStream getOutputStream() throws IOException {
- return ((MimeResponse) response).getPortletOutputStream();
- }
-
- /**
- * Gets the original, unwrapped portlet response.
- *
- * @return the unwrapped portlet response
- */
- public PortletResponse getPortletResponse() {
- return response;
- }
-
- @Override
- public void setContentType(String type) {
- ((MimeResponse) response).setContentType(type);
- }
-
- @Override
- public PrintWriter getWriter() throws IOException {
- return ((MimeResponse) response).getWriter();
- }
-
- @Override
- public void setStatus(int responseStatus) {
- response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
- Integer.toString(responseStatus));
- }
-
- @Override
- public void setHeader(String name, String value) {
- response.setProperty(name, value);
- }
-
- @Override
- public void setDateHeader(String name, long timestamp) {
- response.setProperty(name, HTTP_DATE_FORMAT.format(new Date(timestamp)));
- }
-
- @Override
- public void setCacheTime(long milliseconds) {
- WrappedHttpServletResponse.doSetCacheTime(this, milliseconds);
- }
-
- @Override
- public void sendError(int errorCode, String message) throws IOException {
- setStatus(errorCode);
- getWriter().write(message);
- }
-
- @Override
- public PortletService getVaadinService() {
- return vaadinService;
- }
-}
\ No newline at end of file
diff --git a/server/src/com/vaadin/server/WrappedRequest.java b/server/src/com/vaadin/server/WrappedRequest.java
deleted file mode 100644
index aeaff2b384..0000000000
--- a/server/src/com/vaadin/server/WrappedRequest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-
-import com.vaadin.ui.UI;
-
-/**
- * A generic request to the server, wrapping a more specific request type, e.g.
- * HttpServletReqest or PortletRequest.
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-public interface WrappedRequest extends Serializable {
-
- /**
- * Detailed information extracted from the browser.
- *
- * @see WrappedRequest#getBrowserDetails()
- * @deprecated might be refactored or removed before 7.0.0
- */
- @Deprecated
- public interface BrowserDetails extends Serializable {
- /**
- * Gets the URI hash fragment for the request. This is typically used to
- * encode navigation within an application.
- *
- * @return the URI hash fragment
- */
- public String getUriFragment();
-
- /**
- * Gets the value of window.name from the browser. This can be used to
- * keep track of the specific window between browser reloads.
- *
- * @return the string value of window.name in the browser
- */
- public String getWindowName();
-
- /**
- * Gets a reference to the {@link WebBrowser} object containing
- * additional information, e.g. screen size and the time zone offset.
- *
- * @return the web browser object
- */
- public WebBrowser getWebBrowser();
- }
-
- /**
- * Gets the named request parameter This is typically a HTTP GET or POST
- * parameter, though other request types might have other ways of
- * representing parameters.
- *
- * @see javax.servlet.ServletRequest#getParameter(String)
- * @see javax.portlet.PortletRequest#getParameter(String)
- *
- * @param parameter
- * the name of the parameter
- * @return The paramter value, or null
if no parameter with the
- * given name is present
- */
- public String getParameter(String parameter);
-
- /**
- * Gets all the parameters of the request.
- *
- * @see #getParameter(String)
- *
- * @see javax.servlet.ServletRequest#getParameterMap()
- * @see javax.portlet.PortletRequest#getParameter(String)
- *
- * @return A mapping of parameter names to arrays of parameter values
- */
- public Mapnull
if there is no
- * attribute with the given name
- *
- * @see javax.servlet.ServletRequest#getAttribute(String)
- * @see javax.portlet.PortletRequest#getAttribute(String)
- */
- public Object getAttribute(String name);
-
- /**
- * Defines a request attribute.
- *
- * @param name
- * the name of the attribute
- * @param value
- * the attribute value
- *
- * @see javax.servlet.ServletRequest#setAttribute(String, Object)
- * @see javax.portlet.PortletRequest#setAttribute(String, Object)
- */
- public void setAttribute(String name, Object value);
-
- /**
- * Gets the path of the requested resource relative to the application. The
- * path be null
if no path information is available. Does
- * always start with / if the path isn't null
.
- *
- * @return a string with the path relative to the application.
- *
- * @see javax.servlet.http.HttpServletRequest#getPathInfo()
- */
- public String getRequestPathInfo();
-
- /**
- * Gets the session associated with this request, creating a new if there is
- * no session.
- *
- * @see WrappedSession
- * @see HttpServletRequest#getSession()
- * @see PortletRequest#getPortletSession()
- *
- * @return the wrapped session for this request
- */
- public WrappedSession getWrappedSession();
-
- /**
- * Gets the session associated with this request, optionally creating a new
- * if there is no session.
- *
- * @param allowSessionCreation
- * true
to create a new session for this request if
- * necessary; false
to return null
if
- * there's no current session
- *
- * @see WrappedSession
- * @see HttpServletRequest#getSession(boolean)
- * @see PortletRequest#getPortletSession(boolean)
- *
- * @return the wrapped session for this request
- */
- public WrappedSession getWrappedSession(boolean allowSessionCreation);
-
- /**
- * Returns the MIME type of the body of the request, or null if the type is
- * not known.
- *
- * @return a string containing the name of the MIME type of the request, or
- * null if the type is not known
- *
- * @see javax.servlet.ServletRequest#getContentType()
- * @see javax.portlet.ResourceRequest#getContentType()
- *
- */
- public String getContentType();
-
- /**
- * Gets detailed information about the browser from which the request
- * originated. This consists of information that is not available from
- * normal HTTP requests, but requires additional information to be extracted
- * for instance using javascript in the browser.
- *
- * This information is only guaranteed to be available in some special
- * cases, for instance in {@link UI#init(WrappedRequest)}.
- *
- * @return the browser details, or null
if details are not
- * available
- *
- * @see BrowserDetails
- * @deprecated might be refactored or removed before 7.0.0
- */
- @Deprecated
- public BrowserDetails getBrowserDetails();
-
- /**
- * Gets locale information from the query, e.g. using the Accept-Language
- * header.
- *
- * @return the preferred Locale
- *
- * @see ServletRequest#getLocale()
- * @see PortletRequest#getLocale()
- */
- public Locale getLocale();
-
- /**
- * Returns the IP address from which the request came. This might also be
- * the address of a proxy between the server and the original requester.
- *
- * @return a string containing the IP address, or null
if the
- * address is not available
- *
- * @see ServletRequest#getRemoteAddr()
- */
- public String getRemoteAddr();
-
- /**
- * Checks whether the request was made using a secure channel, e.g. using
- * https.
- *
- * @return a boolean indicating if the request is secure
- *
- * @see ServletRequest#isSecure()
- * @see PortletRequest#isSecure()
- */
- public boolean isSecure();
-
- /**
- * Gets the value of a request header, e.g. a http header for a
- * {@link HttpServletRequest}.
- *
- * @param headerName
- * the name of the header
- * @return the header value, or null
if the header is not
- * present in the request
- *
- * @see HttpServletRequest#getHeader(String)
- */
- public String getHeader(String headerName);
-
- /**
- * Gets the vaadin service for the context of this request.
- *
- * @return the vaadin service
- *
- * @see VaadinService
- */
- public VaadinService getVaadinService();
-
-}
diff --git a/server/src/com/vaadin/server/WrappedResponse.java b/server/src/com/vaadin/server/WrappedResponse.java
deleted file mode 100644
index 90c9a356e1..0000000000
--- a/server/src/com/vaadin/server/WrappedResponse.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.server;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-
-import javax.portlet.MimeResponse;
-import javax.portlet.PortletResponse;
-import javax.portlet.ResourceResponse;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * A generic response from the server, wrapping a more specific response type,
- * e.g. HttpServletResponse or PortletResponse.
- *
- * @since 7.0
- */
-public interface WrappedResponse extends Serializable {
-
- /**
- * Sets the (http) status code for the response. If you want to include an
- * error message along the status code, use {@link #sendError(int, String)}
- * instead.
- *
- * @param statusCode
- * the status code to set
- * @see HttpServletResponse#setStatus(int)
- *
- * @see ResourceResponse#HTTP_STATUS_CODE
- */
- public void setStatus(int statusCode);
-
- /**
- * Sets the content type of this response. If the content type including a
- * charset is set before {@link #getWriter()} is invoked, the returned
- * PrintWriter will automatically use the defined charset.
- *
- * @param contentType
- * a string specifying the MIME type of the content
- *
- * @see ServletResponse#setContentType(String)
- * @see MimeResponse#setContentType(String)
- */
- public void setContentType(String contentType);
-
- /**
- * Sets the value of a generic response header. If the header had already
- * been set, the new value overwrites the previous one.
- *
- * @param name
- * the name of the header
- * @param value
- * the header value.
- *
- * @see HttpServletResponse#setHeader(String, String)
- * @see PortletResponse#setProperty(String, String)
- */
- public void setHeader(String name, String value);
-
- /**
- * Properly formats a timestamp as a date header. If the header had already
- * been set, the new value overwrites the previous one.
- *
- * @param name
- * the name of the header
- * @param timestamp
- * the number of milliseconds since epoch
- *
- * @see HttpServletResponse#setDateHeader(String, long)
- */
- public void setDateHeader(String name, long timestamp);
-
- /**
- * Returns a OutputStream
for writing binary data in the
- * response.
- * OutputStream
for writing binary data
- * @throws IOException
- * if an input or output exception occurred
- *
- * @see #getWriter()
- * @see ServletResponse#getOutputStream()
- * @see MimeResponse#getPortletOutputStream()
- */
- public OutputStream getOutputStream() throws IOException;
-
- /**
- * Returns a PrintWriter
object that can send character text to
- * the client. The PrintWriter uses the character encoding defined using
- * setContentType.
- * PrintWriter
for writing character text
- * @throws IOException
- * if an input or output exception occurred
- *
- * @see #getOutputStream()
- * @see ServletResponse#getWriter()
- * @see MimeResponse#getWriter()
- */
- public PrintWriter getWriter() throws IOException;
-
- /**
- * Sets cache time in milliseconds, -1 means no cache at all. All required
- * headers related to caching in the response are set based on the time.
- *
- * @param milliseconds
- * Cache time in milliseconds
- */
- public void setCacheTime(long milliseconds);
-
- /**
- * Sends an error response to the client using the specified status code and
- * clears the buffer. In some configurations, this can cause a predefined
- * error page to be displayed.
- *
- * @param errorCode
- * the HTTP status code
- * @param message
- * a message to accompany the error
- * @throws IOException
- * if an input or output exception occurs
- *
- * @see HttpServletResponse#sendError(int, String)
- */
- public void sendError(int errorCode, String message) throws IOException;
-
- /**
- * Gets the vaadin service for the context of this response.
- *
- * @return the vaadin service
- *
- * @see VaadinService
- */
- public VaadinService getVaadinService();
-}
diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java
index 219413974b..3cc801817f 100644
--- a/server/src/com/vaadin/ui/AbstractMedia.java
+++ b/server/src/com/vaadin/ui/AbstractMedia.java
@@ -26,8 +26,8 @@ import java.util.regex.Pattern;
import com.vaadin.server.ConnectorResource;
import com.vaadin.server.Resource;
import com.vaadin.server.ResourceReference;
-import com.vaadin.server.WrappedRequest;
-import com.vaadin.server.WrappedResponse;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinResponse;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.AbstractMediaState;
import com.vaadin.shared.ui.MediaControl;
@@ -79,8 +79,8 @@ public abstract class AbstractMedia extends AbstractComponent {
}
@Override
- public boolean handleConnectorRequest(WrappedRequest request,
- WrappedResponse response, String path) throws IOException {
+ public boolean handleConnectorRequest(VaadinRequest request,
+ VaadinResponse response, String path) throws IOException {
Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path);
if (matcher.matches()) {
List