Improve exception un invalid email

This commit is contained in:
Paulo Gustavo Veiga 2022-03-22 20:44:07 -03:00
parent 20a9978577
commit 0ee642c246
3 changed files with 44 additions and 4 deletions

View File

@ -0,0 +1,39 @@
/*
* Copyright [2022] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wisemapping.exceptions;
import org.springframework.lang.Nullable;
import javax.validation.constraints.NotNull;
public class InvalidEmailException
extends ClientException {
private static final String EMAIL_IS_INVALID = "INVALID_EMAIL_ADDRESS";
public InvalidEmailException(@NotNull String emails) {
super("Invalid email exception:" + emails, Severity.WARNING);
}
@NotNull
@Override
protected String getMsgBundleKey() {
return EMAIL_IS_INVALID;
}
}

View File

@ -243,7 +243,7 @@ public class MindmapController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/collabs/", consumes = {"application/json", "application/xml"}, produces = {"application/json", "application/xml"})
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException {
public void updateCollabs(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException {
final Mindmap mindMap = findMindmapById(id);
// Only owner can change collaborators...
@ -259,7 +259,7 @@ public class MindmapController extends BaseController {
// Is a valid email address ?
if (!EmailValidator.getInstance().isValid(email)) {
throw new IllegalArgumentException(email + " is not valid email address");
throw new InvalidEmailException(email);
}
final Collaboration collaboration = mindMap.findCollaboration(email);
@ -269,7 +269,7 @@ public class MindmapController extends BaseController {
throw new IllegalArgumentException(roleStr + " is not a valid role");
}
// Remove from the list of pendings to remove ...
// Remove from the list of pending to remove ...
if (collaboration != null) {
collabsToRemove.remove(collaboration);
}
@ -407,7 +407,7 @@ public class MindmapController extends BaseController {
// Is a valid email address ?
final EmailValidator emailValidator = EmailValidator.getInstance();
if (!emailValidator.isValid(email)) {
throw new IllegalArgumentException(email + " is not valid email address");
throw new InvalidEmailException(email);
}
final Mindmap mindmap = findMindmapById(id);

View File

@ -4,6 +4,7 @@ SITE.TITLE = WiseMapping
FIELD_REQUIRED = Required field cannot be left blank
EMAIL_ALREADY_EXIST = There is an account already with this email.
NO_VALID_EMAIL_ADDRESS = Invalid email address
INVALID_EMAIL_ADDRESS = Invalid email address. Please, verify that your entered valid email address.
PASSWORD_MISMATCH = Your password entries did not match
CREATOR = Creator
WELCOME = Welcome