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

michi at wyona.com michi at wyona.com
Mon Aug 10 14:12:51 CEST 2009


Author: michi
Date: 2009-08-10 14:12:51 +0200 (Mon, 10 Aug 2009)
New Revision: 44096

Modified:
   public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java
Log:
check SMTP host 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	2009-08-10 12:07:00 UTC (rev 44095)
+++ public/yanel/trunk/src/contributions/resources/forgotpw/src/java/org/wyona/yanel/impl/resources/forgotpw/ForgotPassword.java	2009-08-10 12:12:51 UTC (rev 44096)
@@ -70,6 +70,8 @@
     private static final String NAMESPACE = "http://www.wyona.org/yanel/1.0";
     private static final long  DEFAULT_TOTAL_VALID_HRS = 24L;
 
+    private static final String SMTP_HOST_PROPERTY_NAME = "smtpHost";
+
     /**
      * This is the main method that handles all view request. The first time the request
      * is made to enter the data.
@@ -134,10 +136,23 @@
             }
         } else {
             log.debug("default handler");
-            Element requestElement = (Element) rootElement.appendChild(adoc.createElementNS(NAMESPACE, "requestemail"));
+            String smtpEmailServer = getResourceConfigProperty(SMTP_HOST_PROPERTY_NAME);
+            if (smtpEmailServer != 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("SMTP host has not been configured yet. Please make sure to configure the various smtp properties at: " + resConfigFilename);
+            }
         }
     }
 
+    /**
+     *
+     */
     private User findRepoUser(String usrGuid, long duration_hour) throws Exception {
         User upUser = null;
         Map<String, ResetPWExpire> pwHM = getOblivionMap(getEnvironment().getRequest());
@@ -255,7 +270,7 @@
                     //String emailStr = "Please go to the following URL to reset password: <https://192.168.1.69:8443/yanel" + request.getServletPath().toString() + "?pwresetid=" + guid + ">.";
                     String emailStr = "Please go to the following URL to reset password: <" + request.getRequestURL().toString() + "?pwresetid=" + guid + ">.";
                     log.debug(emailStr);
-                    String emailServer = getResourceConfigProperty("smtpHost");
+                    String emailServer = getResourceConfigProperty(SMTP_HOST_PROPERTY_NAME);
                     int port = Integer.parseInt(getResourceConfigProperty("smtpPort"));
                     String from = getResourceConfigProperty("smtpFrom");
                     String to =  userList[i].getEmail();



More information about the Yanel-commits mailing list