diff --git a/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java new file mode 100755 index 00000000..92739682 --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/exceptions/InvalidEmailException.java @@ -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; + } +} diff --git a/wise-webapp/src/main/java/com/wisemapping/model/User.java b/wise-webapp/src/main/java/com/wisemapping/model/User.java index 78e4e8ab..663c6a00 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/User.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/User.java @@ -168,7 +168,6 @@ public class User return "User{" + "firstname='" + firstname + '\'' + ", lastname='" + lastname + '\'' + - ", password='" + password + '\'' + "', email = '" + this.getEmail() + "}"; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 9697fa5d..93e7ab20 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -244,7 +244,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... @@ -260,7 +260,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); @@ -270,7 +270,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); } @@ -408,7 +408,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); diff --git a/wise-webapp/src/main/resources/messages_en.properties b/wise-webapp/src/main/resources/messages_en.properties index a6a9fafc..163f0a66 100644 --- a/wise-webapp/src/main/resources/messages_en.properties +++ b/wise-webapp/src/main/resources/messages_en.properties @@ -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