cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1464355 - in /cxf/trunk/rt: frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ frontend/jaxrs/src/main/java/o...
Date Thu, 04 Apr 2013 08:42:42 GMT
Author: sergeyb
Date: Thu Apr  4 08:42:42 2013
New Revision: 1464355

URL: http://svn.apache.org/r1464355
Log:
[CXF-4825] Replacing MediaType.toString calls with the internal util calls

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
Thu Apr  4 08:42:42 2013
@@ -100,6 +100,10 @@ public class MediaTypeHeaderProvider imp
     }
     
     public String toString(MediaType type) {
+        return typeToString(type);
+    }
+    
+    public static String typeToString(MediaType type) {
         StringBuilder sb = new StringBuilder();
         sb.append(type.getType()).append('/').append(type.getSubtype());
         
@@ -133,7 +137,7 @@ public class MediaTypeHeaderProvider imp
             } else {
                 mt = MediaType.WILDCARD_TYPE;
             }
-            LOG.fine("Converting a malformed media type '" + mType + "' to '" + mt.toString()
+ "'");
+            LOG.fine("Converting a malformed media type '" + mType + "' to '" + typeToString(mt)
+ "'");
             return mt;
         } else {
             throw new IllegalArgumentException("Media type separator is missing");

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
Thu Apr  4 08:42:42 2013
@@ -41,6 +41,7 @@ import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.core.Variant;
 
 import org.apache.cxf.jaxrs.utils.HttpUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 
@@ -83,7 +84,7 @@ public final class ResponseBuilderImpl e
     }
 
     public ResponseBuilder type(MediaType type) {
-        return type(type == null ? null : type.toString());
+        return type(type == null ? null : JAXRSUtils.mediaTypeToString(type));
     }
 
     public ResponseBuilder type(String type) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Thu Apr  4 08:42:42 2013
@@ -237,7 +237,7 @@ public class JAXRSOutInterceptor extends
             .createMessageBodyWriterInterceptor(targetType, genericType, annotations, responseMediaType,
message);
         
         responseMediaType = checkFinalContentType(responseMediaType);
-        responseContentType = responseMediaType.toString();
+        responseContentType = JAXRSUtils.mediaTypeToString(responseMediaType);
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Response content type is: " + responseContentType);
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Thu Apr  4 08:42:42 2013
@@ -731,7 +731,7 @@ public class WadlGenerator implements Co
         for (MediaType mt : types) {
             
             sb.append("<representation");
-            sb.append(" mediaType=\"").append(mt.toString()).append("\"");
+            sb.append(" mediaType=\"").append(JAXRSUtils.mediaTypeToString(mt)).append("\"");
             if (isJson && !mt.getSubtype().contains("json")) {
                 sb.append("/>");
                 continue;

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Thu
Apr  4 08:42:42 2013
@@ -443,7 +443,7 @@ public final class JAXRSUtils {
                                 MediaType pMediaType = matchProduceTypes(acceptType, ori);
                                 if (mMatched && cMatched && pMediaType !=
null) {
                                     subresourcesOnly = false;
-                                    map.putSingle(Message.CONTENT_TYPE, pMediaType.toString());
+                                    map.putSingle(Message.CONTENT_TYPE, mediaTypeToString(pMediaType));
                                     candidateList.put(ori, map);
                                     added = true;
                                 } else {
@@ -521,7 +521,7 @@ public final class JAXRSUtils {
                                                    message.get(Message.REQUEST_URI),
                                                    getCurrentPath(firstCri.getValue()),
                                                    httpMethod,
-                                                   requestType.toString(),
+                                                   mediaTypeToString(requestType),
                                                    convertTypesToString(acceptContentTypes));
         if (!"OPTIONS".equalsIgnoreCase(httpMethod)) {
             LOG.warning(errorMsg.toString());
@@ -608,7 +608,7 @@ public final class JAXRSUtils {
     private static String convertTypesToString(List<MediaType> types) {
         StringBuilder sb = new StringBuilder();
         for (MediaType type : types) {
-            sb.append(type.toString()).append(',');
+            sb.append(mediaTypeToString(type)).append(',');
         }
         return sb.toString();
     }
@@ -1216,7 +1216,7 @@ public final class JAXRSUtils {
                 String errorMessage = new org.apache.cxf.common.i18n.Message("NO_MSG_READER",
                                                        BUNDLE,
                                                        targetTypeClass.getSimpleName(),
-                                                       contentType).toString();
+                                                       mediaTypeToString(contentType)).toString();
                 LOG.warning(errorMessage);
                 throw new WebApplicationException(Response.Status.UNSUPPORTED_MEDIA_TYPE);
             }
@@ -1599,6 +1599,10 @@ public final class JAXRSUtils {
         }
     }
     
+    public static String mediaTypeToString(MediaType mt) {
+        return MediaTypeHeaderProvider.typeToString(mt);
+    }
+    
     public static MediaType toMediaType(String value) {
         return MediaTypeHeaderProvider.valueOf(value);
     }

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Thu
Apr  4 08:42:42 2013
@@ -143,7 +143,7 @@ public abstract class AbstractClient imp
      */
     public Client accept(MediaType... types) {
         for (MediaType mt : types) {
-            possiblyAddHeader(HttpHeaders.ACCEPT, mt.toString());
+            possiblyAddHeader(HttpHeaders.ACCEPT, JAXRSUtils.mediaTypeToString(mt));
         }
         return this;
     }
@@ -152,7 +152,7 @@ public abstract class AbstractClient imp
      * {@inheritDoc}
      */
     public Client type(MediaType ct) {
-        return type(ct.toString());
+        return type(JAXRSUtils.mediaTypeToString(ct));
     }
     
     /**
@@ -709,7 +709,7 @@ public abstract class AbstractClient imp
             new org.apache.cxf.common.i18n.Message(name, 
                                                    BUNDLE,
                                                    cls,
-                                                   ct.toString());
+                                                   JAXRSUtils.mediaTypeToString(ct));
         LOG.severe(errorMsg.toString());
         if (response == null) {
             throw new ProcessingException(errorMsg.toString(), cause);

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Thu Apr  4 08:42:42 2013
@@ -329,7 +329,7 @@ public class ClientProxyImpl extends Abs
             } else {
                 String cType = ori.getConsumeTypes().isEmpty() 
                     || ori.getConsumeTypes().get(0).equals(MediaType.WILDCARD_TYPE) 
-                    ? MediaType.APPLICATION_XML : ori.getConsumeTypes().get(0).toString();
  
+                    ? MediaType.APPLICATION_XML : JAXRSUtils.mediaTypeToString(ori.getConsumeTypes().get(0));
  
                 headers.putSingle(HttpHeaders.CONTENT_TYPE, cType);
             }
         }
@@ -349,7 +349,7 @@ public class ClientProxyImpl extends Abs
             }
             
             for (MediaType mt : accepts) {
-                headers.add(HttpHeaders.ACCEPT, mt.toString());
+                headers.add(HttpHeaders.ACCEPT, JAXRSUtils.mediaTypeToString(mt));
             }
         }
             

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1464355&r1=1464354&r2=1464355&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Thu Apr
 4 08:42:42 2013
@@ -929,7 +929,7 @@ public class WebClient extends AbstractC
         
         if (responseClass != null && responseClass != Response.class 
             && headers.getFirst(HttpHeaders.ACCEPT) == null) {
-            headers.putSingle(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_TYPE.toString());
+            headers.putSingle(HttpHeaders.ACCEPT, JAXRSUtils.mediaTypeToString(MediaType.APPLICATION_XML_TYPE));
         }
         return headers;
     }



Mime
View raw message