From: Sandy M. <san...@us...> - 2004-04-19 20:44:36
|
Update of /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4675/src/java/edu/ufl/osg/webmail/actions Modified Files: FolderAction.java Log Message: Implements message view code for showing junk mail 'flag' with prefetching optimizations. Index: FolderAction.java =================================================================== RCS file: /cvsroot/gatormail/GatorMail/src/java/edu/ufl/osg/webmail/actions/FolderAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FolderAction.java 22 Feb 2004 07:59:55 -0000 1.2 --- FolderAction.java 19 Apr 2004 20:44:23 -0000 1.3 *************** *** 152,157 **** final PreferencesProvider pp = (PreferencesProvider)getServlet().getServletContext().getAttribute(Constants.PREFERENCES_PROVIDER); final Properties prefs = pp.getPreferences(user, session); ! if (Boolean.valueOf(prefs.getProperty("folder.list.threading")).booleanValue()) { ! prefetchMessageHeaders(messageList, folder); } --- 152,160 ---- final PreferencesProvider pp = (PreferencesProvider)getServlet().getServletContext().getAttribute(Constants.PREFERENCES_PROVIDER); final Properties prefs = pp.getPreferences(user, session); ! if (Boolean.valueOf(prefs.getProperty("folder.list.threading", "false")).booleanValue()) { ! prefetchThreadingMessageHeaders(messageList, folder); ! } ! if (Integer.valueOf(prefs.getProperty("message.junk.threashold", "0")).intValue() > 0) { ! prefetchJunkMessageHeaders(messageList, folder); } *************** *** 208,214 **** /** ! * Prefetches the {@link IMAPFolder.FetchProfileItem#HEADERS} for each ! * {@link Message}. All messages in <code>messageList</code> must be from ! * <code>folder</code>. * * @param messageList the list of {@link Message} objects. --- 211,216 ---- /** ! * Prefetches the <code>References</code> and <code>In-Reply-To</code> {@link IMAPFolder.FetchProfileItem#HEADERS} ! * for each {@link Message}. All messages in <code>messageList</code> must be from <code>folder</code>. * * @param messageList the list of {@link Message} objects. *************** *** 220,225 **** * Message}[]</code>. */ ! private static void prefetchMessageHeaders(final List messageList, final Folder folder) throws MessagingException, ArrayStoreException { ! // Prefetch the date headers for all messages. final FetchProfile fp = new FetchProfile(); //fp.add(IMAPFolder.FetchProfileItem.HEADERS); --- 222,227 ---- * Message}[]</code>. */ ! private static void prefetchThreadingMessageHeaders(final List messageList, final Folder folder) throws MessagingException, ArrayStoreException { ! // Prefetch the threading headers for all messages. final FetchProfile fp = new FetchProfile(); //fp.add(IMAPFolder.FetchProfileItem.HEADERS); *************** *** 230,233 **** --- 232,257 ---- } + /** + * Prefetches the <code>X-Spam-Leve</code> {@link IMAPFolder.FetchProfileItem#HEADERS} for each + * {@link Message}. All messages in <code>messageList</code> must be from <code>folder</code>. + * + * @param messageList the list of {@link Message} objects. + * @param folder the folder for which to prefetch from. + * @throws MessagingException if there is a problem with {@link + * Folder#fetch}. + * @throws ArrayStoreException if the <code>messageList</code> cannot be + * converted to a <code>{@link + * Message}[]</code>. + */ + private static void prefetchJunkMessageHeaders(final List messageList, final Folder folder) throws MessagingException, ArrayStoreException { + // Prefetch the spam headers for all messages. + final FetchProfile fp = new FetchProfile(); + //fp.add(IMAPFolder.FetchProfileItem.HEADERS); + fp.add("X-Spam-Level"); + //fp.add("X-Spam-Status"); + final Message[] msgs = (Message[])messageList.toArray(new Message[] {}); + folder.fetch(msgs, fp); + } + private static void flagMessagesWithAttachments(final List messages) { final Iterator iter = messages.iterator(); |