jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1551043 - in /jspwiki/trunk/jspwiki-war/src: main/java/org/apache/wiki/auth/UserManager.java main/java/org/apache/wiki/util/MailUtil.java main/webapp/LostPassword.jsp test/java/org/apache/wiki/util/MailUtilTest.java
Date Sun, 15 Dec 2013 19:30:21 GMT
Author: juanpablo
Date: Sun Dec 15 19:30:21 2013
New Revision: 1551043

URL: http://svn.apache.org/r1551043
Log:
changed from:
MailUtil.sendMessage(WikiEngine, String, String, String) 

to:
MailUtil.sendMessage(Properties, String, String, String) 

use WikiEngine.getWikiProperties() to pass the appropiate object

Modified:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/MailUtil.java
    jspwiki/trunk/jspwiki-war/src/main/webapp/LostPassword.jsp
    jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/MailUtilTest.java

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java?rev=1551043&r1=1551042&r2=1551043&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/UserManager.java Sun Dec
15 19:30:21 2013
@@ -603,7 +603,6 @@ public class UserManager {
          * No-op.
          * @throws WikiSecurityException never...
          */
-        @SuppressWarnings("deprecation")
         public void commit() throws WikiSecurityException
         {
             // No operation
@@ -787,7 +786,7 @@ public class UserManager {
                                                profile.getFullname(),
                                                profile.getEmail(),
                                                m_engine.getURL( WikiContext.LOGIN, null,
null, true ) );
-                    MailUtil.sendMessage( m_engine, to, subject, content);
+                    MailUtil.sendMessage( m_engine.getWikiProperties(), to, subject, content);
                 }
                 catch ( AddressException e)
                 {

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/MailUtil.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/MailUtil.java?rev=1551043&r1=1551042&r2=1551043&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/MailUtil.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/util/MailUtil.java Sun Dec 15
19:30:21 2013
@@ -35,7 +35,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiEngine;
+
 
 /**
  * <p>Contains static methods for sending e-mails to recipients using JNDI-supplied
@@ -189,8 +189,8 @@ import org.apache.wiki.WikiEngine;
  * <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40668">here</a>.
  *
  */
-public final class MailUtil
-{
+public final class MailUtil {
+
     private static final String JAVA_COMP_ENV = "java:comp/env";
 
     private static final String FALSE = "false";
@@ -267,11 +267,10 @@ public final class MailUtil
      * @throws AddressException If the address is invalid
      * @throws MessagingException If the message cannot be sent.
      */
-    public static void sendMessage(WikiEngine engine, String to, String subject, String content)
+    public static void sendMessage( Properties props, String to, String subject, String content)
         throws AddressException, MessagingException
     {
-        Properties props = engine.getWikiProperties();
-        Session session = getMailSession(engine);
+        Session session = getMailSession( props );
         getSenderEmailAddress(session, props);
 
         try
@@ -342,10 +341,9 @@ public final class MailUtil
      * @param engine a <code>WikiEngine</code>
      * @return <code>Session</code>
      */
-    private static Session getMailSession(WikiEngine engine)
+    private static Session getMailSession(Properties props)
     {
         Session result = null;
-        Properties props = engine.getWikiProperties();
         String jndiName = props.getProperty(PROP_MAIL_JNDI_NAME, DEFAULT_MAIL_JNDI_NAME).trim();
 
         if (c_useJndi)
@@ -386,8 +384,7 @@ public final class MailUtil
      * @param props the properties that contain mail session properties
      * @return the initialized JavaMail Session
      */
-    protected static Session getStandaloneMailSession( Properties props )
-    {
+    protected static Session getStandaloneMailSession( Properties props ) {
         // Read the JSPWiki settings from the properties
         String host     = props.getProperty( PROP_MAIL_HOST, DEFAULT_MAIL_HOST );
         String port     = props.getProperty( PROP_MAIL_PORT, DEFAULT_MAIL_PORT );
@@ -465,8 +462,7 @@ public final class MailUtil
      * Simple {@link javax.mail.Authenticator} subclass that authenticates a user to
      * an SMTP server.
      */
-    protected static class SmtpAuthenticator extends Authenticator
-    {
+    protected static class SmtpAuthenticator extends Authenticator {
 
         private static final String BLANK = "";
         private final String m_pass;

Modified: jspwiki/trunk/jspwiki-war/src/main/webapp/LostPassword.jsp
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/webapp/LostPassword.jsp?rev=1551043&r1=1551042&r2=1551043&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/webapp/LostPassword.jsp (original)
+++ jspwiki/trunk/jspwiki-war/src/main/webapp/LostPassword.jsp Sun Dec 15 19:30:21 2013
@@ -75,7 +75,9 @@
             String mailMessage = MessageFormat.format( rb.getString( "lostpwd.newpassword.email"
), args );
 
             Object[] args2 = { wiki.getApplicationName() };
-            MailUtil.sendMessage( wiki, email, MessageFormat.format( rb.getString( "lostpwd.newpassword.subject"
), args2 ),
+            MailUtil.sendMessage( wiki.getWikiProperties(), 
+            		              email, 
+            		              MessageFormat.format( rb.getString( "lostpwd.newpassword.subject"
), args2 ),
                                   mailMessage );
 
             log.info( "User " + email + " requested and received a new password." );

Modified: jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/MailUtilTest.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/MailUtilTest.java?rev=1551043&r1=1551042&r2=1551043&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/MailUtilTest.java (original)
+++ jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/util/MailUtilTest.java Sun Dec
15 19:30:21 2013
@@ -60,26 +60,17 @@ public class MailUtilTest extends TestCa
     static final String TEST_RECEIVER = "someone@somewhere.org";
     static final String TEST_SENDER = "homer.simpson@burns.com";
     
-    public MailUtilTest( String s )
-    {
+    public MailUtilTest( String s ) {
         super( s );
     }
 
-    public void setUp()
-        throws Exception
-    {
+    public void setUp() throws Exception {
         PropertyConfigurator.configure(m_props);
-        
         TestEngine testEngine = new TestEngine( m_props );
-        
         m_context = new WikiContext( testEngine,
                                      new WikiPage( testEngine, PAGE_NAME ) );
     }
 
-    public void tearDown()
-    {
-    }
-
     /**
      * Verifies that the properties loaded by tests/etc/jspwiki.properties are the ones we
expect.
      * Three of them (account, password, jndi name) are commented out, so we expect null.
@@ -110,7 +101,7 @@ public class MailUtilTest extends TestCa
         
         try
         {
-            MailUtil.sendMessage(m_context.getEngine(), 
+            MailUtil.sendMessage(m_context.getEngine().getWikiProperties(), 
                                  user, 
                                  "Mail test", 
                                  "This is a test mail generated by MailUtilTest.");     
      
@@ -119,8 +110,7 @@ public class MailUtilTest extends TestCa
         {
             if( e.getCause() instanceof ConnectException )
             {
-                // This can occur if you do not have a SMTP server set up.  We just log this
-                // and don't fail.
+                // This can occur if you do not have a SMTP server set up.  We just log this
and don't fail.
                 System.out.println("I could not test whether mail sending works, since I
could not connect to your SMTP server.");
                 System.out.println("Reason: "+e.getMessage());
                 return;



Mime
View raw message