]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/wot/AssurePage.java
fix: number-format-exception thrown on assurance entry
[gigi.git] / src / org / cacert / gigi / pages / wot / AssurePage.java
index 94c582f220e5765f19c3d2d2d7d05d8182646d9c..dfd72b7b6966a85536a8c2f5cf7b3dd97fe1c61e 100644 (file)
@@ -2,8 +2,6 @@ package org.cacert.gigi.pages.wot;
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.sql.Date;
-import java.util.Calendar;
 import java.util.HashMap;
 
 import javax.servlet.http.HttpServletRequest;
@@ -54,14 +52,18 @@ public class AssurePage extends Page {
         PrintWriter out = resp.getWriter();
         if (req.getParameter("search") == null) {
             AssuranceForm form = Form.getForm(req, AssuranceForm.class);
-            if (form.submit(out, req)) {
-                out.println(translate(req, "Assurance complete."));
-            } else {
+            try {
+                if (form.submit(out, req)) {
+                    out.println(translate(req, "Assurance complete."));
+                    return;
+                }
+            } catch (GigiApiException e) {
+                e.format(out, Page.getLanguage(req));
                 try {
                     Notary.checkAssuranceIsPossible(LoginPage.getUser(req), form.getAssuree());
                     form.output(out, getLanguage(req), new HashMap<String, Object>());
-                } catch (GigiApiException e) {
-                    e.format(out, Page.getLanguage(req));
+                } catch (GigiApiException e1) {
+                    e1.format(out, Page.getLanguage(req));
                 }
             }
 
@@ -69,10 +71,10 @@ public class AssurePage extends Page {
         }
 
         try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `users`.`id`, `verified` FROM `users` INNER JOIN `certOwners` ON `certOwners`.`id`=`users`.`id` WHERE `email`=? AND `dob`=? AND `deleted` IS NULL")) {
+            ds.update(req);
+
             ps.setString(1, req.getParameter("email"));
-            Calendar c = Calendar.getInstance();
-            c.set(Integer.parseInt(req.getParameter("year")), Integer.parseInt(req.getParameter("month")) - 1, Integer.parseInt(req.getParameter("day")));
-            ps.setDate(2, new Date(c.getTimeInMillis()));
+            ps.setDate(2, ds.getDate().toSQLDate());
             GigiResultSet rs = ps.executeQuery();
             int id = 0;
             if (rs.next()) {
@@ -97,12 +99,12 @@ public class AssurePage extends Page {
                     }
                 }
             } else {
-                out.print("<div class='formError'>");
-
-                out.println(translate(req, "I'm sorry, there was no email and date of birth matching" + " what you entered in the system. Please double check" + " your information."));
-                out.print("</div>");
+                throw new GigiApiException("I'm sorry, there was no email and date of birth matching" //
+                        + " what you entered in the system. Please double check your information.");
             }
 
+        } catch (GigiApiException e) {
+            e.format(out, getLanguage(req));
         }
     }
 }