[Bedework-commit] selfreg r4 - trunk/selfreg/src/org/bedework/selfreg

svnadmin at bedework.org svnadmin at bedework.org
Tue Mar 10 16:23:30 EDT 2009


Author: douglm
Date: 2009-03-10 16:23:30 -0400 (Tue, 10 Mar 2009)
New Revision: 4

Modified:
   trunk/selfreg/src/org/bedework/selfreg/ConfigProperties.java
   trunk/selfreg/src/org/bedework/selfreg/DbUtil.java
   trunk/selfreg/src/org/bedework/selfreg/RegAbstractAction.java
Log:
Fixed bugs in handling repeat requests

Modified: trunk/selfreg/src/org/bedework/selfreg/ConfigProperties.java
===================================================================
--- trunk/selfreg/src/org/bedework/selfreg/ConfigProperties.java	2009-03-10 19:47:49 UTC (rev 3)
+++ trunk/selfreg/src/org/bedework/selfreg/ConfigProperties.java	2009-03-10 20:23:30 UTC (rev 4)
@@ -31,6 +31,8 @@
  *
  */
 public class ConfigProperties {
+  private String appRoot;
+
   /* Ldap properties */
 
   private String dirUrl;
@@ -78,6 +80,20 @@
   private String reCaptchaKey2;
 
   /**
+   * @param val
+   */
+  public void setAppRoot(String val) {
+    appRoot = val;
+  }
+
+  /**
+   * @return where we find the stylesheets
+   */
+  public String getAppRoot() {
+    return appRoot;
+  }
+
+  /**
    *
    * @param val
    */

Modified: trunk/selfreg/src/org/bedework/selfreg/DbUtil.java
===================================================================
--- trunk/selfreg/src/org/bedework/selfreg/DbUtil.java	2009-03-10 19:47:49 UTC (rev 3)
+++ trunk/selfreg/src/org/bedework/selfreg/DbUtil.java	2009-03-10 20:23:30 UTC (rev 4)
@@ -61,7 +61,7 @@
    * @throws RegException
    */
   public void saveOrUpdate(UserInfo ui) throws RegException {
-    if (fetch(ui.getEmail()) != null) {
+    if (fetch(ui.getEmail(), ui.getAccount()) != null) {
       // I know - we should merge
       update(ui);
     } else {
@@ -71,11 +71,12 @@
 
   /**
    * @param email
+   * @param account
    * @return UserInfo or null
    * @throws RegException
    */
-  public UserInfo fetch(String email) throws RegException {
-    return fetch("email", email);
+  public UserInfo fetch(String email, String account) throws RegException {
+    return fetch("email", email, "account", account);
   }
 
   /**
@@ -84,7 +85,7 @@
    * @throws RegException
    */
   public UserInfo findDbConfirm(String val) throws RegException {
-    return fetch("confirm", val);
+    return fetch("confirm", val, null, null);
   }
 
   /**
@@ -92,7 +93,8 @@
    * @return UserInfo or null
    * @throws RegException
    */
-  private UserInfo fetch(String fieldName, String val) throws RegException {
+  private UserInfo fetch(String fieldName1, String val1,
+                         String fieldName2, String val2) throws RegException {
     Connection c = null;
     PreparedStatement s = null;
     ResultSet rs = null;
@@ -100,19 +102,30 @@
     try {
       c = getConnection();
 
-      s = c.prepareStatement("select * from " +
-                             cp.getTableName() + " where " +
-                             fieldName + " = ?");
-      s.setString(1, val);
+      StringBuilder qstr = new StringBuilder(
+                         "select * from ");
+      qstr.append(cp.getTableName());
+      qstr.append(" where ");
+      qstr.append(fieldName1);
+      qstr.append(" = ?");
 
+      if (fieldName2 != null) {
+        qstr.append("or ");
+        qstr.append(fieldName2);
+        qstr.append(" = ?");
+      }
+
+      s = c.prepareStatement(qstr.toString());
+      s.setString(1, val1);
+      if (fieldName2 != null) {
+        s.setString(2, val2);
+      }
+
       rs = s.executeQuery();
 
       UserInfo ui = getUserInfo(rs);
 
       if (ui == null) {
-        if (debug) {
-          trace("No reg info with " + fieldName + " = \"" + val + "\"");
-        }
         return null;
       }
 
@@ -172,7 +185,7 @@
                                  "organization = ?, " +
                                  "confirm = ?, " +
                                  "pw = ?, " +
-                                 "updated = ?, " +
+                                 "updated = ? " +
                              "where email = ?");
 
       String rfcdt = DateTimeUtil.rfcDateTime();

Modified: trunk/selfreg/src/org/bedework/selfreg/RegAbstractAction.java
===================================================================
--- trunk/selfreg/src/org/bedework/selfreg/RegAbstractAction.java	2009-03-10 19:47:49 UTC (rev 3)
+++ trunk/selfreg/src/org/bedework/selfreg/RegAbstractAction.java	2009-03-10 20:23:30 UTC (rev 4)
@@ -37,6 +37,7 @@
 import edu.rpi.sss.util.OptionsI;
 import edu.rpi.sss.util.jsp.Request;
 import edu.rpi.sss.util.jsp.UtilAbstractAction;
+import edu.rpi.sss.util.servlets.PresentationState;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -110,6 +111,12 @@
     RegActionForm form = (RegActionForm)request.getForm();
     cp = getConfig(request.getRequest());
 
+    PresentationState ps = form.getPresentationState();
+
+    if (ps != null) {
+      ps.setAppRoot(cp.getAppRoot());
+    }
+
     if (debug) {
       dumpRequest(request.getRequest());
     }



More information about the Bedework-commit mailing list