portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r755814 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/ jetspeed-api/src/main/java/org/apache/jetspeed/
Date Thu, 19 Mar 2009 02:26:07 GMT
Author: ate
Date: Thu Mar 19 02:26:07 2009
New Revision: 755814

URL: http://svn.apache.org/viewvc?rev=755814&view=rev
Log:
JS2-871: Upgrade Pluto container
See: http://issues.apache.org/jira/browse/JS2-871
- implemented all the basic (still portlet 1.0 only) response context handling, e.g. on level
with Jetspeed-2.1.3 functionality
- adding new PortalReservedParameter PORTLET_CONTENT_ATTRIBUTE to get hold of the PortletContent
object to write to

Note: PortletContentDispatcher is probably going to "lose" its functional usage as no request/response
wrapping will be needed anymore.
Without this need for the PortletContentDispatcher(Ctrl) getRequestForWindow and getResponseForWindow
methods
it then downgrades to a simple wrapper without additional functionality. 

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletActionResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletMimeResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRenderResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextServiceImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResourceResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletStateAwareResponseContextImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletActionResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletActionResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletActionResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletActionResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -51,12 +51,12 @@
             close();
             if (!redirect || renderURLParamName != null)
             {               
+                String portalURL = getRequestContext().getPortalURL().getPortalURL();
                 if (redirect)
                 {
-                    String portalURL = getPortalURL().getPortalURL();
                     if (redirectLocation.indexOf("://") != -1 && portalURL.indexOf("://")==-1)
                     {
-                        portalURL = getPortalURL().getBaseURL() + portalURL;
+                        portalURL = getRequestContext().getPortalURL().getBaseURL() + portalURL;
                     }
                     try
                     {
@@ -70,7 +70,7 @@
                 }
                 else
                 {
-                    return getPortalURL().getPortalURL();
+                    return portalURL;
                 }
             }
             else

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletMimeResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletMimeResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletMimeResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletMimeResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -17,9 +17,6 @@
 
 package org.apache.jetspeed.container.impl;
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
 import java.util.Locale;
 
 import javax.portlet.CacheControl;
@@ -92,7 +89,6 @@
     }
     
     private CacheControl cacheControl;
-    private OutputStream outputStream;
     
     public PortletMimeResponseContextImpl(PortletContainer container, HttpServletRequest
containerRequest,
                                           HttpServletResponse containerResponse, PortletWindow
window)
@@ -103,23 +99,9 @@
     public void close()
     {
         cacheControl = null;
-        outputStream = null;
         super.close();
     }
 
-    public void flushBuffer() throws IOException
-    {
-        if (!isClosed())
-        {
-            // TODO
-        }
-    }
-
-    public int getBufferSize()
-    {
-        return 0; // TODO
-    }
-
     public CacheControl getCacheControl()
     {
         if (isClosed())
@@ -128,83 +110,31 @@
         }        
         if (cacheControl == null)
         {
-            // TODO
+            cacheControl = new CacheControlImpl();
         }
         return cacheControl;
     }
 
     public String getCharacterEncoding()
     {
-        return isClosed() ? null : null; // TODO
+        return isClosed() ? null : getServletResponse().getCharacterEncoding();
     }
 
     public String getContentType()
     {
-        return isClosed() ? null : null; //TODO
+        return isClosed() ? null : getServletResponse().getContentType();
     }
 
     public Locale getLocale()
     {
-        return isClosed() ? null : null; //TODO
-    }
-
-    public OutputStream getOutputStream() throws IOException, IllegalStateException
-    {
-        if (isClosed())
-        {
-            return null;
-        }
-        if (outputStream == null)
-        {
-            // TODO
-        }
-        return outputStream;
-    }
-
-    public PrintWriter getWriter() throws IOException, IllegalStateException
-    {
-        return isClosed() ? null : null; //TODO
-    }
-
-    public boolean isCommitted()
-    {
-        return false; //TODO
-    }
-
-    public void reset()
-    {
-        //TODO
-    }
-
-    public void resetBuffer()
-    {
-        if (!isClosed())
-        {
-            //TODO
-        }
-    }
-
-    public void setBufferSize(int size)
-    {
-        if (!isClosed())
-        {
-            //TODO
-        }
-    }
-
-    public void setContentType(String contentType)
-    {
-        if (!isClosed())
-        {
-            //TODO
-        }
+        return isClosed() ? null : getServletResponse().getLocale();
     }
 
     public PortletURLProvider getPortletURLProvider(TYPE type)
     {
         if (!isClosed())
         {
-            return new PortletURLProviderImpl(getPortalURL(), getPortletWindow(), type);
+            return new PortletURLProviderImpl(getRequestContext().getPortalURL(), getPortletWindow(),
type);
         }
         return null;
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRenderResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRenderResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRenderResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRenderResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -17,6 +17,9 @@
 
 package org.apache.jetspeed.container.impl;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.util.Collection;
 
 import javax.portlet.PortletMode;
@@ -25,7 +28,11 @@
 
 import org.apache.pluto.container.PortletContainer;
 import org.apache.pluto.container.PortletRenderResponseContext;
+import org.apache.pluto.container.util.PrintWriterServletOutputStream;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.services.title.DynamicTitleService;
 
 /**
  * @version $Id$
@@ -34,64 +41,92 @@
 public class PortletRenderResponseContextImpl extends PortletMimeResponseContextImpl implements
                 PortletRenderResponseContext
 {
+    private boolean committed;
+    private PortletContent portletContent;
+    private OutputStream outputStream;
+    private DynamicTitleService titleService;
+    
     public PortletRenderResponseContextImpl(PortletContainer container, HttpServletRequest
containerRequest,
-                                            HttpServletResponse containerResponse, PortletWindow
window)
+                                            HttpServletResponse containerResponse, PortletWindow
window, DynamicTitleService titleService)
     {
         super(container, containerRequest, containerResponse, window);
+        this.portletContent = (PortletContent)getRequestContext().getPortletWindowAttributes(getPortletWindow()).get(PortalReservedParameters.PORTLET_CONTENT_ATTRIBUTE);
+    }
+
+    public void flushBuffer() throws IOException
+    {
+        committed = true;
     }
 
+    public int getBufferSize()
+    {
+        return Integer.MAX_VALUE;
+    }
+    
+    public boolean isCommitted()
+    {
+        return committed;
+    }
+    
+    public OutputStream getOutputStream() throws IOException, IllegalStateException
+    {
+        if (isClosed())
+        {
+            return null;
+        }
+        if (outputStream == null)
+        {
+            outputStream = new PrintWriterServletOutputStream(portletContent.getWriter(),
+                                                              getServletResponse().getCharacterEncoding());
+        }
+        return outputStream;
+    }
+
+    public PrintWriter getWriter() throws IOException, IllegalStateException
+    {
+        return portletContent.getWriter();
+    }
+    
     public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
     {
         //TODO
     }
 
-    public void setTitle(String title)
+    public void reset()
     {
         if (!isClosed())
         {
-            //TODO
+            // TODO
+        }
+    }
 
-            // TODO: 2.2 jetspeed uses a title service        
-//            String title = null;
-//            if (titleArg == null || titleArg.length() == 0)
-//            {
-//                title = getTitleFromPortletDefinition(portletWindow, request);
-//            }
-//            else
-//            {
-//                title = titleArg;
-//            }
-//            request.setAttribute(
-//                    PortalReservedParameters.OVERRIDE_PORTLET_TITLE_ATTR
-//                            + "::window.id::" + portletWindow.getId(), title);        
+    public void resetBuffer()
+    {
+        if (!isClosed())
+        {
+            // TODO
+        }
+    }
 
+    public void setBufferSize(int size)
+    {
+        // ignore
+    }
+
+    public void setContentType(String contentType)
+    {
+        if (!isClosed())
+        {
+            // TODO
         }
     }
-    
-//    protected final String getTitleFromPortletDefinition(org.apache.pluto.PortletWindow
window, HttpServletRequest request)
-//    {
-//        String title = null;
-//        RequestContext requestContext = (RequestContext) request
-//                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-//        
-//        org.apache.jetspeed.container.PortletWindow  jsWindow = (org.apache.jetspeed.container.PortletWindow)window;
-//        PortletEntity entity = jsWindow.getPortletEntity();
-//        if (entity != null && entity.getPortletDefinition() != null)
-//        {
-//            title = requestContext.getPreferedLanguage(
-//                    entity.getPortletDefinition()).getTitle();
-//        }
-//
-//        if (title == null && entity.getPortletDefinition() != null)
-//        {
-//            title = entity.getPortletDefinition().getPortletName();
-//        }
-//        else if (title == null)
-//        {
-//            title = "Invalid portlet entity " + entity.getId();
-//        }
-//        
-//        return title;
-//    }
-    
+
+    public void setTitle(String title)
+    {
+        if (!isClosed())
+        {
+            portletContent.setTitle(title);
+            titleService.setDynamicTitle(getPortletWindow(), getContainerRequest(), title);
+        }
+    } 
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -66,6 +66,7 @@
     private PortletContext portletContext;
     private ServletContext servletContext;
     private Cookie cookies[];
+    private JetspeedRequestContext requestContext;
     private Map<String, Object> windowAttributes;
     
     private Map<String, String[]> privateParameters;
@@ -77,8 +78,13 @@
         this.containerRequest = containerRequest;
         this.containerResponse = containerResponse;
         this.window = window;
-        JetspeedRequestContext rc = (JetspeedRequestContext)containerRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-        windowAttributes = rc.getPortletWindowAttributes(window);
+        this.requestContext = (JetspeedRequestContext)containerRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        windowAttributes = requestContext.getPortletWindowAttributes(window);
+    }
+    
+    protected JetspeedRequestContext getRequestContext()
+    {
+        return requestContext;
     }
     
     private static boolean getMetaDataBooleanValue(GenericMetadata metaData, String fieldName,
boolean defaultValue )
@@ -128,21 +134,17 @@
             
             // get portlet *private* navigational params
             privateParameters = new HashMap<String, String[]>();
-            JetspeedRequestContext context = (JetspeedRequestContext) getAttribute("org.apache.jetspeed.request.RequestContext");
-            if (context != null)
-            {
-                NavigationalState ns = context.getPortalURL().getNavigationalState();
-                mergeRequestParameters = ns.getPortletWindowOfAction() != null || ns.getPortletWindowOfResource()
!= null;
-                Iterator<String> iter = ns.getParameterNames(getPortletWindow());
-                while (iter.hasNext())
-                {
-                    String name = iter.next();
-                    String[] values = ns.getParameterValues(getPortletWindow(), name);
-                    privateParameters.put(name, values);
-                }
+            NavigationalState ns = requestContext.getPortalURL().getNavigationalState();
+            mergeRequestParameters = ns.getPortletWindowOfAction() != null || ns.getPortletWindowOfResource()
!= null;
+            Iterator<String> iter = ns.getParameterNames(getPortletWindow());
+            while (iter.hasNext())
+            {
+                String name = iter.next();
+                String[] values = ns.getParameterValues(getPortletWindow(), name);
+                privateParameters.put(name, values);
             }
             
-            PortletDefinition portletDef = getPortletWindow().getPortletEntity().getPortletDefinition();
+            PortletDefinition portletDef = window.getPortletEntity().getPortletDefinition();
             if(portletDef != null)
             {
                 GenericMetadata metaData = portletDef.getMetadata();
@@ -169,18 +171,17 @@
             //get request params
             if (mergeRequestParameters)
             {
-                String encoding = (String)getContainerRequest().getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE);
-                boolean decode = getContainerRequest().getAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE)
== null
+                String encoding = (String)containerRequest.getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE);
+                boolean decode = containerRequest.getAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE)
== null
                         && encoding != null;
                 if (decode)
                 {
-                    getContainerRequest().setAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE,
-                            new Boolean(true));
+                    containerRequest.setAttribute(PortalReservedParameters.PARAMETER_ALREADY_DECODED_ATTRIBUTE,new
Boolean(true));
                 }
-                for (Enumeration parameters = getContainerRequest().getParameterNames();
parameters.hasMoreElements();)
+                for (Enumeration parameters = containerRequest.getParameterNames(); parameters.hasMoreElements();)
                 {
                     String paramName = (String) parameters.nextElement();
-                    String[] paramValues = getContainerRequest().getParameterValues(paramName);
+                    String[] paramValues = containerRequest.getParameterValues(paramName);
 
                     if (decode)
                     {
@@ -292,9 +293,8 @@
     
     public Locale getPreferredLocale()
     {
-        RequestContext requestContext = (RequestContext)getContainerRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
         Locale preferedLocale = requestContext.getLocale();
-        return preferedLocale != null ? preferedLocale : getContainerRequest().getLocale();
+        return preferedLocale != null ? preferedLocale : containerRequest.getLocale();
     }
 
     public void init(PortletContext portletContext, ServletContext servletContext, HttpServletRequest
servletRequest, HttpServletResponse servletResponse)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextServiceImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletRequestContextServiceImpl.java
Thu Mar 19 02:26:07 2009
@@ -20,6 +20,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.jetspeed.services.title.DynamicTitleService;
 import org.apache.pluto.container.PortletActionResponseContext;
 import org.apache.pluto.container.PortletContainer;
 import org.apache.pluto.container.PortletEventResponseContext;
@@ -35,6 +36,13 @@
  */
 public class PortletRequestContextServiceImpl implements PortletRequestContextService
 {
+    private DynamicTitleService titleService;
+    
+    public PortletRequestContextServiceImpl(DynamicTitleService titleService)
+    {
+        this.titleService = titleService;
+    }
+    
     public PortletRequestContext getPortletActionRequestContext(PortletContainer container,
HttpServletRequest containerRequest,
                                                                 HttpServletResponse containerResponse,
PortletWindow window)
     {
@@ -73,7 +81,7 @@
                                                                         HttpServletResponse
containerResponse,
                                                                         PortletWindow window)
     {
-        return new PortletRenderResponseContextImpl(container, containerRequest, containerResponse,
(org.apache.jetspeed.container.PortletWindow)window);
+        return new PortletRenderResponseContextImpl(container, containerRequest, containerResponse,
(org.apache.jetspeed.container.PortletWindow)window, titleService);
     }
 
     public PortletResourceRequestContext getPortletResourceRequestContext(PortletContainer
container,

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResourceResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResourceResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResourceResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResourceResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -17,34 +17,164 @@
 
 package org.apache.jetspeed.container.impl;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Collection;
 import java.util.Locale;
 
+import javax.portlet.PortletMode;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.pluto.container.PortletContainer;
+import org.apache.pluto.container.PortletRenderResponseContext;
 import org.apache.pluto.container.PortletResourceResponseContext;
+import org.apache.pluto.container.util.PrintWriterServletOutputStream;
 import org.apache.jetspeed.container.PortletWindow;
 
 /**
+ * PortletResourceResponseContextImpl implements <em>both</em> PortletResourceResponseContext
+ * and PortletRenderResponseContext to support Portlet 1.0 based Portlets using the 
+ * Portals Bridges pre Portlet 2.0 PortletResourceURLFactory to serve resources on top of
+ * a RenderURL.
+ * 
+ * Jetspeed still provides backwards compatibility by forwarding to the portlet and plugging
+ * in this PortletResourceResponseContextImpl instead of PortletRenderResponseContextImpl,
+ * which is why it needs to implement both interfaces.
+ * 
+ * The PortletRenderResponseContext specific methods however simply ignore any invocation.
+ * 
  * @version $Id$
  *
  */
 public class PortletResourceResponseContextImpl extends PortletMimeResponseContextImpl implements
-                PortletResourceResponseContext
+                PortletResourceResponseContext, PortletRenderResponseContext
 {
+    private static final String DEFAULT_CONTAINER_CHARSET = "UTF-8";
+    
+    private OutputStream outputStream;
+    private boolean charsetSet;
     
     public PortletResourceResponseContextImpl(PortletContainer container, HttpServletRequest
containerRequest,
                                               HttpServletResponse containerResponse, PortletWindow
window)
     {        
         super(container, containerRequest, containerResponse, window);
     }
+    
+    /**
+     * PortletRenderResponseContext method provided to support PortletResourceURLFactory
usage
+     * which is served over a RenderURL. Any invocation is ignored.
+     */
+    public void setTitle(String title)
+    {
+        // ignore
+    }
+
+    /**
+     * PortletRenderResponseContext method provided to support PortletResourceURLFactory
usage
+     * which is served over a RenderURL. Any invocation is ignored.
+     */
+    public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
+    {
+        //ignore
+    }
+
+    public void flushBuffer() throws IOException
+    {
+        if (!isClosed())
+        {
+            getServletResponse().flushBuffer();
+        }
+    }
+    
+    public int getBufferSize()
+    {
+        return getServletResponse().getBufferSize();
+    }
+
+    @Override
+    public void close()
+    {
+        outputStream = null;
+        super.close();
+    }
+
+    public boolean isCommitted()
+    {
+        return getServletResponse().isCommitted();
+    }
+
+    public OutputStream getOutputStream() throws IOException, IllegalStateException
+    {
+        if (isClosed())
+        {
+            return null;
+        }
+        if (outputStream == null)
+        {
+            try
+            {
+                outputStream = getServletResponse().getOutputStream();
+            }
+            catch (IllegalStateException e)
+            {
+                // handle situation where underlying ServletResponse its getWriter()
+                // has been called already anyway: return a wrapped PrintWriter in that case
+                if (!charsetSet)
+                {
+                    setCharacterEncoding(DEFAULT_CONTAINER_CHARSET);
+                }
+                outputStream = new PrintWriterServletOutputStream(getServletResponse().getWriter(),
+                                                                   getServletResponse().getCharacterEncoding());
+            }
+        }
+        return outputStream;
+    }
+
+    public PrintWriter getWriter() throws IOException, IllegalStateException
+    {
+        return isClosed() ? null : getServletResponse().getWriter();
+    }
+
+    public void reset()
+    {
+        if (!isClosed())
+        {
+            getServletResponse().reset();
+        }
+    }
+
+    public void resetBuffer()
+    {
+        if (!isClosed())
+        {
+            getServletResponse().reset();
+        }
+    }
+
+    public void setBufferSize(int size)
+    {
+        if (!isClosed())
+        {
+            getServletResponse().setBufferSize(size);
+        }
+    }
+
+    public void setContentType(String contentType)
+    {
+        if (!isClosed())
+        {
+            getServletResponse().setContentType(contentType);
+        }
+    }
 
     public void setCharacterEncoding(String charset)
     {
         if (!isClosed())
         {
-            //TODO
+            charsetSet = true;
+            getContainerResponse().setCharacterEncoding(charset);
         }
     }
 
@@ -52,7 +182,7 @@
     {
         if (!isClosed())
         {
-            //TODO
+            getContainerResponse().setContentLength(len);
         }
     }
 
@@ -60,7 +190,7 @@
     {
         if (!isClosed())
         {
-            //TODO
+            getContainerResponse().setLocale(locale);
         }
     }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -26,9 +26,7 @@
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.container.providers.ResourceURLProviderImpl;
-import org.apache.jetspeed.container.url.PortalURL;
 import org.apache.jetspeed.request.JetspeedRequestContext;
-import org.apache.jetspeed.request.RequestContext;
 import org.apache.pluto.container.ResourceURLProvider;
 import org.w3c.dom.Element;
 
@@ -46,7 +44,7 @@
     private PortletWindow window;
     private boolean closed;
     private boolean released;
-    private PortalURL portalURL;
+    private JetspeedRequestContext requestContext;
     
     public PortletResponseContextImpl(PortletContainer container, HttpServletRequest containerRequest,
                                       HttpServletResponse containerResponse, PortletWindow
window)
@@ -55,13 +53,12 @@
         this.containerRequest = containerRequest;
         this.containerResponse = containerResponse;
         this.window = window;
-        JetspeedRequestContext rc = (JetspeedRequestContext)containerRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-        portalURL = rc.getPortalURL();
+        this.requestContext = (JetspeedRequestContext)containerRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
     }
     
-    protected PortalURL getPortalURL()
+    protected JetspeedRequestContext getRequestContext()
     {
-        return portalURL;
+        return requestContext;
     }
     
     protected boolean isClosed()
@@ -145,6 +142,7 @@
         container = null;
         servletRequest = null;
         servletResponse = null;
+        requestContext = null;
         window = null;
     }
 
@@ -161,8 +159,7 @@
     {
         if (!isReleased())
         {
-            RequestContext rc = (RequestContext) servletRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-            return new ResourceURLProviderImpl(rc, window);
+            return new ResourceURLProviderImpl(requestContext, window);
         }
         return null;
     

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletStateAwareResponseContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletStateAwareResponseContextImpl.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletStateAwareResponseContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/impl/PortletStateAwareResponseContextImpl.java
Thu Mar 19 02:26:07 2009
@@ -32,11 +32,9 @@
 import org.apache.pluto.container.PortletStateAwareResponseContext;
 import org.apache.pluto.container.PortletURLProvider;
 import org.apache.pluto.container.impl.PortletURLImpl;
-import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.container.providers.PortletURLProviderImpl;
 import org.apache.jetspeed.events.JetspeedEventCoordinationService;
-import org.apache.jetspeed.request.JetspeedRequestContext;
 
 /**
  * @version $Id$
@@ -52,8 +50,7 @@
                                                 HttpServletResponse containerResponse, PortletWindow
window)
     {
         super(container, containerRequest, containerResponse, window);
-        JetspeedRequestContext rc = (JetspeedRequestContext)containerRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
       
-        this.portletURLProvider = new PortletURLProviderImpl(rc.getPortalURL(), window, PortletURLProvider.TYPE.RENDER);
+        this.portletURLProvider = new PortletURLProviderImpl(getRequestContext().getPortalURL(),
window, PortletURLProvider.TYPE.RENDER);
     }
     
     @Override

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java?rev=755814&r1=755813&r2=755814&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
Thu Mar 19 02:26:07 2009
@@ -52,6 +52,7 @@
     public static final String PREFERED_LANGUAGE_ATTRIBUTE = "org.apache.jetspeed.prefered.language";
     public static final String PREFERED_LOCALE_ATTRIBUTE = "org.apache.jetspeed.prefered.locale";
     public static final String PREFERED_CHARACTERENCODING_ATTRIBUTE = "org.apache.jetspeed.prefered.characterencoding";
+    public static final String PORTLET_CONTENT_ATTRIBUTE = "org.apache.jetspeed.PortletContent";
     public static final String CONTENT_DISPATCHER_ATTRIBUTE = "org.apache.jetspeed.ContentDispatcher";
     public static final String OVERRIDE_PORTLET_TITLE_ATTR = "org.apache.jetspeed.portlet.title";
     public static final String HEADER_RESOURCE_ATTRIBUTE = "org.apache.jetspeed.headerresource";



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message