Skip to content

Commit b001a77

Browse files
committed
combine 2 email exceptions into 1
1 parent ff97d9f commit b001a77

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/AccountsEndpoint.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
import org.restcomm.connect.http.exceptions.AuthorizationException;
6666
import org.restcomm.connect.http.exceptions.EmailAlreadyExisted;
6767
import org.restcomm.connect.http.exceptions.InsufficientPermission;
68-
import org.restcomm.connect.http.exceptions.InvalidEmailFormat;
68+
import org.restcomm.connect.http.exceptions.InvalidEmailException;
6969
import org.restcomm.connect.http.exceptions.PasswordTooWeak;
7070
import org.restcomm.connect.http.exceptions.RcmlserverNotifyError;
7171
import org.restcomm.connect.identity.EmailValidator;
@@ -465,7 +465,7 @@ private Client createClientFrom(final Sid accountSid, final MultivaluedMap<Strin
465465
* @throws AccountAlreadyClosed
466466
*/
467467
private Account prepareAccountForUpdate(final Account account, final MultivaluedMap<String, String> data)
468-
throws AccountAlreadyClosed, PasswordTooWeak, EmailAlreadyExisted, InvalidEmailFormat {
468+
throws AccountAlreadyClosed, PasswordTooWeak, EmailAlreadyExisted, InvalidEmailException {
469469
Account result = account;
470470
boolean isPasswordReset = false;
471471
Account.Status newStatus = null;
@@ -513,14 +513,14 @@ private Account prepareAccountForUpdate(final Account account, final Multivalued
513513
if (data.containsKey("EmailAddress")) {
514514
String newEmailAddress = data.getFirst("EmailAddress").toLowerCase();
515515
if (!EmailValidator.isValidEmailFormat(newEmailAddress)) {
516-
throw new InvalidEmailFormat();
516+
throw new InvalidEmailException();
517517
}
518518
if (accountsDao.getAccount(newEmailAddress) != null) {
519519
throw new EmailAlreadyExisted();
520520
}
521521
result = result.setEmailAddress(newEmailAddress);
522522
}
523-
} catch (AuthorizationException | AccountAlreadyClosed | PasswordTooWeak | EmailAlreadyExisted | InvalidEmailFormat e) {
523+
} catch (AuthorizationException | AccountAlreadyClosed | PasswordTooWeak | EmailAlreadyExisted | InvalidEmailException e) {
524524
// some exceptions should reach outer layers and result in 403
525525
throw e;
526526
} catch (Exception e) {

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/EmailMessagesEndpoint.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.restcomm.connect.email.api.Mail;
2727
import org.restcomm.connect.http.converter.EmailMessageConverter;
2828
import org.restcomm.connect.http.converter.RestCommResponseConverter;
29+
import org.restcomm.connect.http.exceptions.InvalidEmailException;
2930
import org.restcomm.connect.identity.EmailValidator;
3031

3132
import javax.annotation.PostConstruct;
@@ -258,16 +259,6 @@ public void onReceive(final Object message) throws Exception {
258259
}
259260
}
260261

261-
private static class InvalidEmailException extends Exception {
262-
//Parameterless Constructor
263-
public InvalidEmailException() {}
264-
265-
//Constructor that accepts a message
266-
public InvalidEmailException(String message) {
267-
super(message);
268-
}
269-
}
270-
271262
}
272263

273264

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/exceptions/InvalidEmailFormat.java renamed to restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/exceptions/InvalidEmailException.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020

2121
package org.restcomm.connect.http.exceptions;
2222

23-
import org.restcomm.connect.commons.exceptions.RestcommRuntimeException;
24-
2523

2624
/**
2725
* @author ddh.huy@gmail.com (Huy Dang)
2826
*/
29-
public class InvalidEmailFormat extends RestcommRuntimeException {
27+
public class InvalidEmailException extends RuntimeException {
28+
//Parameterless Constructor
29+
public InvalidEmailException() {}
30+
31+
//Constructor that accepts a message
32+
public InvalidEmailException(String message) {
33+
super(message);
34+
}
3035
}

0 commit comments

Comments
 (0)