@JsonValue public char asCharacter() { return right.asCharacter(); }
private static Stream<Right> convert(char flag) throws UnsupportedRightException { switch (flag) { case c_ObsoleteCreate: return Stream.of(Right.CreateMailbox, Right.DeleteMailbox); case d_ObsoleteDelete: return Stream.of(Right.PerformExpunge, Right.DeleteMessages, Right.DeleteMailbox); default: return Stream.of(Right.forChar(flag)); } }
MailboxACL.Right.Administer.toString(), command.getName(), mailboxName
MailboxACL.Right.Administer.toString(), command.getName(), mailboxName
MailboxACL.Right.Administer.toString(), command.getName(), mailboxName
MailboxACL.Right.Administer.toString(), command.getName(), mailboxName
} else { Object[] params = new Object[]{ MailboxACL.Right.Read.toString(), command.getName(), message.getMailboxName()
@Override protected void doProcess(GetQuotaRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { try { QuotaRoot quotaRoot = quotaRootResolver.fromString(message.getQuotaRoot()); if (hasRight(quotaRoot, session)) { Quota<QuotaCount> messageQuota = quotaManager.getMessageQuota(quotaRoot); Quota<QuotaSize> storageQuota = quotaManager.getStorageQuota(quotaRoot); if (messageQuota.getLimit().isLimited()) { responder.respond(new QuotaResponse(ImapConstants.MESSAGE_QUOTA_RESOURCE, quotaRoot.getValue(), messageQuota)); } if (storageQuota.getLimit().isLimited()) { responder.respond(new QuotaResponse(ImapConstants.STORAGE_QUOTA_RESOURCE, quotaRoot.getValue(), storageQuota)); } okComplete(command, tag, responder); } else { Object[] params = new Object[]{ MailboxACL.Right.Read.toString(), command.getName(), "Any mailbox of this user USER" }; HumanReadableText humanReadableText = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, humanReadableText); } } catch (MailboxException me) { taggedBad(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX); } }
/** * Tells whether the implementation supports the given right. * * @param right * @return true if this supports the given right. */ public boolean isSupported(Right right) { try { contains(right.asCharacter()); return true; } catch (UnsupportedRightException e) { return false; } }
public UnsupportedRightException(Right unsupportedRight) { this(unsupportedRight.asCharacter()); }
public static Right forChar(char c) throws UnsupportedRightException { return Right.allRights .stream() .filter(r -> r.asCharacter() == c) .findFirst() .orElseThrow(() -> new UnsupportedRightException(c)); } }
/** * Tells whether this contains the given right. * * @throws UnsupportedRightException if the given right is not supported. */ public boolean contains(char flag) throws UnsupportedRightException { return contains(Right.forChar(flag)); }