From 6d46c473d41c6c47e6b8bd8c676d925e544bd378 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Fri, 5 Jul 2024 12:43:13 -0400 Subject: More cleanup --- .../main/java/net/wotonomy/web/WODirectAction.java | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java') diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java index 002e2a3..db3bbc8 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WODirectAction.java @@ -89,13 +89,15 @@ public class WODirectAction { * Returns the existing session, or null if no session exists. */ public WOSession existingSession() { - // FIXME: this is incorrect - // To do this correctly, probably want to use WOSessionStore + // TODO check this actually works + WOSessionStore store = WOSessionStore.serverSessionStore(); HttpSession session = request.servletRequest().getSession(); if (session == null) return null; - WOSession wosession = new WOSession(); - wosession.setServletSession(session); + WOSession wosession = store.restoreSessionWithID(session.getId(), request); + + //WOSession wosession = new WOSession(); + //wosession.setServletSession(session); return wosession; } @@ -105,9 +107,17 @@ public class WODirectAction { * ids/cookies, this will create a new session with each request. */ public WOSession session() { - // FIXME: this is incorrect - WOSession wosession = new WOSession(); - wosession.setServletSession(request.servletRequest().getSession(true)); + // TODO check this actually works + + WOSessionStore store = WOSessionStore.serverSessionStore(); + HttpSession session = request.servletRequest().getSession(); + if (session == null) + return null; + WOSession wosession = store.restoreSessionWithID(session.getId(), request); + if (wosession == null) { + wosession = new WOSession(); + wosession.setServletSession(request.servletRequest().getSession(true)); + } return wosession; } @@ -150,7 +160,7 @@ public class WODirectAction { * this object with matching names whose type is NSArray or is convertable from * a Collection. */ - public void takeFormValueArraysForKeyArray(NSArray anArray) { + public void takeFormValueArraysForKeyArray(NSArray anArray) { if (anArray == null) return; @@ -190,14 +200,14 @@ public class WODirectAction { * Assigns the form values for the specified keys to properties on this object * with matching names. */ - public void takeFormValuesForKeyArray(NSArray anArray) { + public void takeFormValuesForKeyArray(NSArray anArray) { if (anArray == null) return; Method m; Object key; Object value; - java.util.Enumeration e = anArray.objectEnumerator(); + java.util.Enumeration e = anArray.objectEnumerator(); while (e.hasMoreElements()) { key = e.nextElement(); value = request.formValueForKey(key.toString()); -- cgit v1.2.3