You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2016/02/25 19:53:47 UTC
svn commit: r1732342 -
/axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java
Author: veithen
Date: Thu Feb 25 18:53:47 2016
New Revision: 1732342
URL: http://svn.apache.org/viewvc?rev=1732342&view=rev
Log:
Normalize whitespace.
Modified:
axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java
Modified: axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java?rev=1732342&r1=1732341&r2=1732342&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java (original)
+++ axis/axis2/java/core/trunk/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java Thu Feb 25 18:53:47 2016
@@ -39,133 +39,133 @@ import java.util.Iterator;
public class FastInfosetMessageFormatter implements MessageFormatter {
- private static Log logger = LogFactory.getLog(FastInfosetMessageFormatter.class);
-
- /**
- * Fast Infoset message formatter doesn't need to handle SOAP. Hence do nothing.
- *
- * @see org.apache.axis2.transport.MessageFormatter#formatSOAPAction(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
- */
- public String formatSOAPAction(MessageContext messageContext,
- OMOutputFormat format, String soapAction) {
-
- return null;
- }
-
- /**
- * Retrieves the raw bytes from the SOAP envelop.
- *
- * @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat)
- */
- public byte[] getBytes(MessageContext messageContext, OMOutputFormat format)
- throws AxisFault {
- OMElement element = messageContext.getEnvelope();
- ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-
- try {
- //Creates StAX document serializer which actually implements the XMLStreamWriter
- XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
- element.serializeAndConsume(streamWriter);
- //TODO Looks like the SOAP envelop doesn't have an end document tag. Find out why?
- streamWriter.writeEndDocument();
-
- return outStream.toByteArray();
-
- } catch (XMLStreamException xmlse) {
- logger.error(xmlse.getMessage());
- throw new AxisFault(xmlse.getMessage(), xmlse);
- }
- }
-
- /**
- * Returns the content type
- *
- * @see org.apache.axis2.transport.MessageFormatter#getContentType(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
- */
- public String getContentType(MessageContext messageContext,
- OMOutputFormat format, String soapAction) {
- String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
- String encoding = format.getCharSetEncoding();
-
- //If the Content Type is not available with the property "Content Type" retrieve it from the property "Message Type"
- if (contentType == null) {
- contentType = (String) messageContext.getProperty(Constants.Configuration.MESSAGE_TYPE);
- }
-
- if (encoding != null) {
- contentType += "; charset=" + encoding;
- }
-
- return contentType;
- }
-
- /**
- * Returns the target address to send the response
- * FIXME This is very HTTP specific. What about other transport?
- *
- * @see org.apache.axis2.transport.MessageFormatter#getTargetAddress(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.net.URL)
- */
- public URL getTargetAddress(MessageContext messageContext,
- OMOutputFormat format, URL targetURL) throws AxisFault {
+ private static Log logger = LogFactory.getLog(FastInfosetMessageFormatter.class);
+
+ /**
+ * Fast Infoset message formatter doesn't need to handle SOAP. Hence do nothing.
+ *
+ * @see org.apache.axis2.transport.MessageFormatter#formatSOAPAction(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
+ */
+ public String formatSOAPAction(MessageContext messageContext,
+ OMOutputFormat format, String soapAction) {
+
+ return null;
+ }
+
+ /**
+ * Retrieves the raw bytes from the SOAP envelop.
+ *
+ * @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat)
+ */
+ public byte[] getBytes(MessageContext messageContext, OMOutputFormat format)
+ throws AxisFault {
+ OMElement element = messageContext.getEnvelope();
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+
+ try {
+ //Creates StAX document serializer which actually implements the XMLStreamWriter
+ XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
+ element.serializeAndConsume(streamWriter);
+ //TODO Looks like the SOAP envelop doesn't have an end document tag. Find out why?
+ streamWriter.writeEndDocument();
+
+ return outStream.toByteArray();
+
+ } catch (XMLStreamException xmlse) {
+ logger.error(xmlse.getMessage());
+ throw new AxisFault(xmlse.getMessage(), xmlse);
+ }
+ }
+
+ /**
+ * Returns the content type
+ *
+ * @see org.apache.axis2.transport.MessageFormatter#getContentType(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
+ */
+ public String getContentType(MessageContext messageContext,
+ OMOutputFormat format, String soapAction) {
+ String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
+ String encoding = format.getCharSetEncoding();
+
+ //If the Content Type is not available with the property "Content Type" retrieve it from the property "Message Type"
+ if (contentType == null) {
+ contentType = (String) messageContext.getProperty(Constants.Configuration.MESSAGE_TYPE);
+ }
+
+ if (encoding != null) {
+ contentType += "; charset=" + encoding;
+ }
+
+ return contentType;
+ }
+
+ /**
+ * Returns the target address to send the response
+ * FIXME This is very HTTP specific. What about other transport?
+ *
+ * @see org.apache.axis2.transport.MessageFormatter#getTargetAddress(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.net.URL)
+ */
+ public URL getTargetAddress(MessageContext messageContext,
+ OMOutputFormat format, URL targetURL) throws AxisFault {
String httpMethod =
(String) messageContext.getProperty(Constants.Configuration.HTTP_METHOD);
URL targetAddress = targetURL; //Let's initialize to this
- //if the http method is GET, parameters are attached to the target URL
- if ((httpMethod != null)
- && Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
- String param = getParam(messageContext);
-
- if (param.length() > 0) {
- String returnURLFile = targetURL.getFile() + "?" + param;
- try {
- targetAddress =
- new URL(targetURL.getProtocol(), targetURL.getHost(), targetURL.getPort(), returnURLFile);
- } catch (MalformedURLException murle) {
- logger.error(murle.getMessage());
- throw new AxisFault(murle.getMessage(), murle);
- }
- }
- }
-
- return targetAddress;
- }
-
- /**
- * Write the SOAP envelop to the given OutputStream.
- *
- * @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean)
- */
- public void writeTo(MessageContext messageContext, OMOutputFormat format,
- OutputStream outputStream, boolean preserve) throws AxisFault {
+ //if the http method is GET, parameters are attached to the target URL
+ if ((httpMethod != null)
+ && Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
+ String param = getParam(messageContext);
+
+ if (param.length() > 0) {
+ String returnURLFile = targetURL.getFile() + "?" + param;
+ try {
+ targetAddress =
+ new URL(targetURL.getProtocol(), targetURL.getHost(), targetURL.getPort(), returnURLFile);
+ } catch (MalformedURLException murle) {
+ logger.error(murle.getMessage());
+ throw new AxisFault(murle.getMessage(), murle);
+ }
+ }
+ }
+
+ return targetAddress;
+ }
+
+ /**
+ * Write the SOAP envelop to the given OutputStream.
+ *
+ * @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean)
+ */
+ public void writeTo(MessageContext messageContext, OMOutputFormat format,
+ OutputStream outputStream, boolean preserve) throws AxisFault {
OMElement element = messageContext.getEnvelope();
-
- try {
- //Create the StAX document serializer
- XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream);
- if (preserve) {
- element.serialize(streamWriter);
- } else {
- element.serializeAndConsume(streamWriter);
- }
-// TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why?
- streamWriter.writeEndDocument();
- } catch (XMLStreamException xmlse) {
- logger.error(xmlse.getMessage());
- throw new AxisFault(xmlse.getMessage(), xmlse);
- }
- }
-
- /**
- * Construct URL parameters like, "param1=value1¶m2=value2"
- * FIXME This is very HTTP specific. What about other transports
- *
- * @param messageContext
- * @return Formatted URL parameters
- */
+
+ try {
+ //Create the StAX document serializer
+ XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream);
+ if (preserve) {
+ element.serialize(streamWriter);
+ } else {
+ element.serializeAndConsume(streamWriter);
+ }
+// TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why?
+ streamWriter.writeEndDocument();
+ } catch (XMLStreamException xmlse) {
+ logger.error(xmlse.getMessage());
+ throw new AxisFault(xmlse.getMessage(), xmlse);
+ }
+ }
+
+ /**
+ * Construct URL parameters like, "param1=value1¶m2=value2"
+ * FIXME This is very HTTP specific. What about other transports
+ *
+ * @param messageContext
+ * @return Formatted URL parameters
+ */
private String getParam(MessageContext messageContext) {
- OMElement dataOut = messageContext.getEnvelope().getBody().getFirstElement();
+ OMElement dataOut = messageContext.getEnvelope().getBody().getFirstElement();
Iterator it = dataOut.getChildElements();
StringBuffer paramBuffer = new StringBuffer();