List of usage examples for javax.mail Folder toString
@Override
public String toString()
From source file:org.jasig.portlet.emailpreview.controller.AjaxUpdateInboxFolderController.java
@ResourceMapping("inboxFolder") public ModelAndView inboxFolder(ResourceRequest req, ResourceResponse res) throws MessagingException { IEmailAccountService accountDao = serviceBroker.getEmailAccountService(req); PortletPreferences prefs = req.getPreferences(); String selectedFolder = prefs.getValue(EmailAccountSummaryController.INBOX_NAME_PREFERENCE, INBOX_DEFAULT_VALUE_PREF);//from w w w . j av a2 s . co m String authenticationServiceKey = prefs.getValue(AUTH_SERVICE_PREFERENCE, AUTH_SERVICE_DEFAULT_VALUE_PREFERENCE); Map<String, String> jsonData = new Hashtable<String, String>(); if (AUTH_SERVICE_TEST_PREFERENCE.equals(authenticationServiceKey)) { jsonData.put("INBOX", "INBOX"); //For demo : must have the same name that the json files in src/main/resources jsonData.put("demoTest", "demoTest"); jsonData.put("Important", "Important"); for (Map.Entry<String, String> entry : jsonData.entrySet()) { if (entry.getValue().equals(selectedFolder)) { jsonData.put(SELECTED_OPTION, entry.getValue()); break; } } } else { for (Folder folderName : accountDao.getAllUserInboxFolders(req)) { if ((folderName.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) { String unreadMsgCount = ""; if (folderName.getUnreadMessageCount() != 0 && (!selectedFolder.equals(folderName.toString()))) { unreadMsgCount = " (".concat(String.valueOf(folderName.getUnreadMessageCount())).concat(")") .concat(UNREAD_MSG_FLAG); } jsonData.put(folderName.toString().concat(unreadMsgCount), folderName.toString()); if (selectedFolder.equals(folderName.toString())) { jsonData.put(SELECTED_OPTION, folderName.toString()); } } } } return new ModelAndView("json", jsonData); }
From source file:net.wastl.webmail.server.WebMailSession.java
/** Disconnect from mailhost "name"// www. j ava 2 s .com */ public void disconnect(String name) { try { Folder f = connections.get(name); if (f != null && f.isOpen()) { f.close(true); Store st = connections.get(name).getStore(); //st.close(); log.info("Mail: Disconnected from folder " + f.toString() + " at store " + st.toString() + "."); } else { log.warn("Mail: Folder " + name + " was null???."); } } catch (MessagingException ex) { // Should not happen log.fatal("Unexpected failure to disconnect", ex); } catch (NullPointerException ex) { // This happens when deleting a folder with an error log.fatal("Failed to disconnect after deleting folder? " + ex); // Log exception too if the comment above is wrong } finally { connections.remove(name); } }