Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337902

Summary: Pluginregistry needs to separate session and persistent store
Product: [ECD] Orion Reporter: Simon Kaegi <simon_kaegi>
Component: ClientAssignee: Simon Kaegi <simon_kaegi>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: malgorzata.tomczyk, Szymon.Brandys
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 337888    

Description Simon Kaegi CLA 2011-02-22 16:10:29 EST
At the moment the pluginregistry is storing plugins and their associated data in the browsers localStorage. For testing we added a mechanism to let us inject an arbitrary storage object but we need to further factor this out to use a Storage API like in  http://dev.w3.org/html5/webstorage/#storage-0 so that we can for example persist the plugin registry to a user profile stored on a server.

We need to work out something a little bit better, such that when a user profile is available we use its contents but still need to balance this with performance and caching needs. For example we want to avoid preventing a page from loading while waiting to fetch the user profile so need to synchronize the contents with sessionStorage when triggered by logging in/out or by updating the plugin registry.
Comment 1 Simon Kaegi CLA 2011-02-22 16:13:56 EST
Wanted to add that we also will likely want to provide something like a default set of plugins for a user to both serve as a starting point when a new user profile is created and for anonymous access.
Comment 2 Simon Kaegi CLA 2011-02-23 01:31:32 EST
I played around with sessionStorage today and found that approach doesn't work as well as I had hoped. The biggest problem I found was that the lack of caching between tabs would force us to reload the user profile and settings and also makes sharing settings updates tricky. 

User settings are used by just about every page so ideally it would be good to cache this info once when the user logs in and then use "storage" eventing to keep all the tabs in synch if we really need that sort of inter-window liveness.

localStorage already provides a good starting point but we need to figure out how to interact with a user logging in and out. For now it might be simplest to just clear localStorage (or some namespaced subset) and re-populate it with user profile settings when a user logs in. Likewise persisting a user profile would be a matter of taking a snapshot of localStorage at certain checkpoints or when the user explicitly chooses to save their settings.

If you want to try the clear and re-populate approach we can start with any keys in localStorage that start with "plugin." as these are what the pluginregistry looks for when it loads.

I checked in a change that would let us install a plugin without loading the iframe that should help if we want to react to events but I need to do more testing for that still and I think a simple clear and repopulate approach is sufficient for M6.
Comment 3 Szymon Brandys CLA 2011-02-23 07:44:07 EST
(In reply to comment #1)
> Wanted to add that we also will likely want to provide something like a default
> set of plugins for a user to both serve as a starting point when a new user
> profile is created and for anonymous access.

This is what we do, at least for the user profile plug-ins. Each logged in user has his profile. The profile contains a list of plug-ins to install (just URLs). The list of plug-ins is populated by capabilities existing on the server (like Git). The user does not have to add anything manually. However users lists may be different.

For example:
- For Orion without Git bundle, GET /users/[userId] will return a profile with only one plug-in URL i.e. /plugins/user/userProfilePlugin.html
- For Orion with Git you will get two URLs i.e. /plugins/user/userProfilePlugin.html and /plugins/git/userProfilePlugin.html

I don't know how to get the list for anonymous users though. I will think about it.

(In reply to comment #2)
> If you want to try the clear and re-populate approach we can start with any keys
> in localStorage that start with "plugin." as these are what the pluginregistry
> looks for when it loads.

I'm not sure. So you would like to get the storage from the user profile. And you will clear localStorage and copy plug-ins from the profile to localStorage for each user login?

Anyway it seems like we are talking about two lists of plug-ins in the user profile. One is plug-ins to install, the approach that I described at the beginning with just URLs. The other is installed plug-ins. Am I right?
Comment 4 Simon Kaegi CLA 2011-04-26 22:07:56 EDT
.