@Test void getQuotaRootShouldWorkWhenUserIsNull() { QuotaRoot quotaRoot = testee.getQuotaRoot(new MailboxPath("#private", null, "INBOX")); assertThat(quotaRoot).isEqualTo(QuotaRoot.quotaRoot("#private", Optional.empty())); }
@Override public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) { Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR); return Optional.ofNullable(mailboxPath.getUser()) .map(user -> { Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR); return mailboxPath.getUser(); }) .map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart())) .orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty())); }
DefaultUserQuotaRootResolver implements UserQuotaRootResolver { @Override public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) { Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR); return Optional.ofNullable(mailboxPath.getUser()) .map(user -> { Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR); return mailboxPath.getUser(); }) .map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart())) .orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty())); } }
DefaultUserQuotaRootResolver implements UserQuotaRootResolver { @Override public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) { Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR); return Optional.ofNullable(mailboxPath.getUser()) .map(user -> { Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR); return mailboxPath.getUser(); }) .map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart())) .orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty())); } @Inject  DefaultUserQuotaRootResolver(SessionProvider sessionProvider, MailboxSessionMapperFactory factory); }
DefaultUserQuotaRootResolver implements UserQuotaRootResolver { @Override public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) { Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR); return Optional.ofNullable(mailboxPath.getUser()) .map(user -> { Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR); return mailboxPath.getUser(); }) .map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart())) .orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty())); } @Inject  DefaultUserQuotaRootResolver(SessionProvider sessionProvider, MailboxSessionMapperFactory factory); @Override QuotaRoot forUser(Username username); @Override QuotaRoot getQuotaRoot(MailboxPath mailboxPath); @Override QuotaRoot getQuotaRoot(Mailbox mailbox); @Override QuotaRoot getQuotaRoot(MailboxId mailboxId); @Override Mono<QuotaRoot> getQuotaRootReactive(MailboxId mailboxId); @Override QuotaRoot fromString(String serializedQuotaRoot); @Override Flux<Mailbox> retrieveAssociatedMailboxes(QuotaRoot quotaRoot, MailboxSession mailboxSession); }
DefaultUserQuotaRootResolver implements UserQuotaRootResolver { @Override public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) { Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR), "Namespace should not contain %s", SEPARATOR); return Optional.ofNullable(mailboxPath.getUser()) .map(user -> { Preconditions.checkArgument(!mailboxPath.getUser().asString().contains(SEPARATOR), "Username should not contain %s", SEPARATOR); return mailboxPath.getUser(); }) .map(user -> QuotaRoot.quotaRoot(mailboxPath.getNamespace() + SEPARATOR + user.asString(), user.getDomainPart())) .orElseGet(() -> QuotaRoot.quotaRoot(mailboxPath.getNamespace(), Optional.empty())); } @Inject  DefaultUserQuotaRootResolver(SessionProvider sessionProvider, MailboxSessionMapperFactory factory); @Override QuotaRoot forUser(Username username); @Override QuotaRoot getQuotaRoot(MailboxPath mailboxPath); @Override QuotaRoot getQuotaRoot(Mailbox mailbox); @Override QuotaRoot getQuotaRoot(MailboxId mailboxId); @Override Mono<QuotaRoot> getQuotaRootReactive(MailboxId mailboxId); @Override QuotaRoot fromString(String serializedQuotaRoot); @Override Flux<Mailbox> retrieveAssociatedMailboxes(QuotaRoot quotaRoot, MailboxSession mailboxSession); static final String SEPARATOR; }