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

Bug 387509

Summary: Support JSON preference values
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ServerAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 1.0   
Target Milestone: 1.0 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2012-08-17 15:39:32 EDT
1. Go to Settings > Plugin Settings
2. Set the JSLint validation options to anything (eg. 'foo')
3. Unfocus the field so it saves. You should see
> PUT /prefs/user/cm/configurations/jslint.config
> {"properties":{"options":"foo"}}
in the network log.
4. Open the JavaScript console and type
> localStorage.clear()
5. Reload the page. Note that your custom JSLint options are lost.

This is because when it tries to retrieve the properties from the Preferences node, we do
> prefNode.get('properties')

expecting to receive an object, but instead get back a JSON string:
> "{"options":"foo"}"

This only happens after localStorage has been repopulated from the server.
Comment 2 Mark Macdonald CLA 2012-08-17 16:38:47 EDT
Oops, wrong bug. Reopening
Comment 3 Mark Macdonald CLA 2012-08-17 16:39:19 EDT
Pretend comment #1 never happened
Comment 4 Mark Macdonald CLA 2012-08-31 16:52:31 EDT
(In reply to comment #0)
The problem can be seen in these 2 requests:

PUT http://myserver:8080/prefs/user/cm/configurations/jslint.config
{"properties":{"options":"foo:true, bar:false"}}

but...

GET http://myserver:8080/prefs/user/cm/configurations/jslint.config
{
  "properties" : "{\"options\":\"foo:true, bar:false\"}"
}      

This happens because PreferencesServlet forces all keys to have a string value when writing the pref node:
> node.put(key, newNode.getString(key));
Comment 5 Mark Macdonald CLA 2012-08-31 18:41:22 EDT
The prefs API should give back the same data that we put in. Moving to server...
Comment 6 John Arthorne CLA 2012-09-04 15:41:52 EDT
The server side backing store only accepts string values. I think we never expected this possibility from the client, but we can add support for this.
Comment 7 John Arthorne CLA 2012-09-04 16:00:57 EDT
This should work now. Implementation and regression test in single commit:

http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=c53cec15eb3127369b26adcdb9b3fe6b0879ac3d