]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/account/domain/DomainOverview.java
upd: convert to PostgreSQL
[gigi.git] / src / org / cacert / gigi / pages / account / domain / DomainOverview.java
index 1677029252fea60efe71a0209d48175287464a4f..7a851c36ef106b15d34102efa58221cffae47614 100644 (file)
@@ -6,10 +6,8 @@ import java.util.HashMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.cacert.gigi.Gigi;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Domain;
-import org.cacert.gigi.dbObjects.DomainPingConfiguration;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.pages.Page;
@@ -28,10 +26,15 @@ public class DomainOverview extends Page {
         String pi = req.getPathInfo();
         if (pi.length() - PATH.length() > 0) {
             int i = Integer.parseInt(pi.substring(PATH.length()));
-            Domain d = Domain.getById(i);
+            Domain d;
+            try {
+                d = Domain.getById(i);
+            } catch (IllegalArgumentException e) {
+                resp.getWriter().println(getLanguage(req).getTranslation("Access denied"));
+                return;
+            }
             if (u.getId() != d.getOwner().getId()) {
-                System.out.println(u.getId());
-                System.out.println(d.getOwner().getId());
+                resp.getWriter().println(getLanguage(req).getTranslation("Access denied"));
                 return;
             }
             new DomainPinglogForm(req, d).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
@@ -58,22 +61,25 @@ public class DomainOverview extends Page {
 
     @Override
     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        User u = getUser(req);
         String pi = req.getPathInfo();
         if (pi.length() - PATH.length() > 0) {
-            int i = Integer.parseInt(pi.substring(PATH.length()));
-            Domain d = Domain.getById(i);
-            if (u.getId() != d.getOwner().getId()) {
-                return;
-            }
-            int reping = Integer.parseInt(req.getParameter("configId"));
-            DomainPingConfiguration dpc = DomainPingConfiguration.getById(reping);
-            if (dpc.getTarget() != d) {
+            try {
+                if (req.getParameter("configId") != null) {
+                    if ( !Form.getForm(req, DomainPinglogForm.class).submit(resp.getWriter(), req)) {
+                        // error?
+                    }
+
+                } else {
+                    if ( !Form.getForm(req, PingConfigForm.class).submit(resp.getWriter(), req)) {
+
+                    }
+                }
+            } catch (GigiApiException e) {
+                e.format(resp.getWriter(), getLanguage(req));
                 return;
             }
-            dpc.requestReping();
-            Gigi.notifyPinger();
-            resp.sendRedirect(PATH + i);
+
+            resp.sendRedirect(pi);
         }
         if (req.getParameter("adddomain") != null) {
             DomainAddForm f = Form.getForm(req, DomainAddForm.class);