1 32 33 package scioworks.imap.presentation.imapWeb; 34 35 import java.net.URLEncoder ; 36 import java.util.Vector ; 37 38 import javax.mail.*; 39 import javax.activation.*; 40 41 import org.w3c.dom.*; 42 import org.w3c.dom.html.*; 43 44 import com.lutris.appserver.server.httpPresentation.*; 45 46 import scioworks.imap.presentation.base.*; 47 import scioworks.imap.presentation.imapWeb.*; 48 import scioworks.imap.spec.ImapWebConstant; 49 import scioworks.imap.spec.beans.*; 50 import scioworks.imap.spec.ImapWebException; 51 52 public class folder_list extends BasePO { 53 protected boolean isLoginRequired() { 55 return false; 56 } 57 58 public String handleDefault() 59 throws HttpPresentationException { 60 61 folder_listHTML page = (folder_listHTML)m_comms.xmlcFactory.create(folder_listHTML.class); 62 63 64 try { 65 66 HTMLTableRowElement folderListRow = page.getElementFolderListRow(); 68 Node folderListTable = folderListRow.getParentNode(); 69 70 HTMLAnchorElement mailListLink = page.getElementMailListLink(); 72 73 String currLink = mailListLink.getHref() + "?" + 74 PARAM_folder + "="; 75 76 78 Folder folder = super.getImapWebSessionData().getImapStore().getFolder("INBOX"); 79 80 page.setTextInboxMessageCount(Integer.toString(folder.getMessageCount())); 81 page.setTextInboxUnreadMessageCount(Integer.toString(folder.getUnreadMessageCount())); 82 83 folder = super.getImapWebSessionData().getImapStore().getFolder(ImapWebConstant.singleton().folderSent()); 85 page.setTextSentName(ImapWebConstant.singleton().folderSent()); 86 page.setTextSentMessageCount(Integer.toString(folder.getMessageCount())); 87 page.setTextSentUnreadMessageCount(Integer.toString(folder.getUnreadMessageCount())); 88 page.getElementSentLink().setHref(currLink + URLEncoder.encode(ImapWebConstant.singleton().folderSent())); 89 90 folder = super.getImapWebSessionData().getImapStore().getFolder(ImapWebConstant.singleton().folderTrash()); 92 page.setTextTrashName(ImapWebConstant.singleton().folderTrash()); 93 page.setTextTrashMessageCount(Integer.toString(folder.getMessageCount())); 94 page.setTextTrashUnreadMessageCount(Integer.toString(folder.getUnreadMessageCount())); 95 page.getElementTrashLink().setHref(currLink + URLEncoder.encode(ImapWebConstant.singleton().folderTrash())); 96 97 HTMLElement msgCountEle = page.getElementMessageCount(); 99 HTMLElement unreadMsgCountEle = page.getElementUnreadMessageCount(); 100 101 msgCountEle.removeAttribute("id"); 102 unreadMsgCountEle.removeAttribute("id"); 103 104 Folder[] folders = super.getImapWebSessionData().getImapStore().getDefaultFolder().list(); 105 106 for (int i=0; i<folders.length; i++) { 107 108 folder = folders[i]; 109 110 if (folder.getName().equalsIgnoreCase("INBOX")) { 111 continue; 112 } else if (folder.getName().equalsIgnoreCase(ImapWebConstant.singleton().folderSent())) { 113 continue; 114 } else if (folder.getName().equalsIgnoreCase(ImapWebConstant.singleton().folderTrash())) { 115 continue; 116 } 117 118 page.setTextFolderName(folder.getName()); 119 page.setTextMessageCount(Integer.toString(folder.getMessageCount())); 120 page.setTextUnreadMessageCount(Integer.toString(folder.getUnreadMessageCount())); 121 122 mailListLink.setHref(currLink + URLEncoder.encode(folder.getName())); 123 124 folderListTable.appendChild(folderListRow.cloneNode(true)); 125 } 126 folderListTable.removeChild(folderListRow); 127 128 129 IWMessage iwMsg = IWMessageFactory.getIWMessage("scioworks.imap.business.beans.IWMessageImpl"); 131 132 try { 133 Vector targetFolders = iwMsg.getFolderNames(super.getImapWebSessionData().getImapStore(), 134 "INBOX"); 135 super.processSelectList(page, page.getElementFolder(), 136 targetFolders, targetFolders, "-1"); 137 138 139 140 } catch (ImapWebException e) { 141 return super.showErrorPage(MSG_OPERATION_FAILED, e.getMessage(), "", ""); 142 } 143 144 }catch(NullPointerException ex) { 145 149 return ((folder_listHTML)m_comms.xmlcFactory.create(folder_listHTML.class)).toDocument(); 150 151 } catch (MessagingException e) { 152 e.printStackTrace(); 153 return super.showErrorPage("Error getting folders", e.getMessage(), "", ""); 154 } 155 156 157 return page.toDocument(); 158 } 159 } | Popular Tags |