You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2003/10/20 05:52:54 UTC
cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request RequestContext.java JetspeedRequestContext.java
weaver 2003/10/19 20:52:54
Modified: portal/src/java/org/apache/jetspeed/request
RequestContext.java JetspeedRequestContext.java
Log:
Added methods to get requests and responses tailored specifically
for a individual PortletWindow instance
Revision Changes Path
1.3 +47 -5 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/RequestContext.java
Index: RequestContext.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/RequestContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RequestContext.java 15 Aug 2003 00:27:54 -0000 1.2
+++ RequestContext.java 20 Oct 2003 03:52:53 -0000 1.3
@@ -72,15 +72,20 @@
public interface RequestContext
{
/**
- * Gets the HTTP Servlet Request
+ * Gets the HTTP Servlet Request. This is the Servlet
+ * containers raw request object. This request should
+ * be wrapped using <code>getPortletRequestForWindow()</code> before
+ * being processed by the portlet container.
*
- * @return HttpServletRequest
+ * @return HttpServletRequest
*/
public HttpServletRequest getRequest();
/**
- * Gets the HTTP Servlet Response
- *
+ * Gets the HTTP Servlet Response. This is the Servlet
+ * containers raw response object. This response should
+ * be wrapped using <code>getPortletResponseForWindow()</code> before
+ * being processed by the portlet container.
* @return HttpServletResponse
*/
public HttpServletResponse getResponse();
@@ -194,5 +199,42 @@
* @param enc
*/
public void setCharacterEncoding(String enc);
+
+ /**
+ *
+ * <p>
+ * getRequestForWindow
+ * </p>
+ *
+ * Takes a PortletWindow and generates a HttpServletRequest that
+ * accurately represents that PortletWindow's request parameters
+ *
+ *
+ * @param window PortetlWindow that we are build a request for
+ * @return HttpServletRequest that wraps the existing servlet
+ * container's request that can interpret encoded portlet information
+ * for this PortletWindow
+ *
+ */
+ HttpServletRequest getRequestForWindow(PortletWindow window);
+
+ /**
+ *
+ * <p>
+ * getResponseForWindow
+ * </p>
+ *
+ * Takes a PortletWindow and generates a HttpServletResponse that
+ * accurately represents that PortletWindow's request parameters.
+ *
+ *
+ * @param window PortetlWindow that we are build a response for
+ * @return HttpServletRequest that wraps the existing servlet
+ * container's request that can interpret encoded portlet information
+ * for this PortletWindow
+ *
+ *
+ */
+ HttpServletResponse getResponseForWindow(PortletWindow window);
}
1.2 +101 -67 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java
Index: JetspeedRequestContext.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JetspeedRequestContext.java 28 Jul 2003 23:47:46 -0000 1.1
+++ JetspeedRequestContext.java 20 Oct 2003 03:52:53 -0000 1.2
@@ -59,9 +59,12 @@
import org.apache.jetspeed.PortalContext;
import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.services.factory.FactoryManager;
import org.apache.jetspeed.capability.CapabilityMap;
import org.apache.jetspeed.engine.core.PortalControlParameter;
import org.apache.jetspeed.engine.core.PortalURL;
+import org.apache.jetspeed.engine.servlet.ServletRequestFactory;
+import org.apache.jetspeed.engine.servlet.ServletResponseFactory;
import org.apache.pluto.om.window.PortletWindow;
import org.apache.pluto.om.portlet.PortletDefinition;
@@ -82,13 +85,13 @@
private ServletConfig config;
private Profile profile;
private PortletDefinition portletDefinition;
-
- private CapabilityMap capabilityMap;
- private String mimeType;
- private String mediaType;
- private PortalURL requestedPortalURL;
- private PortletWindow actionWindow;
- private String encoding;
+
+ private CapabilityMap capabilityMap;
+ private String mimeType;
+ private String mediaType;
+ private PortalURL requestedPortalURL;
+ private PortletWindow actionWindow;
+ private String encoding;
public final static String REQUEST_PORTALENV = "org.apache.jetspeed.request.RequestContext";
@@ -100,22 +103,19 @@
* @param response
* @param config
*/
- public JetspeedRequestContext(PortalContext pc,
- HttpServletRequest request,
- HttpServletResponse response,
- ServletConfig config)
+ public JetspeedRequestContext(PortalContext pc, HttpServletRequest request, HttpServletResponse response, ServletConfig config)
{
this.pc = pc;
this.request = request;
this.response = response;
this.config = config;
-
+
// set context in Request for later use
if (null != this.request)
{
this.request.setAttribute(REQUEST_PORTALENV, this);
- }
- requestedPortalURL = new PortalURL(this);
+ }
+ requestedPortalURL = new PortalURL(this);
}
private JetspeedRequestContext()
@@ -131,7 +131,7 @@
*/
public static RequestContext getRequestContext(HttpServletRequest request)
{
- return (RequestContext)request.getAttribute(REQUEST_PORTALENV);
+ return (RequestContext) request.getAttribute(REQUEST_PORTALENV);
}
public PortalContext getPortalContext()
@@ -173,69 +173,69 @@
{
this.portletDefinition = portletDefinition;
}
-
+
/** Set the capabilityMap. Used by the CapabilityValve
*
* @param capabilityMap
*/
- public void setCapabilityMap(CapabilityMap map)
- {
- this.capabilityMap = map;
- }
-
- /** get the Capability Map
- *
- */
- public CapabilityMap getCapabilityMap()
- {
- return this.capabilityMap;
- }
+ public void setCapabilityMap(CapabilityMap map)
+ {
+ this.capabilityMap = map;
+ }
- /** Set the Mimetype. Used by the CapabilityValve
- *
- * @param mimeType
- */
- public void setMimeType(String mimeType)
- {
- this.mimeType = mimeType;
- }
+ /** get the Capability Map
+ *
+ */
+ public CapabilityMap getCapabilityMap()
+ {
+ return this.capabilityMap;
+ }
- /** get the mimeType for the request
- *
- */
- public String getMimeType()
- {
- return this.mimeType;
- }
-
- /** Set the mediaType. Used by the CapabilityValve
- *
- * @param mediaType
- */
- public void setMediaType(String mediaType)
- {
- this.mediaType = mediaType;
- }
-
- /** get the Media Type
- *
- */
- public String getMediaType()
- {
- return this.mediaType;
- }
+ /** Set the Mimetype. Used by the CapabilityValve
+ *
+ * @param mimeType
+ */
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ /** get the mimeType for the request
+ *
+ */
+ public String getMimeType()
+ {
+ return this.mimeType;
+ }
+
+ /** Set the mediaType. Used by the CapabilityValve
+ *
+ * @param mediaType
+ */
+ public void setMediaType(String mediaType)
+ {
+ this.mediaType = mediaType;
+ }
+
+ /** get the Media Type
+ *
+ */
+ public String getMediaType()
+ {
+ return this.mediaType;
+ }
public PortalURL getRequestedPortalURL()
{
return requestedPortalURL;
}
-
+
public void changeRequestedPortalURL(PortalURL url, PortalControlParameter control)
{
requestedPortalURL = url;
requestedPortalURL.analyzeControlInformation(control);
}
-
+
/**
* Get the target Portlet Action Window
*
@@ -245,7 +245,7 @@
{
return actionWindow;
}
-
+
/**
* Sets the target Portlet Action Window
*
@@ -255,7 +255,7 @@
{
this.actionWindow = portletWindow;
}
-
+
/**
* get the character encoding
*
@@ -265,7 +265,7 @@
{
return this.encoding;
}
-
+
/**
* set character encoding
*
@@ -275,6 +275,40 @@
{
this.encoding = enc;
}
-
+
+ /**
+ * <p>
+ * getRequestForWindow
+ * </p>
+ *
+ * @see org.apache.jetspeed.request.RequestContext#getRequestForWindow(org.apache.pluto.om.window.PortletWindow)
+ * @param window
+ * @return
+ */
+ public HttpServletRequest getRequestForWindow(PortletWindow window)
+ {
+ ServletRequestFactory reqFac =
+ (ServletRequestFactory) FactoryManager.getFactory(javax.servlet.http.HttpServletRequest.class);
+ HttpServletRequest requestWrapper = reqFac.getServletRequest(request, window);
+ return requestWrapper;
+ }
+
+ /**
+ * <p>
+ * getResponseForWindow
+ * </p>
+ *
+ * @see org.apache.jetspeed.request.RequestContext#getResponseForWindow(org.apache.pluto.om.window.PortletWindow)
+ * @param window
+ * @return
+ */
+ public HttpServletResponse getResponseForWindow(PortletWindow window)
+ {
+ return response;
+ // TODO: Get the wrapper worker, as of now, it appears no content type is returned so we get plain text
+ // ServletResponseFactory rspFac = (ServletResponseFactory) FactoryManager.getFactory(HttpServletResponse.class);
+ // HttpServletResponse wrappedResponse = rspFac.getServletResponse(response);
+ // return wrappedResponse;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org