]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/account/domain/DomainAddForm.java
upd: enforce a more strict Form call pattern.
[gigi.git] / src / org / cacert / gigi / pages / account / domain / DomainAddForm.java
index 7c198b726f2a39ac9cfc85d2bd3004226bb98b81..584821796f6496b6e657d4a33a573421ba9e7aba 100644 (file)
@@ -9,10 +9,9 @@ import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
-import org.cacert.gigi.output.Form;
-import org.cacert.gigi.output.Outputable;
+import org.cacert.gigi.output.template.Form;
+import org.cacert.gigi.output.template.Outputable;
 import org.cacert.gigi.output.template.Template;
-import org.cacert.gigi.pages.Page;
 
 public class DomainAddForm extends Form {
 
@@ -20,32 +19,27 @@ public class DomainAddForm extends Form {
 
     private User target;
 
-    PingconfigForm pcf;
+    PingConfigForm pcf;
 
     public DomainAddForm(HttpServletRequest hsr, User target) throws GigiApiException {
         super(hsr);
         this.target = target;
-        pcf = new PingconfigForm(hsr, null);
+        pcf = new PingConfigForm(hsr, null);
     }
 
     @Override
-    public boolean submit(PrintWriter out, HttpServletRequest req) {
+    public SubmissionResult submit(HttpServletRequest req) throws GigiApiException {
         try {
             String parameter = req.getParameter("newdomain");
             if (parameter.trim().isEmpty()) {
                 throw new GigiApiException("No domain inserted.");
             }
-            Domain d = new Domain(target, parameter);
-            d.insert();
+            Domain d = new Domain(target, target, parameter);
             pcf.setTarget(d);
-            pcf.submit(out, req);
-            return true;
+            pcf.submit(req);
+            return new RedirectResult(DomainOverview.PATH);
         } catch (NumberFormatException e) {
-            new GigiApiException("A number could not be parsed").format(out, Page.getLanguage(req));
-            return false;
-        } catch (GigiApiException e) {
-            e.format(out, Page.getLanguage(req));
-            return false;
+            throw new GigiApiException("A number could not be parsed");
         }
     }