upd: change the find user routine to search for all email addresses
[gigi.git] / src / org / cacert / gigi / pages / admin / support / FindUserForm.java
1 package org.cacert.gigi.pages.admin.support;
2
3 import java.io.PrintWriter;
4 import java.util.Map;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.cacert.gigi.GigiApiException;
9 import org.cacert.gigi.dbObjects.EmailAddress;
10 import org.cacert.gigi.localisation.Language;
11 import org.cacert.gigi.output.template.Form;
12 import org.cacert.gigi.output.template.SprintfCommand;
13 import org.cacert.gigi.output.template.Template;
14
15 public class FindUserForm extends Form {
16
17     private EmailAddress emails[];
18
19     private static final Template t = new Template(FindDomainForm.class.getResource("FindUserForm.templ"));
20
21     public FindUserForm(HttpServletRequest hsr) {
22         super(hsr);
23     }
24
25     @Override
26     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
27         EmailAddress[] emails = EmailAddress.findByAllEmail(req.getParameter("email"));
28         if (emails.length == 0) {
29             throw new GigiApiException(SprintfCommand.createSimple("No users found matching {0}", req.getParameter("email")));
30         }
31         this.emails = emails;
32         return true;
33     }
34
35     @Override
36     protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
37         t.output(out, l, vars);
38     }
39
40     public EmailAddress[] getEmails() {
41         return emails;
42     }
43
44 }