Example usage for javax.mail MessagingException getMessage

List of usage examples for javax.mail MessagingException getMessage

Introduction

In this page you can find the example usage for javax.mail MessagingException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sonicle.webtop.mail.Service.java

public void processHideFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String sout = null;//from  w  w w  .j  a  va  2 s.c o  m
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        if (account.isSpecialFolder(folder)) {
            result = false;
        } else {
            hideFolder(account, folder);
        }
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processTrashFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String sout = null;//from   ww  w.ja va 2s.  c  o  m
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        if (!account.isUnderFolder(account.getFolderArchive(), folder) && account.isSpecialFolder(folder)) {
            result = false;
        } else {
            FolderCache newfc = account.trashFolder(folder);
            if (newfc != null) {
                sout += "newid: '" + StringEscapeUtils.escapeEcmaScript(newfc.getFolder().getFullName())
                        + "',\n";
                sout += "trashid: '"
                        + StringEscapeUtils.escapeEcmaScript(newfc.getParent().getFolder().getFullName())
                        + "',\n";
            }
            result = true;
        }
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processSeenMessages(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String fromfolder = request.getParameter("fromfolder");
    String uids[] = request.getParameterValues("ids");
    String multifolder = request.getParameter("multifolder");
    boolean mf = multifolder != null && multifolder.equals("true");
    String sout = null;/*from w ww  .  ja  v  a  2s  . com*/
    try {
        account.checkStoreConnected();
        FolderCache mcache = account.getFolderCache(fromfolder);
        if (!mf) {
            setMessagesSeen(mcache, toLongs(uids));
        } else {
            long iuids[] = new long[1];
            for (String uid : uids) {
                int ix = uid.indexOf("|");
                fromfolder = uid.substring(0, ix);
                uid = uid.substring(ix + 1);
                mcache = account.getFolderCache(fromfolder);
                iuids[0] = Long.parseLong(uid);
                setMessagesSeen(mcache, iuids);
            }
        }
        long millis = System.currentTimeMillis();
        sout = "{\nresult: true, millis: " + millis + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processUnseenMessages(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String fromfolder = request.getParameter("fromfolder");
    String uids[] = request.getParameterValues("ids");
    String multifolder = request.getParameter("multifolder");
    boolean mf = multifolder != null && multifolder.equals("true");
    String sout = null;//  w  w  w .  j  av  a  2s. co m
    try {
        account.checkStoreConnected();
        FolderCache mcache = account.getFolderCache(fromfolder);
        if (!mf) {
            setMessagesUnseen(mcache, toLongs(uids));
        } else {
            long iuids[] = new long[1];
            for (String uid : uids) {
                int ix = uid.indexOf("|");
                fromfolder = uid.substring(0, ix);
                uid = uid.substring(ix + 1);
                mcache = account.getFolderCache(fromfolder);
                iuids[0] = Long.parseLong(uid);
                setMessagesUnseen(mcache, iuids);
            }
        }
        long millis = System.currentTimeMillis();
        sout = "{\nresult: true, millis: " + millis + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processUnseenFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    boolean recursive = false;
    String srecursive = request.getParameter("recursive");
    if (srecursive != null) {
        recursive = srecursive.equals("1");
    }/*  w  w w. j a  va2s .c om*/
    String sout = null;
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        setMessagesSeen(mcache, false, recursive);
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + folder + "', oldname: '"
                + (mcache != null ? mcache.getFolder().getName() : "unknown") + "', text:'"
                + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processSeenFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    boolean recursive = false;
    String srecursive = request.getParameter("recursive");
    if (srecursive != null) {
        recursive = srecursive.equals("1");
    }//  ww w .  j  a  v a  2  s  .  co  m
    String sout = null;
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        setMessagesSeen(mcache, true, recursive);
        long millis = System.currentTimeMillis();
        sout += "result: " + result + ", millis: " + millis + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + folder + "', oldname: '"
                + (mcache != null ? mcache.getFolder().getName() : "unknown") + "', text:'"
                + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processEmptyFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String sout = null;//from w ww  .  j a v a  2 s.c  o  m
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        account.emptyFolder(folder);
        sout += "oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "',\n";
        sout += "result: true\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "', oldname: '"
                + StringEscapeUtils.escapeEcmaScript(mcache != null ? mcache.getFolder().getName() : "unknown")
                + "', text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processDeleteFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String sout = null;/*from  w ww.ja v  a2s  .c o m*/
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        if (!account.isUnderFolder(account.getFolderArchive(), folder) && account.isSpecialFolder(folder)) {
            result = false;
        } else {
            result = account.deleteFolder(folder);
            if (result) {
                sout += "oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "',\n";
            }
        }
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "', oldname: '"
                + StringEscapeUtils.escapeEcmaScript(mcache != null ? mcache.getFolder().getName() : "unknown")
                + "', text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processRenameFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String name = request.getParameter("name");
    String sout = null;/*from  w w w  . j a v a  2  s . co  m*/
    FolderCache mcache = null;
    MailUserSettings.FavoriteFolders favorites = us.getFavoriteFolders();

    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        name = account.normalizeName(name);
        String newid = account.renameFolder(folder, name);

        if (favorites.contains(account.getId(), folder)) {
            favorites.remove(account.getId(), folder);
            favorites.add(account.getId(), newid, name);
            us.setFavoriteFolders(favorites);
        }
        sout += "oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "',\n";
        sout += "newid: '" + StringEscapeUtils.escapeEcmaScript(newid) + "',\n";
        sout += "newname: '" + StringEscapeUtils.escapeEcmaScript(name) + "',\n";
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "', oldname: '"
                + StringEscapeUtils.escapeEcmaScript(mcache != null ? mcache.getFolder().getName() : "unknown")
                + "', text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}

From source file:com.sonicle.webtop.mail.Service.java

public void processMoveFolder(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    MailAccount account = getAccount(request);
    String folder = request.getParameter("folder");
    String to = request.getParameter("to");
    String sout = null;//from  www.j av  a 2s .  c o m
    FolderCache mcache = null;
    try {
        account.checkStoreConnected();
        boolean result = true;
        sout = "{\n";
        mcache = account.getFolderCache(folder);
        if (account.isSpecialFolder(folder)) {
            result = false;
        } else {
            FolderCache newfc = account.moveFolder(folder, to);
            Folder newf = newfc.getFolder();
            sout += "oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "',\n";
            sout += "newid: '" + StringEscapeUtils.escapeEcmaScript(newf.getFullName()) + "',\n";
            sout += "newname: '" + StringEscapeUtils.escapeEcmaScript(newf.getName()) + "',\n";
            if (to != null) {
                sout += "parent: '" + StringEscapeUtils.escapeEcmaScript(newf.getParent().getFullName())
                        + "',\n";
            }
            result = true;
        }
        sout += "result: " + result + "\n}";
    } catch (MessagingException exc) {
        Service.logger.error("Exception", exc);
        sout = "{\nresult: false, oldid: '" + StringEscapeUtils.escapeEcmaScript(folder) + "', oldname: '"
                + StringEscapeUtils.escapeEcmaScript(mcache != null ? mcache.getFolder().getName() : "unknown")
                + "', text:'" + StringEscapeUtils.escapeEcmaScript(exc.getMessage()) + "'\n}";
    }
    out.println(sout);
}