org.apache.mailet.Mail.getState()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.apache.mailet.Mail.getState()方法的一些代码示例,展示了Mail.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mail.getState()方法的具体详情如下:
包路径:org.apache.mailet.Mail
类名称:Mail
方法名:getState

Mail.getState介绍

[英]Returns the current state of the message, such as GHOST, ERROR or DEFAULT.
[中]返回消息的当前状态,例如重影、错误或默认值。

代码示例

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Override
public boolean matches(Exchange ex) {
  Mail m = ex.getIn().getBody(Mail.class);
  return !state.equals(m.getState());
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Override
public boolean matches(Exchange ex) {
  Mail m = ex.getIn().getBody(Mail.class);
  return state.equals(m.getState());
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

private void terminateSmoothly(Exchange exchange, CamelMailetProcessor container, CamelProcessor terminatingMailetProcessor) throws Exception {
  Mail mail = exchange.getIn().getBody(Mail.class);
  if (mail.getState().equals(container.getState())) {
    terminatingMailetProcessor.process(mail);
  }
  if (mail.getState().equals(Mail.GHOST)) {
    dispose(exchange, mail);
  }
  complete(exchange, container);
}

代码示例来源:origin: org.apache.james/apache-mailet-base

public static void logEndOfMailetProcess(Mailet mailet, Mail mail) {
    LOGGER.debug("Mail: {} End of mailet: {}", mail.getState(), mailet.getMailetInfo());
  }
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

private void complete(Exchange exchange, CamelMailetProcessor container) {
  LOGGER.debug("End of mailetprocessor for state {} reached", container.getState());
  exchange.setProperty(Exchange.ROUTE_STOP, true);
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Override
public void sendMail(Mail mail) throws MessagingException {
  sendMail(mail, Optional.ofNullable(mail.getState()).orElse(Mail.DEFAULT));
}

代码示例来源:origin: org.apache.james/apache-mailet-base

public static void logBeginOfMailetProcess(Mailet mailet, Mail mail) {
  LOGGER.debug("Mail: {} Entering mailet: {}", mail.getState(), mailet.getMailetInfo());
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

private void handleMailet(Exchange exchange, CamelMailetProcessor container, CamelProcessor mailetProccessor) throws Exception {
  Mail mail = exchange.getIn().getBody(Mail.class);
  boolean isMatched = mail.removeAttribute(MatcherSplitter.MATCHER_MATCHED_ATTRIBUTE) != null;
  if (isMatched) {
    mailetProccessor.process(mail);
  }
  if (mail.getState().equals(Mail.GHOST)) {
    dispose(exchange, mail);
    return;
  }
  if (!mail.getState().equals(container.getState())) {
    container.toProcessor(mail);
    complete(exchange, container);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Override
public void service(Mail mail) {
  if (!(Mail.ERROR.equals(mail.getState()))) {
    // Don't complain if we fall off the end of the
    // error processor. That is currently the
    // normal situation for James, and the message
    // will show up in the error store.
    LOGGER.warn("Message {} reached the end of this processor, and is automatically deleted. " +
      "This may indicate a configuration error.", mail.getName());
  }
  // Set the mail to ghost state
  mail.setState(Mail.GHOST);
}

代码示例来源:origin: org.apache.james/james-server-mailets

/**
 * Delivers a mail to a local mailbox in a given folder.
 */
@Override
public void service(Mail mail) throws MessagingException {
  if (!mail.getState().equals(Mail.GHOST)) {
    doService(mail);
    if (consume) {
      mail.setState(Mail.GHOST);
    }
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

private void handleTemporaryFailure(Mail mail, ExecutionResult executionResult) throws MailQueue.MailQueueException {
  if (!mail.getState().equals(Mail.ERROR)) {
    mail.setState(Mail.ERROR);
    DeliveryRetriesHelper.initRetries(mail);
    mail.setLastUpdated(dateSupplier.get());
  }
  int retries = DeliveryRetriesHelper.retrieveRetries(mail);
  if (retries < configuration.getMaxRetries()) {
    reAttemptDelivery(mail, retries);
  } else {
    LOGGER.debug("Bouncing message {} after {} retries", mail.getName(), retries);
    bouncer.bounce(mail, new Exception("Too many retries failure. Bouncing after " + retries + " retries.", executionResult.getException().orElse(null)));
  }
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Test
public void bounceShouldEnqueueEmailWithRootState() throws Exception {
  MailImpl mail = new MailImpl();
  mail.setSender(mailAddress);
  mail.setRecipients(ImmutableList.of(mailAddress));
  mail.setMessage(MimeMessageUtil.defaultMimeMessage());
  testee.bounce(mail, "message");
  ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class);
  verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture());
  verifyNoMoreInteractions(spoolMailQueue);
  assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Test
public void sendMailShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
  MailImpl mail = new MailImpl();
  mail.setSender(mailAddress);
  mail.setRecipients(ImmutableList.of(mailAddress));
  mail.setMessage(MimeMessageUtil.defaultMimeMessage());
  String other = "other";
  testee.sendMail(mail, other);
  ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class);
  verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture());
  verifyNoMoreInteractions(spoolMailQueue);
  assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(other);
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Test
public void sendMailShouldEnqueueEmailWithRootState() throws Exception {
  MailImpl mail = new MailImpl();
  mail.setSender(mailAddress);
  mail.setRecipients(ImmutableList.of(mailAddress));
  mail.setMessage(MimeMessageUtil.defaultMimeMessage());
  testee.sendMail(mail);
  ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class);
  verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture());
  verifyNoMoreInteractions(spoolMailQueue);
  assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Test
public void sendMailForMessageShouldEnqueueEmailWithRootState() throws Exception {
  MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
    .addFrom(mailAddress.asString())
    .addToRecipient(mailAddress.asString())
    .setText("Simple text")
    .build();
  testee.sendMail(message);
  ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class);
  verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture());
  verifyNoMoreInteractions(spoolMailQueue);
  assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(Mail.DEFAULT);
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Test
public void sendMailForMessageAndEnvelopeShouldEnqueueEmailWithOtherStateWhenSpecified() throws Exception {
  MimeMessage message = MimeMessageBuilder.mimeMessageBuilder()
    .addFrom(mailAddress.asString())
    .addToRecipient(mailAddress.asString())
    .setText("Simple text")
    .build();
  MailAddress sender = mailAddress;
  ImmutableList<MailAddress> recipients = ImmutableList.of(mailAddress);
  String otherState = "other";
  testee.sendMail(sender, recipients, message, otherState);
  ArgumentCaptor<Mail> mailArgumentCaptor = ArgumentCaptor.forClass(Mail.class);
  verify(spoolMailQueue).enQueue(mailArgumentCaptor.capture());
  verifyNoMoreInteractions(spoolMailQueue);
  assertThat(mailArgumentCaptor.getValue().getState()).isEqualTo(otherState);
}

代码示例来源:origin: org.apache.james/james-server-mailets

@Test
public void consumeOptionShouldNotGhostTheMailByDefault() throws Exception {
  testee.init(FakeMailetConfig.builder()
    .mailetName(MAILET_NAME)
    .mailetContext(mailetContext)
    .build());
  Mail mail = createMail();
  testee.service(mail);
  assertThat(mail.getState()).isEqualTo(Mail.DEFAULT);
}

代码示例来源:origin: org.apache.james/james-server-mailets

@Test
public void consumeOptionShouldGhostTheMail() throws Exception {
  testee.init(FakeMailetConfig.builder()
    .mailetName(MAILET_NAME)
    .mailetContext(mailetContext)
    .setProperty(ToRecipientFolder.CONSUME_PARAMETER, "true")
    .build());
  Mail mail = createMail();
  testee.service(mail);
  assertThat(mail.getState()).isEqualTo(Mail.GHOST);
}

代码示例来源:origin: org.apache.james/james-server-mailets

@Test
public void remoteDeliveryShouldGhostMails() throws Exception {
  remoteDelivery.init(FakeMailetConfig.builder()
    .setProperty(RemoteDeliveryConfiguration.DELIVERY_THREADS, "1")
    .build());
  Mail mail = FakeMail.builder().name(MAIL_NAME).recipients(MailAddressFixture.ANY_AT_JAMES).build();
  remoteDelivery.service(mail);
  assertThat(mail.getState()).isEqualTo(Mail.GHOST);
}

代码示例来源:origin: org.apache.james/james-server-mailrepository-api

default void checkMailEquality(Mail actual, Mail expected) {
  assertSoftly(Throwing.consumer(softly -> {
    softly.assertThat(actual.getMessage().getContent()).isEqualTo(expected.getMessage().getContent());
    softly.assertThat(actual.getMessageSize()).isEqualTo(expected.getMessageSize());
    softly.assertThat(actual.getName()).isEqualTo(expected.getName());
    softly.assertThat(actual.getState()).isEqualTo(expected.getState());
    softly.assertThat(actual.getAttribute(TEST_ATTRIBUTE)).isEqualTo(expected.getAttribute(TEST_ATTRIBUTE));
    softly.assertThat(actual.getErrorMessage()).isEqualTo(expected.getErrorMessage());
    softly.assertThat(actual.getRemoteHost()).isEqualTo(expected.getRemoteHost());
    softly.assertThat(actual.getRemoteAddr()).isEqualTo(expected.getRemoteAddr());
    softly.assertThat(actual.getLastUpdated()).isEqualTo(expected.getLastUpdated());
    softly.assertThat(actual.getPerRecipientSpecificHeaders()).isEqualTo(expected.getPerRecipientSpecificHeaders());
  }));
}

相关文章