diff --git a/action-chaining/pom.xml b/action-chaining/pom.xml
index f75624d7..4891543e 100644
--- a/action-chaining/pom.xml
+++ b/action-chaining/pom.xml
@@ -5,11 +5,10 @@
Appication scope attribute key under which the in-memory version of * our database is stored.
*/ public static final String DATABASE_KEY = "database"; - /** *Application scope attribute key under which the valid selection * items for the protocol property is stored.
*/ public static final String PROTOCOLS_KEY = "protocols"; - // ------------------------------------------------------ Instance Variables - - /** *The ServletContext for this web application.
Logging output for this plug in instance.
*/ - private Logger log = LogManager.getLogger(this.getClass()); - - // ------------------------------------------------------------- Properties - + private Logger log = LogManager.getLogger(ApplicationListener.class); /** *The web application resource path of our persistent database storage @@ -121,9 +108,6 @@ public void setPathname(String pathname) { this.pathname = pathname; } - // ------------------------------------------ ServletContextListener Methods - - /** *
Gracefully shut down this database, releasing any resources that * were allocated at initialization.
@@ -131,7 +115,6 @@ public void setPathname(String pathname) { * @param event ServletContextEvent to process */ public void contextDestroyed(ServletContextEvent event) { - log.info("Finalizing memory database plug in"); if (database != null) { @@ -146,10 +129,8 @@ public void contextDestroyed(ServletContextEvent event) { context.removeAttribute(PROTOCOLS_KEY); database = null; context = null; - } - /** *Initialize and load our initial database from persistent * storage.
@@ -157,9 +138,7 @@ public void contextDestroyed(ServletContextEvent event) { * @param event The context initialization event */ public void contextInitialized(ServletContextEvent event) { - - log.info("Initializing memory database plug in from '" + - pathname + "'"); + log.info("Initializing memory database plug in from '" + pathname + "'"); // Remember our associated ServletContext this.context = event.getServletContext(); @@ -179,12 +158,8 @@ public void contextInitialized(ServletContextEvent event) { pathname + "': " + e); } context.setAttribute(DATABASE_KEY, database); - } - // -------------------------------------------------------- Private Methods - - /** *Calculate and return an absolute pathname to the XML file to contain * our persistent storage information.
@@ -192,7 +167,6 @@ public void contextInitialized(ServletContextEvent event) { * @throws Exception if an input/output error occurs */ private String calculatePath() throws Exception { - // Can we access the database via file I/O? String path = context.getRealPath(pathname); if (path != null) { @@ -200,8 +174,7 @@ private String calculatePath() throws Exception { } // Does a copy of this file already exist in our temporary directory - File dir = (File) - context.getAttribute("javax.servlet.context.tempdir"); + File dir = (File) context.getAttribute("javax.servlet.context.tempdir"); File file = new File(dir, "struts-example-database.xml"); if (file.exists()) { return (file.getAbsolutePath()); @@ -225,8 +198,6 @@ private String calculatePath() throws Exception { bos.close(); bis.close(); return (file.getAbsolutePath()); - } - } diff --git a/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/AuthenticationInterceptor.java similarity index 88% rename from mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/AuthenticationInterceptor.java index 0984a2e7..bb0b5186 100644 --- a/mailreader/src/main/java/mailreader2/AuthenticationInterceptor.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/AuthenticationInterceptor.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package mailreader2; +package org.apache.struts.examples.mailreader2; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; -import org.apache.struts.apps.mailreader.dao.User; +import org.apache.struts.examples.mailreader2.dao.User; import java.util.Map; @@ -32,11 +32,8 @@ public void destroy () {} public void init() {} public String intercept(ActionInvocation actionInvocation) throws Exception { - - Map session = actionInvocation.getInvocationContext().getSession(); - + MapManifest constants for the MailReader application.
@@ -52,11 +52,6 @@ public final class Constants { */ public static final String EDIT = "Edit"; - /** - *The package name for this application.
- */ - public static final String PACKAGE = "org.apache.struts.apps.mailreader"; - /** *The session scope attribute under which the Subscription object * currently selected by our logged-in User is stored.
diff --git a/mailreader/src/main/java/mailreader2/Login.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LoginAction.java similarity index 78% rename from mailreader/src/main/java/mailreader2/Login.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LoginAction.java index 14e24fd1..6ec7da00 100644 --- a/mailreader/src/main/java/mailreader2/Login.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LoginAction.java @@ -17,30 +17,25 @@ * under the License. */ -package mailreader2; +package org.apache.struts.examples.mailreader2; -import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException; -import org.apache.struts.apps.mailreader.dao.User; +import org.apache.struts.examples.mailreader2.dao.ExpiredPasswordException; +import org.apache.struts.examples.mailreader2.dao.User; /** *Validate a user login.
*/ -public final class Login extends MailreaderSupport { - - public String execute() throws ExpiredPasswordException { +public final class LoginAction extends MailreaderSupport { + public String execute() throws ExpiredPasswordException { User user = findUser(getUsername(), getPassword()); - if (user != null) { setUser(user); } - if (hasErrors()) { return INPUT; } - return SUCCESS; - } } diff --git a/mailreader/src/main/java/mailreader2/Logout.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LogoutAction.java similarity index 90% rename from mailreader/src/main/java/mailreader2/Logout.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LogoutAction.java index 564a0315..c7464b93 100644 --- a/mailreader/src/main/java/mailreader2/Logout.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/LogoutAction.java @@ -17,17 +17,16 @@ * under the License. */ -package mailreader2; +package org.apache.struts.examples.mailreader2; /** *Log user out of the current session.
*/ -public class Logout extends MailreaderSupport { +public class LogoutAction extends MailreaderSupport { public String execute() { - setUser(null); - return SUCCESS; } + } diff --git a/mailreader/src/main/java/mailreader2/MailreaderSupport.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java similarity index 95% rename from mailreader/src/main/java/mailreader2/MailreaderSupport.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java index 5b916942..b6cdcbd8 100644 --- a/mailreader/src/main/java/mailreader2/MailreaderSupport.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java @@ -17,17 +17,17 @@ * under the License. */ -package mailreader2; +package org.apache.struts.examples.mailreader2; import com.opensymphony.xwork2.ActionSupport; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException; -import org.apache.struts.apps.mailreader.dao.Subscription; -import org.apache.struts.apps.mailreader.dao.User; -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.struts.examples.mailreader2.dao.ExpiredPasswordException; +import org.apache.struts.examples.mailreader2.dao.Subscription; +import org.apache.struts.examples.mailreader2.dao.User; +import org.apache.struts.examples.mailreader2.dao.UserDatabase; +import org.apache.struts.examples.mailreader2.dao.impl.memory.MemorySubscription; +import org.apache.struts.examples.mailreader2.dao.impl.memory.MemoryUser; import org.apache.struts2.interceptor.ApplicationAware; import org.apache.struts2.interceptor.SessionAware; @@ -49,8 +49,7 @@ * the temporary object, and the new object is saved. It's kludge, but it * avoids creating unnecessary local properties. Pick your poison. */ -public class MailreaderSupport extends ActionSupport - implements SessionAware, ApplicationAware { +public class MailreaderSupport extends ActionSupport implements SessionAware, ApplicationAware { /** * Return CANCEL so apropriate result can be selected. @@ -385,7 +384,7 @@ public User findUser(String username, String password) /** *Log instance for this application.
Persist the User object, including subscriptions, to the database. @@ -489,9 +488,7 @@ public void setSubscription(Subscription subscription) { * @return The matching Subscription or null */ public Subscription findSubscription(String host) { - Subscription subscription; - subscription = getUser().findSubscription(host); - return subscription; + return getUser().findSubscription(host); } /** diff --git a/mailreader/src/main/java/mailreader2/Registration.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/RegistrationAction.java similarity index 95% rename from mailreader/src/main/java/mailreader2/Registration.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/RegistrationAction.java index 41e985b7..bdf1a720 100644 --- a/mailreader/src/main/java/mailreader2/Registration.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/RegistrationAction.java @@ -17,15 +17,14 @@ * under the License. */ -package mailreader2; - -import org.apache.struts.apps.mailreader.dao.User; +package org.apache.struts.examples.mailreader2; +import org.apache.struts.examples.mailreader2.dao.User; /** *
Insert or update a User object to the persistent store.
*/ -public class Registration extends MailreaderSupport { +public class RegistrationAction extends MailreaderSupport { /** *Double check that there is not a valid User login.
diff --git a/mailreader/src/main/java/mailreader2/Subscription.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/SubscriptionAction.java similarity index 89% rename from mailreader/src/main/java/mailreader2/Subscription.java rename to mailreader2/src/main/java/org/apache/struts/examples/mailreader2/SubscriptionAction.java index df12d524..e4a50536 100644 --- a/mailreader/src/main/java/mailreader2/Subscription.java +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/SubscriptionAction.java @@ -17,9 +17,10 @@ * under the License. */ -package mailreader2; +package org.apache.struts.examples.mailreader2; import com.opensymphony.xwork2.Preparable; +import org.apache.struts.examples.mailreader2.dao.Subscription; import java.util.LinkedHashMap; import java.util.Map; @@ -28,20 +29,19 @@ *Provide an Edit method for retrieving an existing subscription, and a * Save method for updating or inserting a subscription.
*/ -public class Subscription extends MailreaderSupport - implements Preparable { +public class SubscriptionAction extends MailreaderSupport implements Preparable { /** *Field to store list of MailServer types
*/ - private Map types = null; + private MapProvide the list of MailServer types.
* * @return List of MailServer types */ - public Map getTypes() { + public MapA Subscription which is stored, along with the + * associated {@link User}, in a {@link UserDatabase}.
+ * + * @version $Rev$ $Date$ + */ +public interface Subscription { + + // ------------------------------------------------------------- Properties + + /** + * Return the auto-connect flag. + */ + boolean getAutoConnect(); + + /** + * Set the auto-connect flag. + * + * @param autoConnect The new auto-connect flag + */ + void setAutoConnect(boolean autoConnect); + + /** + * Return the host name. + */ + String getHost(); + + /** + * Return the password. + */ + String getPassword(); + + /** + * Set the password. + * + * @param password The new password + */ + void setPassword(String password); + + /** + * Return the subscription type. + */ + String getType(); + + /** + * Set the subscription type. + * + * @param type The new subscription type + */ + void setType(String type); + + /** + * Return the {@link User} owning this Subscription. + */ + User getUser(); + + /** + * Return the username. + */ + String getUsername(); + + /** + * Set the username. + * + * @param username The new username + */ + void setUsername(String username); + +} diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/User.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/User.java new file mode 100644 index 00000000..6dd91244 --- /dev/null +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/User.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.struts.examples.mailreader2.dao; + +/** + *A User which is stored, along with his or her + * associated {@link Subscription}s, in a {@link UserDatabase}.
+ */ +public interface User { + + // ------------------------------------------------------------- Properties + + /** + * Return the {@link UserDatabase} with which we are associated. + */ + UserDatabase getDatabase(); + + /** + * Return the from address. + */ + String getFromAddress(); + + /** + * Set the from address. + * + * @param fromAddress The new from address + */ + void setFromAddress(String fromAddress); + + /** + * Return the full name. + */ + String getFullName(); + + /** + * Set the full name. + * + * @param fullName The new full name + */ + void setFullName(String fullName); + + /** + * Return the password. + */ + String getPassword(); + + /** + * Set the password. + * + * @param password The new password + */ + void setPassword(String password); + + /** + * Return the reply-to address. + */ + String getReplyToAddress(); + + /** + * Set the reply-to address. + * + * @param replyToAddress The new reply-to address + */ + void setReplyToAddress(String replyToAddress); + + /** + * Find and return all {@link Subscription}s associated with this user. + * If there are none, a zero-length array is returned. + */ + Subscription[] getSubscriptions(); + + /** + * Return the username. + */ + String getUsername(); + + // --------------------------------------------------------- Public Methods + + /** + * Create and return a new {@link Subscription} associated with this + * User, for the specified host name. + * + * @param host Host name for which to create a subscription + * + * @exception IllegalArgumentException if the host name is not unique + * for this user + */ + Subscription createSubscription(String host); + + /** + * Find and return the {@link Subscription} associated with the specified + * host. If none is found, returnnull.
+ *
+ * @param host Host name to look up
+ */
+ Subscription findSubscription(String host);
+
+ /**
+ * Remove the specified {@link Subscription} from being associated
+ * with this User.
+ *
+ * @param subscription Subscription to be removed
+ *
+ * @exception IllegalArgumentException if the specified subscription is not
+ * associated with this User
+ */
+ void removeSubscription(Subscription subscription);
+
+}
diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/UserDatabase.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/UserDatabase.java
new file mode 100644
index 00000000..154e66e6
--- /dev/null
+++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/UserDatabase.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.struts.examples.mailreader2.dao;
+
+/**
+ * A Data Access Object (DAO) interface describing + * the available operations for retrieving and storing {@link User}s + * (and their associated {@link Subscription}s) in some persistence layer + * whose characteristics are not specified here. One or more implementations + * will be created to perform the actual I/O that is required.
+ */ +public interface UserDatabase { + + // --------------------------------------------------------- Public Methods + + /** + *Create and return a new {@link User} defined in this user database. + *
+ * + * @param username Username of the new user + * + * @exception IllegalArgumentException if the specified username + * is not unique + */ + User createUser(String username); + + /** + *Finalize access to the underlying persistence layer.
+ * + * @exception Exception if a database access error occurs + */ + void close() throws Exception; + + /** + *Return the existing {@link User} with the specified username,
+ * if any; otherwise return null.
Return the set of {@link User}s defined in this user database.
+ */ + User[] findUsers(); + + /** + *Return true if open() has been called.
+ * + * @exception Exception if a database access error occurs + */ + boolean isOpen(); + + /** + *Initiate access to the underlying persistence layer.
+ * + * @exception Exception if a database access error occurs + */ + void open() throws Exception; + + /** + * Remove the specified {@link User} from this database. + * + * @param user User to be removed + * + * @exception IllegalArgumentException if the specified user is not + * associated with this database + */ + void removeUser(User user); + + /** + *Save any pending changes to the underlying persistence layer.
+ * + * @exception Exception if a database access error occurs + */ + void save() throws Exception; + +} \ No newline at end of file diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/AbstractSubscription.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/AbstractSubscription.java new file mode 100644 index 00000000..c327c8dc --- /dev/null +++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/AbstractSubscription.java @@ -0,0 +1,179 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.struts.examples.mailreader2.dao.impl; + +import org.apache.struts.examples.mailreader2.dao.Subscription; +import org.apache.struts.examples.mailreader2.dao.User; + +/** + *Concrete implementation of {@link AbstractSubscription}.
+ * + * @version $Rev$ + * @since Struts 1.1 + */ + +public class AbstractSubscription implements Subscription { + + + // ----------------------------------------------------------- Constructors + + + /** + *Construct a new Subscription associated with the specified
+ * {@link User}.
+ *
+ * @param user The user with which we are associated
+ * @param host The mail host for this subscription
+ */
+ public AbstractSubscription(User user, String host) {
+
+ super();
+ this.user = user;
+ this.host = host;
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The mail host for this subscription.
+ */
+ private String host = null;
+
+
+ /**
+ * The {@link User} with which we are associated.
+ */
+ private User user = null;
+
+
+ // ------------------------------------------------------------- Properties
+
+
+ /**
+ * Should we auto-connect at startup time?
+ */
+ private boolean autoConnect = false;
+
+ public boolean getAutoConnect() {
+ return (this.autoConnect);
+ }
+
+ public void setAutoConnect(boolean autoConnect) {
+ this.autoConnect = autoConnect;
+ }
+
+
+ /**
+ * The mail host for this subscription.
+ */
+ public String getHost() {
+ return (this.host);
+ }
+
+
+ /**
+ * The password (in clear text) for this subscription.
+ */
+ private String password = null;
+
+ public String getPassword() {
+ return (this.password);
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+ /**
+ * The subscription type ("imap" or "pop3").
+ */
+ private String type = "imap";
+
+ public String getType() {
+ return (this.type);
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+ /**
+ * The User owning this Subscription.
+ */
+ public User getUser() {
+ return (this.user);
+ }
+
+
+ /**
+ * The username for this subscription.
+ */
+ private String username = null;
+
+ public String getUsername() {
+ return (this.username);
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return a String representation of this object.
+ */
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer(" Concrete implementation of {@link AbstractUser}. Construct a new User associated with the specified
+ * {@link UserDatabase}.
+ *
+ * @param database The user database with which we are associated
+ * @param username The username of this user
+ */
+ public AbstractUser(UserDatabase database, String username) {
+
+ super();
+ this.database = database;
+ this.username = username;
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The {@link UserDatabase} with which we are associated.
+ */
+ private UserDatabase database = null;
+
+
+ /**
+ * The {@link Subscription}s for this User, keyed by hostname.
+ */
+ private HashMap subscriptions = new HashMap();
+
+
+ /**
+ * The username for this user.
+ */
+ private String username = null;
+
+
+ // ------------------------------------------------------------- Properties
+
+
+ /**
+ * The {@link UserDatabase} with which we are associated.
+ */
+ public UserDatabase getDatabase() {
+ return (this.database);
+ }
+
+
+ /**
+ * The email address from which messages are sent.
+ */
+ private String fromAddress = null;
+
+ public String getFromAddress() {
+ return (this.fromAddress);
+ }
+
+ public void setFromAddress(String fromAddress) {
+ this.fromAddress = fromAddress;
+ }
+
+
+ /**
+ * The full name of this user, included in from addresses.
+ */
+ private String fullName = null;
+
+ public String getFullName() {
+ return (this.fullName);
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+
+ /**
+ * The password (in clear text).
+ */
+ private String password = null;
+
+ public String getPassword() {
+ return (this.password);
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+ /**
+ * The EMAIL address to which replies should be sent.
+ */
+ private String replyToAddress = null;
+
+ public String getReplyToAddress() {
+ return (this.replyToAddress);
+ }
+
+ public void setReplyToAddress(String replyToAddress) {
+ this.replyToAddress = replyToAddress;
+ }
+
+
+ /**
+ * Find and return all {@link Subscription}s associated with this user.
+ * If there are none, a zero-length array is returned.
+ */
+ public Subscription[] getSubscriptions() {
+
+ synchronized (subscriptions) {
+ Subscription results[] = new Subscription[subscriptions.size()];
+ return ((Subscription[]) subscriptions.values().toArray(results));
+ }
+
+ }
+
+
+ /**
+ * The username (must be unique).
+ */
+ public String getUsername() {
+ return (this.username);
+ }
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Create and return a new {@link Subscription} associated with this
+ * User, for the specified host name.
+ *
+ * @param host Host name for which to create a subscription
+ *
+ * @exception IllegalArgumentException if the host name is not unique
+ * for this user
+ */
+ public Subscription createSubscription(String host) {
+
+ synchronized (subscriptions) {
+ if (subscriptions.get(host) != null) {
+ throw new IllegalArgumentException("Duplicate host '" + host
+ + "' for user '" +
+ username + "'");
+ }
+ Subscription subscription =
+ new AbstractSubscription(this, host);
+ synchronized (subscriptions) {
+ subscriptions.put(host, subscription);
+ }
+ return (subscription);
+ }
+
+ }
+
+
+ /**
+ * Find and return the {@link Subscription} associated with the specified
+ * host. If none is found, return Concrete implementation of {@link AbstractUser} used for an in-memory
+ * database backed by an XML data file. Concrete implementation of {@link UserDatabase} for an in-memory
+ * database backed by an XML data file.null.
+ *
+ * @param host Host name to look up
+ */
+ public Subscription findSubscription(String host) {
+
+ synchronized (subscriptions) {
+ return ((Subscription) subscriptions.get(host));
+ }
+
+ }
+
+
+ /**
+ * Remove the specified {@link Subscription} from being associated
+ * with this User.
+ *
+ * @param subscription Subscription to be removed
+ *
+ * @exception IllegalArgumentException if the specified subscription is not
+ * associated with this User
+ */
+ public void removeSubscription(Subscription subscription) {
+
+ if (!(this == subscription.getUser())) {
+ throw new IllegalArgumentException
+ ("Subscription not associated with this user");
+ }
+ synchronized (subscriptions) {
+ subscriptions.remove(subscription.getHost());
+ }
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemorySubscription.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemorySubscription.java
new file mode 100644
index 00000000..843a4919
--- /dev/null
+++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemorySubscription.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.struts.examples.mailreader2.dao.impl.memory;
+
+import org.apache.struts.examples.mailreader2.dao.User;
+import org.apache.struts.examples.mailreader2.dao.impl.AbstractSubscription;
+
+public class MemorySubscription extends AbstractSubscription {
+
+ public MemorySubscription(User user, String host) {
+ super(user, host);
+ }
+
+}
diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemoryUser.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemoryUser.java
new file mode 100644
index 00000000..544b7752
--- /dev/null
+++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/dao/impl/memory/MemoryUser.java
@@ -0,0 +1,71 @@
+/*
+ * $Id: $
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.struts.examples.mailreader2.dao.impl.memory;
+
+import org.apache.struts.examples.mailreader2.dao.UserDatabase;
+import org.apache.struts.examples.mailreader2.dao.impl.AbstractUser;
+
+/**
+ * Language Options
A simple "forward thru" action element
The Welcome action element
-<action name="Welcome" class="mailreader2.Welcome">
+
@@ -475,10 +475,10 @@ <action name="Welcome" class="org.apache.struts.examples.mailreader2.Welcome">
<result>/pages/Welcome.jsp</result>
<interceptor-ref name="guest"/>
</action>Application
<listener>
<listener-class>
- mailreader2.ApplicationListener
+ org.apache.struts.examples.mailreader2.ApplicationListener
</listener-class>
</listener>
package mailreader2;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.ActionInvocation;
@@ -1551,7 +1551,7 @@ MainMenu
Action mapping element for MainMenu
-<action name="MainMenu" class="mailreader2.MailreaderSupport">
+<action name="MainMenu" class="org.apache.struts.examples.mailreader2.MailreaderSupport">
<result>/pages/MainMenu.jsp</result>
</action>
@@ -1967,7 +1967,7 @@
mailreader-support.xml Subscription element
-<action name="Subscription_*" method="{1}" class="mailreader2.Subscription">
+<action name="Subscription_*" method="{1}" class="org.apache.struts.examples.mailreader2.Subscription">
<result name="input">/pages/Subscription.jsp</result>
<result type="redirect-action">Registration_input</result>
</action>
@@ -2427,17 +2427,17 @@ mailreader-support.xml
<result type="redirect-action">Registration_input</result>
</global-results>
- <action name="Subscription_save" method="save" class="mailreader2.Subscription">
+ <action name="Subscription_save" method="save" class="org.apache.struts.examples.mailreader2.Subscription">
<interceptor-ref name="user-submit" />
</action>
- <action name="Subscription_*" method="{1}" class="mailreader2.Subscription" />
+ <action name="Subscription_*" method="{1}" class="org.apache.struts.examples.mailreader2.Subscription" />
</package>
<package name="wildcard" namespace="/" extends="mailreader-support">
- <action name="*" class="mailreader2.MailreaderSupport">
+ <action name="*" class="org.apache.struts.examples.mailreader2.MailreaderSupport">
<result>/{1}.jsp</result>
</action>
diff --git a/message-resource/pom.xml b/message-resource/pom.xml
index d60d3080..3c2fdf91 100644
--- a/message-resource/pom.xml
+++ b/message-resource/pom.xml
@@ -6,13 +6,11 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
message-resource
-
Message resource
-
Message resource example application for the Struts 2 getting started tutorials
war
diff --git a/message-store/pom.xml b/message-store/pom.xml
index 26865fb9..a08f80ba 100644
--- a/message-store/pom.xml
+++ b/message-store/pom.xml
@@ -5,14 +5,14 @@
struts-examples
org.apache.struts
- 1.0.0
+ 1.1.0
message-store
- 1.0-SNAPSHOT
- war
Message Store
+ war
+
javax.servlet
diff --git a/pom.xml b/pom.xml
index 407999d7..bf8862e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,10 +2,12 @@
4.0.0
+
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
pom
+
Struts 2 Examples
This is the parent pom for the Struts 2 examples that
@@ -89,7 +91,7 @@
interceptors
json
json-customize
- mailreader
+ mailreader2
message-resource
message-store
portlet
@@ -116,19 +118,34 @@
org.apache.struts
struts2-core
- ${struts2.version}
-
org.apache.logging.log4j
log4j-core
- ${log4j2.version}
+
+ org.apache.struts
+ struts2-core
+ ${struts2.version}
+
+
+
+ org.apache.struts
+ struts2-config-browser-plugin
+ ${struts2.version}
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j2.version}
+
+
org.apache.logging.log4j
log4j-api
diff --git a/portlet/pom.xml b/portlet/pom.xml
index 16df2b55..0956a12b 100644
--- a/portlet/pom.xml
+++ b/portlet/pom.xml
@@ -24,13 +24,14 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
portlet
- war
Portlet Webapp
+ war
+
pluto
diff --git a/preparable-interface/pom.xml b/preparable-interface/pom.xml
index fef9a702..1ed49e6c 100644
--- a/preparable-interface/pom.xml
+++ b/preparable-interface/pom.xml
@@ -6,13 +6,11 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
preparable-interface
-
Preparable Interface
-
Struts 2 example application for the preparable interface getting started tutorial
war
diff --git a/rest-angular/pom.xml b/rest-angular/pom.xml
index 6146ad5c..8b7bf6a6 100644
--- a/rest-angular/pom.xml
+++ b/rest-angular/pom.xml
@@ -5,16 +5,15 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
rest-angular
- war
-
REST Plugin based application with AngularJS
-
A REST Plugin based Struts2 application with AngularJS frontend, Bean validation, Exception Handling and multi language support.
+ war
+
UTF-8
2.10.1
diff --git a/restful2actionmapper/pom.xml b/restful2actionmapper/pom.xml
index 707a79ad..371f5305 100644
--- a/restful2actionmapper/pom.xml
+++ b/restful2actionmapper/pom.xml
@@ -6,18 +6,14 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
restful2actionmapper
-
- war
-
REST to Action Mapper Example Application
+ Example of using Rest style URLs for Struts 2 Getting Started tutorials
- Example of using Rest style URLs for
- Struts 2 Getting Started tutorials
-
+ war
reststyleactionmapper
diff --git a/shiro-basic/pom.xml b/shiro-basic/pom.xml
index 35e8fc2c..97c7c6e0 100644
--- a/shiro-basic/pom.xml
+++ b/shiro-basic/pom.xml
@@ -4,11 +4,10 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
shiro-basic
-
Struts2 with Basic Shiro Security Integration
war
diff --git a/spring-struts/pom.xml b/spring-struts/pom.xml
index 8431070d..a6ddd54f 100644
--- a/spring-struts/pom.xml
+++ b/spring-struts/pom.xml
@@ -6,11 +6,10 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
spring-struts
-
Struts2 with Spring Integration
war
diff --git a/text-provider/pom.xml b/text-provider/pom.xml
index c1b302a0..c7d3a404 100644
--- a/text-provider/pom.xml
+++ b/text-provider/pom.xml
@@ -5,13 +5,14 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
text-provider
- war
Custom TextProvider
+ war
+
UTF-8
diff --git a/themes-override/pom.xml b/themes-override/pom.xml
index 89cac9a0..3a395f38 100644
--- a/themes-override/pom.xml
+++ b/themes-override/pom.xml
@@ -6,13 +6,11 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
themes-override
-
Struts 2 Themes Override
-
Struts 2 themes override example application for the Struts 2 getting started tutorials
war
diff --git a/themes/pom.xml b/themes/pom.xml
index 8061c042..cf9648ac 100644
--- a/themes/pom.xml
+++ b/themes/pom.xml
@@ -6,16 +6,12 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
themes
-
Struts 2 Themes
-
- Struts 2 themes example application for the
- Struts 2 getting started tutorials
-
+ Struts 2 themes example application for the Struts 2 getting started tutorials
war
diff --git a/tiles/pom.xml b/tiles/pom.xml
index 82cd6b03..598408d8 100644
--- a/tiles/pom.xml
+++ b/tiles/pom.xml
@@ -5,13 +5,14 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
tiles
- war
Struts Tiles Example
+ war
+
org.apache.struts
diff --git a/type-conversion/pom.xml b/type-conversion/pom.xml
index 32eb0522..d320d7ce 100644
--- a/type-conversion/pom.xml
+++ b/type-conversion/pom.xml
@@ -6,13 +6,14 @@
struts-examples
org.apache.struts
- 1.0.0
+ 1.1.0
type-conversion
- war
Type Conversion
+ war
+
UTF-8
diff --git a/unit-testing/pom.xml b/unit-testing/pom.xml
index 0dfb546d..a8f4c4a3 100644
--- a/unit-testing/pom.xml
+++ b/unit-testing/pom.xml
@@ -6,11 +6,10 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
unit-testing
-
Unit Testing
war
diff --git a/unknown-handler/pom.xml b/unknown-handler/pom.xml
index 9f5a520d..32dfaae2 100644
--- a/unknown-handler/pom.xml
+++ b/unknown-handler/pom.xml
@@ -6,14 +6,14 @@
struts-examples
org.apache.struts
- 1.0.0
+ 1.1.0
- org.apache.org
unknown-handler
- war
Unknown handler
+ war
+
UTF-8
diff --git a/using-tags/pom.xml b/using-tags/pom.xml
index ae084fd8..427be91f 100644
--- a/using-tags/pom.xml
+++ b/using-tags/pom.xml
@@ -6,12 +6,11 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
using-tags
Using Struts 2 Tags
-
Struts 2 example application for the Using Struts 2 Tags getting started tutorial
war
diff --git a/validation-messages/pom.xml b/validation-messages/pom.xml
index 131dbb72..0af2449f 100644
--- a/validation-messages/pom.xml
+++ b/validation-messages/pom.xml
@@ -5,7 +5,7 @@
struts-examples
org.apache.struts
- 1.0.0
+ 1.1.0
validation-messages
diff --git a/wildcard-method-selection/pom.xml b/wildcard-method-selection/pom.xml
index 46a9b5c7..29b9a6f6 100644
--- a/wildcard-method-selection/pom.xml
+++ b/wildcard-method-selection/pom.xml
@@ -6,15 +6,13 @@
org.apache.struts
struts-examples
- 1.0.0
+ 1.1.0
wildcard-method-selection
-
Wildcard Method Selection
+ Wildcard method selection example application for the Struts 2 getting started tutorials
- Wildcard method selection example application for the Struts 2 getting started tutorials
-
war
diff --git a/wildcard-regex/pom.xml b/wildcard-regex/pom.xml
index e5521a88..7c0dba5e 100644
--- a/wildcard-regex/pom.xml
+++ b/wildcard-regex/pom.xml
@@ -5,15 +5,14 @@
struts-examples
org.apache.struts
- 1.0.0
+ 1.1.0
- org.apache.struts
wildcard-regex
- war
- 1
Wildcard RegEx pattern matching
+ war
+
UTF-8