Is the method not only search messages but also paging messages by javamail imap.

I can use SearchTerm and FlagTerm to search messages in ImapFolder.
And I can use follow code to sort messages.
Message[] messages = userFolder.getMessages();
   Arrays.sort(messages, new Comparator<Message>()
   public int compare(Message message1, Message message2)
   int returnValue = 0;
   try
   if (sortCriteria == SORT_SENT_DATE)
  returnValue = message1.getSentDate().compareTo(message2.getSentDate());
   } catch (Exception e)
   System.out.println(e.getMessage());
  e.printStackTrace();
   if (sortType == SORT_TYPE_DESCENDING)
  returnValue = -returnValue;
   return returnValue;
Actually This solution is working fine, but it fails in logic for paging Being a Web based application, i cant expect server to load all messages for every user and sort them (We do have situations >1000 Simultaneous users with mail boxes having > 1000 messages each )
It also does not make sense for the web server to load all, sort them, return just a small part (say 1-20), and on the next request, again load all sort them and return (21-40). Caching possible, but whts the gaurantee user would actually make a request ?
I need a solution that could also work in Search operation (searching with paging), I have built an archietecture to create a SearchTerm but here too i would require paging.

If your mail server supports the IMAP SORT extension, you can use the IMAPFolder.getSortedMessages method to get the list of messages in sorted order.  They you only need to fetch the data for the messages in the current page.
If your server doesn't support SORT, you'll need to do what you're currently doing, and use the fetch method to prefetch the data you'll need for the comparison.
Either way, you'll almost certainly want to cache some information in the session to provide consistency from page to page.  You only need to update the sort if messages are added or deleted.

Similar Messages

  • I updated my IPhone 3GS to the new 5.1 operating system and have since had a range of problems with not only my phone but also my IPad.

    I updated my IPhone 3GS to the new 5.1 operating system and have since had a range of problems with not only my phone but also my IPad.
    Programs (Safari, mail, messages) keep crashing, mail will not delete properly (some will keep popping into my inbox again for no reason!!!), slow, settings lock up etc. etc.
    This only seemed to become an issue once I updated to ios 5.1 and funnily also affected my Ipad even though i hadn't updated the software yet. I have since updated the software on my ipad thinking it might help too but that only made things worse!! So I am not sure if it's an ICloud issue, but when i try to disable ICloud my devices lock up as well.
    The battery life is also shocking!!
    I have hard reset both devices, restored both devices, reset the setting and tried a whole host of other suggestions (like closing background programs) on this forum buit nothing works and i am tearing my hair out.
    I looked in the phone and ipad log and there do seem to be low memory reports though i don't know why these are occuring now when they never have before??
    I don't know if I can restore the old operating system (If I can please let me know how). The phone or ipad are not jailbroken.

    but you should have a backup in itunes.
    Every time you sync your iOS device iTunes creates a backup. go check if its there, iTunes Preferences >Devices. and there you should see if you have a backup, and in case from which date the backup is.
    And ofcourse you can get your icloud data back by just logging in with your Appleid under icloud in settings on the iphone.
    But anyway, if the iPhone works when you restor it as new: try adding your backup, and see if the issue comes back. And experiment with your backup and try to work out what is causing the issue, my guess is that its some app!   Good Luck!

  • SUS - not only missing updates, but also hiding some...

    Hi *,
    i have the same problem with OSX SUS on 10.6.2 as described in several threads within this forum... with some add-on: not only that SUS is missing some of the updates available on Apple's public SUS service, it seems that at least one of the missing updates shows up in an intermitting way.
    In Server-Admin / Software Update Service / Updates the package "Final Cut Server Update" V1.5.1 of 11/24/09 does not appear on the list of available updates, unless i press the tiny rescan button which is located just below the list of update package. When i press it, the "Final Cut Server Update" appears immediately on the list. BUT it doesn't show up persistently -> when i switch in Server Admin over to another Service, e.g. SMB, and toggle the scope back to SUS, then all the packages which had been shown before toggling are displayed again, except that "Final Cut Server Update" is missing again.
    Really weird behaviour... hope that Apple fixes that soon, SUS is one of the major reason's why i'm running a MacMini Server @ home - i'm sitting with four Macs on a tiny network connect.
    Regards, KS

    I'm with you on this. Have really tried to get SUS running as I can really see the benefit, including resetting it completely several times.
    Thought I had it working, but now realised that even though the latest version of Safari 4.0.4 is downloaded and enabled, clients are reporting they are up to date (They have Safari 4.0.3).
    The OS 10.6.2 update downloaded correctly - so why not this?
    There are some serious flaws with SUS. Even the way you have to specify the server path is wrong if you ask me. Why can't there be a browse button? Why do you have to remember / look up what the correct filename is for the sucatalog depending on the OS version. Seems rather clunky to me.
    Andrew

  • How do I share not only my music but also my apps with other users on the same computer?

    I've searched around and this one link keeps comming up:
    http://support.apple.com/kb/HT1203
    That link only tells me how share with music I want apps and everything else shared between multiple users on the same windows computer.
    Thanks.

    Thank you Joe - I tried this but it's only showing a teensy amount of music - the stuff on the second users account as opposed to the giagntic library on the 'main' account. I actually went to a Genius Bar and they said that apple doesn't really want you to share music between accounts - parents don't want to hear their kids music etc. Which seemed strange, but it might be the case sadly   Thanks anyway!

  • In large PDF files my cursor moves around the page at warp speed. It does not seem to make any difference if I slow it down with Sys Prefs. This is not only in preview but also other programs to open PDFs.

    In large PDF files the cursor moves at warp speed with a mind of it's own, I've tried slowing it down in Sys Pref with no luck. On small files cursor action is normal. This happens in Safari, Preview and other programs that use PDF files. Sorry to say this does not seem to be a new problem with 7.# I've had it with prvevious versions of operating system Right now I'm using a Apple wireless mouse and key board. Using the USB keyboard and mouse the same problem does not go away.

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you boot, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • Pick and Pack check Fulfillment% not only by item but also by document

    when user set sales order set
    Allow Partial Delivery per Row = FALSE
    Allow Partial Delivery = FALSE
    when Pick and Pack check Fulfillment% set 100-100
    i have a sales order which have multi-line . but line 2 item didn't have enough quantity.so this document can not  shipping because it do not allow partial delivery.
    But in Pick and Pack manager still include some line in picklist which the item line  Fulfillment% = 100.
    This kind of pick list will very confuse warehouse person.
    Edited by: Jimmy Cheng on Jan 24, 2008 12:43 PM

    Sorry, it seems that the responsible people are too busy with other tasks.
    I had raised the lacking presence to someone in that area 3 months back - and he confirmed that they need to engage more, but apparently that didn't come true yet to the extent it should.
    I'll try again.
    Regards,
    Frank

  • Why can't I find events with cmd-F? I can see the appointment I am searching for, but the search cmd-F function does not find it. Why is this. It used to work...

    Why can't I find events with cmd-F? I can see the appointment I am searching for, but the search cmd-F function does not find it. Why is this. It used to work...

    Why can't I find events with cmd-F? I can see the appointment I am searching for, but the search cmd-F function does not find it. Why is this. It used to work...

  • I have mainstage 3 installed and works 1oo% when connected to the battery, but when connecting to the mains for charging the program crashes. sounds do not obey. is one, even very bad horrible latency. and I need to work on music not only in time but the

    i have mainstage 3 installed and works 1oo% when connected to the battery, but when connecting to the mains for charging the program crashes. sounds do not obey. is one, even very bad horrible latency.
    and I need to work on music not only in time but the battery after that.
    I ask for help please

    Thanks for the swift reply, I have been looking online and a loose plug seems to be somewhat of an issue with many, I hope mine is actually a problem and not what others are experiencing. It's taken me this long to even reach out for the simple fact I HATE being a complainer but this is just horrible.
    Do you have an iPad 3 as well? And is yours not experiencing any issues close to mine?
    Thanks again!

  • My Macpro attracts much dust whenever I turn on it. Not only on screen, but the trackpad and keyboard. What can I do?

    My Macpro attracts much dust whenever I turn on it. Not only on screen, but the trackpad and keyboard. What can I do?

    nothing, electrostatic attraction due to a DRY environment.
    humidifier in room, but thats WAY too much trouble.

  • How do i get rid of the "iPad Not Backed Up" message?

    How do I get rid of the "iPad Not Backed Up" message?  A week ago this happened, I searched for help, I was told to reboot and the message would go away.  It worked...for awhile.  The message is back, but now I cannot even reboot/reset the ipad.  The message blocks me and prevents me from using the "slide to power off".

    I'm not totally sure why the screen locks up like that, but it seems to happen to a number of users. I see that question being asked several time a day.
    My advice would be to backup regularly with iCloud so that the message does not appear. If you are already doing so, I can only assume that it is some low memory bug that is causing it, and that is merely a guess.

  • Can I go back to the old look of the 'server not found' error messages?

    After updating to Firefox 32, I noticed that the 'server not found' error messages now look differently. I don't like the new look, so I wonder if you know about an add-on that restores the old look. I've tried searching for it, but I don't know the proper name of these error messages, so I'm not sure what search phrase I should use.

    To recall what it looked like before, I did a search: [https://www.google.com/search?q=server+not+found+picture+firefox&client=firefox-beta&hs=wiy&rls=org.mozilla:en-US:official&channel=fflb&tbm=isch&tbo=u&source=univ&sa=X&ei=QUIXVPz7Eou7ogSl8YD4Bg&ved=0CB8QsAQ&biw=1036&bih=554#facrc=_&imgdii=_&imgrc=dFf2lmJRgVlgyM%253A%3BS3EdEuvyajjWqM%3Bhttp%253A%252F%252Fi.stack.imgur.com%252F2ZJR2.jpg%3Bhttp%253A%252F%252Fsuperuser.com%252Fquestions%252F584305%252Ffirefox-says-server-not-found-because-its-adding-www-how-do-i-stop-this%3B851%3B455 Images of Server not found in Firefox]
    I did not find an addon, but I did find an old hack for the profile folder in this thread: [http://forums.mozillazine.org/viewtopic.php?f=7&t=492177&start=0]
    EDIT:
    There was also [https://addons.mozilla.org/en-US/firefox/addon/errorzilla-mod/ ErrorZilla addon]

  • When i want to return to my home page I click on the home icon and it resets the page to my home page but also open a blak tab which i don't want how can I stop this as i have too many tabs open.

    When I want to return to my home page after looking at a website I click on the home icon and it resets the page to my home page but also open a blak tab which i don't want.How can I stop this as I have too many tabs open and have to close all of them.

    You may have an unwanted extension that is modifying sites (or the toolbar area). Try this:
    Disable ALL nonessential or unrecognized extensions on the Add-ons page. Either:
    * Ctrl+Shift+a
    * orange Firefox button (or Tools menu) > Add-ons
    In the left column, click Extensions. Then, if in doubt, disable.
    Usually a link will appear above at least one disabled extension to restart Firefox. You can complete your work on the tab and click one of the links as the last step.
    Does that flush the tab?
    Please report back on anything suspicious you find so others can learn about its bad behavior.

  • TS4123 I ran the Autorun and Bonjour came up but also "EasyRedirect.dll" did what is this so I can update it?

    I ran the Autorun and Bonjour came up but also "EasyRedirect.dll" did what is this so I can update it?

    I think that EasyRedirect.dll is part of Easy Hide IP.
    By way of experiment, try uninstalling your Easy Hide IP. Can you get through to the Store now?

  • How to override the onTouchUp in the user control which can be used to fire the event not only on this user control, but whole application

     I am a new to the C# and WPF. Right now, I want to override onTouchUp event in my user control. Then I can add user control in
    the references for reuse. The problem is each time I want to test this event on the application, the event only fire at area of user control, not whole screen. Anyone has solution for this?

    You cannot just add a UserControl to a window and expect its OnTouchUp method to get invoked when a TouchUp event occurs outside of the user control. That is not how routed events work.
    The OnTouchUp method of the UserControl will only be invoked when a TouchUp event occurs from within the UserControl.
    The event will indeed bubble up to the parent elements of the UserControl and you could for example handle the event in the parent window:
    <Window x:Class="WpfApplicationSlider.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" TouchUp="Window_TouchUp">
    The OnTouchUp method of the UserControl will however never get invoked when you touch an element outside of the UserControl because an event only travels between the source element and the handler(s). This is how routed events work.
    If you want a "global" TouchUp event handler you should override the OnTouchUp of the top-level
    window:
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    protected override void OnTouchUp(TouchEventArgs e)
    base.OnTouchUp(e);
    //do your thing...
    If you want to be able to reuse the functionality across all of your windows in case you have several you could for example create an abstract window class and make all your windows inherit from this one:
    namespace WpfApplication1
    public abstract class BaseWindow : System.Windows.Window
    protected override void OnTouchUp(System.Windows.Input.TouchEventArgs e)
    base.OnTouchUp(e);
    //do your thing...
    MainWindow:
    public partial class MainWindow : BaseWindow
    public MainWindow()
    InitializeComponent();
    <local:BaseWindow x:Class="WpfApplicationSlider.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1"
    Title="MainWindow" Height="350" Width="525">
    </local:BaseWindow>
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and please start a new thread if you have a new question.

  • Firefox crashes when I try to search for something using the Google or MSN search engines, but not with other search engines. What causes this and how can i fix this?

    I type something into the Google or MSN search engine and as soon as I hit search, Firefox crashes. Hotmail still works fine, as do every other website I have tried, including other search engines. What is the problem?

    I got the same issue to and crashes in the same exact manner. Been using IE in the mean time, thought it was just me. I tried reinstalling Firefox and everything, even rolled back windows.

Maybe you are looking for

  • My Brand New Nano's Battery Life is Short

    I just got my first Ipod nano last week so this may be my fault cause I'm still learning. The first time I charged my battery it lasted about 3 hours. I though it may have been because it was new that it was depleted so fast. I fully charged it last

  • Moved itunes to external hard drive problems

    Hi I am trying to clean up room on my laptop and followed directions on how to move my iTunes music to an external hard drive.....I did that and they are on that hard drive, but when I open up iTunes on my laptop, nothing is there and none of my list

  • Third Party Returns

    Hi all, Can anyone explain the third party returns process and  step by step configuration in IMG. its urgent. u can mail me to [email protected] tks

  • Vendor payment in another currency

    Please clarify the following: I have posted a vendor invoice in USD. Is it possible to pay the vendor in another currency ?

  • XSQL: How to embed the XML document(s) instead of posting?

    Dear all. I'm trying to use XSQL for a self-contained database schema setup. This setup should be able to handle DML (INSERT/UPDATE/DELETE), PL/SQL calls etc and I thought XSQL looks perfect for the job. As such, I wouldn't be using XSQL as a publish