]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/account/certs/CertificateModificationForm.java
upd: use a more strict pattern for handling forms
[gigi.git] / src / org / cacert / gigi / pages / account / certs / CertificateModificationForm.java
index 6553a77323fc805e6af8c8ac92e5eb31be01f3cd..e6f53cce877a9f2098f1ff44b07838c20e8b3bed 100644 (file)
@@ -17,9 +17,9 @@ import org.cacert.gigi.pages.LoginPage;
 
 public class CertificateModificationForm extends Form {
 
-    CertificateOwner target;
+    private CertificateOwner target;
 
-    final boolean withRevoked;
+    private final boolean withRevoked;
 
     public CertificateModificationForm(HttpServletRequest hsr, boolean withRevoked) {
         super(hsr);
@@ -32,7 +32,11 @@ public class CertificateModificationForm extends Form {
     private static final Template myTemplate = new Template(CertificateModificationForm.class.getResource("CertificateModificationForm.templ"));
 
     @Override
-    public boolean submit(PrintWriter out, HttpServletRequest req) {
+    public boolean submit(HttpServletRequest req) {
+        String action = req.getParameter("action");
+        if ( !"revoke".equals(action)) {
+            return false;
+        }
         String[] certs = req.getParameterValues("certs[]");
         if (certs == null) {
             // nothing to do
@@ -48,15 +52,11 @@ public class CertificateModificationForm extends Form {
         }
         long start = System.currentTimeMillis();
         for (Job job : revokes) {
-            try {
-                int toWait = (int) (60000 + start - System.currentTimeMillis());
-                if (toWait > 0) {
-                    job.waitFor(toWait);
-                } else {
-                    break; // canceled... waited too log
-                }
-            } catch (InterruptedException e) {
-                e.printStackTrace();
+            int toWait = (int) (60000 + start - System.currentTimeMillis());
+            if (toWait > 0) {
+                job.waitFor(toWait);
+            } else {
+                break; // canceled... waited too log
             }
         }
 
@@ -67,6 +67,13 @@ public class CertificateModificationForm extends Form {
     protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
         vars.put("certs", new CertificateIterable(target.getCertificates(withRevoked)));
         vars.put("certTable", certTable);
+        if (withRevoked) {
+            vars.put("all", "btn-primary");
+            vars.put("current", "btn-info");
+        } else {
+            vars.put("all", "btn-info");
+            vars.put("current", "btn-primary");
+        }
         myTemplate.output(out, l, vars);
     }