From: Sandy M. <san...@us...> - 2005-03-04 20:45:09
|
Update of /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9729/src/java/edu/ufl/osg/webmail/actions Modified Files: FolderAction.java Log Message: Don't forget to close a Folder when we're done with it. Index: FolderAction.java =================================================================== RCS file: /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/actions/FolderAction.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FolderAction.java 1 Dec 2004 22:13:23 -0000 1.11 --- FolderAction.java 4 Mar 2005 20:44:51 -0000 1.12 *************** *** 128,193 **** // Get the current Folder final Folder folder = ActionsUtil.fetchFolder(folderForm, request); ! request.setAttribute("folder", folder); ! ! if (folder == null) { ! return mapping.findForward("inbox"); ! } ! ! final HttpSession session = request.getSession(); ! final User user = Util.getUser(session); ! final PreferencesProvider pp = (PreferencesProvider)getServlet().getServletContext().getAttribute(Constants.PREFERENCES_PROVIDER); ! final Properties prefs = pp.getPreferences(user, session); ! // Get valid Messages in the folder ! final List messageList; ! final List addressBookList = Util.getAddressList(request.getSession()); // TODO: Only fetch when filtering ! final SearchTerm searchTerms = buildSearchFilter(folderForm.getFilterType(), folderForm.getFilter(), addressBookList, prefs); ! Message[] messages = folder.search(searchTerms); ! List ml = Arrays.asList(messages); ! prefetchMessageEnvelope(folder, ml); ! Collections.sort(ml, comparator); // XXX Sort on user's preferences ! if ((folderForm.getFilterType() == null || "none".equals(folderForm.getFilterType())) && folderForm.getPage().intValue() > 0) { ! int start = Math.min(messages.length, Math.max(0, (folderForm.getPage().intValue() - 1) * 25)); ! int end = Math.min(messages.length, start + 25); ! int pages = (int)Math.ceil(messages.length / 25d); ! messages = (Message[])Arrays.asList(messages).subList(start, end).toArray(new Message[0]); ! request.setAttribute("folderListPage", new Integer(folderForm.getPage().intValue())); ! request.setAttribute("folderListPages", new Integer(pages)); ! request.setAttribute("folderListFilterType", folderForm.getFilterType()); ! request.setAttribute("folderListFilter", folderForm.getFilter()); ! } ! prefetchEverything(folder, messages); ! messageList = ActionsUtil.buildMessageList(messages); ! flagMessagesWithAttachments(messageList); ! /* ! prefetchMessageEnvelopeUID(messageList, folder); ! if (Boolean.valueOf(prefs.getProperty("folder.list.threading", "false")).booleanValue()) { ! prefetchThreadingMessageHeaders(messageList, folder); ! } ! if (Integer.valueOf(prefs.getProperty("message.junk.threshold", "8")).intValue() > 0) { ! prefetchJunkMessageHeaders(messageList, folder); } - */ - - - - - // Populate the request attributes - request.setAttribute("messages", messageList); final Folder inbox = Util.getFolder(session, "INBOX"); ! ! // Populate Quota info ! final List quotaList = ActionsUtil.getQuotaList(inbox); ! request.setAttribute("quotaList", quotaList); ! Util.releaseFolder(inbox); // clean up // Populate the folderNameList --- 128,185 ---- // Get the current Folder final Folder folder = ActionsUtil.fetchFolder(folderForm, request); ! final HttpSession session; ! try { ! request.setAttribute("folder", folder); ! if (folder == null) { ! return mapping.findForward("inbox"); ! } ! session = request.getSession(); ! final User user = Util.getUser(session); ! final PreferencesProvider pp = (PreferencesProvider)getServlet().getServletContext().getAttribute(Constants.PREFERENCES_PROVIDER); ! final Properties prefs = pp.getPreferences(user, session); ! // Get valid Messages in the folder ! final List messageList; ! final List addressBookList = Util.getAddressList(request.getSession()); // TODO: Only fetch when filtering ! final SearchTerm searchTerms = buildSearchFilter(folderForm.getFilterType(), folderForm.getFilter(), addressBookList, prefs); ! Message[] messages = folder.search(searchTerms); ! List ml = Arrays.asList(messages); ! prefetchMessageEnvelope(folder, ml); ! Collections.sort(ml, comparator); // XXX Sort on user's preferences ! if ((folderForm.getFilterType() == null || "none".equals(folderForm.getFilterType())) && folderForm.getPage().intValue() > 0) { ! int start = Math.min(messages.length, Math.max(0, (folderForm.getPage().intValue() - 1) * 25)); ! int end = Math.min(messages.length, start + 25); ! int pages = (int)Math.ceil(messages.length / 25d); ! messages = (Message[])Arrays.asList(messages).subList(start, end).toArray(new Message[0]); ! request.setAttribute("folderListPage", new Integer(folderForm.getPage().intValue())); ! request.setAttribute("folderListPages", new Integer(pages)); ! request.setAttribute("folderListFilterType", folderForm.getFilterType()); ! request.setAttribute("folderListFilter", folderForm.getFilter()); ! } + prefetchEverything(folder, messages); + messageList = ActionsUtil.buildMessageList(messages); ! flagMessagesWithAttachments(messageList); ! // Populate the request attributes ! request.setAttribute("messages", messageList); ! } finally { ! Util.releaseFolder(folder); // clean up } final Folder inbox = Util.getFolder(session, "INBOX"); ! try { ! // Populate Quota info ! final List quotaList = ActionsUtil.getQuotaList(inbox); ! request.setAttribute("quotaList", quotaList); ! } finally { ! Util.releaseFolder(inbox); // clean up ! } // Populate the folderNameList |