Example usage for javax.mail.event ConnectionEvent OPENED

List of usage examples for javax.mail.event ConnectionEvent OPENED

Introduction

In this page you can find the example usage for javax.mail.event ConnectionEvent OPENED.

Prototype

int OPENED

To view the source code for javax.mail.event ConnectionEvent OPENED.

Click Source Link

Document

A connection was opened.

Usage

From source file:com.sun.mail.pop3.POP3Folder.java

/**
 * Throws <code>FolderNotFoundException</code> unless this
 * folder is named "INBOX"./* ww  w .  ja v a 2s  .c  o m*/
 *
 * @exception   FolderNotFoundException   if not INBOX
 * @exception   AuthenticationException   authentication failures
 * @exception   MessagingException   other open failures
 */
public synchronized void open(int mode) throws MessagingException {
    checkClosed();
    if (!exists)
        throw new FolderNotFoundException(this, "folder is not INBOX");

    try {
        port = ((POP3Store) store).getPort(this);
        Status s = port.stat();
        total = s.total;
        size = s.size;
        this.mode = mode;
        opened = true;
    } catch (IOException ioex) {
        try {
            if (port != null)
                port.quit();
        } catch (IOException ioex2) {
            // ignore
        } finally {
            port = null;
            ((POP3Store) store).closePort(this);
        }
        throw new MessagingException("Open failed", ioex);
    }

    // Create the message cache vector of appropriate size
    message_cache = new Vector(total);
    message_cache.setSize(total);
    doneUidl = false;

    notifyConnectionListeners(ConnectionEvent.OPENED);
}

From source file:org.sourceforge.net.javamail4ews.store.EwsFolder.java

@Override
public void open(int mode) throws MessagingException {
    this.mode = mode;
    try {/*  w w  w  .j  a  v  a2 s.co m*/
        if (!exists()) {
            throw new FolderNotFoundException();
        }
        ItemView view = new ItemView(ITEM_VIEW_MAX_ITEMS);
        folder = Folder.bind(getService(), folder.getId());

        if (prefetchItems) {
            FindItemsResults<Item> lFindResults = getService().findItems(folder.getId(), view);
            messages = new ArrayList<>(lFindResults.getTotalCount());
            unreadMessages = new ArrayList<>();
            for (Item aItem : lFindResults) {
                if (aItem instanceof EmailMessage) {
                    logger.info("Fetching content of item {}", aItem.getId());

                    EmailMessage aEmailMessage = (EmailMessage) aItem;

                    EwsMailConverter aConverter = new EwsMailConverter(this, aEmailMessage,
                            messages.size() + 1);

                    messages.add(aConverter.convert());

                } else {
                    logger.warn("Skipping item {} as it is a {}", aItem.getId(), aItem.getClass());
                }
            }
        } else {

        }
        timestamp = new Date();
        getStore().notifyConnectionListeners(ConnectionEvent.OPENED);
    } catch (Exception e) {
        throw new MessagingException(e.getMessage(), e);
    }
}