当前位置: 首页>>代码示例>>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;未经允许,请勿转载。