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:03 UTC
svn commit: r706825 - in
/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl:
PortletRequestImpl.java PortletSessionImpl.java
Author: ate
Date: Tue Oct 21 17:48:02 2008
New Revision: 706825
URL: http://svn.apache.org/viewvc?rev=706825&view=rev
Log:
Fixing PLUTO-516: Pluto's PorletSessionImpl#setAttribute sometimes sets var into APPLICATION_SCOPE without explanation
Modified:
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=706825&r1=706824&r2=706825&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java Tue Oct 21 17:48:02 2008
@@ -104,7 +104,7 @@
private PortalContext portalContext;
/** The portlet session. */
- private PortletSession portletSession;
+ private PortletSessionImpl portletSession;
/** Response content types. */
private Vector contentTypes;
@@ -275,12 +275,6 @@
internalPortletWindow,
httpSession);
}
- //for RequestDispatcher
- if (isForwarded() || isIncluded())
- ((PortletSessionImpl)portletSession).setIncludeOrForward(true);
- else
- ((PortletSessionImpl)portletSession).setIncludeOrForward(false);
-
return portletSession;
}
@@ -1034,22 +1028,38 @@
}
@Override
- public HttpSession getSession() {
- if (isIncluded() || isForwarded()){
- PortletSession session = getPortletSession();
- return (HttpSession)session;
- }
- return super.getSession();
- }
+ public HttpSession getSession() {
+ if (isIncluded() || isForwarded()){
+ // 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) {
- if (isIncluded() || isForwarded()){
- PortletSession session = getPortletSession(arg0);
- return (HttpSession)session;
- }
- return super.getSession();
- }
+ public HttpSession getSession(boolean create) {
+ if (isIncluded() || isForwarded()){
+ // 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();
+ }
// ============= private methods ==================
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java?rev=706825&r1=706824&r2=706825&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletSessionImpl.java Tue Oct 21 17:48:02 2008
@@ -26,9 +26,7 @@
import javax.portlet.PortletContext;
import javax.portlet.PortletSession;
import javax.portlet.PortletSessionUtil;
-import javax.servlet.http.HttpSessionContext;
import javax.servlet.http.HttpSession;
-import javax.servlet.ServletContext;
import org.apache.pluto.internal.InternalPortletWindow;
import org.apache.pluto.util.ArgumentUtility;
@@ -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 internal portlet window. */
private InternalPortletWindow internalPortletWindow;
- //
- 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,9 +129,6 @@
}
public void removeAttribute(String name) {
- if(isIncludeOrForward)
- removeAttribute(name, APPLICATION_SCOPE);
- else
removeAttribute(name, DEFAULT_SCOPE);
}
@@ -146,9 +142,6 @@
}
public void setAttribute(String name, Object value) {
- if (isIncludeOrForward)
- setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
- else
setAttribute(name, value, DEFAULT_SCOPE);
}
@@ -257,49 +250,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);
@@ -339,9 +289,6 @@
}
- public void setIncludeOrForward(boolean isIncludeOrForward) {
- this.isIncludeOrForward = isIncludeOrForward;
- }
/**
* Returns a <code>Map</code> of the session attributes in
* the portlet session scope.