public static final HumanReadableText unseen(long numberUnseen) { return new HumanReadableText("org.apache.james.imap.UNSEEN", "Message " + numberUnseen + " is first unseen"); }
@Override public String localize(HumanReadableText text, Locales locales) { String result; if (text == null) { result = null; } else { //FIXME implement the locale selection final Locale chosenLocale = Locale.US; //FIXME implement the localized value lookup depending on chosenLocale result = text.getDefaultValue(); Object[] params = text.getParameters(); if (params != null && params.length > 0) { MessageFormat messageFormat = new MessageFormat(result, chosenLocale); result = messageFormat.format(params); } } return result; }
private void handleResponseException(final ImapProcessor.Responder responder, MailboxException e, final HumanReadableText message, ImapSession session) { session.getLog().info(message.toString()); session.getLog().debug(message.toString(), e); // TODO: consider whether error message should be passed to the user final StatusResponse response = factory.untaggedNo(message); responder.respond(response); }
protected void permanentFlags(Responder responder, MessageManager.MetaData metaData, SelectedMailbox selected) { final Flags permanentFlags = metaData.getPermanentFlags(); if (permanentFlags.contains(Flags.Flag.USER)) { permanentFlags.add(selected.getApplicableFlags()); } final StatusResponse untaggedOk = factory.untaggedOk(HumanReadableText.permanentFlags(permanentFlags), ResponseCode.permanentFlags(permanentFlags)); responder.respond(untaggedOk); }
private boolean unseen(Responder responder, MessageUid firstUnseen, SelectedMailbox selected, MailboxSession session) throws MailboxException { if (firstUnseen != null) { final MessageUid unseenUid = firstUnseen; int msn = selected.msn(unseenUid); if (msn == SelectedMailbox.NO_SUCH_MESSAGE) { LOGGER.debug("No message found with uid {} in mailbox {}", unseenUid, selected.getPath().getFullName(session.getPathDelimiter())); return false; } final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.unseen(msn), ResponseCode.unseen(msn)); responder.respond(untaggedOk); } return true; }
@Test public void processShouldResponseNoWhenManagerThrowsAnnotationException() throws Exception { doThrow(AnnotationException.class).when(mockMailboxManager).updateAnnotations(eq(inbox), eq(mockMailboxSession), eq(mailboxAnnotations)); processor.process(request, mockResponder, mockImapSession); verify(mockStatusResponseFactory, times(1)).taggedNo(any(String.class), any(ImapCommand.class), humanTextCaptor.capture()); assertThat(humanTextCaptor.getAllValues().get(FIRST_ELEMENT_INDEX).getKey()).isEqualTo(HumanReadableText.MAILBOX_ANNOTATION_KEY); } }
protected void permanentFlags(Responder responder, MessageManager.MetaData metaData, SelectedMailbox selected) { final Flags permanentFlags = metaData.getPermanentFlags(); if (permanentFlags.contains(Flags.Flag.USER)) { permanentFlags.add(selected.getApplicableFlags()); } final StatusResponse untaggedOk = factory.untaggedOk(HumanReadableText.permanentFlags(permanentFlags), ResponseCode.permanentFlags(permanentFlags)); responder.respond(untaggedOk); }
private boolean unseen(Responder responder, Long firstUnseen, final SelectedMailbox selected, MailboxSession session) throws MailboxException { if (firstUnseen != null) { final long unseenUid = firstUnseen; int msn = selected.msn(unseenUid); if (msn == SelectedMailbox.NO_SUCH_MESSAGE) { if (session.getLog().isDebugEnabled()) { session.getLog().debug("No message found with uid " + unseenUid + " in mailbox " + selected.getPath().getFullName(session.getPathDelimiter())); } return false; } final StatusResponse untaggedOk = statusResponseFactory.untaggedOk(HumanReadableText.unseen(msn), ResponseCode.unseen(msn)); responder.respond(untaggedOk); } return true; }
public static final HumanReadableText unseen(long numberUnseen) { return new HumanReadableText("org.apache.james.imap.UNSEEN", "MailboxMessage " + numberUnseen + " is first unseen"); }
/** * @see Localizer#localize(HumanReadableText, Locales) */ public String localize(HumanReadableText text, Locales locales) { String result; if (text == null) { result = null; } else { //FIXME implement the locale selection final Locale chosenLocale = Locale.US; //FIXME implement the localized value lookup depending on chosenLocale result = text.getDefaultValue(); Object[] params = text.getParameters(); if (params != null && params.length > 0) { MessageFormat messageFormat = new MessageFormat(result, chosenLocale); result = messageFormat.format(params); } } return result; }
public static final HumanReadableText permanentFlags(Flags flags) { String text; if (flags.getSystemFlags() != null && flags.getSystemFlags().length > 0) { text = "Limited"; } else { text = "No permanent flags permitted"; } return new HumanReadableText("org.apache.james.imap.PERMANENT_FLAGS", text); }
public static final HumanReadableText permanentFlags(Flags flags) { String text; if (flags.getSystemFlags() != null && flags.getSystemFlags().length > 0) { text = "Limited"; } else { text = "No permanent flags permitted"; } return new HumanReadableText("org.apache.james.imap.PERMANENT_FLAGS", text); }
@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); }
@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); } }
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text); HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params); taggedBad(command, tag, responder, text); } catch (MailboxNotFoundException e) {
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text); HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params); taggedBad(command, tag, responder, text); } catch (MailboxNotFoundException e) {
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text);
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text); } else { HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params); taggedBad(command, tag, responder, text); } catch (MailboxNotFoundException e) {
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text);
mailboxName }; HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params); no(command, tag, responder, text); } else { HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params); taggedBad(command, tag, responder, text); } catch (MailboxNotFoundException e) {