@Override protected void doProcess(SetQuotaRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { Object[] params = new Object[]{ "Full admin rights", command.getName(), "Can not perform SETQUOTA commands" }; HumanReadableText humanReadableText = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, humanReadableText); }
/** * @see * org.apache.james.imap.encode.ImapResponseComposer#commandResponse(org.apache.james.imap.api.ImapCommand, * java.lang.String) */ public ImapResponseComposer commandResponse(ImapCommand command, String message) throws IOException { untagged(); commandName(command.getName()); message(message); end(); return this; }
@Override public ImapResponseComposer commandResponse(ImapCommand command, String message) throws IOException { untagged(); commandName(command.getName()); message(message); end(); return this; }
@Override protected void doProcess(GetAnnotationRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { try { proceed(message, session, tag, command, responder); } catch (MailboxNotFoundException e) { LOGGER.info("The command: {} is failed because not found mailbox {}", command.getName(), message.getMailboxName()); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate()); } catch (MailboxException e) { LOGGER.error("GetAnnotation on mailbox {} failed for user {}", message.getMailboxName(), ImapSessionUtils.getUserName(session), e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }
@Override protected void doProcess(SetAnnotationRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { final MailboxManager mailboxManager = getMailboxManager(); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); final String mailboxName = message.getMailboxName(); try { MailboxPath mailboxPath = PathConverter.forSession(session).buildFullPath(mailboxName); mailboxManager.updateAnnotations(mailboxPath, mailboxSession, message.getMailboxAnnotations()); okComplete(command, tag, responder); } catch (MailboxNotFoundException e) { LOGGER.info("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate()); } catch (AnnotationException e) { LOGGER.info("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, new HumanReadableText(HumanReadableText.MAILBOX_ANNOTATION_KEY, e.getMessage())); } catch (MailboxException e) { LOGGER.error("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }
protected final void process(M message, Responder responder, ImapSession session) { ImapCommand command = message.getCommand(); String tag = message.getTag(); TimeMetric timeMetric = metricFactory.timer(IMAP_PREFIX + command.getName()); doProcess(message, command, tag, responder, session); timeMetric.stopAndPublish(); }
composer.commandName(command.getName());
Logger log = session.getLog(); if (log.isInfoEnabled()) { log.info(command.getName() + " failed for mailbox " + mailboxName, e);
no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } catch (MailboxException e) { LOGGER.error("{} failed for mailbox {}", command.getName(), mailboxName, e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
composer.commandName(command.getName());
@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); } }
Object[] params = new Object[]{ MailboxACL.Right.Read.toString(), command.getName(), message.getMailboxName() };