當前位置: 首頁>>代碼示例>>Java>>正文


Java MessagingException.getMessage方法代碼示例

本文整理匯總了Java中javax.mail.MessagingException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MessagingException.getMessage方法的具體用法?Java MessagingException.getMessage怎麽用?Java MessagingException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.mail.MessagingException的用法示例。


在下文中一共展示了MessagingException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SubethaEmailMessagePart

import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
 * Object can be built on existing message part only.
 * 
 * @param messagePart Message part.
 */
public SubethaEmailMessagePart(Part messagePart)
{
    ParameterCheck.mandatory("messagePart", messagePart);

    try
    {
        fileSize = messagePart.getSize();
        fileName = messagePart.getFileName();
        contentType = messagePart.getContentType();

        Matcher matcher = encodingExtractor.matcher(contentType);
        if (matcher.find())
        {
            encoding = matcher.group(1);
            if (!Charset.isSupported(encoding))
            {
                throw new EmailMessageException(ERR_UNSUPPORTED_ENCODING, encoding);
            }
        }

        try
        {
            contentInputStream = messagePart.getInputStream(); 
        }
        catch (Exception ex)
        {
            throw new EmailMessageException(ERR_FAILED_TO_READ_CONTENT_STREAM, ex.getMessage());
        }
    }
    catch (MessagingException e)
    {
        throw new EmailMessageException(ERR_INCORRECT_MESSAGE_PART, e.getMessage());
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:40,代碼來源:SubethaEmailMessagePart.java

示例2: getAttributes

import javax.mail.MessagingException; //導入方法依賴的package包/類
public MailMessageAttributes getAttributes() throws FolderException {
    if (attributes == null) {
        attributes = new SimpleMessageAttributes();
        try {
            attributes.setAttributesFor(mimeMessage);
        } catch (MessagingException e) {
            throw new FolderException("Could not parse mime message." + e.getMessage());
        }
    }
    return attributes;
}
 
開發者ID:Alfresco,項目名稱:alfresco-greenmail,代碼行數:12,代碼來源:SimpleStoredMessage.java

示例3: pageInRowIndex

import javax.mail.MessagingException; //導入方法依賴的package包/類
/**
 * Pages in a row index, making sure that it (and all other
 * messages in its block) are available.
 */
public void pageInRowIndex(int index)
{
  if (_loaded[index] == null)
  {

    try
    {
      if (_LOG.isLoggable(Level.FINEST))
      {
        _LOG.finest("total messages before open:"+_folder.getMessageCount());
      }

      _folder.open(Folder.READ_ONLY);
      // after the folder is opened, the count may change:
      _count = _folder.getMessageCount();

      // Calculate "from" and "to", zero-indexed
      // Round down to the start of the block
      int fromIndex = (index / _blockSize) * _blockSize;
      int toIndex = fromIndex + _blockSize - 1;
      if (toIndex >= _count)
        toIndex = _count - 1;

      try
      {
        // Retrieve the messages from the one-indexed Javamail API
        int jmFromIndex = _getFlippedIndex(toIndex) + 1;
        int jmToIndex = _getFlippedIndex(fromIndex) + 1;
        if (_LOG.isLoggable(Level.FINEST))
          _LOG.finest("fetching messages from:"+jmFromIndex+
                      " to:"+jmToIndex+
                      " total:"+ getRowCount() +
                      " actual total:"+_folder.getMessageCount());
        Message[] messages = _folder.getMessages(
                                jmFromIndex,
                                jmToIndex);
        _folder.fetch(messages, _fetchProfile);
        for (int i = 0; i < messages.length; i++)
        {
          Message message = messages[messages.length - i - 1];
          _loaded[i + fromIndex] = new MessageData(message);
        }
      }
      finally
      {
        _folder.close(false);
      }
    }
    // This is poor;  for starters, the page is likely
    // already displaying, so it's too late to show an error message.
    // We should try paging in rows up front via a RangeChangeListener to
    // catch the earlier and provide useful errors.
    catch (MessagingException me)
    {
      _LOG.log(Level.SEVERE, me.getMessage(), me);
      FacesMessage errorMessage = new FacesMessage(
                        FacesMessage.SEVERITY_ERROR,
                        me.getMessage(),
                        me.getStackTrace().toString());

      FacesContext context = FacesContext.getCurrentInstance();
      context.addMessage(null, errorMessage);
    }
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:70,代碼來源:MessageDataModel.java


注:本文中的javax.mail.MessagingException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。