jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dvit...@apache.org
Subject svn commit: r1656001 - in /jspwiki/trunk: jspwiki-war/pom.xml jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java pom.xml
Date Fri, 30 Jan 2015 13:02:03 GMT
Author: dvittor
Date: Fri Jan 30 13:02:03 2015
New Revision: 1656001

URL: http://svn.apache.org/r1656001
Log:
JSPWIKI-566: Removed pom.xml dependency for com.metaparadigm json-rpc. Replaced with GSon.

Modified:
    jspwiki/trunk/jspwiki-war/pom.xml
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java
    jspwiki/trunk/pom.xml

Modified: jspwiki/trunk/jspwiki-war/pom.xml
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/pom.xml?rev=1656001&r1=1656000&r2=1656001&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/pom.xml (original)
+++ jspwiki/trunk/jspwiki-war/pom.xml Fri Jan 30 13:02:03 2015
@@ -94,11 +94,6 @@
     </dependency>
 
     <dependency>
-      <groupId>com.metaparadigm</groupId>
-      <artifactId>json-rpc</artifactId>
-    </dependency>
-
-    <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
     </dependency>

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java?rev=1656001&r1=1656000&r2=1656001&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/preferences/Preferences.java Fri
Jan 30 13:02:03 2015
@@ -19,9 +19,15 @@
 package org.apache.wiki.preferences;
 
 import java.text.DateFormat;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.TimeZone;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
@@ -35,7 +41,8 @@ import org.apache.wiki.i18n.Internationa
 import org.apache.wiki.util.HttpUtil;
 import org.apache.wiki.util.PropertyReader;
 import org.apache.wiki.util.TextUtil;
-import org.json.JSONObject;
+
+import com.google.gson.Gson;
 
 /**
  *  Represents an object which is used to store user preferences.
@@ -132,25 +139,21 @@ public class Preferences
      *  @param prefs The default hashmap of preferences
      *  
      */
-    private static void parseJSONPreferences( HttpServletRequest request, Preferences prefs
)
+	private static void parseJSONPreferences( HttpServletRequest request, Preferences prefs
)
     {
         //FIXME: urlDecodeUTF8 should better go in HttpUtil ??
         String prefVal = TextUtil.urlDecodeUTF8( HttpUtil.retrieveCookieValue( request, "JSPWikiUserPrefs"
) );
         
         if( prefVal != null )
         {
-            try
-            {
-                JSONObject jo = new JSONObject( prefVal );
-    
-                for( Iterator i = jo.keys(); i.hasNext(); )
-                {
-                    String key = TextUtil.replaceEntities( (String)i.next() );
-                    prefs.put(key, jo.getString(key) );
-                }
-            }
-            catch( ParseException e )
-            {
+            Gson gson=new Gson(); 
+            Map<String,String> map = new HashMap<String,String>();
+            // Convert prefVal JSON to a generic hashmap
+            map=gson.fromJson(prefVal, map.getClass());
+
+            for (String key : map.keySet()) {
+                key = TextUtil.replaceEntities( key );
+                prefs.put(key, map.get(key) );
             }
         }
     }

Modified: jspwiki/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jspwiki/trunk/pom.xml?rev=1656001&r1=1656000&r2=1656001&view=diff
==============================================================================
--- jspwiki/trunk/pom.xml (original)
+++ jspwiki/trunk/pom.xml Fri Jan 30 13:02:03 2015
@@ -67,12 +67,6 @@
     <dependencies>       <!-- ordered alphabetically by scope:groupId:artifactId
                                    -->
       <!-- compile dependencies -->
       <dependency>
-        <groupId>com.metaparadigm</groupId>
-        <artifactId>json-rpc</artifactId>
-        <version>1.0</version>
-      </dependency>
-
-      <dependency>
         <groupId>com.google.code.gson</groupId>
         <artifactId>gson</artifactId>
         <version>2.3.1</version>



Mime
View raw message