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/07 08:13:10 UTC

[GitHub] [james-project] vttranlina commented on a change in pull request #681: JAMES-3657 Generalise entity validation Upon creation

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



##########
File path: server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
##########
@@ -309,6 +332,22 @@ public void addGroupMapping(MappingSource source, String address) throws Recipie
         addMapping(source, mapping);
     }
 
+    private void ensureGroupNotShadowingAnotherAddress(MailAddress groupAddress) throws Exception {
+        ensureNoConflict(GROUP, groupAddress);
+    }
+
+    private void ensureAliasNotShadowingAnotherAddress(MailAddress groupAddress) throws Exception {
+        ensureNoConflict(ALIAS, groupAddress);
+    }
+
+    private void ensureNoConflict(UserEntityValidator.EntityType entity, MailAddress groupAddress) throws Exception {
+        Username username = usersRepository.getUsername(groupAddress);
+        Optional<UserEntityValidator.ValidationFailure> validationFailure = userEntityValidator.canCreate(username, ImmutableSet.of(entity));

Review comment:
       you can use `.ifPresent`, it will less boilerplate




-- 
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