forked from wso2/wso2-axis2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
erandasooriyabandara
committed
Feb 3, 2014
1 parent
8479869
commit 43e269f
Showing
373 changed files
with
40,025 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.axis2</groupId> | ||
<artifactId>axis2-parent</artifactId> | ||
<version>1.6.1-wso2v11-SNAPSHOT</version> | ||
<relativePath>../../parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<groupId>org.apache.axis2</groupId> | ||
<artifactId>axis2-transport-base</artifactId> | ||
<name>Apache Axis2 - Transport - Base</name> | ||
<description>Apache Axis2 - Base Transport</description> | ||
<packaging>bundle</packaging> | ||
|
||
<scm> | ||
<connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/base</connection> | ||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/transports/trunk/modules/base</developerConnection> | ||
<url>http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/base</url> | ||
</scm> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>1.4.0</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<Bundle-Name>${project.artifactId}</Bundle-Name> | ||
<Bundle-Vendor>Apache Software Foundation</Bundle-Vendor> | ||
<Bundle-Description>${project.description}</Bundle-Description> | ||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> | ||
<Export-Package> | ||
org.apache.axis2.transport.base.*;-split-package:=merge-last, | ||
org.apache.axis2.format.*;-split-package:=merge-last, | ||
</Export-Package> | ||
<Import-Package> | ||
!javax.xml.namespace, | ||
javax.xml.namespace; version=0.0.0, | ||
*;resolution:=optional, | ||
</Import-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- Axis2 --> | ||
<dependency> | ||
<groupId>org.apache.axis2</groupId> | ||
<artifactId>axis2-kernel</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>logkit</groupId> | ||
<artifactId>logkit</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>avalon-framework</groupId> | ||
<artifactId>avalon-framework</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>xmlunit</groupId> | ||
<artifactId>xmlunit</artifactId> | ||
<version>1.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>wso2-nexus</id> | ||
<name>WSO2 internal Repository</name> | ||
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>daily</updatePolicy> | ||
<checksumPolicy>fail</checksumPolicy> | ||
</releases> | ||
</repository> | ||
</repositories> | ||
</project> |
78 changes: 78 additions & 0 deletions
78
modules/transport/base/src/main/java/org/apache/axis2/format/BinaryBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.axis2.format; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import javax.activation.DataHandler; | ||
import javax.activation.DataSource; | ||
import javax.xml.namespace.QName; | ||
|
||
import org.apache.axiom.attachments.ByteArrayDataSource; | ||
import org.apache.axiom.om.OMAbstractFactory; | ||
import org.apache.axiom.om.OMElement; | ||
import org.apache.axiom.om.OMFactory; | ||
import org.apache.axis2.AxisFault; | ||
import org.apache.axis2.context.MessageContext; | ||
import org.apache.axis2.description.Parameter; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.axis2.transport.base.BaseConstants; | ||
import org.apache.axis2.transport.base.BaseUtils; | ||
|
||
/** | ||
* Message builder for binary payloads. | ||
* <p> | ||
* This builder processes the input message as binary and wraps | ||
* the data in a wrapper element. The name of the wrapper element can | ||
* be configured as a service parameter (see {@link BaseConstants#WRAPPER_PARAM}). | ||
* It defaults to {@link BaseConstants#DEFAULT_BINARY_WRAPPER}. | ||
*/ | ||
public class BinaryBuilder implements DataSourceMessageBuilder { | ||
public OMElement processDocument(DataSource dataSource, | ||
String contentType, | ||
MessageContext msgContext) throws AxisFault { | ||
QName wrapperQName = BaseConstants.DEFAULT_BINARY_WRAPPER; | ||
if (msgContext.getAxisService() != null) { | ||
Parameter wrapperParam = msgContext.getAxisService().getParameter(BaseConstants.WRAPPER_PARAM); | ||
if (wrapperParam != null) { | ||
wrapperQName = BaseUtils.getQNameFromString(wrapperParam.getValue()); | ||
} | ||
} | ||
OMFactory factory = OMAbstractFactory.getOMFactory(); | ||
OMElement wrapper = factory.createOMElement(wrapperQName, null); | ||
DataHandler dataHandler = new DataHandler(dataSource); | ||
wrapper.addChild(factory.createOMText(dataHandler, true)); | ||
msgContext.setDoingMTOM(true); | ||
return wrapper; | ||
} | ||
|
||
public OMElement processDocument(InputStream inputStream, | ||
String contentType, | ||
MessageContext msgContext) throws AxisFault { | ||
// TODO: this could be further optimized by deferring the read operation | ||
byte[] msgBytes; | ||
try { | ||
msgBytes = IOUtils.toByteArray(inputStream); | ||
} catch (IOException ex) { | ||
throw new AxisFault("Unable to read message payload", ex); | ||
} | ||
return processDocument(new ByteArrayDataSource(msgBytes), contentType, msgContext); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
modules/transport/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.axis2.format; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.net.URL; | ||
|
||
import javax.activation.DataHandler; | ||
import javax.activation.DataSource; | ||
|
||
import org.apache.axiom.om.OMElement; | ||
import org.apache.axiom.om.OMNode; | ||
import org.apache.axiom.om.OMOutputFormat; | ||
import org.apache.axiom.om.OMText; | ||
import org.apache.axis2.AxisFault; | ||
import org.apache.axis2.context.MessageContext; | ||
import org.apache.axis2.transport.http.util.URLTemplatingUtil; | ||
import org.apache.axis2.transport.base.BaseConstants; | ||
|
||
public class BinaryFormatter implements MessageFormatterEx { | ||
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
writeTo(messageContext, format, baos, true); | ||
return baos.toByteArray(); | ||
} | ||
|
||
private DataHandler getDataHandler(MessageContext messageContext) { | ||
OMElement firstChild = messageContext.getEnvelope().getBody().getFirstElement(); | ||
if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) { | ||
OMNode omNode = firstChild.getFirstOMChild(); | ||
if (omNode != null && omNode instanceof OMText) { | ||
Object dh = ((OMText)omNode).getDataHandler(); | ||
if (dh != null && dh instanceof DataHandler) { | ||
return (DataHandler)dh; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public void writeTo(MessageContext messageContext, OMOutputFormat format, | ||
OutputStream outputStream, boolean preserve) throws AxisFault { | ||
DataHandler dh = getDataHandler(messageContext); | ||
if (dh != null) { | ||
try { | ||
dh.writeTo(outputStream); | ||
} catch (IOException e) { | ||
throw new AxisFault("Error serializing binary content of element : " + | ||
BaseConstants.DEFAULT_BINARY_WRAPPER, e); | ||
} | ||
} | ||
} | ||
|
||
public String getContentType(MessageContext messageContext, | ||
OMOutputFormat format, String soapAction) { | ||
DataHandler dh = getDataHandler(messageContext); | ||
if (dh != null) { | ||
return dh.getContentType(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public URL getTargetAddress(MessageContext messageContext, | ||
OMOutputFormat format, URL targetURL) throws AxisFault { | ||
return URLTemplatingUtil.getTemplatedURL(targetURL, messageContext, false); | ||
} | ||
|
||
public String formatSOAPAction(MessageContext messageContext, | ||
OMOutputFormat format, String soapAction) { | ||
return null; | ||
} | ||
|
||
public DataSource getDataSource(MessageContext messageContext, | ||
OMOutputFormat format, String soapAction) throws AxisFault { | ||
return getDataHandler(messageContext).getDataSource(); | ||
} | ||
} |
Oops, something went wrong.