]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/admin/support/FindDomainForm.java
upd: change the find user routine to search for all email addresses
[gigi.git] / src / org / cacert / gigi / pages / admin / support / FindDomainForm.java
index dca6b34db735886d2206acfe7a479ca6399d5b7b..93c4b0c158bfffe0eb00f14b2afaac09bac1f0a8 100644 (file)
@@ -6,19 +6,18 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.cacert.gigi.GigiApiException;
+import org.cacert.gigi.dbObjects.CertificateOwner;
 import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.template.Form;
+import org.cacert.gigi.output.template.SprintfCommand;
 import org.cacert.gigi.output.template.Template;
 
 public class FindDomainForm extends Form {
 
-    private int userId = -1;
+    private CertificateOwner res = null;
 
-    private static Template t;
-    static {
-        t = new Template(FindDomainForm.class.getResource("FindDomainForm.templ"));
-    }
+    private static final Template t = new Template(FindDomainForm.class.getResource("FindDomainForm.templ"));
 
     public FindDomainForm(HttpServletRequest hsr) {
         super(hsr);
@@ -27,19 +26,20 @@ public class FindDomainForm extends Form {
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
         String request = req.getParameter("domain");
+        Domain d = null;
         if (request.matches("#[0-9]+")) {
             try {
-                Domain domainById = Domain.getById(Integer.parseInt(request.substring(1)));
-                userId = domainById.getOwner().getId();
+                d = Domain.getById(Integer.parseInt(request.substring(1)));
             } catch (IllegalArgumentException e) {
-                throw (new GigiApiException("No personal domains found matching the id " + request.substring(1) + "."));
+                throw new GigiApiException(SprintfCommand.createSimple("No personal domains found matching the id {0}", request.substring(1)));
             }
         } else {
-            userId = Domain.searchUserIdByDomain(request);
+            d = Domain.searchUserIdByDomain(request);
         }
-        if (userId == -1) {
-            throw (new GigiApiException("No personal domains found matching " + request));
+        if (d == null) {
+            throw new GigiApiException(SprintfCommand.createSimple("No personal domains found matching {0}", request));
         }
+        res = d.getOwner();
         return true;
     }
 
@@ -48,8 +48,8 @@ public class FindDomainForm extends Form {
         t.output(out, l, vars);
     }
 
-    public int getUserId() {
-        return userId;
+    public CertificateOwner getRes() {
+        return res;
     }
 
 }