You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/08/03 01:43:29 UTC
svn commit: r428196 [1/2] - in /struts/struts2/trunk/apps/mailreader/src:
main/java/mailreader2/ main/java/mailreader2/registration/
main/java/mailreader2/subscription/ main/resources/
main/resources/mailreader2/ main/resources/sql/ main/webapp/WEB-INF...
Author: husted
Date: Wed Aug 2 16:43:27 2006
New Revision: 428196
URL: http://svn.apache.org/viewvc?rev=428196&view=rev
Log:
WW-1353 Refactor MailReader to use namespaces and conventional, finely-grained actions with no aliases. (Refactoring for wildcards is next.)
Added:
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome-action.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Input.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Support.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Delete.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Input.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Support.java
Removed:
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logon.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Registration.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/RegistrationSave.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Subscription.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/SubscriptionSave.java
struts/struts2/trunk/apps/mailreader/src/main/resources/mailreader2/Logon-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/mailreader2/Registration-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/mailreader2/RegistrationSave-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/mailreader2/Subscription-validation.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/mailreader2/SubscriptionSave-validation.xml
Modified:
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AppData.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/ApplicationListener.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Constants.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logoff.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java
struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome.java
struts/struts2/trunk/apps/mailreader/src/main/resources/sql-map-config.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/sql/sql-map.xml
struts/struts2/trunk/apps/mailreader/src/main/resources/struts.xml
struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/ChangePassword.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Error.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Logon.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/MainMenu.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Registration.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Subscription.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Welcome.jsp
struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/tour.html
struts/struts2/trunk/apps/mailreader/src/test/java/mailreader2/BaseSqlMapTest.java
struts/struts2/trunk/apps/mailreader/src/test/java/mailreader2/SqlMapTest.java
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AppData.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AppData.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AppData.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AppData.java Wed Aug 2 16:43:27 2006
@@ -37,6 +37,7 @@
/**
* <p>Adapt internal Integer value to external boolean value. </p>
+ *
* @return False if host_auto==0, True otherwise
*/
public boolean isHost_auto_checkbox() {
@@ -57,6 +58,7 @@
/**
* <p>Return true if a logic or state test passed,
* such as whether a record already exists.</p>
+ *
* @return True if a business logic test passed.
*/
public boolean isNominal() {
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/ApplicationListener.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/ApplicationListener.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/ApplicationListener.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/ApplicationListener.java Wed Aug 2 16:43:27 2006
@@ -29,7 +29,7 @@
/**
* <p><code>ServletContextListener</code> that initializes and finalizes the
- * persistent storage of User and Subscription information for the Struts
+ * persistent storage of User and Support information for the Struts
* Demonstration Application, using an in-memory database backed by an XML
* file.</p>
* <p/>
@@ -50,7 +50,7 @@
* <li>Class to store protocol list (an array here). </li>
* <p/>
* </ul>
- * <p>
+ * <p/>
* DEVELOPMENT NOTE - Another approach would be to instantiate the database via Spring.
* </p>
*/
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java Wed Aug 2 16:43:27 2006
@@ -1,16 +1,19 @@
package mailreader2;
-import com.opensymphony.xwork2.interceptor.Interceptor;
-import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Action;
-import java.util.Map;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.Interceptor;
import org.apache.struts.apps.mailreader.dao.User;
-public class AuthenticationInterceptor implements Interceptor {
+import java.util.Map;
+
+public class AuthenticationInterceptor implements Interceptor {
- public void destroy () {}
+ public void destroy() {
+ }
- public void init() {}
+ public void init() {
+ }
public String intercept(ActionInvocation actionInvocation) throws Exception {
@@ -18,12 +21,11 @@
User user = (User) session.get(Constants.USER_KEY);
- boolean isAuthenticated = (null!=user) && (null!=user.getDatabase());
+ boolean isAuthenticated = (null != user) && (null != user.getDatabase());
if (!isAuthenticated) {
- return Action.LOGIN;
- }
- else {
+ return Action.LOGIN;
+ } else {
return actionInvocation.invoke();
}
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Constants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Constants.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Constants.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Constants.java Wed Aug 2 16:43:27 2006
@@ -75,7 +75,7 @@
public static final String PACKAGE = "org.apache.struts.apps.mailreader";
/**
- * <p> The session scope attribute under which the Subscription object
+ * <p> The session scope attribute under which the Support object
* currently selected by our logged-in User is stored. </p>
*/
public static final String SUBSCRIPTION_KEY = "subscription";
@@ -91,11 +91,10 @@
*/
public static final String HOST = "host";
-
// ---- Error Messages ----
/**
- * <p>
+ * <p/>
* A static message in case message resource is not loaded.
* </p>
*/
@@ -103,31 +102,31 @@
"ERROR: Message resources not loaded -- check servlet container logs for error messages.";
/**
- * <p>
+ * <p/>
* A static message in case database resource is not loaded.
- * <p>
+ * <p/>
*/
public static final String ERROR_DATABASE_NOT_LOADED =
"ERROR: User database not loaded -- check servlet container logs for error messages.";
/**
- * <p>
+ * <p/>
* A standard key from the message resources file, to test if it is available.
- * <p>
+ * <p/>
*/
public static final String ERROR_DATABASE_MISSING = "error.database.missing";
/**
- * <P>
+ * <p/>
* A "magic" username to trigger an ExpiredPasswordException for testing.
- *</p>
+ * </p>
*/
public static final String EXPIRED_PASSWORD_EXCEPTION = "ExpiredPasswordException";
/**
- * <p>
+ * <p/>
* Name of field to associate with authentification errors.
- * <p>
+ * <p/>
*/
public static final String PASSWORD_MISMATCH_FIELD = "password";
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logoff.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logoff.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logoff.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Logoff.java Wed Aug 2 16:43:27 2006
@@ -24,9 +24,7 @@
public class Logoff extends MailreaderSupport {
public String execute() {
-
setUser(null);
-
return SUCCESS;
}
}
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/MailreaderSupport.java Wed Aug 2 16:43:27 2006
@@ -19,8 +19,6 @@
package mailreader2;
import com.opensymphony.util.BeanUtils;
-import org.apache.struts2.interceptor.ApplicationAware;
-import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,6 +28,8 @@
import org.apache.struts.apps.mailreader.dao.UserDatabase;
import org.apache.struts.apps.mailreader.dao.impl.memory.MemorySubscription;
import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUser;
+import org.apache.struts2.interceptor.ApplicationAware;
+import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
@@ -54,13 +54,13 @@
/**
* Return CANCEL so apropriate result can be selected.
+ *
* @return "cancel" so apropriate result can be selected.
*/
public String cancel() {
return Constants.CANCEL;
}
-
// ---- ApplicationAware ----
/**
@@ -140,7 +140,7 @@
* @param value The task to set.
*/
public void setTask(String value) {
- task = value;
+ task = value;
}
// ---- Token property (utilized by UI) ----
@@ -166,18 +166,17 @@
* @param value The token to set.
*/
public void setToken(String value) {
- token = value;
+ token = value;
}
-
// ---- Host property ----
/**
- * <p>Field to store Subscription host.</p>
+ * <p>Field to store Support host.</p>
* <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>
+ * Support. </p>
*/
private String host;
@@ -191,7 +190,7 @@
}
/**
- * <p>Store new Subscription host.</p>
+ * <p>Store new Support host.</p>
*
* @param value
*/
@@ -401,7 +400,7 @@
try {
user = database.findUser(username);
- }
+ }
catch (ExpiredPasswordException e) {
user = getUser(); // Just so that it is not null
@@ -437,19 +436,19 @@
}
}
- // ---- Subscription property ----
+ // ---- Support property ----
/**
- * <p>Obtain the cached Subscription object, if any. </p>
+ * <p>Obtain the cached Support object, if any. </p>
*
- * @return Cached Subscription object or null
+ * @return Cached Support object or null
*/
public Subscription getSubscription() {
return (Subscription) getSession().get(Constants.SUBSCRIPTION_KEY);
}
/**
- * <p>Store new User Subscription.</p>
+ * <p>Store new User Support.</p>
*
* @param subscription
*/
@@ -458,13 +457,13 @@
}
/**
- * <p> Obtain User Subscription object for the given host, or return null
+ * <p> Obtain User Support object for the given host, or return null
* if not found. </p>
- *
+ * <p/>
* <p>It would be possible for this code to throw a NullPointerException,
* but the ExceptionHandler in the xwork.xml will catch that for us.</p>
*
- * @return The matching Subscription or null
+ * @return The matching Support or null
*/
public Subscription findSubscription(String host) {
Subscription subscription;
@@ -473,19 +472,19 @@
}
/**
- * <p>Obtain uSER Subscription for the local Host property.</p>
+ * <p>Obtain uSER Support for the local Host property.</p>
* <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
+ * @return Support or null if not found
*/
public Subscription findSubscription() {
return findSubscription(getHost());
}
/**
- * <p>Provide a "temporary" User Subscription object that can be used to
+ * <p>Provide a "temporary" User Support object that can be used to
* capture input values.</p>
*/
public void createInputSubscription() {
@@ -495,11 +494,11 @@
}
/**
- * <p>Provide new User Subscription object for the given host, or null if
+ * <p>Provide new User Support object for the given host, or null if
* the host is not unique.</p>
*
* @param host
- * @return New User Subscription object or null
+ * @return New User Support object or null
*/
public Subscription createSubscription(String host) {
@@ -509,7 +508,7 @@
if (null != sub) {
// FIXME - localization - "error.host.unique")
- addFieldError(Constants.HOST,"That hostname is already defined");
+ addFieldError(Constants.HOST, "That hostname is already defined");
return null;
}
@@ -517,10 +516,10 @@
}
/**
- * <p>Create a new Subscription from the current Subscription object,
- * making the new Subscription the current Subscription. </p>
+ * <p>Create a new Support from the current Support object,
+ * making the new Support the current Support. </p>
* <p/>
- * <p>Usually, the "current" Subscription is a temporary object being used
+ * <p>Usually, the "current" Support is a temporary object being used
* to capture input values.</p>
*
* @param host
@@ -536,17 +535,17 @@
}
/**
- * <p>Delete the current Subscription object from the database.</p>
+ * <p>Delete the current Support object from the database.</p>
*/
- public void removeSubscription() {
+ public void removeSubscription() {
getUser().removeSubscription(getSubscription());
getSession().remove(Constants.SUBSCRIPTION_KEY);
}
/**
- * <p>Provide MailServer Host for current User Subscription.</p>
+ * <p>Provide MailServer Host for current User Support.</p>
*
- * @return MailServer Host for current User Subscription
+ * @return MailServer Host for current User Support
*/
public String getSubscriptionHost() {
Subscription sub = getSubscription();
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome-action.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome-action.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome-action.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome-action.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+ <package name="Welcome" namespace="/" extends="MailreaderSupport">
+
+ <action name="Welcome" class="mailreader2.Welcome">
+ <result>/pages/Welcome.jsp</result>
+ <interceptor-ref name="guest"/>
+ </action>
+
+ </package>
+</struts>
Modified: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome.java?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome.java (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/Welcome.java Wed Aug 2 16:43:27 2006
@@ -14,14 +14,13 @@
}
// Confirm database loaded
- if (null==getDatabase()) {
- addActionError(Constants.ERROR_DATABASE_NOT_LOADED);
+ if (null == getDatabase()) {
+ addActionError(Constants.ERROR_DATABASE_NOT_LOADED);
}
if (hasErrors()) {
return ERROR;
- }
- else {
+ } else {
return SUCCESS;
}
}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create-validation.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create-validation.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create-validation.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,28 @@
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+
+ <field name="password">
+ <field-validator type="requiredstring">
+ <message key="error.password.required"/>
+ </field-validator>
+ <field-validator type="stringlength">
+ <param name="trim">true</param>
+ <param name="minLength">4</param>
+ <param name="maxLength">10</param>
+ <message key="errors.range"/>
+ </field-validator>
+ </field>
+
+ <field name="password2">
+ <field-validator type="requiredstring">
+ <message key="error.password2.required"/>
+ </field-validator>
+ </field>
+
+ <validator type="expression">
+ <param name="expression">password eq password2</param>
+ <message key="error.password.match"/>
+ </validator>
+
+</validators>
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Create.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,33 @@
+package mailreader2.registration;
+
+import mailreader2.Constants;
+import org.apache.struts.apps.mailreader.dao.User;
+
+/**
+ * <p>Insert new user, providing extra validation.</p>
+ * <p/>
+ * <p>(On an update, the password change is optional.)</p>
+ */
+public final class Create extends Update {
+
+ public String execute()
+ throws Exception {
+
+ // trust but verify
+ boolean creating = Constants.CREATE.equals(getTask());
+ creating = creating && isCreating();
+ if (!creating) return ERROR;
+
+ User user = findUser(getUsername(), getPassword());
+ boolean haveUser = (user != null);
+
+ if (haveUser) {
+ addActionError(getText("error.username.unique"));
+ return INPUT;
+ }
+
+ copyUser(getUsername(), getPassword());
+
+ return SUCCESS;
+ }
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Input.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Input.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Input.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Input.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,31 @@
+package mailreader2.registration;
+
+import mailreader2.Constants;
+
+/**
+ * <p> Retrieve User object to edit or null if User does not exist. </p>
+ */
+public class Input extends Support {
+
+ /**
+ * <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
+ */
+ public String execute() throws Exception {
+
+ if (isCreating()) {
+ createInputUser();
+ setTask(Constants.CREATE);
+ } else {
+ setTask(Constants.EDIT);
+ setUsername(getUser().getUsername());
+ setPassword(getUser().getPassword());
+ setPassword2(getUser().getPassword());
+ }
+
+ return SUCCESS;
+ }
+
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve-validation.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve-validation.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve-validation.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,14 @@
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+ <field name="username">
+ <field-validator type="requiredstring">
+ <message key="error.username.required"/>
+ </field-validator>
+ </field>
+ <field name="password">
+ <field-validator type="requiredstring">
+ <message key="error.password.required"/>
+ </field-validator>
+ </field>
+</validators>
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Retrieve.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,46 @@
+/*
+ * $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.registration;
+
+import mailreader2.MailreaderSupport;
+import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
+import org.apache.struts.apps.mailreader.dao.User;
+
+/**
+ * <p> Validate a user logon. </p>
+ */
+public final class Retrieve extends MailreaderSupport {
+
+ public String execute() throws ExpiredPasswordException {
+
+ User user = findUser(getUsername(), getPassword());
+
+ if (user != null) {
+ setUser(user);
+ }
+
+ if (hasErrors()) {
+ return INPUT;
+ }
+
+ return SUCCESS;
+
+ }
+
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Support.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Support.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Support.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Support.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,20 @@
+package mailreader2.registration;
+
+import mailreader2.MailreaderSupport;
+import org.apache.struts.apps.mailreader.dao.User;
+
+/**
+ * <p>Base class to store shared methods.</p>
+ */
+public class Support extends MailreaderSupport {
+
+ /**
+ * <p>Double check that there is not a valid User logon. </p>
+ *
+ * @return True if there is not a valid User logon
+ */
+ protected boolean isCreating() {
+ User user = getUser();
+ return (null == user) || (null == user.getDatabase());
+ }
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update-validation.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update-validation.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update-validation.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,32 @@
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+
+ <field name="username">
+ <field-validator type="requiredstring">
+ <message key="error.username.required"/>
+ </field-validator>
+ </field>
+
+ <field name="user.fullName">
+ <field-validator type="requiredstring">
+ <message key="error.fullName.required"/>
+ </field-validator>
+ </field>
+
+ <field name="user.fromAddress">
+ <field-validator type="requiredstring">
+ <message key="error.fromAddress.required"/>
+ </field-validator>
+ <field-validator type="email">
+ <message key="errors.email"/>
+ </field-validator>
+ </field>
+
+ <field name="user.replyToAddress">
+ <field-validator type="email">
+ <message key="errors.email"/>
+ </field-validator>
+ </field>
+
+</validators>
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/registration/Update.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,41 @@
+package mailreader2.registration;
+
+import mailreader2.Constants;
+
+/**
+ * <p> Update a User object to the persistent store. </p>
+ */
+public class Update extends Support {
+
+ private String fixNull(String value) {
+ if (value == null) return null;
+ String buffer = value.trim();
+ if (buffer.length() == 0) return null;
+ return buffer;
+ }
+
+ public String execute()
+ throws Exception {
+
+ boolean creating = Constants.CREATE.equals(getTask());
+ creating = creating && isCreating(); // trust but verify
+ if (creating) return ERROR;
+ // FIXME: Any way to call the RegisrationSave validators from here?
+ String newPassword = fixNull(getPassword());
+ String confirmPassword = fixNull(getPassword2());
+ if (newPassword != null) {
+ boolean matches = ((confirmPassword != null)
+ && (confirmPassword.equals(newPassword)));
+ if (matches) {
+ getUser().setPassword(newPassword);
+ } else {
+ addActionError(getText("error.password.match"));
+ return INPUT;
+ }
+ }
+
+ saveUser();
+
+ return SUCCESS;
+ }
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Delete.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Delete.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Delete.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Delete.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,15 @@
+package mailreader2.subscription;
+
+import mailreader2.Constants;
+
+/**
+ * <p>Prepare to present a confirmation page before removing
+ * subscription.</p>
+ */
+public class Delete extends Edit {
+
+ public String execute() throws Exception {
+ setTask(Constants.DELETE);
+ return find();
+ }
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit-validation.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit-validation.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit-validation.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,11 @@
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+
+ <field name="host">
+ <field-validator type="requiredstring">
+ <message key="error.host.required"/>
+ </field-validator>
+ </field>
+
+</validators>
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Edit.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,16 @@
+package mailreader2.subscription;
+
+import mailreader2.Constants;
+
+/**
+ * <p>Prepare to edit User Support.</p>
+ */
+public class Edit extends Support {
+
+ public String execute() throws Exception {
+ setTask(Constants.EDIT);
+ return find();
+ }
+
+
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Input.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Input.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Input.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Input.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,17 @@
+package mailreader2.subscription;
+
+import mailreader2.Constants;
+
+/**
+ * <p>Setup a temporary User Support object to capture input
+ * values.</p>
+ */
+public class Input extends Support {
+
+ public String execute() {
+ createInputSubscription();
+ setTask(Constants.CREATE);
+ return SUCCESS;
+ }
+
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save-validation.xml?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save-validation.xml (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save-validation.xml Wed Aug 2 16:43:27 2006
@@ -0,0 +1,23 @@
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+
+ <field name="subscription.username">
+ <field-validator type="requiredstring">
+ <message key="error.username.required"/>
+ </field-validator>
+ </field>
+
+ <field name="subscription.password">
+ <field-validator type="requiredstring">
+ <message key="error.password.required"/>
+ </field-validator>
+ </field>
+
+ <field name="subscription.type">
+ <field-validator type="requiredstring">
+ <message key="error.type.invalid"/>
+ </field-validator>
+ </field>
+
+</validators>
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Save.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,38 @@
+package mailreader2.subscription;
+
+import mailreader2.Constants;
+
+/**
+ * <p> Workaround class. Submitting to an alias doesn't seem to work. </p>
+ */
+public final class Save extends Edit {
+
+ public void prepare() {
+ super.prepare();
+ // checkbox workaround
+ getSubscription().setAutoConnect(false);
+ }
+
+ /**
+ * <p> Examine the Task property and DELETE, CREATE, or save the User
+ * Support, as appropriate. </p>
+ *
+ * @return SUCCESS
+ * @throws Exception on a database error
+ */
+ public String execute() throws Exception {
+
+ if (Constants.DELETE.equals(getTask())) {
+ removeSubscription();
+ }
+
+ if (Constants.CREATE.equals(getTask())) {
+ copySubscription(getHost());
+ }
+
+ if (hasErrors()) return INPUT;
+
+ saveUser();
+ return SUCCESS;
+ }
+}
Added: struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Support.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Support.java?rev=428196&view=auto
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Support.java (added)
+++ struts/struts2/trunk/apps/mailreader/src/main/java/mailreader2/subscription/Support.java Wed Aug 2 16:43:27 2006
@@ -0,0 +1,66 @@
+package mailreader2.subscription;
+
+import com.opensymphony.xwork2.Preparable;
+import mailreader2.MailreaderSupport;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * <p> Provide an Edit method for retrieving an existing subscription, and a
+ * Save method for updating or inserting a subscription. </p>
+ */
+public class Support 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;
+ }
+
+ /**
+ * <p>Setup the MailerServer types and set the local Host property from
+ * the User Support (if any). </p>
+ */
+ public void prepare() {
+
+ Map m = new LinkedHashMap();
+ m.put("imap", "IMAP Protocol");
+ m.put("pop3", "POP3 Protocol");
+ types = m;
+
+ setHost(getSubscriptionHost());
+
+ }
+
+ /**
+ * <p>Load User Support for the local Host property.</p>
+ * <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 Support is not found
+ */
+ public String find() {
+
+ org.apache.struts.apps.mailreader.dao.Subscription
+ sub = findSubscription();
+
+ if (sub == null) {
+ return ERROR;
+ }
+
+ setSubscription(sub);
+
+ return SUCCESS;
+ }
+}
Modified: struts/struts2/trunk/apps/mailreader/src/main/resources/sql-map-config.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/resources/sql-map-config.xml?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/resources/sql-map-config.xml (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/resources/sql-map-config.xml Wed Aug 2 16:43:27 2006
@@ -1,25 +1,25 @@
<!DOCTYPE sqlMapConfig PUBLIC
- "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
- "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
+ "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
+ "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
- <properties resource="sql/sql-map-config-hsql.properties"/>
+ <properties resource="sql/sql-map-config-hsql.properties"/>
- <settings cacheModelsEnabled="true" enhancementEnabled="false"
- maxSessions="64" maxTransactions="8" maxRequests="128"/>
+ <settings cacheModelsEnabled="true" enhancementEnabled="false"
+ maxSessions="64" maxTransactions="8" maxRequests="128"/>
- <transactionManager type="JDBC">
- <dataSource type="SIMPLE">
- <property value="${driver}" name="JDBC.Driver"/>
- <property value="${url}" name="JDBC.ConnectionURL"/>
- <property value="${username}" name="JDBC.Username"/>
- <property value="${password}" name="JDBC.Password"/>
- <property value="15" name="Pool.MaximumActiveConnections"/>
- <property value="15" name="Pool.MaximumIdleConnections"/>
- <property value="1000" name="Pool.MaximumWait"/>
- </dataSource>
- </transactionManager>
+ <transactionManager type="JDBC">
+ <dataSource type="SIMPLE">
+ <property value="${driver}" name="JDBC.Driver"/>
+ <property value="${url}" name="JDBC.ConnectionURL"/>
+ <property value="${username}" name="JDBC.Username"/>
+ <property value="${password}" name="JDBC.Password"/>
+ <property value="15" name="Pool.MaximumActiveConnections"/>
+ <property value="15" name="Pool.MaximumIdleConnections"/>
+ <property value="1000" name="Pool.MaximumWait"/>
+ </dataSource>
+ </transactionManager>
- <sqlMap resource="sql/sql-map.xml"/>
+ <sqlMap resource="sql/sql-map.xml"/>
</sqlMapConfig>
Modified: struts/struts2/trunk/apps/mailreader/src/main/resources/sql/sql-map.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/resources/sql/sql-map.xml?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/resources/sql/sql-map.xml (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/resources/sql/sql-map.xml Wed Aug 2 16:43:27 2006
@@ -1,10 +1,10 @@
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
- "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+ "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="mailreader">
<typeAlias alias="data"
- type="mailreader2.AppData"/>
+ type="mailreader2.AppData"/>
<select id="LOCALE_LIST" resultClass="data">
SELECT pk_locale AS locale_key, locale_code
@@ -19,7 +19,7 @@
<insert id="REGISTRATION_INSERT" parameterClass="data">
INSERT INTO registration
- (pk_registration, fk_locale, username, password, fullname, email_from, email_replyto)
+ (pk_registration, fk_locale, username, password, fullname, email_from, email_replyto)
VALUES (#registration_key#, #locale_key#, #username#, #password#, #fullname#, #email_from#, #email_replyto#);
</insert>
@@ -37,7 +37,7 @@
<select id="REGISTRATION_EDIT" parameterClass="data" resultClass="data">
SELECT pk_registration AS registration_key, fk_locale AS locale_key,
- username, password, fullname, email_from, email_replyto
+ username, password, fullname, email_from, email_replyto
FROM registration
WHERE pk_registration=#registration_key#;
</select>
@@ -45,7 +45,7 @@
<update id="REGISTRATION_UPDATE" parameterClass="data">
UPDATE registration
SET fk_locale=#locale_key#, username=#username#, password=#password#, fullname=#fullname#,
- email_from=#email_from#, email_replyto=#email_replyto#
+ email_from=#email_from#, email_replyto=#email_replyto#
WHERE pk_registration=#registration_key#;
</update>
@@ -53,36 +53,36 @@
SELECT COUNT(*)
FROM subscription
WHERE fk_registration=#registration_key#
- AND subscription_host=#subscription_host#;
+ AND subscription_host=#subscription_host#;
</select>
<insert id="SUBSCRIPTION_INSERT" parameterClass="data">
INSERT INTO subscription
- (pk_subscription, fk_registration, fk_protocol, subscription_host, host_user, host_pass, host_auto)
+ (pk_subscription, fk_registration, fk_protocol, subscription_host, host_user, host_pass, host_auto)
VALUES (#subscription_key#, #registration_key#, #protocol_key#, #subscription_host#,
- #host_user#, #host_pass#, #host_auto#);
+ #host_user#, #host_pass#, #host_auto#);
</insert>
<select id="SUBSCRIPTION_LIST" parameterClass="data" resultClass="data">
SELECT pk_subscription AS subscription_key,
- subscription_host, host_user, host_pass, host_auto, protocol_name
+ subscription_host, host_user, host_pass, host_auto, protocol_name
FROM subscription
- JOIN protocol ON pk_protocol=fk_protocol
+ JOIN protocol ON pk_protocol=fk_protocol
WHERE fk_registration=#registration_key#;
</select>
<select id="SUBSCRIPTION_EDIT" parameterClass="data" resultClass="data">
SELECT pk_subscription AS subscription_key, fk_protocol AS protocol_key,
- subscription_host, host_user, host_pass, host_auto, protocol_name
+ subscription_host, host_user, host_pass, host_auto, protocol_name
FROM subscription
- JOIN protocol ON pk_protocol=fk_protocol
+ JOIN protocol ON pk_protocol=fk_protocol
WHERE pk_subscription=#subscription_key#;
</select>
<update id="SUBSCRIPTION_UPDATE" parameterClass="data">
UPDATE subscription
SET fk_registration=#registration_key#, fk_protocol=#protocol_key#,
- subscription_host=#subscription_host#, host_user=#host_user#, host_pass=#host_pass#, host_auto=#host_auto#
+ subscription_host=#subscription_host#, host_user=#host_user#, host_pass=#host_pass#, host_auto=#host_auto#
WHERE pk_subscription=#subscription_key#;
</update>
Modified: struts/struts2/trunk/apps/mailreader/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/resources/struts.xml?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/resources/struts.xml (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/resources/struts.xml Wed Aug 2 16:43:27 2006
@@ -1,112 +1,169 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
- <package name="default" namespace="/" extends="struts-default">
+ <package name="default" namespace="" extends="struts-default">
<interceptors>
<interceptor name="authentication"
class="mailreader2.AuthenticationInterceptor"/>
- <interceptor-stack name="user" >
- <interceptor-ref name="authentication" />
+ <interceptor-stack name="user">
+ <interceptor-ref name="authentication"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
- <interceptor-stack name="user-submit" >
- <interceptor-ref name="token-session" />
+ <interceptor-stack name="user-submit">
+ <interceptor-ref name="token-session"/>
<interceptor-ref name="user"/>
</interceptor-stack>
- <interceptor-stack name="guest" >
+ <interceptor-stack name="guest">
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
- <interceptor-stack name="guest-submit" >
- <interceptor-ref name="token-session" />
+ <interceptor-stack name="guest-submit">
+ <interceptor-ref name="token-session"/>
<interceptor-ref name="guest"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="user"/>
-
- <default-action-ref name="Welcome"/>
+
+ <!-- default-action-ref name="Welcome"/ -->
<global-results>
<result name="error">/pages/Error.jsp</result>
<result name="invalid.token">/pages/Error.jsp</result>
- <result name="login" type="redirect-action">Logon!input</result>
+ <result name="login" type="redirect-action">Logon</result>
+ <result name="cancel" type="redirect-action">Welcome</result>
+ <result name="success" type="redirect-action">MainMenu</result>
+ <result name="expired" type="chain">ChangePassword</result>
</global-results>
<global-exception-mappings>
<exception-mapping
result="error"
exception="java.lang.Throwable"/>
+ <exception-mapping
+ exception="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException"
+ result="expired"/>
</global-exception-mappings>
- <action name="Welcome" class="mailreader2.Welcome">
- <result>/pages/Welcome.jsp</result>
- <interceptor-ref name="guest"/>
+ <!--
+ <action name="*" class="mailreader2.{1}">
+ <result name="input">/pages/{1}.jsp</result>
</action>
- <action name="Logon!*" class="mailreader2.Logon" method="{1}">
- <result name="input">/pages/Logon.jsp</result>
- <result name="cancel" type="redirect-action">Welcome</result>
+ <action name="*/*" class="mailreader2.{1}.{2}">
+ <result name="input">/pages/{1}.jsp</result>
<result type="redirect-action">MainMenu</result>
- <result name="expired" type="chain">ChangePassword</result>
- <exception-mapping
- exception="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException"
- result="expired"/>
- <interceptor-ref name="guest"/>
</action>
+ <action name="*/Create" class="mailreader2.{1}.Create">
+ <result name="input">/pages/{1}.jsp</result>
+ <result type="redirect-action">MainMenu</result>
+ <interceptor-ref name="user-submit" />
+ </action>
+
+ <action name="*/Update" class="mailreader2.{1}.Update">
+ <result name="input">/pages/{1}.jsp</result>
+ <result type="redirect-action">MainMenu</result>
+ <interceptor-ref name="user-submit" />
+ </action>
+
+ <action name="*/Save" class="mailreader2.{1}.Save">
+ <result name="input">/pages/{1}.jsp</result>
+ <result type="redirect-action">MainMenu</result>
+ <interceptor-ref name="user-submit" />
+ </action>
+
+ -->
+
<action name="ChangePassword">
- <result>/pages/ChangePassword.jsp</result>
+ <result name="input">/pages/ChangePassword.jsp</result>
+ </action>
+
+ <action name="Logoff" class="mailreader2.Logoff">
+ <result type="redirect-action">Welcome</result>
+ </action>
+
+ <action name="Logon">
+ <result>/pages/Logon.jsp</result>
+ <interceptor-ref name="guest"/>
</action>
<action name="MainMenu" class="mailreader2.MailreaderSupport">
<result>/pages/MainMenu.jsp</result>
</action>
- <action name="Registration!*" class="mailreader2.Registration" method="{1}">
- <result name="input">/pages/Registration.jsp</result>
+ <action name="Tour">
+ <result>/pages/Tour.html</result>
+ <interceptor-ref name="guest"/>
+ </action>
+
+ <action name="Welcome" class="mailreader2.Welcome">
+ <result>/pages/Welcome.jsp</result>
+ <interceptor-ref name="guest"/>
+ </action>
+
+ </package>
+
+ <package name="registration" namespace="/registration" extends="default">
+
+ <action name="Update" class="mailreader2.registration.Update">
+ <result name="input">/pages/registration.jsp</result>
+ <result type="redirect-action">MainMenu</result>
+ </action>
+
+ <action name="Create" class="mailreader2.registration.Create">
+ <result name="input">/pages/registration.jsp</result>
<result type="redirect-action">MainMenu</result>
+ <interceptor-ref name="guest-submit"/>
+ </action>
+
+ <action name="Input" class="mailreader2.registration.Input">
+ <result>/pages/registration.jsp</result>
<interceptor-ref name="guest"/>
</action>
- <!-- last match wins -->
- <action name="Registration_save" class="mailreader2.RegistrationSave">
- <result name="input">/pages/Registration.jsp</result>
+ <action name="Retrieve" class="mailreader2.registration.Retrieve">
+ <result name="input">/pages/Logon.jsp</result>
<result type="redirect-action">MainMenu</result>
- <interceptor-ref name="guest-submit" />
+ <interceptor-ref name="guest"/>
</action>
- <action name="Subscription!*" class="mailreader2.Subscription" method="{1}">
- <result name="input">/pages/Subscription.jsp</result>
- <result type="redirect-action">Registration!input</result>
+ </package>
+
+ <package name="subscription" namespace="/subscription" extends="default">
+
+ <action name="Delete" class="mailreader2.subscription.Delete">
+ <result>/pages/subscription.jsp</result>
</action>
- <!-- last match wins -->
- <action name="Subscription_save" class="mailreader2.SubscriptionSave">
- <result name="input">/pages/Subscription.jsp</result>
- <result type="redirect-action">Registration!input</result>
- <interceptor-ref name="user-submit" />
+ <action name="Edit" class="mailreader2.subscription.Edit">
+ <result>/pages/subscription.jsp</result>
</action>
- <action name="Logoff" class="mailreader2.Logoff">
- <result type="redirect-action">Welcome</result>
+ <action name="Input" class="mailreader2.subscription.Input">
+ <result>/pages/subscription.jsp</result>
</action>
- <action name="Tour">
- <result>/pages/tour.html</result>
- <interceptor-ref name="guest"/>
+ <action name="Save" class="mailreader2.subscription.Save">
+ <result name="input">/pages/subscription.jsp</result>
+ <result type="redirect-action">
+ <param name="actionName">Input</param>
+ <param name="namespace">/registration</param>
+ </result>
+ <interceptor-ref name="user-submit"/>
</action>
</package>
+
</struts>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/WEB-INF/web.xml Wed Aug 2 16:43:27 2006
@@ -33,7 +33,7 @@
mailreader2.ApplicationListener
</listener-class>
</listener>
-
+
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/ChangePassword.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/ChangePassword.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/ChangePassword.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/ChangePassword.jsp Wed Aug 2 16:43:27 2006
@@ -16,7 +16,7 @@
</p>
<p>
- <a href="<s:url action="Logon!input"/>">
+ <a href="<s:url action="Logon"/>">
<s:text name="change.try"/>
</a>
</p>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Error.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Error.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Error.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Error.jsp Wed Aug 2 16:43:27 2006
@@ -20,7 +20,7 @@
<h3>Error Message</h3>
-<s:actionerror />
+<s:actionerror/>
<p>
<s:property value="%{exception.message}"/>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Logon.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Logon.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Logon.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Logon.jsp Wed Aug 2 16:43:27 2006
@@ -9,10 +9,10 @@
type="text/css"/>
</head>
-<body onLoad="self.focus();document.Logon.username.focus()">
+<body onLoad="self.focus();document.Retrieve.username.focus()">
-<s:actionerror />
-<s:form action="Logon!execute" validate="true">
+<s:actionerror/>
+<s:form action="Retrieve" namespace="/registration" validate="true">
<s:textfield label="%{getText('username')}" name="username"/>
<s:password label="%{getText('password')}" name="password" showPassword="true"/>
@@ -21,8 +21,8 @@
<s:reset value="%{getText('button.reset')}"/>
- <s:submit action="Logon!cancel" value="%{getText('button.cancel')}"
- onclick="form.onsubmit=null"/>
+ <s:submit action="Welcome" value="%{getText('button.cancel')}"
+ onclick="form.onsubmit=null"/>
</s:form>
<jsp:include page="Footer.jsp"/>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/MainMenu.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/MainMenu.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/MainMenu.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/MainMenu.jsp Wed Aug 2 16:43:27 2006
@@ -13,13 +13,21 @@
<h3><s:text name="mainMenu.heading"/> <s:property
value="user.fullName"/></h3>
<ul>
- <li><a href="<s:url action="Registration!input" />">
- <s:text name="mainMenu.registration"/>
- </a>
+ <li>
+ <s:url id="Input" action="Input" namespace="/registration"/>
+ <s:a href="%{Input}">
+ <s:text name="mainMenu.registration"/>
+ </s:a>
+ </li>
+ <li>
+ <s:url id="Logoff" action="Logoff"/>
+ <s:a href="%{Logoff}">
+ <s:text name="mainMenu.logoff"/>
+ </s:a>
</li>
- <li><a href="<s:url action="Logoff"/>">
- <s:text name="mainMenu.logoff"/>
- </a>
</ul>
+
+<jsp:include page="Footer.jsp"/>
+
</body>
</html>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Registration.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Registration.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Registration.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Registration.jsp Wed Aug 2 16:43:27 2006
@@ -14,10 +14,10 @@
type="text/css"/>
</head>
-<body onLoad="self.focus();document.Registration.username.focus()">
+<body onLoad="self.focus();document.Update.username.focus()">
<s:actionerror/>
-<s:form action="Registration" validate="true">
+<s:form action="Update" validate="true">
<s:token/>
<s:hidden name="task"/>
<s:if test="task == 'Create'">
@@ -33,29 +33,29 @@
<s:password label="%{getText('password2')}" name="password2"/>
<s:textfield label="%{getText('fullName')}"
- name="user.fullName"/>
+ name="user.fullName"/>
<s:textfield label="%{getText('fromAddress')}"
- name="user.fromAddress"/>
+ name="user.fromAddress"/>
<s:textfield label="%{getText('replyToAddress')}"
- name="user.replyToAddress"/>
+ name="user.replyToAddress"/>
<s:if test="task == 'Create'">
- <s:submit value="%{getText('button.save')}" action="Registration_save"/>
+ <s:submit value="%{getText('button.save')}" action="Create"/>
<s:reset value="%{getText('button.reset')}"/>
<s:submit action="Welcome" value="%{getText('button.cancel')}"
- onclick="form.onsubmit=null"/>
+ onclick="form.onsubmit=null"/>
</s:if>
<s:else>
<s:submit value="%{getText('button.save')}"/>
<s:reset value="%{getText('button.reset')}"/>
- <s:submit action="MainMenu" value="%{getText('button.cancel')}"
- onclick="form.onsubmit=null"/>
+ <s:submit value="%{getText('button.cancel')}"
+ action="MainMenu" onclick="form.onsubmit=null"/>
</s:else>
</s:form>
@@ -100,23 +100,27 @@
<s:property value="autoConnect"/>
</td>
<td align="center">
-
- <a href="<s:url action="Subscription!delete"><s:param name="host" value="host"/></s:url>">
+ <s:url id="Delete" action="Delete" namespace="/subscription">
+ <s:param name="host" value="host"/>
+ </s:url>
+ <s:a href="%{Delete}">
<s:text name="registration.deleteSubscription"/>
- </a>
+ </s:a>
- <a href="<s:url action="Subscription!edit"><s:param name="host" value="host"/></s:url>">
+ <s:url id="Edit" action="Edit" namespace="/subscription">
+ <s:param name="host" value="host"/>
+ </s:url>
+ <s:a href="%{Edit}">
<s:text name="registration.editSubscription"/>
- </a>
-
+ </s:a>
</td>
</tr>
</s:iterator>
</table>
- <a href="<s:url action="Subscription!input"/>"><s:text
- name="registration.addSubscription"/></a>
+ <s:url id="Input" action="Input" namespace="/subscription"/>
+ <s:a href="%{Input}"><s:text name="registration.addSubscription"/></s:a>
</s:if>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Subscription.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Subscription.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Subscription.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Subscription.jsp Wed Aug 2 16:43:27 2006
@@ -17,10 +17,10 @@
type="text/css"/>
</head>
-<body onLoad="self.focus();document.Subscription_save.username.focus()">
+<body onLoad="self.focus();document.Save.username.focus()">
<s:actionerror/>
-<s:form action="Subscription_save" validate="true">
+<s:form action="Save" validate="true">
<s:token/>
<s:hidden name="task"/>
<s:label label="%{getText('username')}" name="user.username"/>
@@ -35,31 +35,31 @@
<s:if test="task == 'Delete'">
<s:label label="%{getText('mailUsername')}"
- name="subscription.username"/>
+ name="subscription.username"/>
<s:label label="%{getText('mailPassword')}"
- name="subscription.password"/>
+ name="subscription.password"/>
<s:label label="%{getText('mailServerType')}"
- name="subscription.type"/>
+ name="subscription.type"/>
<s:label label="%{getText('autoConnect')}"
- name="subscription.autoConnect"/>
+ name="subscription.autoConnect"/>
<s:submit value="%{getText('button.confirm')}"/>
</s:if>
<s:else>
<s:textfield label="%{getText('mailUsername')}"
- name="subscription.username"/>
+ name="subscription.username"/>
<s:textfield label="%{getText('mailPassword')}"
- name="subscription.password"/>
+ name="subscription.password"/>
<s:select label="%{getText('mailServerType')}"
- name="subscription.type" list="types"/>
+ name="subscription.type" list="types"/>
<s:checkbox label="%{getText('autoConnect')}"
- name="subscription.autoConnect"/>
+ name="subscription.autoConnect"/>
<s:submit value="%{getText('button.save')}"/>
<s:reset value="%{getText('button.reset')}"/>
</s:else>
- <s:submit action="Registration!input"
- value="%{getText('button.cancel')}"
- onclick="form.onsubmit=null"/>
+ <s:submit action="MainMenu"
+ value="%{getText('button.cancel')}"
+ onclick="form.onsubmit=null"/>
</s:form>
<jsp:include page="Footer.jsp"/>
Modified: struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Welcome.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Welcome.jsp?rev=428196&r1=428195&r2=428196&view=diff
==============================================================================
--- struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Welcome.jsp (original)
+++ struts/struts2/trunk/apps/mailreader/src/main/webapp/pages/Welcome.jsp Wed Aug 2 16:43:27 2006
@@ -14,10 +14,14 @@
<h3><s:text name="index.heading"/></h3>
<ul>
- <li><a href="<s:url action="Registration!input"/>"><s:text
- name="index.registration"/></a></li>
- <li><a href="<s:url action="Logon!input"/>"><s:text
- name="index.logon"/></a></li>
+ <li>
+ <s:url id="Input" action="Input" namespace="/registration"/>
+ <s:a href="%{Input}"><s:text name="index.registration"/></s:a>
+ </li>
+ <li>
+ <s:url id="Logon" action="Logon"/>
+ <s:a href="%{Logon}"><s:text name="index.logon"/></s:a>
+ </li>
</ul>
<h3>Language Options</h3>
@@ -29,25 +33,31 @@
<s:a href="%{en}">English</s:a>
</li>
<li>
- <a href="<s:url action="Welcome">
+ <s:url id="ja" action="Welcome">
<s:param name="request_locale">ja</s:param>
- </s:url>">Japanese</a>
- </li>
+ </s:url>
+ <s:a href="%{ja}">Japanese</s:a>
+ </li>
<li>
- <a href="<s:url value="Welcome.do">
- <s:param name="request_locale" value="'ru'" />
- </s:url>">Russian</a>
+ <s:url id="ru" action="Welcome">
+ <s:param name="request_locale">ru</s:param>
+ </s:url>
+ <s:a href="%{ru}">Russian</s:a>
</li>
</ul>
<hr/>
-<p><s:i18n name="alternate">
- <img src="<s:text name="struts.logo.path"/>"
- alt="<s:text name="struts.logo.alt"/>"/>
-</s:i18n></p>
+<p>
+ <s:i18n name="alternate">
+ <img src="<s:text name="struts.logo.path"/>"
+ alt="<s:text name="struts.logo.alt"/>"/>
+ </s:i18n>
+</p>
-<p><a href="<s:url action="Tour" />"><s:text name="index.tour"/></a></p>
+<p>
+ <s:url id="Tour" action="Tour"/><s:a href="%{Tour}"><s:text name="index.tour"/></s:a>
+</p>
</body>
</html>