Mentions légales du service

Skip to content
Snippets Groups Projects
Commit d75e813e authored by Gabriel Landais's avatar Gabriel Landais
Browse files

Better message UI

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@20797 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 4a5a1534
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,8 @@ public abstract class AbstractMessage {
protected static final Charset UTF_8 = Charset.forName("UTF-8");
// private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(AbstractMessage.class);
// private static org.apache.log4j.Logger log =
// org.apache.log4j.Logger.getLogger(AbstractMessage.class);
@Id
@Column(name = "id", unique = true, nullable = false)
......@@ -103,6 +104,10 @@ public abstract class AbstractMessage {
return new String(messageReceived, UTF_8);
}
public int getMessageLength() {
return messageReceived.length;
}
public void setMessageReceivedAsString(String messageReceived) {
this.messageReceived = messageReceived.getBytes(UTF_8);
}
......
......@@ -11,7 +11,9 @@ import javax.servlet.http.HttpServletResponse;
import net.ihe.gazelle.proxy.enums.ChannelType;
import net.ihe.gazelle.proxy.model.message.AbstractMessage;
import net.ihe.gazelle.proxy.model.message.HL7Message;
import net.ihe.gazelle.proxy.model.message.HTTPMessage;
import net.ihe.gazelle.proxy.model.message.SyslogMessage;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringEscapeUtils;
......@@ -104,7 +106,7 @@ public class MessageBean {
HttpServletResponse response = (HttpServletResponse) extCtx.getResponse();
byte[] bytes = ArrayUtils.clone(message.getMessageReceived());
ServletOutputStream servletOutputStream = response.getOutputStream();
response.setContentType("application/octet-stream");
response.setContentType("text/plain");
response.setContentLength(bytes.length);
if (!inline) {
response.setHeader("Content-Disposition", "attachment;filename=\"" + message.getId() + "\"");
......@@ -121,7 +123,7 @@ public class MessageBean {
public Boolean shouldDisplayMessageContent() {
if (message instanceof HTTPMessage) {
HTTPMessage httpMessage = (HTTPMessage) message;
if (httpMessage == null || httpMessage.getMessageReceived() == null)
if (httpMessage.getMessageReceived() == null)
return false;
String messageType = httpMessage.getMessageType();
......@@ -134,6 +136,11 @@ public class MessageBean {
return true;
}
}
if (message instanceof SyslogMessage || message instanceof HL7Message) {
if (message.getMessageLength() > 0) {
return true;
}
}
return false;
}
......
......@@ -12,4 +12,12 @@
<h:commandLink action="#{messageBean.downloadFile(true)}"
rendered="#{messageBean.isDownloadable()}" value="View inline"
target="_blank" />
<rich:spacer height="10" />
<div style="font-family: monospace;"><rich:insert
rendered="#{messageBean.shouldDisplayMessageContent()}"
content="#{messageBean.message.getMessageReceivedAsString()}"
highlight="xml" /></div>
</ui:composition>
\ No newline at end of file
......@@ -31,4 +31,14 @@
<h:outputText value="Responder Port :" style="font-weight:bold;" />
<h:outputText value="#{messageBean.message.remotePort}" />
<h:outputText value="Side :" style="font-weight:bold;" />
<h:graphicImage value="/img/request.png"
rendered="#{messageBean.message.proxySide.isRequest()}" />
<h:graphicImage value="/img/response.png"
rendered="#{not messageBean.message.proxySide.isRequest()}" />
<h:outputText value="Message length :" style="font-weight:bold;" />
<h:outputText value="#{messageBean.message.getMessageLength()}" />
</ui:composition>
\ No newline at end of file
......@@ -41,13 +41,6 @@
</h:panelGrid>
<ui:include src="commonDownload.xhtml" />
<rich:spacer height="10" />
<div style="font-family: monospace;"><rich:insert
rendered="#{messageBean.shouldDisplayMessageContent()}"
content="#{messageBean.message.getMessageReceivedAsString()}"
highlight="xml" /></div>
</h:form>
</ui:define>
</ui:composition>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment