[jboss-svn-commits] JBL Code SVN: r37470 - in labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss: soa/esb/listeners/gateway and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Sep 16 14:09:13 EDT 2011
Author: tcunning
Date: 2011-09-16 14:09:12 -0400 (Fri, 16 Sep 2011)
New Revision: 37470
Modified:
labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpMarshaller.java
labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/JBossRemotingUtil.java
labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
Log:
JBESB-3685
Checking in Kevin's patch to correct content-type with respect to JBoss Remoting.
Modified: labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpMarshaller.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpMarshaller.java 2011-09-15 19:58:56 UTC (rev 37469)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpMarshaller.java 2011-09-16 18:09:12 UTC (rev 37470)
@@ -44,6 +44,7 @@
Object result = ((InvocationResponse)object).getResult();
InvocationRequest currentRequest = JBossRemotingGatewayListener.getCurrentRequest();
boolean sendJavaResponse = false;
+ String contentType = null ;
if(result != null && currentRequest != null) {
Map requestMetadata = currentRequest.getRequestPayload();
@@ -51,6 +52,7 @@
String userAgent = (String) requestMetadata.get(HTTPMetadataConstants.REMOTING_USER_AGENT);
sendJavaResponse = JBossRemotingUtil.sendJavaObjectPayload(responseMetadata, userAgent);
+ contentType = JBossRemotingUtil.getContentType(responseMetadata) ;
}
if(!sendJavaResponse) {
@@ -60,6 +62,14 @@
if(result instanceof byte[]) {
outputStream.write((byte[])result);
outputStream.flush();
+ } else if(result instanceof String) {
+ final String charsetName = JBossRemotingUtil.getCharsetName(contentType) ;
+ if (charsetName == null) {
+ outputStream.write(((String) result).getBytes());
+ } else {
+ outputStream.write(((String) result).getBytes(charsetName));
+ }
+ outputStream.flush();
} else {
// Going to rely on the base class to encode it anyway because
// we don't know....
Modified: labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/JBossRemotingUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/JBossRemotingUtil.java 2011-09-15 19:58:56 UTC (rev 37469)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/internal/soa/esb/remoting/JBossRemotingUtil.java 2011-09-16 18:09:12 UTC (rev 37470)
@@ -34,6 +34,8 @@
*/
public class JBossRemotingUtil {
+ private static final String CHARSET = "charset=" ;
+
/**
* Check if the server should expect a Java Object payload.
* <p/>
@@ -101,4 +103,30 @@
return (String) value;
}
+
+ /**
+ * Get the charset name from the specified content type..
+ * @param contentType The content type.
+ * @return The charset, if specified, otherwise null.
+ */
+ public static String getCharsetName(final String contentType) {
+ if (contentType != null) {
+ final int charsetIndex = contentType.indexOf(CHARSET) ;
+ if (charsetIndex >= 0) {
+ final int start = charsetIndex + CHARSET.length() ;
+ final int length = contentType.length() ;
+ if (start <= length) {
+ final String charsetName ;
+ final int end = contentType.indexOf(';', start) ;
+ if (end >= 0) {
+ charsetName = contentType.substring(start, end).trim() ;
+ } else {
+ charsetName = contentType.substring(start).trim() ;
+ }
+ return (charsetName.length() == 0 ? null : charsetName) ;
+ }
+ }
+ }
+ return null ;
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java 2011-09-15 19:58:56 UTC (rev 37469)
+++ labs/jbossesb/branches/JBESB_4_10_CP/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java 2011-09-16 18:09:12 UTC (rev 37470)
@@ -22,6 +22,7 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.remoting.HttpMarshaller;
import org.jboss.internal.soa.esb.remoting.HttpUnmarshaller;
+import org.jboss.internal.soa.esb.remoting.JBossRemotingUtil;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
@@ -639,6 +640,12 @@
if(value instanceof ResponseHeader) {
// JBESB-2511
ResponseHeader header = (ResponseHeader)value;
+ if ("content-type".equalsIgnoreCase(header.getName())) {
+ final String userAgent = (String) responseMap.get(HTTPMetadataConstants.REMOTING_USER_AGENT);
+ if (JBossRemotingUtil.sendJavaObjectPayload(responseMap, userAgent)) {
+ continue ;
+ }
+ }
header.putNameValue(responseMap);
}
// JBESB-2761
More information about the jboss-svn-commits
mailing list