portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdore...@apache.org
Subject svn commit: r577677 - in /portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto: core/ internal/impl/
Date Thu, 20 Sep 2007 10:45:30 GMT
Author: cdoremus
Date: Thu Sep 20 03:45:29 2007
New Revision: 577677

URL: http://svn.apache.org/viewvc?rev=577677&view=rev
Log:
Applied RequestImpl_for_requestDispatcher_030907.patch  for PLUTO-423. Thank you Torsten!

Modified:
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionResponseImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/core/PortletServlet.java
Thu Sep 20 03:45:29 2007
@@ -125,7 +125,8 @@
         }
         portletConfig = new PortletConfigImpl(getServletConfig(),
                                               portletContext,
-                                              portletDD);
+                                              portletDD,
+                                              portletAppDD);
         
         // Create and initialize the portlet wrapped in the servlet.
         try {

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionRequestImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionRequestImpl.java
Thu Sep 20 03:45:29 2007
@@ -20,15 +20,16 @@
 
 import javax.portlet.ActionRequest;
 import javax.portlet.PortletPreferences;
+import javax.servlet.ServletInputStream;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.Constants;
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.internal.InternalActionRequest;
 import org.apache.pluto.internal.InternalPortletWindow;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
 
 /**
  * Implementation of the <code>javax.portlet.ActionRequest</code> interface.
@@ -106,5 +107,18 @@
 		// TODO Auto-generated method stub
 		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}
+	/////////////////////////////////////////////////////////////////////////////////////////
+	//for RequestDispatcher include and forward 
+	/////////////////////////////////////////////////////////////////////////////////////////

+	
     
+	
+    
+    public int getContentLength() {
+        return (super.isIncluded()) ? 0 : super.getContentLength();
+    }
+    
+    public ServletInputStream getInputStream() throws IOException {
+        return (super.isIncluded() || super.isForwarded()) ? (ServletInputStream)getPortletInputStream()
: super.getInputStream();
+    }
 }

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionResponseImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionResponseImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ActionResponseImpl.java
Thu Sep 20 03:45:29 2007
@@ -181,44 +181,6 @@
 	}
 
 	@Override
-	public String encodeRedirectUrl(String arg0) {
-		if (super.isForwarded() || super.isIncluded()){
-			return null;
-		}
-		else
-		return super.encodeRedirectUrl(arg0);
-	}
-
-	@Override
-	public String encodeRedirectURL(String arg0) {
-		if (super.isForwarded() || super.isIncluded()){
-			return null;
-		}
-		else
-			return super.encodeRedirectURL(arg0);
-	}
-
-	@Override
-	public void sendError(int arg0) throws IOException {
-		if (super.isForwarded() || super.isIncluded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0);
-	}
-	
-	
-
-	@Override
-	public void sendError(int arg0, String arg1) throws IOException {
-		if (super.isForwarded() || super.isIncluded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0, arg1);
-	}
-
-	@Override
 	public void setStatus(int arg0, String arg1) {
 		if (super.isForwarded() || super.isIncluded()){
 			// no operation

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
Thu Sep 20 03:45:29 2007
@@ -17,12 +17,16 @@
 package org.apache.pluto.internal.impl;
 
 
+import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.Serializable;
 import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
 
 import javax.portlet.Event;
 import javax.portlet.EventRequest;
 import javax.portlet.PortletPreferences;
+import javax.servlet.ServletInputStream;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.xml.bind.JAXBContext;
@@ -183,4 +187,38 @@
 		// TODO Auto-generated method stub
 		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}
+	
+	
+    
+    //////////////////////////////////////////////////////////////////
+	//for forward and include
+	//////////////////////////////////////////////////////////////////
+	
+	public String getCharacterEncoding() {
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getCharacterEncoding();
+    }
+	
+	public int getContentLength() {
+        return (super.isIncluded() || super.isForwarded()) ? 0 : super.getContentLength();
+    }
+	
+	public String getContentType() {
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getContentType();
+    }
+	
+	public ServletInputStream getInputStream() throws IOException {
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getInputStream();
+    }
+	
+	public BufferedReader getReader()
+    throws UnsupportedEncodingException, IOException {
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getReader();
+    }
+	
+	public void setCharacterEncoding(String encoding)
+    throws UnsupportedEncodingException {
+        if (!super.isIncluded() && !super.isForwarded()) {
+        	super.setCharacterEncoding(encoding);
+        }
+    }
 }

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java
Thu Sep 20 03:45:29 2007
@@ -183,42 +183,6 @@
 	}
 
 	@Override
-	public String encodeRedirectUrl(String arg0) {
-		if (super.isForwarded() || super.isIncluded()){
-			return null;
-		}
-		else
-		return super.encodeRedirectUrl(arg0);
-	}
-
-	@Override
-	public String encodeRedirectURL(String arg0) {
-		if (super.isForwarded() || super.isIncluded()){
-			return null;
-		}
-		else
-			return super.encodeRedirectURL(arg0);
-	}
-
-	@Override
-	public void sendError(int arg0) throws IOException {
-		if (super.isForwarded() || super.isIncluded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0);
-	}
-	
-	@Override
-	public void sendError(int arg0, String arg1) throws IOException {
-		if (super.isForwarded() || super.isIncluded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0, arg1);
-	}
-
-	@Override
 	public void setStatus(int arg0, String arg1) {
 		if (super.isForwarded() || super.isIncluded()){
 			// no operation

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java
Thu Sep 20 03:45:29 2007
@@ -16,18 +16,25 @@
  */
 package org.apache.pluto.internal.impl;
 
-import org.apache.pluto.internal.InternalPortletConfig;
-import org.apache.pluto.descriptors.common.InitParamDD;
-import org.apache.pluto.descriptors.portlet.PortletDD;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
 
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.servlet.ServletConfig;
 import javax.xml.namespace.QName;
 
-import java.util.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.descriptors.common.InitParamDD;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.internal.InternalPortletConfig;
 
 public class PortletConfigImpl implements PortletConfig, InternalPortletConfig {
 
@@ -47,15 +54,22 @@
      * The portlet descriptor.
      */
     protected PortletDD portletDD;
+    
+    /**
+     * The portlet application descriptor.
+     */
+    private PortletAppDD portletAppDD;
 
     private ResourceBundleFactory bundles;
 
     public PortletConfigImpl(ServletConfig servletConfig,
                              PortletContext portletContext,
-                             PortletDD portletDD) {
+                             PortletDD portletDD,
+                             PortletAppDD portletAppDD) {
         this.servletConfig = servletConfig;
         this.portletContext = portletContext;
         this.portletDD = portletDD;
+        this.portletAppDD = portletAppDD;
     }
 
     public String getPortletName() {
@@ -127,9 +141,7 @@
 	}
 
 	public String getDefaultNamespace() {
-		// how to get the corresponding porletAppDD
-		// TODO Auto-generated method stub
-		throw new UnsupportedOperationException("This method needs to be implemented.");
+		return portletAppDD.getDefaultNamespace();
 	}
 
 	public Enumeration<QName> getProcessingEventQNames() {

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
Thu Sep 20 03:45:29 2007
@@ -16,6 +16,34 @@
  */
 package org.apache.pluto.internal.impl;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.ccpp.Profile;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.PortletContainer;
@@ -34,35 +62,6 @@
 import org.apache.pluto.util.StringUtils;
 import org.apache.pluto.util.impl.NamespaceMapperImpl;
 
-import javax.ccpp.Profile;
-import javax.portlet.PortalContext;
-import javax.portlet.Portlet;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.PortletURL;
-import javax.portlet.WindowState;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpSession;
-import java.io.BufferedReader;
-import java.io.UnsupportedEncodingException;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import java.util.Locale;
-import java.security.Principal;
-
 /**
  * Abstract <code>javax.portlet.PortletRequest</code> implementation.
  * This class also implements InternalPortletRequest.
@@ -770,9 +769,165 @@
 		String lifecyclePhase = getLifecyclePhase();
 		this.setAttribute(LIFECYCLE_PHASE, lifecyclePhase);
 	}
+	
+	@Override
+	public String getLocalAddr() {
+		return (isIncluded() || isForwarded()) ? null : super.getLocalAddr();
+	}
+	
 
-	// ============= private methods ==================
+	@Override
+	public String getLocalName() {
+		return (isIncluded() || isForwarded()) ? null : super.getLocalName();
+	}
+
+	@Override
+	public int getLocalPort() {
+		return (isIncluded() || isForwarded()) ? null : super.getLocalPort();
+	}
+	
+	public String getProtocol() {
+        return (isIncluded() || isForwarded()) ? "HTTP/1.1" : super.getProtocol();
+    }
+
+	@Override
+	public String getRealPath(String arg0) {
+		return (isIncluded() || isForwarded()) ? null : super.getRealPath(arg0);
+	}
+
+	@Override
+	public String getRemoteAddr() {
+		return (isIncluded() || isForwarded()) ? null : super.getRemoteAddr();
+	}
+
+	@Override
+	public String getRemoteHost() {
+		return (isIncluded() || isForwarded()) ? null : super.getRemoteHost();
+	}
+
+	@Override
+	public int getRemotePort() {
+		return (isIncluded() || isForwarded()) ? 0 : super.getRemotePort();
+	}
+	
+	@Override
+	public Cookie[] getCookies() {
+		if (isIncluded() || isForwarded()){
+			// TODO:return Cookies from properties
+			return null;
+		}
+		else
+			return super.getCookies();
+	}
+
+	@Override
+	public long getDateHeader(String arg0) {
+		if (isIncluded() || isForwarded()){
+			// TODO:return header from properties
+			return 0;
+		}
+		else
+			return super.getDateHeader(arg0);
+	}
+
+	@Override
+	public String getHeader(String arg0) {
+		if (isIncluded() || isForwarded()){
+			// TODO:return Cookies from properties
+			return null;
+		}
+		else
+			return super.getHeader(arg0);
+	}
+
+	@Override
+	public Enumeration getHeaderNames() {
+		if (isIncluded() || isForwarded()){
+			// TODO:return Cookies from properties
+			return null;
+		}
+		else
+			return super.getHeaderNames();
+	}
+
+	@Override
+	public Enumeration getHeaders(String arg0) {
+		if (isIncluded() || isForwarded()){
+			// TODO:return Cookies from properties
+			return null;
+		}
+		else
+			return super.getHeaders(arg0);
+	}
+
+	@Override
+	public int getIntHeader(String arg0) {
+		if (isIncluded() || isForwarded()){
+			// TODO:return Cookies from properties
+			return 0;
+		}
+		else
+			return super.getIntHeader(arg0);
+	}
 	
+	public String getPathInfo() {
+    	if (isIncluded())
+    		return (String) super.getAttribute("javax.servlet.include.path_info");
+    	else if (isForwarded())
+    		return (String) super.getAttribute("javax.servlet.forward.path_info");
+    	else
+    		return super.getPathInfo();
+    }
+
+    public String getQueryString() {
+    	if (isIncluded())
+    		return (String) super.getAttribute("javax.servlet.include.query_string");
+    	else if (isForwarded())
+    		return (String) super.getAttribute("javax.servlet.forward.query_string");
+    	else
+	    	return super.getQueryString();
+    }
+    
+    
+    public String getPathTranslated() {
+    	if (isIncluded() || isForwarded()){
+    		String path = getServletPath() + getPathInfo() + "?" + getQueryString();
+    		return getRealPath(path);
+    	}
+    	return super.getPathTranslated();
+    }
+    
+    public String getRequestURI() {
+    	if (isIncluded())
+    		return (String) super.getAttribute("javax.servlet.include.request_uri");
+    	else if (isForwarded())
+    		return (String) super.getAttribute("javax.servlet.forward.request_uri");
+    	else
+    		return super.getRequestURI();
+    }
+    
+    public String getServletPath() {
+    	if (isIncluded())
+    		return (String) super.getAttribute("javax.servlet.include.servlet_path");
+    	else if (isForwarded())
+    		return (String) super.getAttribute("javax.servlet.forward.servlet_path");
+    	else
+    		return super.getServletPath();
+    }
+    
+    public StringBuffer getRequestURL() {
+        return (isIncluded() || isForwarded()) ? null : super.getRequestURL();
+    }
+    
+    
+	
+	// ============= private methods ==================
+
+	public String getLifecyclePhase() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
 	private void setCCPPProfile() {
 		Profile profile = container.getRequiredContainerServices().getCCPPProfileService().getCCPPProfile(servletRequest);
 		this.setAttribute(CCPP_PROFILE, profile);

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
Thu Sep 20 03:45:29 2007
@@ -281,6 +281,44 @@
 	     }
 	     return validNamespace.toString();
 	}
+	
+	@Override
+	public String encodeRedirectUrl(String arg0) {
+		if (isForwarded() || isIncluded()){
+			return null;
+		}
+		else
+		return super.encodeRedirectUrl(arg0);
+	}
+
+	@Override
+	public String encodeRedirectURL(String arg0) {
+		if (isForwarded() || isIncluded()){
+			return null;
+		}
+		else
+			return super.encodeRedirectURL(arg0);
+	}
+	
+	@Override
+	public void sendError(int arg0) throws IOException {
+		if (isForwarded() || isIncluded()){
+			// no operation
+		}
+		else
+			super.sendError(arg0);
+	}
+	
+	
+
+	@Override
+	public void sendError(int arg0, String arg1) throws IOException {
+		if (isForwarded() || isIncluded()){
+			// no operation
+		}
+		else
+			super.sendError(arg0, arg1);
+	}
 // InternalRenderResponse Impl ---------------------------------------------
     
     public void setIncluded(boolean included) {

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
Thu Sep 20 03:45:29 2007
@@ -16,20 +16,6 @@
  */
 package org.apache.pluto.internal.impl;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.Constants;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.internal.InternalPortletWindow;
-import org.apache.pluto.internal.InternalPortletRequest;
-import org.apache.pluto.internal.InternalRenderRequest;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.RenderRequest;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -40,6 +26,21 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
+import javax.portlet.PortletPreferences;
+import javax.portlet.RenderRequest;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.Constants;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.internal.InternalPortletRequest;
+import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.InternalRenderRequest;
+
 /**
  * Implementation of the <code>javax.portlet.RenderRequest</code> interface.
  * 
@@ -99,7 +100,7 @@
      * flag is set to true, this method returns null.
      */
     public String getContentType() {
-        return super.isIncluded() ? null : super.getContentType();
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getContentType();
     }
     
     /**
@@ -107,7 +108,7 @@
      * flag is set to true, this method returns 0.
      */
     public int getContentLength() {
-        return super.isIncluded() ? 0 : super.getContentLength();
+        return (super.isIncluded() || super.isForwarded()) ? 0 : super.getContentLength();
     }
     
     /**
@@ -116,7 +117,7 @@
      */
     public BufferedReader getReader()
     throws UnsupportedEncodingException, IOException {
-        return super.isIncluded() ? null : super.getReader();
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getReader();
     }
     
     /**
@@ -124,7 +125,7 @@
      * response. If the included flag is set to true, this method returns null.
      */
     public ServletInputStream getInputStream() throws IOException {
-        return super.isIncluded() ? null : super.getInputStream();
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getInputStream();
     }
     
     
@@ -175,124 +176,19 @@
     	}
     }
     
-    
     // Included HttpServletRequest (Limited) Impl ------------------------------
     
-    /*
-     * -------------------------------------------------------------------------
-     * (non-javadoc)
-     * Portlet Spec. PLT. 16.3.3.
-     * The following methods of the HttpServletRequest must return the path and
-     * query string information used to obtain the PortletRequestDispatcher
-     * object:
-     *   getPathInfo
-     *   getPathTranslated
-     *   getQueryString
-     *   getRequestURI
-     *   getServletPath
-     * -------------------------------------------------------------------------
-     */
-    
-    public String getPathInfo() {
-    	String attr = (String) super.getAttribute(
-    			"javax.servlet.include.path_info");
-    	return (super.isIncluded() && attr != null) ? attr : super.getPathInfo();
-    }
-
-    public String getQueryString() {
-    	String attr = (String) super.getAttribute(
-    			"javax.servlet.include.query_string");
-    	return (super.isIncluded() && attr != null) ? attr : super.getQueryString();
-    }
-    
-    /**
-     * TODO: check PLT.16.3.3. page 67, line 10.
-     */
-    public String getPathTranslated() {
-    	// TODO:
-//        return null;
-		throw new UnsupportedOperationException("This method needs to be implemented.");
-    }
-    
-    public String getRequestURI() {
-    	String attr = (String) super.getAttribute(
-    			"javax.servlet.include.request_uri");
-        return (super.isIncluded() && attr != null) ? attr : super.getRequestURI();
-    }
-    
-    public String getServletPath() {
-        String attr = (String) super.getAttribute(
-                "javax.servlet.include.servlet_path");
-        return (super.isIncluded() && attr != null) ? attr : super.getServletPath();
-    }
-    
-    /*
-     * -------------------------------------------------------------------------
-     * (non-Javadoc)
-     * Portlet Spec. PLT. 16.3.3.
-     * The following methods of the HttpServletRequest must return null:
-     *   getProtocol
-     *   getRemoteAddr
-     *   getRemoteHost
-     *   getRealPath
-     *   getRequestURL
-     * -------------------------------------------------------------------------
-     */
-    
-    public String getProtocol() {
-        return super.isIncluded() ? null : super.getProtocol();
-    }
-
-    public String getRemoteAddr() {
-        return super.isIncluded() ? null : super.getRemoteAddr();
-    }
-
-    public String getRemoteHost() {
-        return super.isIncluded() ? null : super.getRemoteHost();
-    }
-
-    public String getRealPath(String path) {
-        return super.isIncluded() ? null : super.getRealPath(path);
-    }
-
-    public StringBuffer getRequestURL() {
-        return super.isIncluded() ? null : super.getRequestURL();
-    }
-    
-    /*
-     * -------------------------------------------------------------------------
-     * (non-Javadoc)
-     * Portlet Spec. PLT. 16.3.3.
-     * The following methods of the HttpServletRequest must do no operations
-     * and return null:
-     *   getCharacterEncoding
-     *   setCharacterEncoding
-     *   getContentType
-     *   getInputStream
-     *   getReader
-     * The getContentLength method of the HttpServletRequest must return 0.
-     * -------------------------------------------------------------------------
-     */
-    
     public String getCharacterEncoding() {
-        return super.isIncluded() ? null : super.getCharacterEncoding();
+        return (super.isIncluded() || super.isForwarded()) ? null : super.getCharacterEncoding();
     }
     
     public void setCharacterEncoding(String encoding)
     throws UnsupportedEncodingException {
-        if (!super.isIncluded()) {
+        if (!super.isIncluded() && !super.isForwarded()) {
         	super.setCharacterEncoding(encoding);
         }
     }
     
-    /*
-     * -------------------------------------------------------------------------
-     * (non-javadoc)
-     * Portlet Spec. PLT. 16.3.3.
-     * The getMethod method of the HttpServletRequest must always return 'GET'.
-     * -------------------------------------------------------------------------
-     */
-    
     public String getMethod() {
     	return "GET";
     }
@@ -376,5 +272,12 @@
 		// TODO Auto-generated method stub
 		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}
-    
+
+	@Override
+	public HttpSession getSession() {
+		if (isIncluded() || isForwarded()){
+			return (HttpSession) this.getPortletSession();
+		}
+		return super.getSession();
+	}
 }

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
Thu Sep 20 03:45:29 2007
@@ -323,44 +323,6 @@
 	}
 
 	// Included HttpServletResponse (Limited) Impl -----------------------------
-    
-    @Override
-    public String encodeRedirectUrl(String url) {
-    	if (super.isIncluded() || super.isForwarded()) {
-    		return null;
-    	} else {
-    		return super.encodeRedirectUrl(url);
-    	}
-    }
-    
-    @Override
-    public String encodeRedirectURL(String url) {
-    	if (super.isIncluded() || super.isForwarded()) {
-    		return null;
-    	} else {
-    		return super.encodeRedirectURL(url);
-    	}
-    }
-	
-	@Override
-	public void sendError(int arg0, String arg1) throws IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0, arg1);
-	}
-
-
-	@Override
-	public void sendError(int arg0) throws IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0);
-	}
-
 
 	@Override
 	public void sendRedirect(String arg0) throws IOException {

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
Thu Sep 20 03:45:29 2007
@@ -21,6 +21,7 @@
 
 import javax.portlet.PortletPreferences;
 import javax.portlet.ResourceRequest;
+import javax.servlet.ServletInputStream;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
@@ -31,7 +32,6 @@
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.internal.InternalResourceRequest;
 import org.apache.pluto.spi.PortletURLProvider;
-import org.apache.pluto.spi.PublicRenderParameterProvider;
 import org.apache.pluto.util.ArgumentUtility;
 import org.apache.pluto.util.StringUtils;
 
@@ -164,4 +164,7 @@
 		throw new UnsupportedOperationException("This method needs to be implemented.");
 	}
 	
+	public ServletInputStream getInputStream() throws IOException {
+        return (super.isIncluded() || super.isForwarded()) ? (ServletInputStream)getPortletInputStream()
: super.getInputStream();
+    }
 }

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java?rev=577677&r1=577676&r2=577677&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java
Thu Sep 20 03:45:29 2007
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.util.Iterator;
 import java.util.Locale;
 
 import javax.portlet.CacheControl;
@@ -32,10 +33,14 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.PortletContainer;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.descriptors.portlet.SupportsDD;
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.internal.InternalResourceResponse;
 import org.apache.pluto.spi.PortalCallbackService;
+import org.apache.pluto.util.ArgumentUtility;
 import org.apache.pluto.util.StringManager;
+import org.apache.pluto.util.StringUtils;
 
 public class ResourceResponseImpl extends StateAwareResponseImpl
 implements ResourceResponse, InternalResourceResponse {
@@ -114,6 +119,68 @@
         return super.getWriter();
     }
 	
+    public void setContentType(String contentType)
+    throws IllegalArgumentException {
+    	if (super.isIncluded()){
+    		//no operation
+    	}
+    	else{
+    		ArgumentUtility.validateNotNull("contentType", contentType);
+            String mimeType = StringUtils.getMimeTypeWithoutEncoding(contentType);
+            if (!isValidContentType(mimeType)) {
+                throw new IllegalArgumentException("Specified content type '"
+                		+ mimeType + "' is not supported.");
+            }
+            getHttpServletResponse().setContentType(mimeType);
+            this.currentContentType = mimeType;
+    	}
+    }
+    
+    /**
+     * Checks if the specified content type is valid (supported by the portlet).
+     * The specified content type should be a tripped mime type without any
+     * character encoding suffix.
+     * @param contentType  the content type to check.
+     * @return true if the content type is valid, false otherwise.
+     */
+    private boolean isValidContentType(String contentType) {
+    	boolean valid = false;
+    	
+        PortletDD portletDD = getInternalPortletWindow().getPortletEntity()
+        		.getPortletDefinition();
+        for (Iterator it = portletDD.getSupports().iterator();
+        		!valid && it.hasNext(); ) {
+            
+        	SupportsDD supportsDD = (SupportsDD) it.next();
+            String supportedType = supportsDD.getMimeType();
+            
+            // Content type is supported by an exact match.
+            if (supportedType.equals(contentType)) {
+            	valid = true;
+            }
+            // The supported type contains a wildcard.
+            else if (supportedType.indexOf("*") >= 0) {
+            	
+                int index = supportedType.indexOf("/");
+                String supportedPrefix = supportedType.substring(0, index);
+                String supportedSuffix = supportedType.substring(index + 1);
+                
+                index = contentType.indexOf("/");
+                String typePrefix = contentType.substring(0, index);
+                String typeSuffix = contentType.substring(index + 1);
+                
+                // Check if the prefixes match AND the suffixes match.
+                if (supportedPrefix.equals("*") || supportedPrefix.equals(typePrefix)) {
+                    if (supportedSuffix.equals("*") || supportedSuffix.equals(typeSuffix))
{
+                        valid = true;
+                    }
+                }
+            }
+        }
+        // Return the check result.
+        return valid;
+    }
+    
 	public Locale getLocale() {
         return getHttpServletRequest().getLocale();
     }
@@ -219,44 +286,6 @@
 	}
 
 	// Included HttpServletResponse (Limited) Impl -----------------------------
-    
-    @Override
-    public String encodeRedirectUrl(String url) {
-    	if (super.isIncluded() || super.isForwarded()) {
-    		return null;
-    	} else {
-    		return super.encodeRedirectUrl(url);
-    	}
-    }
-    
-    @Override
-    public String encodeRedirectURL(String url) {
-    	if (super.isIncluded() || super.isForwarded()) {
-    		return null;
-    	} else {
-    		return super.encodeRedirectURL(url);
-    	}
-    }
-	
-	@Override
-	public void sendError(int arg0, String arg1) throws IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0, arg1);
-	}
-
-
-	@Override
-	public void sendError(int arg0) throws IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			// no operation
-		}
-		else
-			super.sendError(arg0);
-	}
-
 
 	@Override
 	public void sendRedirect(String arg0) throws IOException {



Mime
View raw message