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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to