mailreader2
Class MailreaderSupport

java.lang.Object
  extended by com.opensymphony.xwork2.ActionSupport
      extended by mailreader2.MailreaderSupport
All Implemented Interfaces:
com.opensymphony.xwork2.Action, com.opensymphony.xwork2.LocaleProvider, com.opensymphony.xwork2.TextProvider, com.opensymphony.xwork2.Validateable, com.opensymphony.xwork2.ValidationAware, Serializable, ApplicationAware, SessionAware
Direct Known Subclasses:
Login, Logout, Registration, Subscription, Welcome

public class MailreaderSupport
extends com.opensymphony.xwork2.ActionSupport
implements SessionAware, ApplicationAware

Base Action for MailreaderSupport application.

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.

See Also:
Serialized Form

Field Summary
protected  com.opensymphony.xwork2.util.logging.Logger log
          Log instance for this application.
 
Fields inherited from class com.opensymphony.xwork2.ActionSupport
LOG
 
Fields inherited from interface com.opensymphony.xwork2.Action
ERROR, INPUT, LOGIN, NONE, SUCCESS
 
Constructor Summary
MailreaderSupport()
           
 
Method Summary
 String cancel()
          Return CANCEL so apropriate result can be selected.
 void copySubscription(String host)
          Create a new Subscription from the current Subscription object, making the new Subscription the current Subscription.
protected  void copySubscription(org.apache.struts.apps.mailreader.dao.Subscription source, org.apache.struts.apps.mailreader.dao.Subscription target)
          Convenience method to copy Subscription properties.
 void copyUser(String _username, String _password)
          Use the current User object to create a new User object, and make the new User object the authenticated user.
protected  void copyUser(org.apache.struts.apps.mailreader.dao.User source, org.apache.struts.apps.mailreader.dao.User target)
          Convenience method to copy User properties.
 void createInputSubscription()
          Provide a "temporary" User Subscription object that can be used to capture input values.
 void createInputUser()
           
 org.apache.struts.apps.mailreader.dao.Subscription createSubscription(String host)
          Provide new User Subscription object for the given host, or null if the host is not unique.
 org.apache.struts.apps.mailreader.dao.User createUser(String username, String password)
           Verify input for creating a new user, create the user, and process the login.
 org.apache.struts.apps.mailreader.dao.Subscription findSubscription()
          Obtain uSER Subscription for the local Host property.
 org.apache.struts.apps.mailreader.dao.Subscription findSubscription(String host)
           Obtain User Subscription object for the given host, or return null if not found.
 org.apache.struts.apps.mailreader.dao.User findUser(String username, String password)
          Obtain User object from database, or return null if the credentials are not found or invalid.
 Map getApplication()
          Provide application context.
 org.apache.struts.apps.mailreader.dao.UserDatabase getDatabase()
          Provide reference to UserDatabase, or null if the database is not available.
 String getHost()
          Provide tSubscription host.
 String getPassword()
          Provide User password
 String getPassword2()
          Provide the User password confirmation.
 Map getSession()
          Provide session context.
 org.apache.struts.apps.mailreader.dao.Subscription getSubscription()
          Obtain the cached Subscription object, if any.
 String getSubscriptionHost()
          Provide MailServer Host for current User Subscription.
 String getTask()
          Provide worklow task.
 String getToken()
          Provide Token.
 org.apache.struts.apps.mailreader.dao.User getUser()
          Provide reference to User object for authenticated user.
 String getUsername()
          Provide User username.
 void removeSubscription()
          Delete the current Subscription object from the database.
 void saveUser()
           Persist the User object, including subscriptions, to the database.
 void setApplication(Map value)
          Store a new application context.
 void setDatabase(org.apache.struts.apps.mailreader.dao.UserDatabase database)
          Store a new reference to UserDatabase
 void setHost(String value)
          Store new Subscription host.
 void setPassword(String value)
          Store new User Password
 void setPassword2(String value)
          Store a new User password confirmation.
 void setSession(Map value)
          Store a new session context.
 void setSubscription(org.apache.struts.apps.mailreader.dao.Subscription subscription)
          Store new User Subscription.
 void setTask(String value)
          Store new workflow task.
 void setToken(String value)
          Store new Token.
 void setUser(org.apache.struts.apps.mailreader.dao.User user)
          Store new reference to User Object.
 void setUsername(String value)
          Store new User username
 
Methods inherited from class com.opensymphony.xwork2.ActionSupport
addActionError, addActionMessage, addFieldError, clearActionErrors, clearErrors, clearErrorsAndMessages, clearFieldErrors, clearMessages, clone, doDefault, execute, getActionErrors, getActionMessages, getErrorMessages, getErrors, getFieldErrors, getFormatted, getLocale, getText, getText, getText, getText, getText, getText, getText, getText, getText, getTexts, getTexts, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, hasKey, input, pause, setActionErrors, setActionMessages, setContainer, setFieldErrors, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected com.opensymphony.xwork2.util.logging.Logger log

Log instance for this application.

Constructor Detail

MailreaderSupport

public MailreaderSupport()
Method Detail

cancel

public String cancel()
Return CANCEL so apropriate result can be selected.

Returns:
"cancel" so apropriate result can be selected.

copyUser

protected void copyUser(org.apache.struts.apps.mailreader.dao.User source,
                        org.apache.struts.apps.mailreader.dao.User target)
Convenience method to copy User properties.


copySubscription

protected void copySubscription(org.apache.struts.apps.mailreader.dao.Subscription source,
                                org.apache.struts.apps.mailreader.dao.Subscription target)
Convenience method to copy Subscription properties.


setApplication

public void setApplication(Map value)

Store a new application context.

Specified by:
setApplication in interface ApplicationAware
Parameters:
value - A Map representing application state

getApplication

public Map getApplication()

Provide application context.


setSession

public void setSession(Map value)

Store a new session context.

Specified by:
setSession in interface SessionAware
Parameters:
value - A Map representing session state

getSession

public Map getSession()

Provide session context.

Returns:
session context

getTask

public String getTask()

Provide worklow task.

Returns:
Returns the task.

setTask

public void setTask(String value)

Store new workflow task.

Parameters:
value - The task to set.

getToken

public String getToken()

Provide Token.

Returns:
Returns the token.

setToken

public void setToken(String value)

Store new Token.

Parameters:
value - The token to set.

getHost

public String getHost()

Provide tSubscription host.

Returns:
host property

setHost

public void setHost(String value)

Store new Subscription host.

Parameters:
value -

getPassword

public String getPassword()

Provide User password

Returns:
Returns the password.

setPassword

public void setPassword(String value)

Store new User Password

Parameters:
value - The password to set.

getPassword2

public String getPassword2()

Provide the User password confirmation.

Returns:
Returns the confirmationpassword.

setPassword2

public void setPassword2(String value)

Store a new User password confirmation.

Parameters:
value - The confirmation password to set.

getUsername

public String getUsername()

Provide User username.

Returns:
Returns the User username.

setUsername

public void setUsername(String value)

Store new User username

Parameters:
value - The username to set.

getDatabase

public org.apache.struts.apps.mailreader.dao.UserDatabase getDatabase()

Provide reference to UserDatabase, or null if the database is not available.

Returns:
a reference to the UserDatabase or null if the database is not available

setDatabase

public void setDatabase(org.apache.struts.apps.mailreader.dao.UserDatabase database)

Store a new reference to UserDatabase

Parameters:
database -

getUser

public org.apache.struts.apps.mailreader.dao.User getUser()

Provide reference to User object for authenticated user.

Returns:
User object for authenticated user.

setUser

public void setUser(org.apache.struts.apps.mailreader.dao.User user)

Store new reference to User Object.

Parameters:
user - User object for authenticated user

findUser

public org.apache.struts.apps.mailreader.dao.User findUser(String username,
                                                           String password)
                                                    throws org.apache.struts.apps.mailreader.dao.ExpiredPasswordException

Obtain User object from database, or return null if the credentials are not found or invalid.

Parameters:
username - User username
password - User password
Returns:
User object or null if not found
Throws:
org.apache.struts.apps.mailreader.dao.ExpiredPasswordException

saveUser

public void saveUser()
              throws Exception

Persist the User object, including subscriptions, to the database.

Throws:
Exception - on database error

createInputUser

public void createInputUser()

createUser

public org.apache.struts.apps.mailreader.dao.User createUser(String username,
                                                             String password)

Verify input for creating a new user, create the user, and process the login.

Returns:
A new User and empty Errors if create succeeds, or null and Errors if create fails

copyUser

public void copyUser(String _username,
                     String _password)

Use the current User object to create a new User object, and make the new User object the authenticated user.

The "current" User object is usually a temporary object being used to capture input.

Parameters:
_username - User username
_password - User password

getSubscription

public org.apache.struts.apps.mailreader.dao.Subscription getSubscription()

Obtain the cached Subscription object, if any.

Returns:
Cached Subscription object or null

setSubscription

public void setSubscription(org.apache.struts.apps.mailreader.dao.Subscription subscription)

Store new User Subscription.

Parameters:
subscription -

findSubscription

public org.apache.struts.apps.mailreader.dao.Subscription findSubscription(String host)

Obtain User Subscription object for the given host, or return null if not found.

It would be possible for this code to throw a NullPointerException, but the ExceptionHandler in the xwork.xml will catch that for us.

Returns:
The matching Subscription or null

findSubscription

public org.apache.struts.apps.mailreader.dao.Subscription findSubscription()

Obtain uSER Subscription for the local Host property.

Usually, the host property will be set from the client request, because it was embedded in a link to the Subcription action.

Returns:
Subscription or null if not found

createInputSubscription

public void createInputSubscription()

Provide a "temporary" User Subscription object that can be used to capture input values.


createSubscription

public org.apache.struts.apps.mailreader.dao.Subscription createSubscription(String host)

Provide new User Subscription object for the given host, or null if the host is not unique.

Parameters:
host -
Returns:
New User Subscription object or null

copySubscription

public void copySubscription(String host)

Create a new Subscription from the current Subscription object, making the new Subscription the current Subscription.

Usually, the "current" Subscription is a temporary object being used to capture input values.

Parameters:
host -

removeSubscription

public void removeSubscription()

Delete the current Subscription object from the database.


getSubscriptionHost

public String getSubscriptionHost()

Provide MailServer Host for current User Subscription.

Returns:
MailServer Host for current User Subscription


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.