chibenwa commented on code in PR #2421:
URL: https://github.com/apache/james-project/pull/2421#discussion_r1777528263


##########
protocols/imap/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java:
##########
@@ -43,10 +48,29 @@ public SetACLCommandParser(StatusResponseFactory 
statusResponseFactory) {
 
     @Override
     protected ImapMessage decode(ImapRequestLineReader request, Tag tag, 
ImapSession session) throws DecodingException {
-        final String mailboxName = request.mailbox();
-        final String identifier = request.astring();
-        final String rights = request.astring();
-        request.eol();
-        return new SetACLRequest(tag, mailboxName, identifier, rights);
+        try {
+            final SetACLRequest.MailboxName mailboxName = new 
SetACLRequest.MailboxName(request.mailbox());
+            final Username identifier = Username.of(request.astring());
+            final String editModeAndRights = request.astring();
+            request.eol();
+
+            MailboxACL.EditMode editMode = MailboxACL.EditMode.REPLACE;
+            if (StringUtils.isNotEmpty(editModeAndRights)) {
+                switch (editModeAndRights.charAt(0)) {
+                    case MailboxACL.ADD_RIGHTS_MARKER:
+                        editMode = MailboxACL.EditMode.ADD;
+                        break;
+                    case MailboxACL.REMOVE_RIGHTS_MARKER:
+                        editMode = MailboxACL.EditMode.REMOVE;
+                        break;
+                }
+            }
+
+            MailboxACL.Rfc4314Rights rights = 
MailboxACL.Rfc4314Rights.deserialize(editModeAndRights.substring(1));
+
+            return new SetACLRequest(tag, mailboxName, identifier, editMode, 
rights);

Review Comment:
   That's... brutal! And a lot of parameter.
   
   Having a high count of method parameter is a code smell.
   
   MailboxACL actually is a nice POJO to bundle ` identifier, editMode, rights` 
together. Can't we use it?



-- 
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-unsubscr...@james.apache.org

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


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

Reply via email to