You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by at...@apache.org on 2008/10/22 02:48:45 UTC
svn commit: r706826 - in
/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl:
PortletRequestImpl.java PortletSessionImpl.java
Author: ate
Date: Tue Oct 21 17:48:44 2008
New Revision: 706826
URL: http://svn.apache.org/viewvc?rev=706826&view=rev
Log:
Fixing PLUTO-516: Pluto's PorletSessionImpl#setAttribute sometimes sets var into APPLICATION_SCOPE without explanation
See: https://issues.apache.org/jira/browse/PLUTO-516
Modified:
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=706826&r1=706825&r2=706826&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java Tue Oct 21 17:48:44 2008
@@ -104,7 +104,7 @@
private PortalContext portalContext;
/** The portlet session. */
- private PortletSession portletSession;
+ private PortletSessionImpl portletSession;
/** Response content types. */
private Vector contentTypes;
@@ -275,11 +275,6 @@
portletWindow,
httpSession);
}
- //for RequestDispatcher
- if (isForwarded() || isIncluded())
- ((PortletSessionImpl)portletSession).setIncludeOrForward(true);
- else
- ((PortletSessionImpl)portletSession).setIncludeOrForward(false);
return portletSession;
}
@@ -1029,17 +1024,33 @@
@Override
public HttpSession getSession() {
if (isIncluded() || isForwarded()){
- PortletSession session = getPortletSession();
- return (HttpSession)session;
+ // ensure cached PortletSession is created (with proper HttpSession invalidation check performed)
+ getPortletSession();
+ if (portletSession != null)
+ {
+ return portletSession.getHttpSession();
+ }
+ else
+ {
+ return null;
+ }
}
return super.getSession();
}
@Override
- public HttpSession getSession(boolean arg0) {
+ public HttpSession getSession(boolean create) {
if (isIncluded() || isForwarded()){
- PortletSession session = getPortletSession(arg0);
- return (HttpSession)session;
+ // ensure cached PortletSession is created (with proper HttpSession invalidation check performed)
+ getPortletSession(create);
+ if (portletSession != null)
+ {
+ return portletSession.getHttpSession();
+ }
+ else
+ {
+ return null;
+ }
}
return super.getSession();
}
Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java?rev=706826&r1=706825&r2=706826&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java Tue Oct 21 17:48:44 2008
@@ -26,9 +26,7 @@
import javax.portlet.PortletContext;
import javax.portlet.PortletSession;
import javax.portlet.PortletSessionUtil;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,7 +37,7 @@
* Implementation of the <code>javax.portlet.PortletSession</code> interface.
*
*/
-public class PortletSessionImpl implements PortletSession, HttpSession {
+public class PortletSessionImpl implements PortletSession {
/** Logger. */
private static final Log LOG = LogFactory.getLog(PortletSessionImpl.class);
@@ -65,9 +63,6 @@
/** The portlet window. */
private PortletWindow portletWindow;
- //
- private boolean isIncludeOrForward = false;
-
// Constructor -------------------------------------------------------------
/**
@@ -81,12 +76,18 @@
this.httpSession = httpSession;
}
+ /**
+ * Packaged scope access to the wrapped HttpSession for usage from PortletRequestImpl.getSession()
+ * @return wrapped HttpSession
+ */
+ HttpSession getHttpSession()
+ {
+ return httpSession;
+ }
// PortletSession Impl: Attributes -----------------------------------------
public Object getAttribute(String name) {
- if (isIncludeOrForward)
- return getAttribute(name, APPLICATION_SCOPE);
return getAttribute(name, DEFAULT_SCOPE);
}
@@ -105,8 +106,6 @@
}
public Enumeration getAttributeNames() {
- if (isIncludeOrForward)
- return getAttributeNames(APPLICATION_SCOPE);
return getAttributeNames(DEFAULT_SCOPE);
}
@@ -130,10 +129,7 @@
}
public void removeAttribute(String name) {
- if(isIncludeOrForward)
- removeAttribute(name, APPLICATION_SCOPE);
- else
- removeAttribute(name, DEFAULT_SCOPE);
+ removeAttribute(name, DEFAULT_SCOPE);
}
public void removeAttribute(String name, int scope) {
@@ -146,10 +142,7 @@
}
public void setAttribute(String name, Object value) {
- if (isIncludeOrForward)
- setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
- else
- setAttribute(name, value, DEFAULT_SCOPE);
+ setAttribute(name, value, DEFAULT_SCOPE);
}
public void setAttribute(String name, Object value, int scope) {
@@ -260,46 +253,6 @@
// HttpSession Impl --------------------------------------------------------
- public ServletContext getServletContext() {
- return httpSession.getServletContext();
- }
-
- /**
- * DEPRECATED: implemented for backwards compatability with HttpSession.
- * @deprecated
- */
- public HttpSessionContext getSessionContext() {
- return httpSession.getSessionContext();
- }
-
- public Object getValue(String name) {
- if (isIncludeOrForward)
- return this.getAttribute(name, APPLICATION_SCOPE);
- else
- return this.getAttribute(name, DEFAULT_SCOPE);
- }
-
- /**
- * DEPRECATED: Implemented for backwards compatibility with HttpSession.
- * @deprecated
- */
- public String[] getValueNames() {
- return httpSession.getValueNames();
- }
-
- public void putValue(String name, Object value) {
- if (isIncludeOrForward)
- this.setAttribute(name, value, APPLICATION_SCOPE);
- this.setAttribute(name, value, DEFAULT_SCOPE);
- }
-
- public void removeValue(String name) {
- if (isIncludeOrForward)
- this.removeAttribute(name, APPLICATION_SCOPE);
- this.removeAttribute(name, DEFAULT_SCOPE);
- }
-
-
public Map<String, Object> getMap() {
List<String> paramNames = getAttributeNamesAsList(DEFAULT_SCOPE);
return fillMap(paramNames, DEFAULT_SCOPE);
@@ -338,10 +291,6 @@
return resultMap;
}
-
- public void setIncludeOrForward(boolean isIncludeOrForward) {
- this.isIncludeOrForward = isIncludeOrForward;
- }
/**
* Returns a <code>Map</code> of the session attributes in
* the portlet session scope.