Author: husted Date: Sat Mar 25 18:17:14 2006 New Revision: 388869 URL: http://svn.apache.org/viewcvs?rev=388869&view=rev Log: Action2 Apps * Mailreader - Work in progress ** JavaDoc pass
Modified: struts/sandbox/trunk/action2/README.txt struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logoff.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml struts/sandbox/trunk/action2/apps/mailreader/src/webapp/WEB-INF/web.xml struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/ChangePassword.jsp struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/MainMenu.jsp struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Welcome.jsp Modified: struts/sandbox/trunk/action2/README.txt URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/README.txt?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/README.txt (original) +++ struts/sandbox/trunk/action2/README.txt Sat Mar 25 18:17:14 2006 @@ -134,7 +134,8 @@ Subscription Add + Cancel + Submit - Submit (bad data) ++ Submit (bad data) + Double submit ---- @@ -158,6 +159,7 @@ + Submit (invalid data) + Submit (data) - Submit (duplicate data) (*) + Double submit Issues (*) * Submit Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java Sat Mar 25 18:17:14 2006 @@ -32,14 +32,18 @@ import java.io.InputStream; /** - * <p><code>ServletContextListener</code> that initializes and finalizes the persistent storage of User and Subscription - * information for the Struts Demonstration Application, using an in-memory database backed by an XML file.</p> - * - * <p><strong>IMPLEMENTATION WARNING</strong> - If this web application is run from a WAR file, or in another - * environment where reading and writing of the web application resource is impossible, the initial contents will be - * copied to a file in the web application temporary directory provided by the container. This is for demonstration - * purposes only - you should <strong>NOT</strong> assume that files written here will survive a restart of your servlet - * container.</p> + * <p><code>ServletContextListener</code> that initializes and finalizes the + * persistent storage of User and Subscription information for the Struts + * Demonstration Application, using an in-memory database backed by an XML + * file.</p> + * + * <p><strong>IMPLEMENTATION WARNING</strong> - If this web application is run + * from a WAR file, or in another environment where reading and writing of the + * web application resource is impossible, the initial contents will be copied + * to a file in the web application temporary directory provided by the + * container. This is for demonstration purposes only - you should + * <strong>NOT</strong> assume that files written here will survive a restart + * of your servlet container.</p> * * <p>This class was borrowed from the Shale Mailreader. Changes were:</p> * @@ -58,14 +62,15 @@ /** - * <p>Appication scope attribute key under which the in-memory version of our database is stored.</p> + * <p>Appication scope attribute key under which the in-memory version of + * our database is stored.</p> */ public static final String DATABASE_KEY = "database"; /** - * <p>Application scope attribute key under which the valid selection items for the protocol property is - * stored.</p> + * <p>Application scope attribute key under which the valid selection + * items for the protocol property is stored.</p> */ public static final String PROTOCOLS_KEY = "protocols"; @@ -85,7 +90,7 @@ /** - * Logging output for this plug in instance. + * <p>Logging output for this plug in instance.</p> */ private Log log = LogFactory.getLog(this.getClass()); @@ -93,14 +98,25 @@ /** - * The web application resource path of our persistent database storage file. + * <p>The web application resource path of our persistent database storage + * file.</p> */ private String pathname = "/WEB-INF/classes/database.xml"; + /** + * <p>Return the application resource path to the database.</p> + * + * @return application resource path path to the database + */ public String getPathname() { return (this.pathname); } + /** + * <p>Set the application resource path to the database.</p> + * + * @param pathname to the database + */ public void setPathname(String pathname) { this.pathname = pathname; } @@ -109,7 +125,8 @@ /** - * <p>Gracefully shut down this database, releasing any resources that were allocated at initialization.</p> + * <p>Gracefully shut down this database, releasing any resources that + * were allocated at initialization.</p> * * @param event ServletContextEvent to process */ @@ -134,7 +151,8 @@ /** - * <p>Initialize and load our initial database from persistent storage.</p> + * <p>Initialize and load our initial database from persistent + * storage.</p> * * @param event The context initialization event */ @@ -168,7 +186,8 @@ /** - * Calculate and return an absolute pathname to the XML file to contain our persistent storage information. + * <p>Calculate and return an absolute pathname to the XML file to contain + * our persistent storage information.</p> * * @throws Exception if an input/output error occurs */ Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java Sat Mar 25 18:17:14 2006 @@ -20,10 +20,7 @@ /** * <p> Manifest constants for the MailReader application. </p> - * - * @version $Rev: 360442 $ $Date: 2005-12-31 15:10:04 -0500 (Sat, 31 Dec 2005) $ */ - public final class Constants { // --- Tokens ---- @@ -34,7 +31,8 @@ public static final String CREATE = "Create"; /** - * <p> The application scope attribute under which our user database is stored. </p> + * <p> The application scope attribute under which our user database is + * stored. </p> */ public static final String DATABASE_KEY = "database"; @@ -49,13 +47,8 @@ public static final String EDIT = "Edit"; /** - * <p> The request attributes key under the WelcomeAction stores an ArrayList of error messages, if required - * resources are missing. </p> - */ - public static final String ERROR_KEY = "ERROR"; - - /** - * <p> The token representing a "failure" result for this application. </p> + * <p> The token representing a "failure" result for this application. + * </p> */ public static final String FAILURE = "Failure"; @@ -70,108 +63,30 @@ public static final String PACKAGE = "org.apache.struts.apps.mailreader"; /** - * <p> The token representing a "save" task. </p> - */ - public static final String SAVE = "Save"; - - /** - * <p> The session scope attribute under which the Subscription object currently selected by our logged-in User is - * stored. </p> + * <p> The session scope attribute under which the Subscription object + * currently selected by our logged-in User is stored. </p> */ public static final String SUBSCRIPTION_KEY = "subscription"; /** - * <p> The token representing a "success" result for this application. </p> + * <p> The token representing a "success" result for this application. + * </p> */ public static final String SUCCESS = "Success"; /** - * <p> The session scope attribute under which the User object for the currently logged in user is stored. </p> + * <p> The session scope attribute under which the User object for the + * currently logged in user is stored. </p> */ public static final String USER_KEY = "user"; - // ---- Error Messages ---- - - /** - * <p> A static message in case database resource is not loaded. <p> - */ - public static final String ERROR_DATABASE_NOT_LOADED = - "ERROR: User database not loaded -- check servlet container logs for error messages."; - - /** - * <p> A static message in case message resource is not loaded. </p> - */ - public static final String ERROR_MESSAGES_NOT_LOADED = - "ERROR: Message resources not loaded -- check servlet container logs for error messages."; - - // ---- Error Tokens ---- - - /** - * <p> The resource key for an error with the transactional token. </p> - */ - public static final String MSG_TRANSACTION_TOKEN = "error.transaction.token"; - // ---- Log Messages ---- /** - * <p> The message to log when cancelling a transaction. </p> - */ - public static final String LOG_CANCEL = " Transaction cancelled: "; - - /** - * <p> The message to log when forwarding to a result. </p> - */ - public static final String LOG_RESULT = " Forwarding to result: "; - - /** - * <p> The message to log when forwarding to a 'failure' result. <p> - */ - public static final String LOG_FAILURE = LOG_RESULT + FAILURE; - - /** - * <p> The message to log when forwarding to a 'logon' result. </p> - */ - public static final String LOG_LOGON = LOG_RESULT + LOGON; - - /** - * <p> The message to log when populating a form. </p> - */ - public static final String LOG_POPULATE_FORM = " Populating form from: "; - - /** - * <p> The message to log when populating a subscription. </p> - */ - public static final String LOG_POPULATE_SUBSCRIPTION = " Populating subscription: "; - - /** - * <p> The message to log when populating a user. </p> - */ - public static final String LOG_POPULATE_USER = " Populating user: "; - - /** - * <p> The message to log when forwarding to a 'success' result. </p> - */ - public static final String LOG_PROCESSING = " Processing: "; - - /** - * <p> The message to log when forwarding to a 'success' result. </p> - */ - public static final String LOG_SUCCESS = LOG_RESULT + SUCCESS; - - /** - * <p> The message to log when setting a transactional token. </p> - */ - public static final String LOG_TOKEN = " Setting transactional control token"; - - /** - * <p> The message to log when checking a transactional token. </p> - */ - public static final String LOG_TOKEN_CHECK = " Checking transactional control token"; - - /** * <p> Message to log if saving a user fails. </p> */ - public static final String LOG_DATABASE_SAVE_ERROR = " Unexpected error when saving User: "; + public static final String LOG_DATABASE_SAVE_ERROR = + " Unexpected error when saving User: "; } Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logoff.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logoff.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logoff.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logoff.java Sat Mar 25 18:17:14 2006 @@ -1,5 +1,26 @@ +/* + * $Id: LogonAction.java 360442 2005-12-31 20:10:04Z husted $ + * + * Copyright 2000-2004 Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package mailreader2; +/** + * <p> Log user out of the current session. </p> + */ public class Logoff extends MailreaderSupport { public String execute() { Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java Sat Mar 25 18:17:14 2006 @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package mailreader2; import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException; @@ -22,14 +23,13 @@ /** * <p> Validate a user logon. </p> - * - * @version $Rev: 360442 $ $Date: 2005-12-31 15:10:04 -0500 (Sat, 31 Dec 2005) $ */ public final class Logon extends MailreaderSupport { /** - * <p> Use "username" and "password" fields to retrieve a User object from the database. If credentials are not - * valid, or database has disappeared, post error messages and forward to input. </p> + * <p> Use "username" and "password" fields to retrieve a User object from + * the database. If credentials are not valid, or database has + * disappeared, post error messages and forward to input. </p> */ public String execute() throws ExpiredPasswordException { Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java Sat Mar 25 18:17:14 2006 @@ -36,35 +36,70 @@ /** * <p> Base Action for MailreaderSupport application. </p> * - * <p> Note that this class does NOT implement model driven because of issues with the pre-existing model. The - * MailReader DAO does not provide a setter for username and does not provide a default constructor, making it difficult - * to use as a POJO or to extend. As an alternative, the username and password properties are provided on the Action and - * then passed to the user class as needed. </p> - * - * @version $Rev: 360442 $ $Date: 2005-12-31 15:10:04 -0500 (Sat, 31 Dec 2005) $ + * <p> Note that this class does NOT implement model driven because of the way + * the pre-existing model is designed. The MailReader DAO includes immutable + * fields that can only be set on construction, and some objects do not have a + * default construction. One approach would be to mirror all the DAO + * properties on the Actions. As an alternative, this implementations uses the + * DAO properties where possible, and uses local Action properties only as + * needed. To create new objects, a blank temporary object is constructed, and + * the page uses a mix of local Action properties and DAO properties. When the + * new object is to be saved, the local Action properties are used to create + * the object using the DAO factory methods, the input values are copied from + * the temporary object, and the new object is saved. It's kludge, but it + * avoids creating unnecessary local properties. Pick your poison.</p> */ -public class MailreaderSupport extends ActionSupport implements SessionAware, ApplicationAware { +public class MailreaderSupport extends ActionSupport + implements SessionAware, ApplicationAware { // ---- ApplicationAware ---- + /** + * <p>Field to store application context or its proxy.</p> + * + * <p>The application context lasts for the life of the application. A + * reference to the database is stored in the application context at + * startup.</p> + */ private Map application; + /** + * <p>Store a new application context.</p> + * + * @param application + */ public void setApplication(Map application) { this.application = application; } + /** + * <p>Provide application context.</p> + */ public Map getApplication() { return this.application; } // ---- SessionAware ---- + /** + * <p>Field to store session context, or its proxy.</p> + */ private Map session; + /** + * <p>Store a new session context.</p> + * + * @param session + */ public void setSession(Map session) { this.session = session; } + /** + * <p>Provide session context.</p> + * + * @return session context + */ public Map getSession() { return session; } @@ -72,12 +107,18 @@ // ---- Task property (utilized by UI) ---- /** - * <p>The task input field.</p> + * <p>Field to store workflow task.</p> + * + * <p>The Task is used to track the state of the CRUD workflows. It can be + * set to Constant.CREATE, Constant.EDIT, or Constant.DELETE as + * needed.</p> */ private String task = null; /** + * <p>Provide worklow task.</p> + * * @return Returns the task. */ public String getTask() { @@ -85,6 +126,8 @@ } /** + * <p>Store new workflow task.</p> + * * @param task The task to set. */ public void setTask(String task) { @@ -93,12 +136,29 @@ // ---- Host property ---- + /** + * <p>Field to store Subscription host.</p> + * + * <p> The host is an immutable property of the Subscrtion DAP object, so + * we need to store it locally until we are ready to create the + * Subscription. </p> + */ private String host; + /** + * <p>Provide tSubscription host.</p> + * + * @return host property + */ public String getHost() { return host; } + /** + * <p>Store new Subscription host.</p> + * + * @param value + */ public void setHost(String value) { host = value; } @@ -106,12 +166,17 @@ // ---- Password property ---- /** - * <p>The password input field.</p> + * <p>Field to store User password property.</p> + * + * <p>The User DAO object password proerty is immutable, so we store it + * locally until we are ready to create the object.</p> */ private String password = null; /** + * <p>Provide User password</p> + * * @return Returns the password. */ public String getPassword() { @@ -119,6 +184,8 @@ } /** + * <p>Store new User Password</p> + * * @param password The password to set. */ public void setPassword(String password) { @@ -128,12 +195,18 @@ // ---- Password2 property (confirmation) ---- /** - * <p>The confirmation password input field.</p> + * <p>Field to store the User password confirmation.</p> + * + * <p>When a User object is created, we ask the client to enter the + * password twice, to help ensure the password is being typed + * correctly.</p> */ private String password2 = null; /** + * <p>Provide the User password confirmation.</p> + * * @return Returns the confirmationpassword. */ public String getPassword2() { @@ -141,6 +214,8 @@ } /** + * <p>Store a new User password confirmation.</p> + * * @param password2 The confirmation password to set. */ public void setPassword2(String password2) { @@ -150,19 +225,26 @@ // ---- Username property ---- /** - * <p>The username input field.</p> + * <p>Field to store User username.</p> + * + * <p>The User DAO object password proerty is immutable, so we store it + * locally until we are ready to create the object.</p> */ private String username = null; /** - * @return Returns the username. + * <p>Provide User username.</p> + * + * @return Returns the User username. */ public String getUsername() { return this.username; } /** + * <p>Store new User username</p> + * * @param username The username to set. */ public void setUsername(String username) { @@ -172,9 +254,11 @@ // ---- Database property ---- /** - * <p> Return a reference to the UserDatabase or null if the database is not available. </p> + * <p>Provide reference to UserDatabase, or null if the database is not + * available. </p> * - * @return a reference to the UserDatabase or null if the database is not available + * @return a reference to the UserDatabase or null if the database is not + * available */ public UserDatabase getDatabase() { Object db = getApplication().get(Constants.DATABASE_KEY); @@ -184,22 +268,47 @@ return (UserDatabase) db; } + /** + * <p>Store a new reference to UserDatabase</p> + * + * @param database + */ public void setDatabase(UserDatabase database) { getApplication().put(Constants.DATABASE_KEY, database); } // ---- User property ---- + /** + * <p>Provide reference to User object for authenticated user.</p> + * + * @return User object for authenticated user. + */ public User getUser() { return (User) getSession().get(Constants.USER_KEY); } + /** + * <p>Store new reference to User Object.</p> + * + * @param user User object for authenticated user + */ public void setUser(User user) { getSession().put(Constants.USER_KEY, user); } - public User findUser(String username, String password) throws ExpiredPasswordException { - // FIXME: Stupid hack to compensate for inadequate DAO layer + /** + * <p>Obtain User object from database, or return null if the credentials + * are not found or invalid.</p> + * + * @param username User username + * @param password User password + * @return User object or null if not found + * @throws ExpiredPasswordException + */ + public User findUser(String username, String password) + throws ExpiredPasswordException { + // FIXME: Stupid testing hack to compensate for inadequate DAO layer if ("Hermes".equals(username)) { throw new ExpiredPasswordException("Hermes"); } @@ -215,12 +324,13 @@ } /** - * <p> The <code>Log</code> instance for this application. </p> + * <p><code>Log</code> instance for this application. </p> */ protected Log log = LogFactory.getLog(Constants.PACKAGE); /** - * <p> Persist the User object, including subscriptions, to the database. </p> + * <p> Persist the User object, including subscriptions, to the database. + * </p> * * @throws javax.servlet.ServletException On any error */ @@ -228,7 +338,8 @@ try { getDatabase().save(); } catch (Exception e) { - String message = Constants.LOG_DATABASE_SAVE_ERROR + getUser().getUsername(); + String message = Constants.LOG_DATABASE_SAVE_ERROR + getUser() + .getUsername(); log.error(message, e); throw new Exception(message, e); } @@ -240,9 +351,11 @@ } /** - * <p> Verify input for creating a new user, create the user, and process the login. </p> + * <p> Verify input for creating a new user, create the user, and process + * the login. </p> * - * @return A new User and empty Errors if create succeeds, or null and Errors if create fails + * @return A new User and empty Errors if create succeeds, or null and + * Errors if create fails */ public User createUser(String username, String password) { @@ -267,6 +380,17 @@ } // Since user.username is immutable, we have to use some local properties + + /** + * <p>Use the current User object to create a new User object, and make + * the new User object the authenticated user.</p> + * + * <p>The "current" User object is usually a temporary object being used + * to capture input.</p> + * + * @param _username User username + * @param _password User password + */ public void copyUser(String _username, String _password) { User input = getUser(); input.setPassword(_password); @@ -280,7 +404,7 @@ // ---- Subscription property ---- /** - * <p> Obtain the cached Subscription object, if any. </p> + * <p>Obtain the cached Subscription object, if any. </p> * * @return Cached Subscription object or null */ @@ -288,12 +412,18 @@ return (Subscription) getSession().get(Constants.SUBSCRIPTION_KEY); } + /** + * <p>Store new User Subscription.</p> + * + * @param subscription + */ public void setSubscription(Subscription subscription) { getSession().put(Constants.SUBSCRIPTION_KEY, subscription); } /** - * <p> Obtain subscription matching host for our User, or return null if not found. </p> + * <p> Obtain User Subscription object for the given host, or return null + * if not found. </p> * * @return The matching Subscription or null */ @@ -311,17 +441,36 @@ return subscription; } + /** + * <p>Obtain uSER Subscription for the local Host property.</p> + * + * <p>Usually, the host property will be set from the client request, + * because it was embedded in a link to the Subcription action. + * + * @return Subscription or null if not found + */ public Subscription findSubscription() { return findSubscription(getHost()); } + /** + * <p>Provide a "temporary" User Subscription object that can be used to + * capture input values.</p> + */ public void createInputSubscription() { Subscription sub = new MemorySubscription(getUser(), null); setSubscription(sub); setHost(sub.getHost()); } + /** + * <p>Provide new User Subscription object for the given host, or null if + * the host is not unique.</p> + * + * @param host + * @return New User Subscription object or null + */ public Subscription createSubscription(String host) { Subscription sub; @@ -336,6 +485,15 @@ return getUser().createSubscription(host); } + /** + * <p>Create a new Subscription from the current Subscription object, + * making the new Subscription the current Subscription. </p> + * + * <p>Usually, the "current" Subscription is a temporary object being used + * to capture input values.</p> + * + * @param host + */ public void copySubscription(String host) { Subscription input = getSubscription(); Subscription sub = createSubscription(host); @@ -346,11 +504,21 @@ } } + /** + * <p>Delete the current Subscription object from the database.</p> + * + * @throws Exception + */ public void removeSubscription() throws Exception { getUser().removeSubscription(getSubscription()); getSession().remove(Constants.SUBSCRIPTION_KEY); } + /** + * <p>Provide MailServer Host for current User Subscription.</p> + * + * @return MailServer Host for current User Subscription + */ public String getSubscriptionHost() { Subscription sub = getSubscription(); if (null == sub) { Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java Sat Mar 25 18:17:14 2006 @@ -4,20 +4,23 @@ /** - * <p> Provide an Edit method for retrieving an existing user, and a Save method for updating or inserting a user. - * </p><p> Both methods utilize a RegistrationForm to obtain or expose User details. If Save is used to create a user, - * additional validations ensure input is nominal. When a user is created, Save also handles the initial logon. </p> + * <p> Provide an Edit method for retrieving an existing user, and a Save + * method for updating or inserting a user. </p> */ public final class Registration extends MailreaderSupport { + /** + * <p>Double check that there is not a valid User logon. </p> + * + * @return True if there is not a valid User logon + */ private boolean isCreating() { User user = getUser(); return (null == user) || (null == user.getDatabase()); } /** - * <p> Retrieve the User object to edit or null if the User does not exist, and set an transactional token to later - * detect multiple Save commands. </p> + * <p> Retrieve User object to edit or null if User does not exist. </p> * * @return The "Success" result for this mapping * @throws Exception on any error @@ -38,8 +41,10 @@ } /** - * <p> Insert or update a User object to the persistent store. </p><p> If a User is not logged in, then a new User - * is created and automatically logged in. Otherwise, the existing User is updated. </p> + * <p> Insert or update a User object to the persistent store. </p> + * + * <p> If a User is not logged in, then a new User is created and + * automatically logged in. Otherwise, the existing User is updated. </p> * * @return The "Success" result for this mapping * @throws Exception on any error Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java Sat Mar 25 18:17:14 2006 @@ -5,24 +5,31 @@ import java.util.LinkedHashMap; import java.util.Map; -public final class Subscription extends MailreaderSupport implements Preparable { - +/** + * <p> Provide an Edit method for retrieving an existing subscription, and a + * Save method for updating or inserting a subscription. </p> + */ +public final class Subscription extends MailreaderSupport + implements Preparable { + + /** + * <p>Field to store list of MailServer types</p> + */ private Map types = null; + /** + * <p>Provide the list of MailServer types.</p> + * + * @return List of MailServer types + */ public Map getTypes() { return types; } - private String host; - - public String getHost() { - return host; - } - - public void setHost(String value) { - host = value; - } - + /** + * <p>Setup the MailerServer types and set the local Host property from + * the User Subscription (if any). </p> + */ public void prepare() { Map m = new LinkedHashMap(); @@ -33,12 +40,26 @@ setHost(getSubscriptionHost()); } + /** + * <p>Setup a temporary User Subscription object to capture input + * values.</p> + * + * @return INPUT + */ public String input() { createInputSubscription(); setTask(Constants.CREATE); return INPUT; } + /** + * <p>Load User Subscription for the local Host property.</p> + * + * <p>Usually, the Host is being set from the request by a link to an Edit + * or Delete task.</p> + * + * @return INPUT or Error, if Subscription is not found + */ public String find() { org.apache.struts.apps.mailreader.dao.Subscription @@ -54,18 +75,36 @@ } + /** + * <p>Prepare to present a confirmation page before removing + * Subscription.</p> + * + * @return INPUT or Error, if Subscription is not found + */ public String delete() { setTask(Constants.DELETE); return find(); } + /** + * <p>Prepare to edit User Subscription.</p> + * + * @return INPUT or Error, if Subscription is not found + */ public String edit() { setTask(Constants.EDIT); return find(); } + /** + * <p> Examine the Task property and DELETE, CREATE, or save the User + * Subscription, as appropriate. </p> + * + * @return SUCCESS + * @throws Exception on a database error + */ public String execute() throws Exception { if (Constants.DELETE.equals(getTask())) { @@ -78,36 +117,6 @@ saveUser(); return SUCCESS; - } - - public static class KeyValue { - String key; - String value; - - public KeyValue(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return this.key; - } - - public String getValue() { - return this.value; - } - - public boolean equals(Object obj) { - if (! (obj instanceof KeyValue)) { - return false; - } else { - return key.equals(((KeyValue) obj).getKey()); - } - } - - public int hashCode() { - return key.hashCode(); - } } } Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml Sat Mar 25 18:17:14 2006 @@ -21,6 +21,16 @@ <result name="expired" type="chain">ChangePassword</result> </action> + <action name="Something" + class="mailreader2.Logon"> + <exception-mapping + exception="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException" + result="expired"/> + <result>/pages/MainMenu.jsp</result> + <result name="input">/pages/Logon.jsp</result> + <result name="expired" type="chain">ChangePassword</result> + </action> + <action name="ChangePassword"> <result>/pages/ChangePassword.jsp</result> </action> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/WEB-INF/web.xml?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/WEB-INF/web.xml (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/WEB-INF/web.xml Sat Mar 25 18:17:14 2006 @@ -6,7 +6,8 @@ <filter> <filter-name>webwork</filter-name> - <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class> + <filter-class> + com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> @@ -15,7 +16,8 @@ </filter-mapping> <listener> - <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + <listener-class> + org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Application Listener for Mailreader database --> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/ChangePassword.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/ChangePassword.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/ChangePassword.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/ChangePassword.jsp Sat Mar 25 18:17:14 2006 @@ -4,7 +4,8 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><saf:text name="change.title"/></title> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp Sat Mar 25 18:17:14 2006 @@ -4,22 +4,24 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><saf:text name="logon.title"/></title> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> -<a2:form method="POST" validate="true"> - <a2:textfield label="%{getText('prompt.username')}" name="username"/> +<saf:form method="POST" validate="true"> + <saf:textfield label="%{getText('prompt.username')}" name="username"/> - <a2:textfield label="%{getText('prompt.password')}" name="password"/> + <saf:textfield label="%{getText('prompt.password')}" name="password"/> - <a2:submit/> + <saf:submit/> - <a2:reset/> + <saf:reset/> - <a2:submit action="Welcome" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/> -</a2:form> + <saf:submit action="Welcome" value="%{getText('button.cancel')}" + onclick="form.onsubmit=null"/> +</saf:form> <jsp:include page="Footer.jsp"/> </body> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/MainMenu.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/MainMenu.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/MainMenu.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/MainMenu.jsp Sat Mar 25 18:17:14 2006 @@ -4,11 +4,13 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><saf:text name="mainMenu.title"/></title> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> -<h3><saf:text name="mainMenu.heading"/> <saf:property value="user.fullName"/></h3> +<h3><saf:text name="mainMenu.heading"/> <saf:property + value="user.fullName"/></h3> <ul> <li><a href="<saf:url action="Registration!input" />"> <saf:text name="mainMenu.registration"/> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp Sat Mar 25 18:17:14 2006 @@ -9,7 +9,8 @@ <saf:if test="task=='Edit'"> <title><saf:text name="registration.title.edit"/></title> </saf:if> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> @@ -28,21 +29,26 @@ <saf:textfield label="%{getText('prompt.password2')}" name="password2"/> - <saf:textfield label="%{getText('prompt.fullName')}" name="user.fullName"/> + <saf:textfield label="%{getText('prompt.fullName')}" + name="user.fullName"/> - <saf:textfield label="%{getText('prompt.fromAddress')}" name="user.fromAddress"/> + <saf:textfield label="%{getText('prompt.fromAddress')}" + name="user.fromAddress"/> - <saf:textfield label="%{getText('prompt.replyToAddress')}" name="user.replyToAddress"/> + <saf:textfield label="%{getText('prompt.replyToAddress')}" + name="user.replyToAddress"/> <saf:submit/> <saf:reset/> <saf:if test="task == 'Create'"> - <saf:submit action="Welcome" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/> + <saf:submit action="Welcome" value="%{getText('button.cancel')}" + onclick="form.onsubmit=null"/> </saf:if> <saf:else> - <saf:submit action="MainMenu" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/> + <saf:submit action="MainMenu" value="%{getText('button.cancel')}" + onclick="form.onsubmit=null"/> </saf:else> </saf:form> @@ -102,7 +108,8 @@ </table> - <a href="<saf:url action="Subscription!input"/>"><saf:text name="registration.addSubscription"/></a> + <a href="<saf:url action="Subscription!input"/>"><saf:text + name="registration.addSubscription"/></a> </saf:if> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp Sat Mar 25 18:17:14 2006 @@ -12,7 +12,8 @@ <saf:if test="task=='Delete'"> <title><saf:text name="subscription.title.delete"/></title> </saf:if> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> @@ -29,22 +30,32 @@ </saf:else> <saf:if test="task == 'Delete'"> - <saf:label label="%{getText('prompt.mailUsername')}" name="subscription.username"/> - <saf:label label="%{getText('prompt.mailPassword')}" name="subscription.password"/> - <saf:label label="%{getText('prompt.mailServerType')}" name="subscription.type"/> - <saf:label label="%{getText('prompt.autoConnect')}" name="subscription.autoConnect"/> + <saf:label label="%{getText('prompt.mailUsername')}" + name="subscription.username"/> + <saf:label label="%{getText('prompt.mailPassword')}" + name="subscription.password"/> + <saf:label label="%{getText('prompt.mailServerType')}" + name="subscription.type"/> + <saf:label label="%{getText('prompt.autoConnect')}" + name="subscription.autoConnect"/> <saf:submit value="%{getText('button.confirm')}"/> </saf:if> <saf:else> - <saf:textfield label="%{getText('prompt.mailUsername')}" name="subscription.username"/> - <saf:textfield label="%{getText('prompt.mailPassword')}" name="subscription.password"/> - <saf:select label="%{getText('prompt.mailServerType')}" name="subscription.type" list="types"/> - <saf:checkbox label="%{getText('prompt.autoConnect')}" name="subscription.autoConnect"/> + <saf:textfield label="%{getText('prompt.mailUsername')}" + name="subscription.username"/> + <saf:textfield label="%{getText('prompt.mailPassword')}" + name="subscription.password"/> + <saf:select label="%{getText('prompt.mailServerType')}" + name="subscription.type" list="types"/> + <saf:checkbox label="%{getText('prompt.autoConnect')}" + name="subscription.autoConnect"/> <saf:submit value="%{getText('button.save')}"/> <saf:reset value="%{getText('button.reset')}"/> </saf:else> - <saf:submit action="Registration!input" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/> + <saf:submit action="Registration!input" + value="%{getText('button.cancel')}" + onclick="form.onsubmit=null"/> </saf:form> <jsp:include page="Footer.jsp"/> Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Welcome.jsp URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Welcome.jsp?rev=388869&r1=388868&r2=388869&view=diff ============================================================================== --- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Welcome.jsp (original) +++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Welcome.jsp Sat Mar 25 18:17:14 2006 @@ -5,15 +5,18 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title><saf:text name="index.title"/></title> - <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/> + <link href="<saf:url value="/css/mailreader.css"/>" rel="stylesheet" + type="text/css"/> </head> <body> <h3><saf:text name="index.heading"/></h3> <ul> - <li><a href="<saf:url action="Registration!input"/>"><saf:text name="index.registration"/></a></li> - <li><a href="<saf:url action="Logon!input"/>"><saf:text name="index.logon"/></a></li> + <li><a href="<saf:url action="Registration!input"/>"><saf:text + name="index.registration"/></a></li> + <li><a href="<saf:url action="Logon!input"/>"><saf:text + name="index.logon"/></a></li> </ul> <h3>Language Options</h3> @@ -27,7 +30,8 @@ </ul> <p><saf:i18n name="alternate"> - <img src="<saf:url><saf:text name="struts.logo.path"/></saf:url>" alt="<saf:text name="struts.logo.alt"/>"/> + <img src="<saf:url><saf:text name="struts.logo.path"/></saf:url>" + alt="<saf:text name="struts.logo.alt"/>"/> </saf:i18n></p> <p><a href="<saf:url action="Tour" />"><saf:text name="index.tour"/></a></p> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]