import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
-import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
@Override
public boolean submit(PrintWriter out, HttpServletRequest req) {
- Map<String, String[]> map = req.getParameterMap();
try {
- for (Entry<String, String[]> e : map.entrySet()) {
- String k = e.getKey();
- String[] p = k.split(":", 2);
- if (p[0].equals("default")) {
- target.updateDefaultEmail(EmailAddress.getById(Integer.parseInt(p[1])));
- }
- if (p[0].equals("delete")) {
- target.deleteEmail(EmailAddress.getById(Integer.parseInt(p[1])));
- }
- if (p[0].equals("reping")) {
- EmailAddress.getById(Integer.parseInt(p[1])).requestReping(Page.getLanguage(req));
- }
+ String d;
+ if ((d = req.getParameter("default")) != null) {
+ target.updateDefaultEmail(EmailAddress.getById(Integer.parseInt(d)));
+ } else if ((d = req.getParameter("delete")) != null) {
+ target.deleteEmail(EmailAddress.getById(Integer.parseInt(d)));
+ } else if ((d = req.getParameter("reping")) != null) {
+ EmailAddress.getById(Integer.parseInt(d)).requestReping(Page.getLanguage(req));
}
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
@Test
public void testMailSetDefaultWeb() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
EmailAddress addr = createVerifiedEmail(u);
- assertNull(executeBasicWebInteraction(cookie, path, "default:" + addr.getId()));
+ assertNull(executeBasicWebInteraction(cookie, path, "default=" + addr.getId()));
ObjectCache.clearAllCaches();
assertEquals(User.getById(u.getId()).getEmail(), addr.getAddress());
}
@Test
public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
EmailAddress addr = new EmailAddress(u, createUniqueName() + "test@test.tld", Locale.ENGLISH);
- assertNotNull(executeBasicWebInteraction(cookie, path, "default:" + addr.getId()));
+ assertNotNull(executeBasicWebInteraction(cookie, path, "default=" + addr.getId()));
assertNotEquals(User.getById(u.getId()).getEmail(), addr.getAddress());
getMailReciever().clearMails();
}
}
}
assertNotEquals(id, -1);
- assertNotNull(executeBasicWebInteraction(cookie, path, "default:" + id));
+ assertNotNull(executeBasicWebInteraction(cookie, path, "default=" + id));
assertNotEquals(User.getById(u.getId()).getEmail(), u2.getEmail());
getMailReciever().clearMails();
}
@Test
public void testMailDeleteWeb() throws InterruptedException, GigiApiException, MalformedURLException, UnsupportedEncodingException, IOException {
EmailAddress addr = createVerifiedEmail(u);
- assertNull(executeBasicWebInteraction(cookie, path, "delete:" + addr.getId(), 0));
+ assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr.getId(), 0));
User u = User.getById(this.u.getId());
EmailAddress[] addresses = u.getEmails();
for (int i = 0; i < addresses.length; i++) {
EmailAddress[] addr = new EmailAddress[] {
createVerifiedEmail(u), createVerifiedEmail(u)
};
- assertNull(executeBasicWebInteraction(cookie, path, "delete:" + addr[0].getId() + "&delete:" + addr[1].getId(), 0));
+ assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr[0].getId(), 0));
+ assertNull(executeBasicWebInteraction(cookie, path, "delete=" + addr[1].getId(), 0));
User u = User.getById(this.u.getId());
EmailAddress[] addresses = u.getEmails();
for (int i = 0; i < addresses.length; i++) {
public void testMailDeleteWebFaulty() throws MalformedURLException, UnsupportedEncodingException, IOException {
User u2 = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@test.tld", TEST_PASSWORD));
EmailAddress em = u2.getEmails()[0];
- assertNotNull(executeBasicWebInteraction(cookie, path, "delete:" + em.getId(), 0));
+ assertNotNull(executeBasicWebInteraction(cookie, path, "delete=" + em.getId(), 0));
u2 = User.getById(u2.getId());
assertNotEquals(u2.getEmails().length, 0);
}
@Test
public void testMailDeleteWebPrimary() throws MalformedURLException, UnsupportedEncodingException, IOException {
- assertNotNull(executeBasicWebInteraction(cookie, path, "delete:" + u.getEmails()[0].getId(), 0));
+ assertNotNull(executeBasicWebInteraction(cookie, path, "delete=" + u.getEmails()[0].getId(), 0));
assertNotEquals(u.getEmails().length, 0);
}
}