You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2016/09/02 15:38:23 UTC
svn commit: r1758980 - in /qpid/java/trunk:
broker-core/src/main/java/org/apache/qpid/server/queue/
broker-plugins/management-http/src/main/java/resources/
broker-plugins/management-http/src/main/java/resources/js/qpid/management/
Author: lquack
Date: Fri Sep 2 15:38:23 2016
New Revision: 1758980
URL: http://svn.apache.org/viewvc?rev=1758980&view=rev
Log:
QPID-7382: [Java Broker, WMC] Add Content-Disposition to Message download
also address Alex's other review comments:
* make content dialogue use 100% width
* move preview markup code from javascript to html
Modified:
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/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/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=1758980&r1=1758979&r2=1758980&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 Fri Sep 2 15:38:23 2016
@@ -20,6 +20,9 @@ package org.apache.qpid.server.queue;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.security.AccessControlContext;
import java.security.AccessControlException;
import java.security.AccessController;
@@ -126,6 +129,7 @@ public abstract class AbstractQueue<X ex
};
private static final long INITIAL_TARGET_QUEUE_SIZE = 102400l;
+ private static final String UTF8 = StandardCharsets.UTF_8.name();
private final VirtualHost<?> _virtualHost;
private final DeletedChildListener _deletedChildListener = new DeletedChildListener();
@@ -2678,14 +2682,13 @@ public abstract class AbstractQueue<X ex
}
}
- public static class MessageContent implements Content, CustomRestHeaders
+ class MessageContent implements Content, CustomRestHeaders
{
-
- public static final int UNLIMITED = -1;
+ private static final int UNLIMITED = -1;
private final MessageReference<?> _messageReference;
private final long _limit;
- public MessageContent(MessageReference<?> messageReference, long limit)
+ MessageContent(MessageReference<?> messageReference, long limit)
{
_messageReference = messageReference;
_limit = (limit == UNLIMITED ? messageReference.getMessage().getSize() : limit);
@@ -2723,18 +2726,37 @@ public abstract class AbstractQueue<X ex
_messageReference.release();
}
+ @SuppressWarnings("unused")
@RestContentHeader("Content-Type")
public String getContentType()
{
return _messageReference.getMessage().getMessageHeader().getMimeType();
}
+ @SuppressWarnings("unused")
@RestContentHeader("Content-Encoding")
public String getContentEncoding()
{
return _messageReference.getMessage().getMessageHeader().getEncoding();
}
+ @SuppressWarnings("unused")
+ @RestContentHeader("Content-Disposition")
+ public String getContentDisposition()
+ {
+ try
+ {
+ String disposition = String.format("attachment; filename=\"%s_msg%09d%s\"",
+ URLEncoder.encode(getName(), UTF8),
+ _messageReference.getMessage().getMessageNumber(),
+ getContentType().startsWith("text") ? ".txt" : "");
+ return disposition;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("JVM does not support UTF8", e);
+ }
+ }
}
private static class AcquireAllQueueEntryFilter implements QueueEntryFilter
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=1758980&r1=1758979&r2=1758980&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 Fri Sep 2 15:38:23 2016
@@ -139,8 +139,6 @@ define(["dojo/dom",
}
}
}
- var contentField = query(".message-content", this.dialogNode)[0];
- populatedFields.push(contentField);
var contentModelObj = {
name: "getMessageContent",
@@ -149,27 +147,24 @@ define(["dojo/dom",
};
var parameters = {messageId: data.id};
var url = management.buildObjectURL(contentModelObj, parameters);
- contentField.innerHTML = '<a href="#" title="' + url + '">Download</a><br/><div id="preview"></div>';
- var href = query('a', contentField)[0]
+ var href = query('a#message-download', this.dialogNode)[0];
+ href.title = url;
connect.connect(href, 'onclick', function ()
{
management.download(contentModelObj, parameters);
});
+ var preview = query('#preview', this.dialogNode)[0];
if (data.mimeType && data.mimeType.match(/text\/.*/))
{
var limit = 1024;
- var preview = query('#preview', contentField)[0];
- preview.innerHTML = 'Preview'
- + (limit < data.size
- ? ' (showing the first ' + limit + ' of ' + data.size + ' bytes)'
- : ' (showing all ' + data.size + ' bytes)')
- + ':<br/>'
- + '<div class="fillRemaining">'
- + '<textarea id="previewContent" readonly rows="5" style="width: 100%"></textarea>'
- + '</div>';
- var previewContent = query("#previewContent", preview)[0];
+ 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",
@@ -184,6 +179,7 @@ define(["dojo/dom",
}
else
{
+ preview.style.display = "none";
registry.byId("showMessage")
.show();
}
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=1758980&r1=1758979&r2=1758980&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 Fri Sep 2 15:38:23 2016
@@ -18,7 +18,7 @@
<div class="dijitHidden">
<div data-dojo-type="dijit.Dialog" style="width:600px;" data-dojo-props="title:'View Message'" id="showMessage">
- <table style="border: 0;">
+ <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>
@@ -78,7 +78,12 @@
<tr style="margin-bottom: 4pt">
<td style="width: 10em; vertical-align: top"><span style="font-weight: bold;">Content:</span></td>
- <td><div class="message-content"></div></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>
+ </div>
+ </td>
</tr>
</table>
<br/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org