You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/10/04 04:58:03 UTC

[GitHub] [james-project] vttranlina commented on a change in pull request #678: JAMES-3657 Modular entity validation for webadmin-data

vttranlina commented on a change in pull request #678:
URL: https://github.com/apache/james-project/pull/678#discussion_r721040257



##########
File path: server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java
##########
@@ -189,14 +194,14 @@ private void ensureDomainIsSupported(Domain domain) throws DomainListException {
         }
     }
 
-    private void ensureUserDoesNotExist(MailAddress mailAddress) throws UsersRepositoryException {
+    private void ensureUserDoesNotExist(MailAddress mailAddress) throws Exception {
         Username username = usersRepository.getUsername(mailAddress);
-
-        if (usersRepository.contains(username)) {
+        Optional<ValidationFailure> validationFailure = userEntityValidator.canCreate(username, ImmutableSet.of(ALIAS));
+        if (validationFailure.isPresent()) {
             throw ErrorResponder.builder()
                 .statusCode(HttpStatus.BAD_REQUEST_400)
                 .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)

Review comment:
       WRONG_STATE ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org