You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ja...@apache.org on 2011/05/31 21:36:53 UTC

svn commit: r1129873 - in /struts/struts2/trunk/plugins/json/src: main/java/org/apache/struts2/json/JSONInterceptor.java main/java/org/apache/struts2/json/JSONUtil.java test/java/org/apache/struts2/json/JSONInterceptorTest.java

Author: jafl
Date: Tue May 31 19:36:53 2011
New Revision: 1129873

URL: http://svn.apache.org/viewvc?rev=1129873&view=rev
Log:
WW-3635 return application/json instead of application/json-rpc

Modified:
    struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
    struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONUtil.java
    struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java

Modified: struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java?rev=1129873&r1=1129872&r2=1129873&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java (original)
+++ struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java Tue May 31 19:36:53 2011
@@ -159,7 +159,7 @@ public class JSONInterceptor extends Abs
             json = addCallbackIfApplicable(request, json);
             boolean writeGzip = enableGZIP && JSONUtil.isGzipInRequest(request);
             JSONUtil.writeJSONToResponse(new SerializationParams(response, this.defaultEncoding,
-                    this.wrapWithComments, json, true, writeGzip, noCache, -1, -1, prefix, contentType));
+                    this.wrapWithComments, json, true, writeGzip, noCache, -1, -1, prefix, "application/json"));
 
             return Action.NONE;
         } else {

Modified: struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONUtil.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONUtil.java?rev=1129873&r1=1129872&r2=1129873&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONUtil.java (original)
+++ struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONUtil.java Tue May 31 19:36:53 2011
@@ -56,7 +56,7 @@ public class JSONUtil {
 
     /**
      * Serializes an object into JSON.
-     * 
+     *
      * @param object
      *            to be serialized
      * @return JSON string
@@ -71,7 +71,7 @@ public class JSONUtil {
     /**
      * Serializes an object into JSON, excluding any properties matching any of
      * the regular expressions in the given collection.
-     * 
+     *
      * @param object
      *            to be serialized
      * @param excludeProperties
@@ -93,7 +93,7 @@ public class JSONUtil {
     /**
      * Serializes an object into JSON, excluding any properties matching any of
      * the regular expressions in the given collection.
-     * 
+     *
      * @param object
      *            to be serialized
      * @param excludeProperties
@@ -117,7 +117,7 @@ public class JSONUtil {
 
     /**
      * Serializes an object into JSON to the given writer.
-     * 
+     *
      * @param writer
      *            Writer to serialize the object to
      * @param object
@@ -133,7 +133,7 @@ public class JSONUtil {
      * Serializes an object into JSON to the given writer, excluding any
      * properties matching any of the regular expressions in the given
      * collection.
-     * 
+     *
      * @param writer
      *            Writer to serialize the object to
      * @param object
@@ -151,7 +151,7 @@ public class JSONUtil {
 
     /**
      * Deserializes a object from JSON
-     * 
+     *
      * @param json
      *            string in JSON
      * @return desrialized object
@@ -164,7 +164,7 @@ public class JSONUtil {
 
     /**
      * Deserializes a object from JSON
-     * 
+     *
      * @param reader
      *            Reader to read a JSON string from
      * @return deserialized object
@@ -219,11 +219,8 @@ public class JSONUtil {
             response.sendError(serializationParams.getErrorCode());
 
         // content type
-        if (serializationParams.isSmd())
-            response.setContentType("application/json-rpc;charset=" + serializationParams.getEncoding());
-        else
-            response.setContentType(serializationParams.getContentType() + ";charset="
-                    + serializationParams.getEncoding());
+        response.setContentType(serializationParams.getContentType() + ";charset="
+                + serializationParams.getEncoding());
 
         if (serializationParams.isNoCache()) {
             response.setHeader("Cache-Control", "no-cache");
@@ -267,9 +264,9 @@ public class JSONUtil {
 
     /**
      * List visible methods carrying the
-     * 
+     *
      * @SMDMethod annotation
-     * 
+     *
      * @param ignoreInterfaces
      *            if true, only the methods of the class are examined. If false,
      *            annotations on every interfaces' methods are examined.
@@ -312,7 +309,7 @@ public class JSONUtil {
 
         /**
          * Called when a new interface/class is encountered
-         * 
+         *
          * @param aClass
          *            the encountered class/interface
          * @return true if the recursion should continue, false to stop
@@ -330,7 +327,7 @@ public class JSONUtil {
      * interface's superclasses (interfaces) super-superclass and so on <p/> The
      * Object base class is base excluded. Classes/interfaces are only visited
      * once each
-     * 
+     *
      * @param aClass
      *            the class to start recursing upwards from
      * @param visitor
@@ -348,7 +345,7 @@ public class JSONUtil {
      * Recursive method to visit all the interfaces of a class (and its
      * superclasses and super-interfaces) if they haven't already been visited.
      * <p/> Always visits itself if it hasn't already been visited
-     * 
+     *
      * @param thisClass
      *            the current class to visit (if not already done so)
      * @param classesVisited
@@ -422,7 +419,7 @@ public class JSONUtil {
         return includePatternData;
     }
 
-	private static final Map<String, Map<String, String>> defaultIncludePatternData = getIncludePatternData();
+    private static final Map<String, Map<String, String>> defaultIncludePatternData = getIncludePatternData();
 
     public static List<Pattern> processIncludePatterns(Set<String> includePatterns, String type) {
         return processIncludePatterns(includePatterns, type, defaultIncludePatternData);

Modified: struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java?rev=1129873&r1=1129872&r2=1129873&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java (original)
+++ struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java Tue May 31 19:36:53 2011
@@ -221,7 +221,7 @@ public class JSONInterceptorTest extends
         String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
         assertEquals(normalizedExpected, normalizedActual);
 
-        assertEquals("application/json-rpc;charset=ISO-8859-1", response.getContentType());
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
     }
 
     public void testSMDReturnObject() throws Exception {
@@ -245,7 +245,7 @@ public class JSONInterceptorTest extends
         String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-12.txt"));
         assertEquals(normalizedExpected, normalizedActual);
 
-        assertEquals("application/json-rpc;charset=ISO-8859-1", response.getContentType());
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
     }
 
     @SuppressWarnings("unchecked")
@@ -293,7 +293,7 @@ public class JSONInterceptorTest extends
         String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
         assertEquals(normalizedExpected, normalizedActual);
 
-        assertEquals("application/json-rpc;charset=ISO-8859-1", response.getContentType());
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
     }
 
     @SuppressWarnings( { "unchecked", "unchecked" })