taylor 2004/05/04 15:05:18
Modified: portal/src/java/org/apache/jetspeed/container/session
NavigationalStateComponent.java
NavigationalState.java
portal/src/java/org/apache/jetspeed/container/session/impl
SessionNavigationalState.java
JetspeedNavigationalStateComponent.java
AbstractNavigationalState.java
portal/src/java/org/apache/jetspeed/velocity
JetspeedPowerTool.java
portal/src/java/org/apache/jetspeed/request
JetspeedRequestContext.java
Log:
completed synchronization of navigational state
found bug with Tomcat 4, it was in SessionNavigationalState impl
The HttpRequest was not being refreshed and stored in nav stae per request
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.4 +8 -1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java
Index: NavigationalStateComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalStateComponent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NavigationalStateComponent.java 6 Apr 2004 19:45:56 -0000 1.3
+++ NavigationalStateComponent.java 4 May 2004 22:05:17 -0000 1.4
@@ -86,4 +86,11 @@
*/
String getNavigationKey(int key);
+ /**
+ * Given a navigational key, such as s_14 (state_windowid), return the window
id portion.
+ * @param key The full key with navigation type and window id (mode_windowid)
+ * @return The window id from the key
+ */
+ String getWindowIdFromKey(String key);
+
}
1.9 +11 -1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalState.java
Index: NavigationalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/NavigationalState.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NavigationalState.java 7 Apr 2004 03:55:00 -0000 1.8
+++ NavigationalState.java 4 May 2004 22:05:17 -0000 1.9
@@ -18,6 +18,7 @@
import javax.portlet.PortletMode;
import javax.portlet.WindowState;
+import org.apache.jetspeed.request.RequestContext;
import org.apache.pluto.om.window.PortletWindow;
/**
@@ -81,5 +82,14 @@
*
*/
void sync();
+
+
+ /**
+ * Initialize the navigation state with the current context.
+ * Necessary to do so per request invocation.
+ *
+ * @param context
+ */
+ void init(RequestContext context);
}
1.11 +34 -8
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/SessionNavigationalState.java
Index: SessionNavigationalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/SessionNavigationalState.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SessionNavigationalState.java 7 Apr 2004 03:55:00 -0000 1.10
+++ SessionNavigationalState.java 4 May 2004 22:05:17 -0000 1.11
@@ -114,27 +114,53 @@
}
public void sync()
- {
- /*
+ {
PortalURL url = context.getPortalURL();
PortalControlParameter pcp = url.getControlParameters();
- System.out.println("SYNCING NOW: " + context.getPath());
-
+ String pathInfo = context.getPath();
+ /*
Iterator stateful =
pcp.getStateFullControlParameter().entrySet().iterator();
while (stateful.hasNext())
{
Map.Entry entry = (Map.Entry)stateful.next();
System.out.println("STATEFUL KEY = " + entry.getKey() + ", VALUE = " +
entry.getValue());
}
+ */
Iterator stateless =
pcp.getStateLessControlParameter().entrySet().iterator();
while (stateless.hasNext())
{
Map.Entry entry = (Map.Entry)stateless.next();
- System.out.println("STATELESS KEY = " + entry.getKey() + ", VALUE = " +
entry.getValue());
+ String key = (String)entry.getKey();
+ String windowId = nav.getWindowIdFromKey(key);
+ if (null == windowId)
+ {
+ continue;
+ }
+ if
(key.startsWith(nav.getNavigationKey(NavigationalStateComponent.STATE)))
+ {
+ String windowState = (String)entry.getValue();
+ WindowState previousState = (WindowState)states.get(windowId);
+ if (previousState != null)
+ {
+ pstates.put(windowId, previousState);
+ }
+ states.put(windowId, new WindowState (windowState));
+ // System.out.println("STATE UPDATED = " + windowId + ", = " +
windowState);
+ }
+ else if
(key.startsWith(nav.getNavigationKey(NavigationalStateComponent.MODE)))
+ {
+ String mode = (String)entry.getValue();
+ PortletMode previousMode = (PortletMode)modes.get(windowId);
+ if (previousMode != null)
+ {
+ pmodes.put(windowId, previousMode);
+ }
+ modes.put(windowId, new PortletMode(mode));
+ // System.out.println("MODE UPDATED = " + windowId + ", = " + mode);
+ }
+
}
- System.out.println("DONE SYNCING NOW: " );
- */
}
}
1.5 +21 -1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java
Index: JetspeedNavigationalStateComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/JetspeedNavigationalStateComponent.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JetspeedNavigationalStateComponent.java 7 Apr 2004 03:55:00 -0000 1.4
+++ JetspeedNavigationalStateComponent.java 4 May 2004 22:05:17 -0000 1.5
@@ -119,6 +119,10 @@
Constructor constructor = navClass.getConstructor(new Class[]
{RequestContext.class, NavigationalStateComponent.class});
state = (NavigationalState) constructor.newInstance(new Object[]
{context, this});
}
+ else
+ {
+ state.init(context);
+ }
if (sessionBased && session != null)
{
@@ -179,4 +183,20 @@
return "";
}
+ /**
+ * Given a navigational key, such as s_14 (state_windowid), return the window id
+ * @param key
+ * @return The window id from the key
+ */
+ public String getWindowIdFromKey(String key)
+ {
+ String delimiter = navigationKeyNames[NavigationalStateComponent.PREFIX];
+ StringTokenizer tokenizer = new StringTokenizer(key, delimiter);
+ if (!tokenizer.hasMoreTokens())
+ return null;
+ tokenizer.nextToken(); // navigational directive
+ if (!tokenizer.hasMoreTokens())
+ return null;
+ return tokenizer.nextToken();
+ }
}
1.3 +7 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/AbstractNavigationalState.java
Index: AbstractNavigationalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/session/impl/AbstractNavigationalState.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractNavigationalState.java 6 Apr 2004 19:45:57 -0000 1.2
+++ AbstractNavigationalState.java 4 May 2004 22:05:17 -0000 1.3
@@ -37,7 +37,12 @@
this.context = context;
this.nav = nav;
}
-
+
+ public void init(RequestContext context)
+ {
+ this.context = context;
+ }
+
public boolean isNavigationalParameter(String token)
{
return
token.startsWith(nav.getNavigationKey(NavigationalStateComponent.PREFIX));
1.11 +28 -1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
Index: JetspeedPowerTool.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JetspeedPowerTool.java 15 Apr 2004 21:22:25 -0000 1.10
+++ JetspeedPowerTool.java 4 May 2004 22:05:18 -0000 1.11
@@ -24,10 +24,12 @@
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
import javax.servlet.jsp.PageContext;
import org.apache.commons.configuration.Configuration;
@@ -39,6 +41,7 @@
import org.apache.jetspeed.capability.CapabilityMap;
import org.apache.jetspeed.components.ComponentManager;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
+import org.apache.jetspeed.container.session.NavigationalState;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
import org.apache.jetspeed.locator.LocatorDescriptor;
import org.apache.jetspeed.locator.TemplateDescriptor;
@@ -212,6 +215,30 @@
}
+ /**
+ * Gets the window state for the current portlet window (fragment)
+ *
+ * @return The window state for the current window
+ */
+ public WindowState getWindowState()
+ {
+ RequestContext context = Jetspeed.getCurrentRequestContext();
+ NavigationalState nav = context.getNavigationalState();
+ return nav.getState(windowAccess.getPortletWindow(getCurrentFragment()));
+ }
+
+ /**
+ * Gets the portlet mode for a current portlet window (fragment)
+ *
+ * @return The portlet mode of the current window
+ */
+ public PortletMode getPortletMode()
+ {
+ RequestContext context = Jetspeed.getCurrentRequestContext();
+ NavigationalState nav = context.getNavigationalState();
+ return nav.getMode(windowAccess.getPortletWindow(getCurrentFragment()));
+ }
+
/**
* @param request
*/
1.16 +12 -5
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- JetspeedRequestContext.java 7 Apr 2004 03:55:31 -0000 1.15
+++ JetspeedRequestContext.java 4 May 2004 22:05:18 -0000 1.16
@@ -65,6 +65,7 @@
private PortalURL url;
private PortletWindow actionWindow;
private String encoding;
+ private String requestPath = null;
public final static String REQUEST_PORTALENV =
"org.apache.jetspeed.request.RequestContext";
@@ -382,12 +383,16 @@
*/
public String getPath()
{
- if (request.getPathInfo() == null)
+ if (this.requestPath != null)
{
+ return this.requestPath;
+ }
+ String pathInfo = request.getPathInfo();
+ if (pathInfo == null)
+ {
+ this.requestPath = null;
return null;
}
- String pathInfo = new String(request.getPathInfo());
- // System.out.println("path info = " + pathInfo);
StringTokenizer tokenizer = new StringTokenizer(pathInfo, "/");
StringBuffer path = new StringBuffer();
int mode = 0; // 0=navigation, 1=control information
@@ -410,9 +415,11 @@
String result = path.toString();
if (result.equals("/") || result.trim().length() == 0)
{
+ this.requestPath = null;
return null;
}
- return result;
+ this.requestPath = result;
+ return this.requestPath;
}
public PortalURL getPortalURL()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]