[Yanel-commits] rev 47374 - public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw

michi at wyona.com michi at wyona.com
Sat Jan 30 23:54:57 CET 2010


Author: michi
Date: 2010-01-30 23:54:57 +0100 (Sat, 30 Jan 2010)
New Revision: 47374

Modified:
   public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java
Log:
use MailUtil and check Yanel re smtp host and port first

Modified: public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java	2010-01-30 22:29:00 UTC (rev 47373)
+++ public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java	2010-01-30 22:54:57 UTC (rev 47374)
@@ -47,7 +47,6 @@
 import org.wyona.commons.xml.XMLHelper;
 import org.wyona.security.core.api.User;
 import org.wyona.yanel.impl.resources.BasicXMLResource;
-import org.wyona.yanel.impl.resources.contactform.SendMail;
 import org.wyona.yarep.core.Node;
 import org.wyona.yarep.core.NodeType;
 
@@ -145,15 +144,25 @@
         } else {
             log.debug("default handler");
             String smtpEmailServer = getResourceConfigProperty(SMTP_HOST_PROPERTY_NAME);
-            if (smtpEmailServer != null) {
-                rootElement.appendChild(adoc.createElementNS(NAMESPACE, "requestemail"));
+            if (smtpEmailServer != null || (getYanel().getSMTPHost() != null && getYanel().getSMTPPort() >= 0)) {
+                String from = getResourceConfigProperty("smtpFrom");
+                if (from != null) {
+                    rootElement.appendChild(adoc.createElementNS(NAMESPACE, "requestemail"));
+                } else {
+                    Element exceptionElement = (Element) rootElement.appendChild(adoc.createElementNS(NAMESPACE, "exception"));
+                    String resConfigFilename = "global-resource-configs/user-forgot-pw_yanel-rc.xml";
+                    if (getConfiguration().getNode() != null) {
+                        resConfigFilename = getConfiguration().getNode().getPath(); 
+                    }
+                    exceptionElement.setTextContent("The FROM address has not been configured yet. Please make sure to configure the FROM address within: " + resConfigFilename);
+                }
             } else {
                 Element exceptionElement = (Element) rootElement.appendChild(adoc.createElementNS(NAMESPACE, "exception"));
                 String resConfigFilename = "global-resource-configs/user-forgot-pw_yanel-rc.xml";
                 if (getConfiguration().getNode() != null) {
                     resConfigFilename = getConfiguration().getNode().getPath(); 
                 }
-                exceptionElement.setTextContent("SMTP host has not been configured yet. Please make sure to configure the various smtp properties at: " + resConfigFilename);
+                exceptionElement.setTextContent("SMTP host has not been configured yet. Please make sure to configure the various smtp properties at: " + resConfigFilename + " (Or within WEB-INF/classes/yanel.xml)");
             }
         }
     }
@@ -404,11 +413,16 @@
         String hrsValid = getResourceConfigProperty(HOURS_VALID_PROPERTY_NAME);
         emailBody = emailBody + "\n\nNOTE: This link is only available during the next " + hrsValid + " hours!";
         if (log.isDebugEnabled()) log.debug(emailBody);
-        String emailServer = getResourceConfigProperty(SMTP_HOST_PROPERTY_NAME);
-        int port = Integer.parseInt(getResourceConfigProperty("smtpPort"));
         String from = getResourceConfigProperty("smtpFrom");
         String to =  emailAddress;
-        SendMail.send(emailServer, port, from, to, emailSubject, emailBody);
+
+        String emailServer = getResourceConfigProperty(SMTP_HOST_PROPERTY_NAME);
+        if (emailServer != null) {
+            int port = Integer.parseInt(getResourceConfigProperty("smtpPort"));
+            org.wyona.yanel.core.util.MailUtil.send(emailServer, port, from, to, emailSubject, emailBody);
+        } else {
+            org.wyona.yanel.core.util.MailUtil.send(from, to, emailSubject, emailBody);
+        }
     }
 
     /**



More information about the Yanel-commits mailing list