Author: husted
Date: Wed Dec  7 18:59:12 2005
New Revision: 354951

URL: http://svn.apache.org/viewcvs?rev=354951&view=rev
Log:
MailReader 
* Collate the "do" methods. 

Modified:
    
struts/apps/trunk/mailreader/src/java/org/apache/struts/apps/mailreader/actions/BaseAction.java

Modified: 
struts/apps/trunk/mailreader/src/java/org/apache/struts/apps/mailreader/actions/BaseAction.java
URL: 
http://svn.apache.org/viewcvs/struts/apps/trunk/mailreader/src/java/org/apache/struts/apps/mailreader/actions/BaseAction.java?rev=354951&r1=354950&r2=354951&view=diff
==============================================================================
--- 
struts/apps/trunk/mailreader/src/java/org/apache/struts/apps/mailreader/actions/BaseAction.java
 (original)
+++ 
struts/apps/trunk/mailreader/src/java/org/apache/struts/apps/mailreader/actions/BaseAction.java
 Wed Dec  7 18:59:12 2005
@@ -41,6 +41,12 @@
 /**
  * <p>
  * Base Action for MailReader application.
+ * </p><p>
+ * All the BaseAction helper methods are prefixed with "do"
+ * so that they can be easily distinguished from Struts and Servlet API 
methods.
+ * BaseAction subclasses may also have prive "do" helpers of their own.
+ * </p><p>
+ * Methods are kept in alphabetical order, to make them easier to find.
  * </p>
  * @version $Rev$ $Date$
  */
@@ -58,6 +64,91 @@
     // ------------------------------------------------------ Protected Methods
 
     /**
+     * <p>Store User object in client session.
+     * If user object is null, any existing user object is removed.</p>
+     *
+     * @param request The request we are processing
+     * @param user The user object returned from the database
+     */
+    void doCacheUser(HttpServletRequest request, User user) {
+
+        HttpSession session = request.getSession();
+        session.setAttribute(Constants.USER_KEY, user);
+        if (log.isDebugEnabled()) {
+            log.debug(
+                "LogonAction: User '"
+                    + user.getUsername()
+                    + "' logged on in session "
+                    + session.getId());
+        }
+    }
+
+    /**
+     * <p>
+     * Helper method to log event and cancel transaction.
+     * </p>
+     * @param session Our HttpSession
+     * @param method Method being processed
+     * @param key Attrkibute to remove from session, if any
+     */
+    protected void doCancel (HttpSession session, String method, String key) {
+        if (log.isTraceEnabled()) {
+            StringBuffer sb = new StringBuffer(128);
+            sb.append(Constants.LOG_CANCEL);
+            sb.append(method);
+            log.trace(sb.toString());
+        }
+        if (key!=null) session.removeAttribute(key);
+    }
+
+    /**
+     * <p>
+     * Return the local or global forward named "failure"
+     * or null if there is no such forward.
+     * </p>
+     * @param mapping Our ActionMapping
+     * @return Return the mapping named "failure" or null if there is no such 
mapping.
+     */
+    protected ActionForward doFindFailure(ActionMapping mapping) {
+        if (log.isTraceEnabled()) {
+            log.trace(Constants.LOG_FAILURE);
+        }
+        return (mapping.findForward(Constants.FAILURE));
+    }
+
+    /**
+     * <p>
+     * Return the local or global forward named "logon"
+     * or null if there is no such forward.
+     * </p>
+     * <p>
+     * </p>
+     * @param mapping Our ActionMapping
+     * @return Return the mapping named "logon" or null if there is no such 
mapping.
+     */
+    protected ActionForward doFindLogon(ActionMapping mapping) {
+        if (log.isTraceEnabled()) {
+            log.trace(Constants.LOG_LOGON);
+        }
+        return (mapping.findForward(Constants.LOGON));
+    }
+
+    /**
+     * <p>
+     * Return the mapping labeled "success"
+     * or null if there is no such mapping.
+     * </p>
+     * @param mapping Our ActionMapping
+     * @return Return the mapping named "success" or null if there is no such 
mapping.
+     */
+    protected ActionForward doFindSuccess(ActionMapping mapping) {
+        if (log.isTraceEnabled()) {
+            log.trace(Constants.LOG_SUCCESS);
+        }
+        return mapping.findForward(Constants.SUCCESS);
+    }
+
+    /**
      * <p>
      * Helper method to fetch a String property from a DynaActionForm.
      * </p>
@@ -83,23 +174,28 @@
         }
         return value;
     }
+
     /**
      * <p>
-     * Helper method to inject a String property into a DynaActionForm.
+     * Obtain the cached Subscription object, if any.
      * </p>
-     * @param form Our DynaActionForm
-     * @param property The name of the property
-     * @param value The value for the property
-     * @return True if the assignment succeeds
+     * @param session Our HttpSession
+     * @return Cached Subscription object or null
      */
-    protected boolean doSet(ActionForm form, String property, String value) {
-        try {
-            DynaActionForm dyna = (DynaActionForm) form;
-            dyna.set(property,value);
-        } catch (Throwable t) {
-            return false;
-        }
-        return true;
+    protected Subscription doGetSubscription(HttpSession session) {
+        return (Subscription) session.getAttribute(Constants.SUBSCRIPTION_KEY);
+    }
+
+    /**
+     * <p>
+     * Obtain the cached Subscription object, if any.
+     * </p>
+     * @param request Our HttpServletRequest
+     * @return Cached Subscription object or null
+     */
+    protected Subscription doGetSubscription(HttpServletRequest request) {
+        HttpSession session = request.getSession();
+        return doGetSubscription(session);
     }
 
     /**
@@ -138,7 +234,6 @@
         }
 
         return user;
-
     }
 
     /**
@@ -155,76 +250,6 @@
 
     /**
      * <p>
-     * Obtain the cached Subscription object, if any.
-     * </p>
-     * @param session Our HttpSession
-     * @return Cached Subscription object or null
-     */
-    protected Subscription doGetSubscription(HttpSession session) {
-        return (Subscription) session.getAttribute(Constants.SUBSCRIPTION_KEY);
-    }
-
-    /**
-     * <p>
-     * Obtain the cached Subscription object, if any.
-     * </p>
-     * @param request Our HttpServletRequest
-     * @return Cached Subscription object or null
-     */
-    protected Subscription doGetSubscription(HttpServletRequest request) {
-        HttpSession session = request.getSession();
-        return doGetSubscription(session);
-    }
-
-    /**
-     * <p>
-     * Return the local or global forward named "failure"
-     * or null if there is no such forward.
-     * </p>
-     * @param mapping Our ActionMapping
-     * @return Return the mapping named "failure" or null if there is no such 
mapping.
-     */
-    protected ActionForward doFindFailure(ActionMapping mapping) {
-        if (log.isTraceEnabled()) {
-            log.trace(Constants.LOG_FAILURE);
-        }
-        return (mapping.findForward(Constants.FAILURE));
-    }
-
-    /**
-     * <p>
-     * Return the local or global forward named "logon"
-     * or null if there is no such forward.
-     * </p>
-     * <p>
-     * </p>
-     * @param mapping Our ActionMapping
-     * @return Return the mapping named "logon" or null if there is no such 
mapping.
-     */
-    protected ActionForward doFindLogon(ActionMapping mapping) {
-        if (log.isTraceEnabled()) {
-            log.trace(Constants.LOG_LOGON);
-        }
-        return (mapping.findForward(Constants.LOGON));
-    }
-
-    /**
-     * <p>
-     * Return the mapping labeled "success"
-     * or null if there is no such mapping.
-     * </p>
-     * @param mapping Our ActionMapping
-     * @return Return the mapping named "success" or null if there is no such 
mapping.
-     */
-    protected ActionForward doFindSuccess(ActionMapping mapping) {
-        if (log.isTraceEnabled()) {
-            log.trace(Constants.LOG_SUCCESS);
-        }
-        return mapping.findForward(Constants.SUCCESS);
-    }
-
-    /**
-     * <p>
      * Helper method to obtain User form session (if any).
      * </p>
      * @param session Our HttpSession
@@ -248,6 +273,21 @@
 
     /**
      * <p>
+     * Save any errors and the transactioonal token, and forward to the 
InputForard result.
+     * </p>
+     * @param mapping Our ActionMapping
+     * @param request Our HttpServletRequest
+     * @param errors Our ActionMessages collectoin
+     * @return The InputForward for this mappintg
+     */
+    protected ActionForward doInputForward(ActionMapping mapping, 
HttpServletRequest request, ActionMessages errors) {
+        this.saveErrors(request, errors);
+        this.saveToken(request);
+        return (mapping.getInputForward());
+    }
+
+    /**
+     * <p>
      * Log a "processing" message for an Action.
      * </p>
      * @param mapping Our ActionMapping
@@ -267,24 +307,6 @@
 
     /**
      * <p>
-     * Helper method to log event and cancel transaction.
-     * </p>
-     * @param session Our HttpSession
-     * @param method Method being processed
-     * @param key Attrkibute to remove from session, if any
-     */
-    protected void doCancel (HttpSession session, String method, String key) {
-        if (log.isTraceEnabled()) {
-            StringBuffer sb = new StringBuffer(128);
-            sb.append(Constants.LOG_CANCEL);
-            sb.append(method);
-            log.trace(sb.toString());
-        }
-        if (key!=null) session.removeAttribute(key);
-    }
-
-    /**
-     * <p>
      * Helper method to log event and save token.
      * </p>
      * @param request Our HttpServletRequest
@@ -318,38 +340,22 @@
      }
 
     /**
-     * <p>Store User object in client session.
-     * If user object is null, any existing user object is removed.</p>
-     *
-     * @param request The request we are processing
-     * @param user The user object returned from the database
-     */
-    void doCacheUser(HttpServletRequest request, User user) {
-
-        HttpSession session = request.getSession();
-        session.setAttribute(Constants.USER_KEY, user);
-        if (log.isDebugEnabled()) {
-            log.debug(
-                "LogonAction: User '"
-                    + user.getUsername()
-                    + "' logged on in session "
-                    + session.getId());
-        }
-    }
-
-    /**
      * <p>
-     * Save any errors and the transactioonal token, and forward to the 
InputForard result.
+     * Helper method to inject a String property into a DynaActionForm.
      * </p>
-     * @param mapping Our ActionMapping
-     * @param request Our HttpServletRequest
-     * @param errors Our ActionMessages collectoin
-     * @return The InputForward for this mappintg
+     * @param form Our DynaActionForm
+     * @param property The name of the property
+     * @param value The value for the property
+     * @return True if the assignment succeeds
      */
-    protected ActionForward doInputForward(ActionMapping mapping, 
HttpServletRequest request, ActionMessages errors) {
-        this.saveErrors(request, errors);
-        this.saveToken(request);
-        return (mapping.getInputForward());
+    protected boolean doSet(ActionForm form, String property, String value) {
+        try {
+            DynaActionForm dyna = (DynaActionForm) form;
+            dyna.set(property,value);
+        } catch (Throwable t) {
+            return false;
+        }
+        return true;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to