@Test public void testListRights() throws MailboxException { MailboxACL acl = MailboxACL.OWNER_FULL_ACL; when(mailboxManager.hasRight(path, MailboxACL.Right.Lookup, mailboxSession)) .thenReturn(true); when(mailboxManager.hasRight(path, MailboxACL.Right.Administer, mailboxSession)) .thenReturn(true); when(metaData.getACL()).thenReturn(acl); when(mailboxManager.listRights(path, user1Key, mailboxSession)) .thenReturn(listRights); subject.doProcess(listRightsRequest, responder, imapSession); ListRightsResponse response = new ListRightsResponse(MAILBOX_NAME, USER_1, listRights); verify(responder, times(2)).respond(argumentCaptor.capture()); verifyNoMoreInteractions(responder); assertThat(argumentCaptor.getAllValues()) .hasSize(2); assertThat(argumentCaptor.getAllValues().get(0)) .isEqualTo(response); assertThat(argumentCaptor.getAllValues().get(1)) .matches(StatusResponseTypeMatcher.OK_RESPONSE_MATCHER::matches); }
@Override protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { final ListRightsResponse listRightsResponse = (ListRightsResponse) acceptableMessage; composer.untagged(); composer.commandName(ImapConstants.LISTRIGHTS_RESPONSE_NAME); String mailboxName = listRightsResponse.getMailboxName(); composer.mailbox(mailboxName == null ? "" : mailboxName); String identifier = listRightsResponse.getIdentifier(); composer.quote(identifier); Rfc4314Rights[] rights = listRightsResponse.getRights(); for (Rfc4314Rights entry : rights) { composer.quote(entry.serialize()); } composer.end(); }
/** * @see * org.apache.james.imap.encode.base.AbstractChainedImapEncoder#doEncode * (org.apache.james.imap.api.ImapMessage, * org.apache.james.imap.encode.ImapResponseComposer, * org.apache.james.imap.api.process.ImapSession) */ protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { final ListRightsResponse listRightsResponse = (ListRightsResponse) acceptableMessage; composer.untagged(); composer.commandName(ImapConstants.LISTRIGHTS_RESPONSE_NAME); String mailboxName = listRightsResponse.getMailboxName(); composer.mailbox(mailboxName == null ? "" : mailboxName); String identifier = listRightsResponse.getIdentifier(); composer.quote(identifier); MailboxACLRights[] rights = listRightsResponse.getRights(); for (MailboxACLRights entry : rights) { composer.quote(entry.serialize()); } composer.end(); }
ListRightsResponse aclResponse = new ListRightsResponse(mailboxName, identifier, rights); responder.respond(aclResponse); okComplete(command, tag, responder);
ListRightsResponse aclResponse = new ListRightsResponse(mailboxName, identifier, rights); responder.respond(aclResponse); okComplete(command, tag, responder);