Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/util FormCache.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/util FormCache.java

Author edk
Full name Ed Korthof
Date 2000-11-03 20:16:42 PST
Message User: edk
  Date: 00/11/03 20:16:42

  Modified: java/org/joist/security UnsecureServlet.java
               java/org/joist/session SessionManager.java
               java/org/joist/util FormCache.java
  Log:
  Changes designed to support redirects better. While the new WebMacro
  doesn't provide a means to update the context, we have control over
  and access to the object used to store form data -- FormCache -- so we
  can override the underlying object which it contains. FormCache has
  been updated for that and reformated slightly.
  
  UnsecureServlet and SessionManager now use that interface to override
  the form parameters after a redirect back. In addition, they store
  the old context (so that servlets which have saved data in it can get
  access to it) in the current context, keyed as
  UnsecureServlet.SAVE​D_CONTEXT_KEY.
  
  A debugging breadcrumb which crept in has been excised.
  
  Revision Changes Path
  1.60 +17 -4 joist/java/org/joist​/security/UnsecureSe​rvlet.java
  
  Index: UnsecureServlet.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/security/Unsec​ureServlet.java,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- UnsecureServlet.java 2000/11/04 03:20:41 1.59
  +++ UnsecureServlet.java 2000/11/04 04:16:42 1.60
  @@ -73,7 +73,7 @@
    * loading to WebMacro servlets.
    *
    * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @version $Revision: 1.59 $
  + * @version $Revision: 1.60 $
    *
    * Copyright (c) 1999 dataweb systems, inc.
    * Copyright (c) 1999, 2000 CollabNet, Inc.
  @@ -133,6 +133,12 @@
       private static Hashtable servletCache = new Hashtable();
   
       /**
  + * Used to when internal redirects require making an old context
  + * available.
  + */
  + public static final String SAVED_CONTEXT_KEY = "JOIST_REDIRECTED_CONTEXT";
  +
  + /**
        * Does connection management and other tasks common to all servlets.
        * This implements the <code>handle()​</code> method specified in
        * <code>WMServle​t</code>.
  @@ -158,8 +164,6 @@
       String templateName;
       Template template = null;
   
  - log.exception("in handle for UnsecureServlet, context "+context);
  -
       // Record the hit.
       if (webStats != null) webStats.addHit();
   
  @@ -404,7 +408,16 @@
           action = (String)original.get("action");
           context.put("action", action);
           if (debug) log.debug(">> original action=" + action);
  - context = original;
  + try {
  + //context.defaultFor​mData(original.getFo​rmData());
  + context.put(SAVED_CONTEXT_KEY, original);
  + if (debug) log.debug("original context: "+original);
  + FormCache form = (FormCache)context.g​etTool("Form");
  + FormCache oldForm =(FormCache)original​.getTool("Form");
  + form.override(oldForm);
  + } catch (ContextException e) {
  + log.exception(e);
  + }
           }
           else
           {
  
  
  
  1.16 +29 -3 joist/java/org/joist​/session/SessionMana​ger.java
  
  Index: SessionManager.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/session/Sessio​nManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SessionManager.java 2000/11/01 20:20:58 1.15
  +++ SessionManager.java 2000/11/04 04:16:42 1.16
  @@ -54,6 +54,7 @@
   
   import org.webmacro.util.*;
   import org.webmacro.servlet.*;
  +import org.webmacro.ContextException;
   
   import com.workingdogs.village.*;
   
  @@ -62,11 +63,13 @@
   import org.joist.security.*;
   import org.joist.database.DataManager;
   
  +import org.joist.security.U​nsecureServlet;
  +
   /**
     * Manages information cached in the session.
     *
     * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
     *
     * Copyright (c) 1999 dataweb systems, inc.
     * Copyright (c) 1999, 2000 Collab.Net, Inc.
  @@ -637,7 +640,17 @@
   
           if (savedContext != null)
           {
  - context = savedContext;
  + try {
  + //context.defaultFor​mData(savedContext.g​etFormData());
  + context.put(Unsecure​Servlet.SAVED_CONTEX​T_KEY,
  + savedContext);
  + log.exception("saved context: "+savedContext);
  + FormCache form = (FormCache)context.g​etTool("Form");
  + FormCache oldForm =(FormCache)savedCon​text.getTool("Form")​;
  + form.override(oldForm);
  + } catch (ContextException e) {
  + log.exception(e);
  + }
           }
   
           if (debug) log.debug("redirectToCancel: cancel to: " + cancelTo +
  @@ -829,7 +842,20 @@
   
           if (savedContext != null)
           {
  - context = savedContext;
  + try {
  + //context.defaultFor​mData(savedContext.g​etFormData());
  + context.put(Unsecure​Servlet.SAVED_CONTEX​T_KEY,
  + savedContext);
  + log.exception("saved context: "+savedContext);
  + FormCache form =
  + (FormCache)context.g​etTool("Form");
  + FormCache oldForm =
  + (FormCache)savedCont​ext.getTool("Form");​
  + form.override(oldForm);
  + } catch (ContextException e) {
  + log.exception(e);
  + }
  + context = savedContext;
           }
           }
           else
  
  
  
  1.2 +45 -41 joist/java/org/joist​/util/FormCache.java​
  
  Index: FormCache.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/util/FormCache​.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormCache.java 2000/11/01 20:24:37 1.1
  +++ FormCache.java 2000/11/04 04:16:42 1.2
  @@ -16,49 +16,53 @@
     */
   final public class FormCache implements Bag
   {
  - private ParameterParser pp = null;
  - //final HttpServletRequest _request;
  + private ParameterParser pp = null;
  + //final HttpServletRequest _request;
   
  - /**
  - * Read the form data from the supplied Request object
  - */
  - FormCache(final HttpServletRequest r) {
  - pp = new ParameterParser(r);
  - //_request = r;
  - }
  + /**
  + * Read the form data from the supplied Request object
  + */
  + FormCache(final HttpServletRequest r) {
  + pp = new ParameterParser(r);
  + //_request = r;
  + }
   
  - /**
  - * Get a form value
  - */
  - final public Object get(String field) {
  - try {
  - return (Object) pp.getObject(field);
  - //return _request.getParamete​rValues(field)[0];
  - } catch (NullPointerException ne) {
  - return null;
  - }
  - }
  + final public void override(FormCache other) {
  + this.pp = other.pp;
  + }
   
  - /**
  - *
  - */
  - final public void put(String key, Object value)
  - {
  - pp.add(key, value.toString());
  - }
  -
  - /**
  - *
  - */
  - final public void remove(String key)
  - {
  - try
  - {
  - pp.remove(key);
  - }
  - catch (Exception e)
  - {
  - // ignore
  + /**
  + * Get a form value
  + */
  + final public Object get(String field) {
  + try {
  + return (Object) pp.getObject(field);
  + //return _request.getParamete​rValues(field)[0];
  + } catch (NullPointerException ne) {
  + return null;
          }
  - }
  + }
  +
  + /**
  + *
  + */
  + final public void put(String key, Object value)
  + {
  + pp.add(key, value.toString());
  + }
  +
  + /**
  + *
  + */
  + final public void remove(String key)
  + {
  + try
  + {
  + pp.remove(key);
  + }
  + catch (Exception e)
  + {
  + // ignore
  + }
  + }
   }

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/util FormCache.java edk Ed Korthof 2000-11-03 20:16:42 PST
     Re: [joist-cvs] CVS update: joist/java/org/joist/util FormCache.java David Pellegrini <davidp at xsitedesign dot com> David Pellegrini <davidp at xsitedesign dot com> 2000-11-04 02:28:33 PST
Messages per page: