1 package org.cacert.gigi.api;
3 import java.io.IOException;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
8 import org.cacert.gigi.GigiApiException;
9 import org.cacert.gigi.dbObjects.EmailAddress;
10 import org.cacert.gigi.dbObjects.User;
11 import org.cacert.gigi.localisation.Language;
13 public class EmailReping extends APIPoint {
15 public static final String PATH = "/account/emails/reping";
18 protected void process(HttpServletRequest req, HttpServletResponse resp, User u) throws IOException {
20 String email = req.getParameter("email");
22 resp.sendError(500, "No parameter 'email'.");
25 for (EmailAddress e : u.getEmails()) {
26 if (e.getAddress().equals(email)) {
27 e.requestReping(Language.getInstance(u.getPreferredLocale()));
28 resp.setContentType("text/plain; charset=UTF-8");
32 resp.sendError(500, "Error, Email address not found.");
33 } catch (IllegalArgumentException e) {
34 resp.sendError(500, "Invalid email");
35 } catch (GigiApiException e) {
37 resp.setContentType("text/plain; charset=UTF-8");
38 e.formatPlain(resp.getWriter());