You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2016/11/02 10:11:40 UTC

svn commit: r1767625 - in /qpid/java/branches/6.1.x: ./ broker-core/src/main/java/org/apache/qpid/server/model/ broker-core/src/main/java/org/apache/qpid/server/virtualhost/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management...

Author: rgodfrey
Date: Wed Nov  2 10:11:40 2016
New Revision: 1767625

URL: http://svn.apache.org/viewvc?rev=1767625&view=rev
Log:
QPID-7469 : Merged from trunk with command svn merge -c 1766666,1767514 ^/qpid/java/trunk .

Modified:
    qpid/java/branches/6.1.x/   (props changed)
    qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/ManageableMessage.java
    qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
    qpid/java/branches/6.1.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java

Propchange: qpid/java/branches/6.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov  2 10:11:40 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1766544,1766547,1766553,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767329,1767332
+/qpid/java/trunk:1766544,1766547,1766553,1766666,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767329,1767332,1767514
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/ManageableMessage.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/ManageableMessage.java?rev=1767625&r1=1767624&r2=1767625&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/ManageableMessage.java (original)
+++ qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/ManageableMessage.java Wed Nov  2 10:11:40 2016
@@ -51,4 +51,6 @@ public interface ManageableMessage exten
     Map<String,Object> getHeaders();
 
     Object getContent();
+
+    String getContentTransferEncoding();
 }

Modified: qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1767625&r1=1767624&r2=1767625&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java (original)
+++ qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java Wed Nov  2 10:11:40 2016
@@ -38,6 +38,7 @@ import java.security.AccessControlContex
 import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
@@ -718,25 +719,43 @@ public abstract class AbstractVirtualHos
         {
             if(messageContent instanceof Map || messageContent instanceof List)
             {
+                if(message.getMimeType() != null || message.getEncoding() != null)
+                {
+                    throw new IllegalArgumentException("If the message content is provided as map or list, the mime type and encoding must be left unset");
+                }
                 body = (Serializable)messageContent;
             }
             else if(messageContent instanceof String)
             {
-                if(message.getMimeType() != null || message.getEncoding() != null)
+                String contentTransferEncoding = message.getContentTransferEncoding();
+                if("base64".equalsIgnoreCase(contentTransferEncoding))
                 {
-                    try
-                    {
-                        body = Strings.decodeBase64((String) messageContent);
-
-                    }
-                    catch(IllegalArgumentException e)
+                    body = Strings.decodeBase64((String) messageContent);
+                }
+                else if(contentTransferEncoding == null || contentTransferEncoding.trim().equals("") || contentTransferEncoding.trim().equalsIgnoreCase("identity"))
+                {
+                    String mimeType = message.getMimeType();
+                    if(mimeType != null && !(mimeType = mimeType.trim().toLowerCase()).equals(""))
                     {
-                        body = (String) messageContent;
+                        if (!(mimeType.startsWith("text/") || Arrays.asList("application/json", "application/xml")
+                                                                    .contains(mimeType)))
+                        {
+                            throw new IllegalArgumentException(message.getMimeType()
+                                                               + " is invalid as a MIME type for this message. "
+                                                               + "Only MIME types of the text type can be used if a string is supplied as the content");
+                        }
+                        else if (mimeType.matches(".*;\\s*charset\\s*=.*"))
+                        {
+                            throw new IllegalArgumentException(message.getMimeType()
+                                                               + " is invalid as a MIME type for this message. "
+                                                               + "If a string is supplied as the content, the MIME type must not include a charset parameter");
+                        }
                     }
+                    body = (String) messageContent;
                 }
                 else
                 {
-                    body = (String) messageContent;
+                    throw new IllegalArgumentException("contentTransferEncoding value '" + contentTransferEncoding + "' is invalid.  The only valid values are base64 and identity");
                 }
             }
             else

Modified: qpid/java/branches/6.1.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1767625&r1=1767624&r2=1767625&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java (original)
+++ qpid/java/branches/6.1.x/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java Wed Nov  2 10:11:40 2016
@@ -43,7 +43,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.Part;
 
-import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.Joiner;
 import com.google.common.base.Predicate;
@@ -1021,7 +1021,15 @@ public class RestServlet extends Abstrac
             {
                 if ("data".equals(part.getName()) && "application/json".equals(part.getContentType()))
                 {
-                    providedObject = (T) mapper.readValue(part.getInputStream(), LinkedHashMap.class);
+                    try
+                    {
+                        providedObject = (T) mapper.readValue(part.getInputStream(), LinkedHashMap.class);
+                    }
+                    catch (JsonProcessingException e)
+                    {
+                        throw new IllegalArgumentException("Cannot parse the operation body as json",e);
+                    }
+
                 }
                 else
                 {
@@ -1039,7 +1047,7 @@ public class RestServlet extends Abstrac
             {
                 providedObject = mapper.readValue(request.getInputStream(), expectedClass);
             }
-            catch (JsonParseException e)
+            catch (JsonProcessingException e)
             {
                 throw new IllegalArgumentException("Cannot parse the operation body as json",e);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org