qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1759209 - in /qpid/java/trunk: broker-core/src/main/java/org/apache/qpid/server/model/ broker-core/src/main/java/org/apache/qpid/server/queue/ broker-plugins/management-http/src/main/java/resources/ broker-plugins/management-http/src/main/...
Date Mon, 05 Sep 2016 08:43:06 GMT
Author: kwall
Date: Mon Sep  5 08:43:06 2016
New Revision: 1759209

URL: http://svn.apache.org/viewvc?rev=1759209&view=rev
Log:
QPID-7380: [Java Broker] Allow non-confidential message info to be viewed from management.

Modified:
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/showMessage.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showMessage.html

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java (original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/Queue.java Mon
Sep  5 08:43:06 2016
@@ -298,11 +298,14 @@ public interface Queue<X extends Queue<X
     Content getMessageContent(@Param(name = "messageId") long messageId,
                               @Param(name = "limit", defaultValue = "-1", description = "Number
of bytes to return") long limit);
 
-    @ManagedOperation(nonModifying = true, secure = true)
-    List<MessageInfo> getMessageInfo(@Param(name = "first", defaultValue = "-1") int
first, @Param(name = "last", defaultValue = "-1") int last);
+    @ManagedOperation(nonModifying = true, paramRequiringSecure = "includeHeaders")
+    List<MessageInfo> getMessageInfo(@Param(name = "first", defaultValue = "-1") int
first,
+                                     @Param(name = "last",  defaultValue = "-1") int last,
+                                     @Param(name = "includeHeaders", defaultValue = "false")
boolean includeHeaders);
 
-    @ManagedOperation(nonModifying = true, secure = true)
-    MessageInfo getMessageInfoById(@Param(name = "messageId") long messageId);
+    @ManagedOperation(nonModifying = true, paramRequiringSecure = "includeHeaders")
+    MessageInfo getMessageInfoById(@Param(name = "messageId") long messageId,
+                                   @Param(name = "includeHeaders", defaultValue = "true")
boolean includeHeaders);
 
     boolean isExclusive();
 

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
Mon Sep  5 08:43:06 2016
@@ -3538,18 +3538,18 @@ public abstract class AbstractQueue<X ex
     }
 
     @Override
-    public List<MessageInfo> getMessageInfo(int first, int last)
+    public List<MessageInfo> getMessageInfo(int first, int last, boolean includeHeaders)
     {
-        final MessageCollector messageCollector = new MessageCollector(first, last, false);
+        final MessageCollector messageCollector = new MessageCollector(first, last, includeHeaders);
         visit(messageCollector);
         return messageCollector.getMessages();
 
     }
 
     @Override
-    public MessageInfo getMessageInfoById(final long messageId)
+    public MessageInfo getMessageInfoById(final long messageId, boolean includeHeaders)
     {
-        final MessageFinder messageFinder = new MessageFinder(messageId);
+        final MessageFinder messageFinder = new MessageFinder(messageId, includeHeaders);
         visit(messageFinder);
         return messageFinder.getMessageInfo();
     }
@@ -3557,11 +3557,13 @@ public abstract class AbstractQueue<X ex
     private class MessageFinder implements QueueEntryVisitor
     {
         private final long _messageNumber;
+        private final boolean _includeHeaders;
         private MessageInfo _messageInfo;
 
-        private MessageFinder(long messageNumber)
+        private MessageFinder(long messageNumber, final boolean includeHeaders)
         {
             _messageNumber = messageNumber;
+            _includeHeaders = includeHeaders;
         }
 
         @Override
@@ -3572,7 +3574,7 @@ public abstract class AbstractQueue<X ex
             {
                 if (_messageNumber == message.getMessageNumber())
                 {
-                    _messageInfo = new MessageInfoImpl(entry, true);
+                    _messageInfo = new MessageInfoImpl(entry, _includeHeaders);
                 }
             }
             return false;

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/JsonRest.js
Mon Sep  5 08:43:06 2016
@@ -31,6 +31,7 @@ define(["dojo/_base/lang", "dojo/json",
             queryOperation: null,
             modelObject: null,
             management: null,
+            queryParams: null,
 
             constructor: function (options)
             {
@@ -38,6 +39,7 @@ define(["dojo/_base/lang", "dojo/json",
                 this.management = options.management;
                 this.modelObject = options.modelObject;
                 this.queryOperation = options.queryOperation;
+                this.queryParams = options.queryParams;
                 declare.safeMixin(this, options);
             },
 
@@ -48,7 +50,7 @@ define(["dojo/_base/lang", "dojo/json",
 
             query: function (query, options)
             {
-                query = query || {};
+                query = lang.mixin(query || {}, this.queryParams);
                 options = options || {};
                 var headers = lang.mixin({Accept: this.accepts}, this.headers, options.headers);
 

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
Mon Sep  5 08:43:06 2016
@@ -108,7 +108,8 @@ define(["dojo/_base/declare",
                     var myStore = new JsonRest({
                         management: that.management,
                         modelObject: that.modelObj,
-                        queryOperation: "getMessageInfo"
+                        queryOperation: "getMessageInfo",
+                        queryParams : {includeHeaders: false}
                     });
                     var messageGridDiv = query(".messages", contentPane.containerNode)[0];
                     that.dataStore = new ObjectStore({objectStore: myStore});

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js
Mon Sep  5 08:43:06 2016
@@ -29,7 +29,6 @@ define(["dojo/parser",
         "qpid/common/util",
         "qpid/common/formatter",
         "qpid/common/UpdatableStore",
-        "dojo/store/JsonRest",
         "dojox/grid/EnhancedGrid",
         "dojo/data/ObjectStore",
         "qpid/management/group/addGroupMember",
@@ -49,7 +48,6 @@ define(["dojo/parser",
               util,
               formatter,
               UpdatableStore,
-              JsonRest,
               EnhancedGrid,
               ObjectStore,
               addGroupMember,

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/showMessage.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/showMessage.js?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/showMessage.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/showMessage.js
Mon Sep  5 08:43:06 2016
@@ -84,7 +84,7 @@ define(["dojo/dom",
 
         };
 
-        showMessage.populateShowMessage = function (management, modelObj, data)
+        showMessage.populateShowMessage = function (management, modelObj, data, includesConfidential)
         {
 
             // clear fields set by previous invocation.
@@ -140,61 +140,103 @@ define(["dojo/dom",
                 }
             }
 
-            var contentModelObj = {
-                name: "getMessageContent",
-                parent: modelObj,
-                type: modelObj.type
-            };
-            var parameters = {messageId: data.id};
-            var url = management.buildObjectURL(contentModelObj, parameters);
-
-            var href = query('a#message-download', this.dialogNode)[0];
-            href.title = url;
-            connect.connect(href, 'onclick', function ()
+            var preview = query('#preview', this.dialogNode)[0];
+            var confidentialInformationWarning = query('#confidentialInformationWarning',
this.dialogNode)[0];
+            confidentialInformationWarning.style.display = includesConfidential ? "none"
: "block";
+            var confidentialCells = query('.confidential', this.dialogNode);
+            for(var i = 0; i < confidentialCells.length; i++)
+            {
+                confidentialCells[i].style.display = includesConfidential ?  "block" : "none";
+            }
+            var confidentialPlaceholderCells = query('.confidentialPlaceholder', this.dialogNode);
+            for(var i = 0; i < confidentialPlaceholderCells.length; i++)
             {
-                management.download(contentModelObj, parameters);
-            });
+                confidentialPlaceholderCells[i].style.display = includesConfidential ?  "none"
: "block";
+            }
 
-            var preview = query('#preview', this.dialogNode)[0];
-            if (data.mimeType && data.mimeType.match(/text\/.*/))
+            if (includesConfidential)
             {
-                var limit = 1024;
-                preview.style.display = "block";
-                var previewDetail = query('#preview-detail', preview)[0];
-                previewDetail.innerHTML = (limit < data.size
-                    ? 'showing the first ' + limit + ' of ' + data.size + ' bytes'
-                    : 'showing all ' + data.size + ' bytes');
-                var previewContent = query("#message-content-preview", preview)[0];
-                var previewParameters = lang.mixin({limit: limit}, parameters);
-                management.load(contentModelObj, previewParameters, {
-                        handleAs: "text",
-                        headers: {"Content-Type": data.mimeType}
-                    })
-                    .then(function (content)
-                    {
-                        previewContent.innerHTML = encode(content);
-                        registry.byId("showMessage")
-                            .show();
-                    });
+                var contentModelObj = {
+                    name: "getMessageContent",
+                    parent: modelObj,
+                    type: modelObj.type
+                };
+                var parameters = {messageId: data.id};
+                var url = management.buildObjectURL(contentModelObj, parameters);
+
+                var href = query('a#message-download', this.dialogNode)[0];
+                href.title = url;
+                connect.connect(href, 'onclick', function ()
+                {
+                    management.download(contentModelObj, parameters);
+                });
+
+                if (data.mimeType && data.mimeType.match(/text\/.*/))
+                {
+                    var limit = 1024;
+                    preview.style.display = "block";
+                    var previewDetail = query('#preview-detail', preview)[0];
+                    previewDetail.innerHTML = (limit < data.size
+                        ? 'showing the first ' + limit + ' of ' + data.size + ' bytes'
+                        : 'showing all ' + data.size + ' bytes');
+                    var previewContent = query("#message-content-preview", preview)[0];
+                    var previewParameters = lang.mixin({limit: limit}, parameters);
+                    management.load(contentModelObj, previewParameters, {
+                            handleAs: "text",
+                            headers: {"Content-Type": data.mimeType}
+                        })
+                        .then(function (content)
+                        {
+                            previewContent.innerHTML = encode(content);
+                            registry.byId("showMessage") .show();
+                        });
+                }
+                else
+                {
+                    preview.style.display = "none";
+                    registry.byId("showMessage").show();
+                }
             }
             else
             {
-                preview.style.display = "none";
-                registry.byId("showMessage")
-                    .show();
+                registry.byId("showMessage").show()
             }
         };
 
         showMessage.show = function (management, modelObj, message)
         {
-            management.load({
-                    name: "getMessageInfoById",
-                    parent: modelObj,
-                    type: modelObj.type
-                }, {messageId: message.id})
+            var obj = {
+                name: "getMessageInfoById",
+                parent: modelObj,
+                type: modelObj.type
+            };
+            management.load(obj,
+                {
+                    messageId: message.id,
+                    includeHeaders: true
+                })
                 .then(function (data)
                 {
-                    showMessage.populateShowMessage(management, modelObj, data);
+                    showMessage.populateShowMessage(management, modelObj, data, true);
+                },
+                function(e)
+                {
+                    if (e.response && e.response.status == 403)
+                    {
+                        management.load(obj,
+                                        {
+                                            messageId: message.id,
+                                            includeHeaders: false
+                                        })
+                            .then(function(data)
+                            {
+                                showMessage.populateShowMessage(management, modelObj, data,
false);
+                            });
+                    }
+                    else
+                    {
+                        management.errorHandler(e);
+                    }
                 });
         };
 

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showMessage.html
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showMessage.html?rev=1759209&r1=1759208&r2=1759209&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showMessage.html
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/showMessage.html
Mon Sep  5 08:43:06 2016
@@ -18,7 +18,11 @@
 <div class="dijitHidden">
     <div data-dojo-type="dijit.Dialog" style="width:600px;" data-dojo-props="title:'View
Message'" id="showMessage">
 
-    <table style="border: 0; width: 100%">
+        <div id="confidentialInformationWarning" class="infoMessage">Confidential message
information (headers
+            and content) is not available on an insecure transport. Switch to a secure management
transport (i.e. one
+            that uses HTTPS) to see the message's full details.</div>
+
+        <table style="border: 0; width: 100%">
         <tr style="margin-bottom: 4pt">
             <td style="width: 10em; vertical-align: top"><span style="font-weight:
bold;">Message Number:</span></td>
             <td><span class="message-id"></span></td>
@@ -73,16 +77,24 @@
         </tr>
         <tr style="margin-bottom: 4pt">
             <td style="width: 10em; vertical-align: top"><span style="font-weight:
bold;">Headers:</span></td>
-            <td><div class="message-headers map"></div></td>
+            <td>
+                <div class="message-headers map confidential"></div>
+                <div class="confidentialPlaceholder highlightedText">Not available</div>
+            </td>
         </tr>
 
         <tr style="margin-bottom: 4pt">
             <td style="width: 10em; vertical-align: top"><span style="font-weight:
bold;">Content:</span></td>
-            <td><a href="#" id="message-download">Download</a><br/>
-                <div id="preview" class="fillRemaining">
-                    Preview (<span id="preview-detail"></span>):<br/>
-                    <textarea id="message-content-preview" readonly rows="5" style="width:
100%"></textarea>
+            <td>
+                <div class="confidential">
+                    <a href="#" id="message-download">Download</a>
+                    <br/>
+                    <div id="preview" class="fillRemaining">
+                        Preview (<span id="preview-detail"></span>):<br/>
+                        <textarea id="message-content-preview" readonly rows="5" style="width:
100%"></textarea>
+                    </div>
                 </div>
+                <div class="confidentialPlaceholder highlightedText">Not available</div>
             </td>
         </tr>
     </table>



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


Mime
View raw message