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

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

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

Mail.getName介绍

[英]Returns the name of this message.
[中]返回此消息的名称。

代码示例

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

/**
 * @see org.apache.james.mailrepository.api.MailRepository#remove(Mail)
 */
public void remove(Mail mail) throws MessagingException {
  remove(mail.getName());
}

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

private void bounceWithMailetContext(Mail mail, Exception ex) {
  LOGGER.debug("Sending failure message {}", mail.getName());
  try {
    mailetContext.bounce(mail, explanationText(mail, ex));
  } catch (MessagingException me) {
    LOGGER.warn("Encountered unexpected messaging exception while bouncing message", me);
  } catch (Exception e) {
    LOGGER.warn("Encountered unexpected exception while bouncing message", e);
  }
}

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

private Stream<Pair<String, byte[]>> toJson(Map.Entry<String, Calendar> entry, Map<String, byte[]> rawCalendars, Mail mail, String sender) {
  return mail.getRecipients()
    .stream()
    .flatMap(recipient -> toICAL(entry, rawCalendars, recipient, sender))
    .flatMap(ical -> toJson(ical, mail.getName()))
    .map(json -> Pair.of(UUID.randomUUID().toString(), json.getBytes(StandardCharsets.UTF_8)));
}

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

private void reprocess(MailRepository repository, Mail mail) {
    try {
      targetProcessor.ifPresent(mail::setState);
      mailQueue.enQueue(mail);
      repository.remove(mail);
    } catch (Exception e) {
      throw new RuntimeException("Error encountered while reprocessing mail " + mail.getName(), e);
    }
  }
}

代码示例来源: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

@Override
public void service(Mail mail) throws javax.mail.MessagingException {
  String logBuffer = "Storing mail " + mail.getName() + " in " + repositoryPath;
  LOGGER.info(logBuffer);
  repository.store(mail);
  if (!passThrough) {
    mail.setState(Mail.GHOST);
  }
}

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

public String composeFailLogMessage(Mail mail, ExecutionResult executionResult) {
  StringWriter sout = new StringWriter();
  PrintWriter out = new PrintWriter(sout, true);
  out.print(permanentAsString(executionResult.isPermanent()) + " exception delivering mail (" + mail.getName()
    + ")" + retrieveExceptionLog(executionResult.getException().orElse(null)) + ": ");
  if (configuration.isDebug()) {
    if (executionResult.getException().isPresent()) {
      executionResult.getException().get().printStackTrace(out);
    }
  }
  return sout.toString();
}

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

private void serviceSingleServer(Mail mail, String originalName, Map.Entry<Domain, Collection<MailAddress>> entry) {
  if (configuration.isDebug()) {
    LOGGER.debug("Sending mail to {} on host {}", entry.getValue(), entry.getKey());
  }
  mail.setRecipients(entry.getValue());
  mail.setName(originalName + NAME_JUNCTION + entry.getKey().name());
  try {
    queue.enQueue(mail);
  } catch (MailQueueException e) {
    LOGGER.error("Unable to queue mail {} for recipients {}", mail.getName(), mail.getRecipients(), e);
  }
}

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

private void serviceNoGateway(Mail mail) {
  String mailName = mail.getName();
  Map<Domain, Collection<MailAddress>> targets = groupByServer(mail.getRecipients());
  for (Map.Entry<Domain, Collection<MailAddress>> entry : targets.entrySet()) {
    serviceSingleServer(mail, mailName, entry);
  }
}

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

private void store(Mail mail, MailRepositoryUrl url) throws MessagingException {
  try {
    Optional<MailRepository> mailRepository = retrieveRepository(url);
    if (!mailRepository.isPresent()) {
      LOGGER.warn("'{}' mail repository does not exist and will not be created. Mail {} will not be stored in it.",
        url, mail.getName());
    }
    ThrowingConsumer<MailRepository> storingConsumer = repository -> repository.store(mail);
    mailRepository.ifPresent(Throwing.consumer(storingConsumer).sneakyThrow());
  } catch (MailRepositoryStore.MailRepositoryStoreException e) {
    throw new MessagingException("Error while selecting url " + url, e);
  }
}

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

@Override
public void service(Mail mail) throws MessagingException {
  try {
    producerTemplate.sendBody(getEndpoint(), mail);
  } catch (CamelExecutionException ex) {
    throw new MessagingException("Unable to process mail " + mail.getName(), ex);
  }
}

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

private void serviceWithGateway(Mail mail) {
  if (configuration.isDebug()) {
    LOGGER.debug("Sending mail to {} via {}", mail.getRecipients(), configuration.getGatewayServer());
  }
  try {
    queue.enQueue(mail);
  } catch (MailQueueException e) {
    LOGGER.error("Unable to queue mail {} for recipients {}", mail.getName(), mail.getRecipients(), e);
  }
}

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

private void reAttemptDelivery(Mail mail, int retries) throws MailQueue.MailQueueException {
  LOGGER.debug("Storing message {} into outgoing after {} retries", mail.getName(), retries);
  DeliveryRetriesHelper.incrementRetries(mail);
  mail.setLastUpdated(dateSupplier.get());
  // Something happened that will delay delivery. Store it back in the retry repository.
  long delay = getNextDelay(DeliveryRetriesHelper.retrieveRetries(mail));
  if (configuration.isUsePriority()) {
    // Use lowest priority for retries. See JAMES-1311
    mail.setAttribute(MailPrioritySupport.MAIL_PRIORITY, MailPrioritySupport.LOW_PRIORITY);
  }
  queue.enQueue(mail, delay, TimeUnit.MILLISECONDS);
}

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

private void doService(Mail mail) throws MessagingException {
  if (mail.hasSender()) {
    MailAddress sender = mail.getMaybeSender().get();
    String username = retrieveUser(sender);
    mailboxAppender.append(mail.getMessage(), username, folder);
    LOGGER.error("Local delivery with ToSenderFolder mailet for mail {} with sender {} in folder {}", mail.getName(), sender, folder);
  }
}

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

@Override
public void storeMail(MailAddress recipient, Mail mail) throws MessagingException {
  String username = computeUsername(recipient);
  String locatedFolder = locateFolder(username, mail);
  ComposedMessageId composedMessageId = mailboxAppender.append(mail.getMessage(), username, locatedFolder);
  metric.increment();
  LOGGER.info("Local delivered mail {} successfully from {} to {} in folder {} with composedMessageId {}", mail.getName(),
    mail.getMaybeSender().asString(), recipient.asPrettyString(), locatedFolder, composedMessageId);
}

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

public static MailProjection from(Mail mail) {
  return new MailProjection(mail.getName(), mail.getRecipients(),
    Iterators.toStream(mail.getAttributeNames())
      .map(name -> Pair.of(name, mail.getAttribute(name)))
      .collect(Guavate.toImmutableMap(Pair::getKey, Pair::getValue)));
}

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

@Test
public void sendShouldEnQueueTheMail() throws Exception {
  FakeMail mail = FakeMail.builder()
    .name(NAME)
    .build();
  mailSpool.send(mail, new MailMetadata(MESSAGE_ID, USERNAME));
  MailQueueItem actual = myQueue.deQueue();
  assertThat(actual.getMail().getName()).isEqualTo(NAME);
}

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

public static MailQueueItemDTO from(ManageableMailQueue.MailQueueItemView mailQueueItemView) {
  return builder()
      .name(mailQueueItemView.getMail().getName())
      .sender(mailQueueItemView.getMail().getMaybeSender().asOptional())
      .recipients(mailQueueItemView.getMail().getRecipients())
      .nextDelivery(mailQueueItemView.getNextDelivery())
      .build();
}

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

@Test
public void reprocessingOneShouldEnqueueMail() throws Exception {
  MailRepository repository = mailRepositoryStore.select(MailRepositoryUrl.fromPathAndProtocol(PATH, MEMORY_PROTOCOL));
  repository.store(mail1);
  repository.store(mail2);
  repository.store(mail3);
  reprocessingService.reprocess(PATH, KEY_2, NO_TARGET_PROCESSOR, SPOOL);
  assertThat(queueFactory.getQueue(SPOOL).get()
    .browse())
    .extracting(item -> item.getMail().getName())
    .containsOnly(NAME_2);
}

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

@Test
public void reprocessingShouldEnqueueAllMails() throws Exception {
  MailRepository repository = mailRepositoryStore.select(MailRepositoryUrl.fromPathAndProtocol(PATH, MEMORY_PROTOCOL));
  repository.store(mail1);
  repository.store(mail2);
  repository.store(mail3);
  reprocessingService.reprocessAll(PATH, NO_TARGET_PROCESSOR, SPOOL, NOOP_CONSUMER);
  assertThat(queueFactory.getQueue(SPOOL).get()
    .browse())
    .extracting(item -> item.getMail().getName())
    .containsOnly(NAME_1, NAME_2, NAME_3);
}

相关文章