You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2005/07/11 17:49:55 UTC
svn commit: r210150 [30/35] - in /webservices/axis/trunk/java: ./ etc/
modules/addressing/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/
modules/addressing/test/org/apache/axis2/handlers/addressing/ mod...
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/InterfaceTest.java Mon Jul 11 08:49:30 2005
@@ -22,84 +22,84 @@
import java.util.Iterator;
public class InterfaceTest extends AbstractTestCase {
- public InterfaceTest(String testName) {
- super(testName);
- }
+ public InterfaceTest(String testName) {
+ super(testName);
+ }
- public void testGetAllOperations() {
- WSDLOperation op;
- WSDLInterface intfc;
- WSDLInterface[] array = new WSDLInterface[5];
- int interfaceCounter = 5;
- int operationCounter = 5;
- for (int j = 0; j < interfaceCounter; j++) {
- intfc = new WSDLInterfaceImpl();
- intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE, "inteface"
- + j));
- for (int i = 0; i < operationCounter; i++) {
- op = new WSDLOperationImpl();
- op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op" + i
- + "of inteface" + j));
- assertNotNull(op.getName());
- intfc.setOperation(op);
- }
- if (j > 0) {
- intfc.addSuperInterface(array[j - 1]);
- }
- array[j] = intfc;
- }
- assertEquals(((WSDLOperation) array[0].getOperation("op0of inteface0"))
- .getName().getLocalPart(), "op0of inteface0");
- assertEquals(((WSDLOperation) array[0].getOperation("op1of inteface0"))
- .getName().getLocalPart(), "op1of inteface0");
- assertEquals(array[interfaceCounter - 1].getAllOperations().size(),
- interfaceCounter * operationCounter);
- assertEquals(interfaceCounter * operationCounter,
- array[interfaceCounter - 1].getAllOperations().size());
- Iterator iter = array[1].getAllOperations().keySet().iterator();
- while (iter.hasNext()) {
- assertNotNull(((WSDLOperation) array[interfaceCounter - 1]
- .getAllOperations().get(iter.next())).getName());
- }
- for (int j = 0; j < interfaceCounter; j++) {
- for (int i = 0; i < operationCounter; i++) {
- WSDLOperation operation = (WSDLOperation) array[interfaceCounter - 1]
- .getAllOperations().get("op" + j + "of inteface" + i);
- assertEquals((operation).getName().getLocalPart(), "op" + j
- + "of inteface" + i);
- }
- }
+ public void testGetAllOperations() {
+ WSDLOperation op;
+ WSDLInterface intfc;
+ WSDLInterface[] array = new WSDLInterface[5];
+ int interfaceCounter = 5;
+ int operationCounter = 5;
+ for (int j = 0; j < interfaceCounter; j++) {
+ intfc = new WSDLInterfaceImpl();
+ intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE, "inteface"
+ + j));
+ for (int i = 0; i < operationCounter; i++) {
+ op = new WSDLOperationImpl();
+ op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "op" + i
+ + "of inteface" + j));
+ assertNotNull(op.getName());
+ intfc.setOperation(op);
+ }
+ if (j > 0) {
+ intfc.addSuperInterface(array[j - 1]);
+ }
+ array[j] = intfc;
+ }
+ assertEquals(((WSDLOperation) array[0].getOperation("op0of inteface0"))
+ .getName().getLocalPart(), "op0of inteface0");
+ assertEquals(((WSDLOperation) array[0].getOperation("op1of inteface0"))
+ .getName().getLocalPart(), "op1of inteface0");
+ assertEquals(array[interfaceCounter - 1].getAllOperations().size(),
+ interfaceCounter * operationCounter);
+ assertEquals(interfaceCounter * operationCounter,
+ array[interfaceCounter - 1].getAllOperations().size());
+ Iterator iter = array[1].getAllOperations().keySet().iterator();
+ while (iter.hasNext()) {
+ assertNotNull(((WSDLOperation) array[interfaceCounter - 1]
+ .getAllOperations().get(iter.next())).getName());
+ }
+ for (int j = 0; j < interfaceCounter; j++) {
+ for (int i = 0; i < operationCounter; i++) {
+ WSDLOperation operation = (WSDLOperation) array[interfaceCounter - 1]
+ .getAllOperations().get("op" + j + "of inteface" + i);
+ assertEquals((operation).getName().getLocalPart(), "op" + j
+ + "of inteface" + i);
+ }
+ }
- }
+ }
- /**
- * When a interface inherit two or more Interfaces the inherited operation
- * who have the same QName should be the same Operation.
- */
- public void testInheritedOperationResolution() throws Exception {
- WSDLOperation op;
- WSDLInterface intfc;
- WSDLInterface[] array = new WSDLInterface[5];
- int interfaceCounter = 5;
- int operationCounter = 5;
- for (int i = 0; i < interfaceCounter; i++) {
- intfc = new WSDLInterfaceImpl();
- for (int j = 0; j < operationCounter; j++) {
- op = new WSDLOperationImpl();
- op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE,
- "operation" + j));
- intfc.setOperation(op);
- }
- intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE,
- "Interface" + i));
- array[i] = intfc;
- }
- WSDLInterface inheritedInterface = new WSDLInterfaceImpl();
- for (int i = 0; i < array.length; i++) {
- inheritedInterface.addSuperInterface(array[i]);
- }
- assertEquals(inheritedInterface.getAllOperations().size(), 5);
+ /**
+ * When a interface inherit two or more Interfaces the inherited operation
+ * who have the same QName should be the same Operation.
+ */
+ public void testInheritedOperationResolution() throws Exception {
+ WSDLOperation op;
+ WSDLInterface intfc;
+ WSDLInterface[] array = new WSDLInterface[5];
+ int interfaceCounter = 5;
+ int operationCounter = 5;
+ for (int i = 0; i < interfaceCounter; i++) {
+ intfc = new WSDLInterfaceImpl();
+ for (int j = 0; j < operationCounter; j++) {
+ op = new WSDLOperationImpl();
+ op.setName(new QName(WSDLConstants.WSDL1_1_NAMESPACE,
+ "operation" + j));
+ intfc.setOperation(op);
+ }
+ intfc.setName(new QName(WSDLConstants.WSDL2_0_NAMESPACE,
+ "Interface" + i));
+ array[i] = intfc;
+ }
+ WSDLInterface inheritedInterface = new WSDLInterfaceImpl();
+ for (int i = 0; i < array.length; i++) {
+ inheritedInterface.addSuperInterface(array[i]);
+ }
+ assertEquals(inheritedInterface.getAllOperations().size(), 5);
- }
+ }
}
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java Mon Jul 11 08:49:30 2005
@@ -32,67 +32,65 @@
/**
* @author chathura@opensource.lk
- *
*/
public class MessageReuseTest extends AbstractTestCase {
- private WSDLDescription womDescription;
+ private WSDLDescription womDescription;
- private Definition wsdl4jDefinition;
+ private Definition wsdl4jDefinition;
- public MessageReuseTest(String arg) {
- super(arg);
- }
+ public MessageReuseTest(String arg) {
+ super(arg);
+ }
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception {
- WSDLVersionWrapper wsdlVersionWrapper = null;
+ WSDLVersionWrapper wsdlVersionWrapper = null;
if (null == this.womDescription) {
InputStream in = new FileInputStream(getTestResourceFile("BookQuote.wsdl"));
wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
- this.womDescription = wsdlVersionWrapper.getDescription();
+ this.womDescription = wsdlVersionWrapper.getDescription();
}
if (null == wsdl4jDefinition) {
this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
}
- }
+ }
- public void testMultipartmessageReuse() throws Exception {
+ public void testMultipartmessageReuse() throws Exception {
+
+ WSDLInterface interface1 = this.womDescription.getInterface(new QName("http://www.Monson-Haefel.com/jwsbook/BookQuote",
+ "BookQuote"));
+ WSDLOperation operation1 = (WSDLOperation) interface1.getAllOperations()
+ .get("getBookPrice");
+ QName element1 = operation1.getInputMessage().getElement();
+ WSDLOperation operation2 = (WSDLOperation) interface1.getAllOperations().get("getBookPriceNonRobust");
+ QName element2 = operation2.getInputMessage().getElement();
+ assertEquals(element1, element2);
+
+ Iterator iterator = womDescription.getTypes().getExtensibilityElements().iterator();
+ Schema types = null;
+ while (iterator.hasNext()) {
+ WSDLExtensibilityElement temp = (WSDLExtensibilityElement) iterator.next();
+ if (ExtensionConstants.SCHEMA.equals(temp.getType())) {
+ types = (Schema) temp;
+ }
+ }
+ int numberOfBookQuote_getBookPrice = 0;
+ NodeList childNodes = types.getElelment().getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node item = childNodes.item(i);
+ if (item instanceof Element) {
+ Element temp = (Element) item;
+ if ("complexType".equals(temp.getNodeName()) &&
+ "BookQuote_getBookPrice".equals(temp.getAttribute("name"))) {
+ numberOfBookQuote_getBookPrice++;
+ }
+
+ }
+ }
+ assertEquals(numberOfBookQuote_getBookPrice, 1);
- WSDLInterface interface1 = this.womDescription.getInterface(
- new QName("http://www.Monson-Haefel.com/jwsbook/BookQuote",
- "BookQuote"));
- WSDLOperation operation1 = (WSDLOperation) interface1.getAllOperations()
- .get("getBookPrice");
- QName element1 = operation1.getInputMessage().getElement();
- WSDLOperation operation2 = (WSDLOperation)interface1.getAllOperations().get("getBookPriceNonRobust");
- QName element2 = operation2.getInputMessage().getElement();
- assertEquals(element1, element2);
-
- Iterator iterator = womDescription.getTypes().getExtensibilityElements().iterator();
- Schema types= null;
- while(iterator.hasNext()){
- WSDLExtensibilityElement temp = (WSDLExtensibilityElement)iterator.next();
- if(ExtensionConstants.SCHEMA.equals(temp.getType())){
- types = (Schema)temp;
- }
- }
- int numberOfBookQuote_getBookPrice = 0;
- NodeList childNodes = types.getElelment().getChildNodes();
- for(int i=0; i< childNodes.getLength(); i++){
- Node item = childNodes.item(i);
- if(item instanceof Element){
- Element temp = (Element)item;
- if("complexType".equals(temp.getNodeName()) &&
- "BookQuote_getBookPrice".equals(temp.getAttribute("name"))){
- numberOfBookQuote_getBookPrice++;
- }
-
- }
- }
- assertEquals(numberOfBookQuote_getBookPrice, 1);
-
- }
+ }
}
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/SOAPActionTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/SOAPActionTest.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/SOAPActionTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/SOAPActionTest.java Mon Jul 11 08:49:30 2005
@@ -29,56 +29,51 @@
/**
* @author chathura@opensource.lk
- *
*/
public class SOAPActionTest extends AbstractTestCase {
- private WSDLDescription womDescription = null;
+ private WSDLDescription womDescription = null;
- private Definition wsdl4jDefinition = null;
+ private Definition wsdl4jDefinition = null;
- public SOAPActionTest(String args) {
- super(args);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- WSDLVersionWrapper wsdlVersionWrapper = null;
- if (null == this.womDescription) {
- InputStream in = new FileInputStream(
- getTestResourceFile("InteropTestDocLit2.wsdl"));
- wsdlVersionWrapper = WOMBuilderFactory.getBuilder(
- WOMBuilderFactory.WSDL11).build(in);
- this.womDescription = wsdlVersionWrapper.getDescription();
-
- }
- if (null == wsdl4jDefinition) {
- this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
- }
- }
-
- public void testSOAPActionPopulation() {
- WSDLBindingOperation bindingOperation = womDescription
- .getFirstBinding().getBindingOperation(
- new QName(
- "http://soapinterop.org/WSDLInteropTestDocLit",
- "echoVoid"));
- Iterator iterator = bindingOperation.getExtensibilityElements()
- .iterator();
- while (iterator.hasNext()) {
- WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator
- .next();
- SOAPOperation soapOperation = null;
- if (ExtensionConstants.SOAP_OPERATION.equals(element.getType())) {
- soapOperation = (SOAPOperation) element;
- }
- if (soapOperation == null) {
- fail();
- } else {
- assertEquals(soapOperation.getSoapAction(),
- "http://soapinterop.org/");
- }
- }
- }
+ public SOAPActionTest(String args) {
+ super(args);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ WSDLVersionWrapper wsdlVersionWrapper = null;
+ if (null == this.womDescription) {
+ InputStream in = new FileInputStream(getTestResourceFile("InteropTestDocLit2.wsdl"));
+ wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
+ this.womDescription = wsdlVersionWrapper.getDescription();
+
+ }
+ if (null == wsdl4jDefinition) {
+ this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
+ }
+ }
+
+ public void testSOAPActionPopulation() {
+ WSDLBindingOperation bindingOperation = womDescription
+ .getFirstBinding().getBindingOperation(new QName("http://soapinterop.org/WSDLInteropTestDocLit",
+ "echoVoid"));
+ Iterator iterator = bindingOperation.getExtensibilityElements()
+ .iterator();
+ while (iterator.hasNext()) {
+ WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator
+ .next();
+ SOAPOperation soapOperation = null;
+ if (ExtensionConstants.SOAP_OPERATION.equals(element.getType())) {
+ soapOperation = (SOAPOperation) element;
+ }
+ if (soapOperation == null) {
+ fail();
+ } else {
+ assertEquals(soapOperation.getSoapAction(),
+ "http://soapinterop.org/");
+ }
+ }
+ }
}
Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java Mon Jul 11 08:49:30 2005
@@ -23,8 +23,6 @@
import javax.wsdl.Operation;
import javax.wsdl.PortType;
import javax.wsdl.Service;
-
-import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Iterator;
@@ -44,12 +42,12 @@
private void initialize() throws Exception {
- WSDLVersionWrapper wsdlVersionWrapper = null;
+ WSDLVersionWrapper wsdlVersionWrapper = null;
if (null == this.womDescription) {
InputStream in = new FileInputStream(getTestResourceFile("InteropTest.wsdl"));
// InputStream in = new FileInputStream(new File("E:/temp/service.wsdl"));
wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
- this.womDescription = wsdlVersionWrapper.getDescription();
+ this.womDescription = wsdlVersionWrapper.getDescription();
}
if (null == wsdl4jDefinition) {
this.wsdl4jDefinition = wsdlVersionWrapper.getDefinition();
@@ -63,7 +61,7 @@
;
assertEquals(womDescription.getServices().size(), wsdl4jDefinition.getServices().size());
assertEquals(womDescription.getBindings().size(), wsdl4jDefinition.getBindings().size());
-
+
}
public void testInterfacesComponent() throws Exception {
@@ -81,11 +79,11 @@
//Will only work if the order is retained in the iteration
while (wsdl4jOprationIterator.hasNext()) {
Operation wsdl4jOperation = (Operation) wsdl4jOprationIterator.next();
- this.operationsWaliking(wsdlInterface.getOperation(wsdl4jOperation.getName()), wsdl4jOperation);
+ this.operationsWaliking(wsdlInterface.getOperation(wsdl4jOperation.getName()), wsdl4jOperation);
}
- while(womOperationIterator.hasNext() ){
- WSDLOperation womOperation = (WSDLOperation)womOperationIterator.next();
- this.operationsWaliking(womOperation, porttype.getOperation(womOperation.getName().getLocalPart(), null,null));
+ while (womOperationIterator.hasNext()) {
+ WSDLOperation womOperation = (WSDLOperation) womOperationIterator.next();
+ this.operationsWaliking(womOperation, porttype.getOperation(womOperation.getName().getLocalPart(), null, null));
}
}
@@ -108,8 +106,8 @@
private void operationsWaliking(WSDLOperation womOperation, Operation wsdl4jOperation) {
assertEquals(womOperation.getName().getLocalPart(), wsdl4jOperation.getName());
//System.out.println(womOperation.getMessageExchangePattern());
-
-
+
+
}
Modified: webservices/axis/trunk/java/modules/xml/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/project.xml?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/project.xml (original)
+++ webservices/axis/trunk/java/modules/xml/project.xml Mon Jul 11 08:49:30 2005
@@ -25,61 +25,59 @@
<description>AXIOM, The Object Model of Axis 2.0. This helps Axis 2.0 to have a light weight, efficient object model on StAX</description>
-<build>
- <nagEmailAddress>axis-dev@ws.apache.org</nagEmailAddress>
- <sourceDirectory>src</sourceDirectory>
- <unitTestSourceDirectory>test</unitTestSourceDirectory>
-
- <unitTest>
- <excludes>
- <exclude>**/*OMOutputTest.java</exclude>
- <exclude>**/*MTOMStAXSOAPModelBuilderTest.java</exclude>
- <exclude>**/*ImageSampleTest.java</exclude>
- <exclude>**/*MIMEHelperTest.java</exclude>
- <exclude>**/*MIMEOutputUtilsTest.java</exclude>
- </excludes>
- <includes>
- <include>**/*Test.java</include>
- </includes>
-
- <resources>
- <resource>
- <directory>${basedir}/test-resources</directory>
- </resource>
- <resource>
- <directory>conf</directory>
- <includes>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </resources>
- </unitTest>
-
- <resources>
- <resource>
- <directory>conf</directory>
- <includes>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </resources>
- </build>
-
-
+ <build>
+ <nagEmailAddress>axis-dev@ws.apache.org</nagEmailAddress>
+ <sourceDirectory>src</sourceDirectory>
+ <unitTestSourceDirectory>test</unitTestSourceDirectory>
+
+ <unitTest>
+ <excludes>
+ <exclude>**/*OMOutputTest.java</exclude>
+ <exclude>**/*MTOMStAXSOAPModelBuilderTest.java</exclude>
+ <exclude>**/*ImageSampleTest.java</exclude>
+ <exclude>**/*MIMEHelperTest.java</exclude>
+ <exclude>**/*MIMEOutputUtilsTest.java</exclude>
+ </excludes>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+
+ <resources>
+ <resource>
+ <directory>${basedir}/test-resources</directory>
+ </resource>
+ <resource>
+ <directory>conf</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </unitTest>
+
+ <resources>
+ <resource>
+ <directory>conf</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
<dependencies>
@@ -92,44 +90,44 @@
<module>true</module>
</properties>
</dependency>
-
- <dependency>
+
+ <dependency>
<groupId>stax</groupId>
<artifactId>stax</artifactId>
<version>1.1.1-dev</version>
<properties>
<module>true</module>
</properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
+ <url>http://dist.codehaus.org/stax/jars/</url>
</dependency>
- <dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.8</version>
<properties>
<module>true</module>
</properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
+ <url>http://dist.codehaus.org/stax/jars/</url>
</dependency>
- <dependency>
+ <dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1-beta-6</version>
<properties>
<module>true</module>
</properties>
- <url>http://www.ibiblio.org/maven/jaxen/jars/</url>
+ <url>http://www.ibiblio.org/maven/jaxen/jars/</url>
</dependency>
- <dependency>
+ <dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0</version>
<properties>
<module>true</module>
</properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
+ <url>http://dist.codehaus.org/stax/jars/</url>
</dependency>
<dependency>
<groupId>geronimo-spec</groupId>
@@ -139,7 +137,7 @@
<module>true</module>
</properties>
</dependency>
- <dependency>
+ <dependency>
<groupId>geronimo-spec</groupId>
<artifactId>geronimo-spec-activation</artifactId>
<version>1.0.2-rc3</version>
@@ -148,6 +146,6 @@
</properties>
</dependency>
</dependencies>
-
+
<reports/>
</project>
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/Base64.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/Base64.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/Base64.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/Base64.java Mon Jul 11 08:49:30 2005
@@ -1,18 +1,18 @@
- /*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
+/*
+* Copyright 2001-2004 The Apache Software Foundation.
+*
+* Licensed 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.attachments;
import java.io.IOException;
@@ -23,12 +23,12 @@
* @author TAMURA Kent <kent@trl.ibm.co.jp>
*/
public class Base64 {
- private static final char[] S_BASE64CHAR = { 'A', 'B', 'C', 'D', 'E', 'F',
- 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
- 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
- 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
- '6', '7', '8', '9', '+', '/' };
+ private static final char[] S_BASE64CHAR = {'A', 'B', 'C', 'D', 'E', 'F',
+ 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
+ '6', '7', '8', '9', '+', '/'};
private static final char S_BASE64PAD = '=';
@@ -38,7 +38,7 @@
for (int i = 0; i < S_DECODETABLE.length; i++)
S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
for (int i = 0; i < S_BASE64CHAR.length; i++)
- // 0 to 63
+ // 0 to 63
S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
}
@@ -53,20 +53,20 @@
int b2 = S_DECODETABLE[ibuf[2]];
int b3 = S_DECODETABLE[ibuf[3]];
switch (outlen) {
- case 1:
- obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- return 1;
- case 2:
- obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- return 2;
- case 3:
- obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
- obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
- obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
- return 3;
- default:
- throw new RuntimeException("internalError00");
+ case 1:
+ obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new RuntimeException("internalError00");
}
}
@@ -126,7 +126,7 @@
*
*/
public static void decode(char[] data, int off, int len,
- OutputStream ostream) throws IOException {
+ OutputStream ostream) throws IOException {
char[] ibuf = new char[4];
int ibufcount = 0;
byte[] obuf = new byte[3];
@@ -215,7 +215,7 @@
* stream.
*/
public static void encode(byte[] data, int off, int len,
- OutputStream ostream) throws IOException {
+ OutputStream ostream) throws IOException {
if (len <= 0)
return;
byte[] out = new byte[4];
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ByteArrayDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ByteArrayDataSource.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ByteArrayDataSource.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ByteArrayDataSource.java Mon Jul 11 08:49:30 2005
@@ -27,43 +27,43 @@
*/
public class ByteArrayDataSource implements DataSource {
- private byte[] data;
+ private byte[] data;
- private String type;
+ private String type;
- public ByteArrayDataSource(byte[] data, String type) {
- super();
- this.data = data;
- this.type = type;
- }
-
- public ByteArrayDataSource(byte[] data) {
- super();
- this.data = data;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getContentType() {
- if (type == null)
- return "application/octet-stream";
- else
- return type;
- }
-
- public InputStream getInputStream() throws IOException {
- return new ByteArrayInputStream(data);
- }
-
- public String getName() {
-
- return "ByteArrayDataSource";
- }
-
- public OutputStream getOutputStream() throws IOException {
- throw new IOException("Not Supported");
- }
+ public ByteArrayDataSource(byte[] data, String type) {
+ super();
+ this.data = data;
+ this.type = type;
+ }
+
+ public ByteArrayDataSource(byte[] data) {
+ super();
+ this.data = data;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getContentType() {
+ if (type == null)
+ return "application/octet-stream";
+ else
+ return type;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return new ByteArrayInputStream(data);
+ }
+
+ public String getName() {
+
+ return "ByteArrayDataSource";
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ throw new IOException("Not Supported");
+ }
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/IOUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/IOUtils.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/IOUtils.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/IOUtils.java Mon Jul 11 08:49:30 2005
@@ -15,42 +15,42 @@
*/
package org.apache.axis2.attachments;
+
import java.io.IOException;
import java.io.InputStream;
/**
* Utility class containing IO helper methods
*/
-public class IOUtils
-{
+public class IOUtils {
private IOUtils() {
}
/**
* Read into a byte array; tries to ensure that the the
* full buffer is read.
- *
+ * <p/>
* Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
+ *
* @see #readFully(java.io.InputStream, byte[], int, int)
*/
public static int readFully(InputStream in, byte[] b)
- throws IOException
- {
+ throws IOException {
return readFully(in, b, 0, b.length);
}
/**
* Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure that
* the entire len number of bytes is read.
- * <p>
+ * <p/>
+ *
* @returns the number of bytes read, or -1 if the end of file is
- * reached before any bytes are read
+ * reached before any bytes are read
*/
public static int readFully(InputStream in, byte[] b, int off, int len)
- throws IOException
- {
+ throws IOException {
int total = 0;
- for (;;) {
+ for (; ;) {
int got = in.read(b, off + total, len - total);
if (got < 0) {
return (total == 0) ? -1 : total;
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java Mon Jul 11 08:49:30 2005
@@ -20,55 +20,55 @@
import java.io.*;
public class ImageDataSource implements DataSource {
-
- public static final String CONTENT_TYPE = "image/jpeg";
-
- private final String name;
-
- private final String contentType;
-
- private byte[] data;
-
- private ByteArrayOutputStream os;
-
- public ImageDataSource(String name, Image data) {
- this(name, CONTENT_TYPE, data);
- } // ctor
-
- public ImageDataSource(String name, String contentType, Image data) {
- this.name = name;
- this.contentType = contentType == null ? CONTENT_TYPE : contentType;
- os = new ByteArrayOutputStream();
- try {
- if (data != null) {
- new JDK13IO().saveImage(this.contentType, data, os);
- }
- } catch (Exception e) {
- // log.error(Messages.getMessage("exception00"), e);
- }
- }
-
- public String getName() {
- return name;
- } // getName
-
- public String getContentType() {
- return contentType;
- } // getContentType
-
- public InputStream getInputStream() throws IOException {
- if (os.size() != 0) {
- data = os.toByteArray();
- os.reset();
- }
- return new ByteArrayInputStream(data == null ? new byte[0] : data);
- } // getInputStream
-
- public OutputStream getOutputStream() throws IOException {
- if (os.size() != 0) {
- data = os.toByteArray();
- os.reset();
- }
- return os;
- } // getOutputStream
+
+ public static final String CONTENT_TYPE = "image/jpeg";
+
+ private final String name;
+
+ private final String contentType;
+
+ private byte[] data;
+
+ private ByteArrayOutputStream os;
+
+ public ImageDataSource(String name, Image data) {
+ this(name, CONTENT_TYPE, data);
+ } // ctor
+
+ public ImageDataSource(String name, String contentType, Image data) {
+ this.name = name;
+ this.contentType = contentType == null ? CONTENT_TYPE : contentType;
+ os = new ByteArrayOutputStream();
+ try {
+ if (data != null) {
+ new JDK13IO().saveImage(this.contentType, data, os);
+ }
+ } catch (Exception e) {
+ // log.error(Messages.getMessage("exception00"), e);
+ }
+ }
+
+ public String getName() {
+ return name;
+ } // getName
+
+ public String getContentType() {
+ return contentType;
+ } // getContentType
+
+ public InputStream getInputStream() throws IOException {
+ if (os.size() != 0) {
+ data = os.toByteArray();
+ os.reset();
+ }
+ return new ByteArrayInputStream(data == null ? new byte[0] : data);
+ } // getInputStream
+
+ public OutputStream getOutputStream() throws IOException {
+ if (os.size() != 0) {
+ data = os.toByteArray();
+ os.reset();
+ }
+ return os;
+ } // getOutputStream
} // class ImageDataSource
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageIO.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageIO.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageIO.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageIO.java Mon Jul 11 08:49:30 2005
@@ -15,22 +15,25 @@
*/
package org.apache.axis2.attachments;
+
import java.awt.*;
import java.io.InputStream;
import java.io.OutputStream;
/**
* This interface defines a ImageIO modules functionality
+ *
* @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
* @since 2.0
*/
public interface ImageIO {
/**
* Save an image.
- * @param id the mime-type of the format to save the image
+ *
+ * @param id the mime-type of the format to save the image
* @param image the image to save
- * @param os the output stream to write to
- * @exception Exception if an error prevents image encoding
+ * @param os the output stream to write to
+ * @throws Exception if an error prevents image encoding
*/
public void saveImage(String id, Image image, OutputStream os)
@@ -38,6 +41,7 @@
/**
* Load an Image.
+ *
* @param in the stream to load the image
* @return the Image
*/
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/JDK13IO.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/JDK13IO.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/JDK13IO.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/JDK13IO.java Mon Jul 11 08:49:30 2005
@@ -33,10 +33,11 @@
public class JDK13IO extends Component implements ImageIO {
/**
* Save an image.
+ *
* @param mimeType the mime-type of the format to save the image
- * @param image the image to save
- * @param os the stream to write to
- * @exception Exception if an error prevents image encoding
+ * @param image the image to save
+ * @param os the stream to write to
+ * @throws Exception if an error prevents image encoding
*/
public void saveImage(String mimeType, Image image, OutputStream os)
throws Exception {
@@ -59,24 +60,23 @@
if ("image/jpeg".equals(mimeType)) {
JPEGImageEncoderImpl j = new JPEGImageEncoderImpl(os);
j.encode(rendImage);
- }
- else {
+ } else {
throw new IOException("Supports Jpeg Only");
}
} // saveImage
/**
* Load an Image.
+ *
* @param in the stream to load the image
* @return the Image
*/
public Image loadImage(InputStream in) throws Exception {
if (in.available() <= 0) {
return null;
- }
- else {
+ } else {
byte[] bytes = new byte[in.available()];
- org.apache.axis2.attachments.IOUtils.readFully(in,bytes);
+ org.apache.axis2.attachments.IOUtils.readFully(in, bytes);
return Toolkit.getDefaultToolkit().createImage(bytes);
}
} // loadImage
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java Mon Jul 11 08:49:30 2005
@@ -16,10 +16,7 @@
*/
package org.apache.axis2.attachments;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.HashMap;
+import org.apache.axis2.om.OMException;
import javax.activation.DataHandler;
import javax.mail.MessagingException;
@@ -27,306 +24,290 @@
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.ParseException;
-
-import org.apache.axis2.om.OMException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.HashMap;
/**
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
public class MIMEHelper {
- /**
- * if the Message is MTOM optimised then <code>MTOM_TYPE</code>
- */
- public static final String MTOM_TYPE = "application/xop+xml";
-
- /**
- * If the message is Soap with Attachments <code>SwA_TYPE</code>
- */
- public static final String SWA_TYPE = "text/xml";
-
- /**
- * <code>rootPart</code> is used as the key for the root BodyPart in the
- * Parts HashMap
- */
- public static final String ROOT_PART = "SoapPart";
-
- /**
- * <code>ContentType</code> of the MIME message
- */
- ContentType contentType;
-
- /**
- * Mime <code>boundary</code> which seperates mime parts
- */
- byte[] boundary;
-
- /**
- * <code>applicationType</code> used to distinguish between MTOM & SWA If
- * the message is MTOM optimised type is application/xop+xml If the message
- * is SWA, type is ??have to find out
- */
- String applicationType = null;
-
- /**
- * <code>pushbackInStream</code> stores the reference to the incoming
- * stream A PushbackStream has the ability to "push back" or "unread" one
- * byte.
- */
- PushbackInputStream pushbackInStream;
-
- /**
- * <code>mimeBodyPartsMap</code> stores the already parsed Mime Body
- * Parts. This Map will be keyed using the content-ID's
- */
- HashMap bodyPartsMap;
-
- /**
- * <code>partIndex</code>- Number of Mime parts parsed
- */
- int partIndex = 0;
-
- String firstPartId=null;
-
- boolean fileCacheEnable = false;
-
- String attachmentRepoDir = null;
-
- public MIMEHelper(InputStream inStream, String contentTypeString,
- boolean fileCacheEnable, String attachmentRepoDir)
- throws OMException {
- this.attachmentRepoDir = attachmentRepoDir;
- this.fileCacheEnable = fileCacheEnable;
- bodyPartsMap = new HashMap();
- try {
- contentType = new ContentType(contentTypeString);
- } catch (ParseException e) {
- throw new OMException(
- "Invalid Content Type Field in the Mime Message"
- + e.toString());
- }
- // Boundary always have the prefix "--".
- this.boundary = ("--" + contentType.getParameter("boundary"))
- .getBytes();
-
- //TODO do we need to wrap InputStream from a BufferedInputStream before
- // wrapping from PushbackStream
- pushbackInStream = new PushbackInputStream(inStream,
- (this.boundary.length + 2));
-
- // Move the read pointer to the begining of the first part
- // read till the end of first boundary
- while (true) {
- int value;
- try {
- value = pushbackInStream.read();
- if ((byte) value == boundary[0]) {
- int boundaryIndex = 0;
- while ((boundaryIndex < boundary.length)
- && ((byte) value == boundary[boundaryIndex])) {
- value = pushbackInStream.read();
- if (value == -1)
- throw new OMException(
- "Unexpected End of Stream while searching for first Mime Boundary");
- boundaryIndex++;
- }
- if (boundaryIndex == boundary.length) { // boundary found
- pushbackInStream.read();
- break;
- }
- } else if ((byte) value == -1) {
- throw new OMException(
- "Mime parts not found. Stream ended while searching for the boundary");
- }
- } catch (IOException e1) {
- throw new OMException("Stream Error" + e1.toString());
- }
- }
- }
-
- public MIMEHelper(InputStream inStream, String contentTypeString)
- throws OMException {
- this(inStream,contentTypeString,false,null);
- }
-
- /**
- * @return whether Message Type is SOAP with Attachments or MTOM optimised
- * by checking the application type parameter in the Contant Type
- */
- public String getAttachmentSpecType() {
- if (this.applicationType == null) {
- applicationType = contentType.getParameter("type");
- if (applicationType.equalsIgnoreCase(MTOM_TYPE)) {
- this.applicationType = MTOM_TYPE;
- } else if (applicationType.equalsIgnoreCase(SWA_TYPE)) {
- this.applicationType = SWA_TYPE;
- } else {
- throw new OMException(
- "Invalid Application type. Support available for MTOM & SwA only.");
- }
- }
- return this.applicationType;
- }
-
- /**
- * @return the InputStream which includes the SOAP Envelope We assumes that
- * the root mime part is always pointed by "start" parameter in
- * content-type
- */
- public InputStream getSOAPPartInputStream() throws OMException {
- String rootContentID = contentType.getParameter("start");
- // to handle the Start parameter not mentioned situation
- if (rootContentID==null)
- {
- if (partIndex==0)
- {
- getNextPart();
- }
- rootContentID=firstPartId;
- }
- else
- {
- rootContentID.trim();
- rootContentID = rootContentID
- .substring(1, (rootContentID.length() - 1));
- }
- DataHandler dh;
- try {
- dh = getDataHandler(rootContentID);
- if (dh == null) {
- throw new OMException(
- "Mandatory Root MIME part containing the SOAP Envelope is missing");
- }
- return dh.getInputStream();
- } catch (IOException e) {
- throw new OMException(
- "Problem with DataHandler of the Root Mime Part. " + e);
- }
- }
-
- /**
- * @param blobContentID
- * @return The DataHandler of the mime part refered by the content-Id
- * @throws OMException
- * First checks whether the MIME part is already parsed by
- * checking the parts HashMap. If it is not parsed yet then call
- * the getNextPart() till we find the required part.
- */
- public DataHandler getDataHandler(String blobContentID) throws OMException {
-
- Part bodyPart;
- blobContentID = "<" + blobContentID + ">";
- boolean attachmentFound = false;
-
- // // without the following part a Null Pointer Exception is thrown
- //
- if (bodyPartsMap.containsKey(blobContentID)) {
- bodyPart = (Part) bodyPartsMap.get(blobContentID);
- attachmentFound = true;
- DataHandler dh;
- try {
- dh = bodyPart.getDataHandler();
- } catch (MessagingException e) {
- throw new OMException("Problem with Mime Body Part No "
- + partIndex + ". " + e);
- }
- return dh;
- } else {
- try {
- while (true) {
- bodyPart = this.getNextPart();
- if (bodyPart == null) {
- return null;
- }
- if (bodyPartsMap.containsKey(blobContentID)) {
- bodyPart = (Part) bodyPartsMap.get(blobContentID);
- DataHandler dh = bodyPart.getDataHandler();
- return dh;
- }
- }
- } catch (MessagingException e) {
- throw new OMException("Invalid Mime Message " + e.toString());
- }
- }
-
- }
-
- /**
- * @return The next MIME Body part in the stream Uses the MimeBodyPartStream
- * to obtain streams delimited by boundaries.
- * @throws MessagingException
- */
- // TODO do we need Locking for this
- private MimeBodyPart getMimeBodyPart() throws OMException {
- MimeBodyPart mimeBodyPart = null;
-
- MimeBodyPartInputStream partStream;
- partStream = new MimeBodyPartInputStream(pushbackInStream,
- boundary);
- try {
- mimeBodyPart = new MimeBodyPart(partStream);
- } catch (MessagingException e) {
- throw new OMException("Problem reading Mime Part No "
- + (partIndex + 1) + ". " + e);
- }
-
- partIndex++;
- return mimeBodyPart;
- }
-
- /**
- * @return The Mime body part which contains the SOAP Envelope In MTOM case
- * it is the first part In SwA case we assumes it to be first
- * part.Have to FIX This
- * @throws MessagingException
- */
- private MimeBodyPart getRootMimeBodyPart() throws OMException {
- MimeBodyPart rootMimeBodyPart;
- if (bodyPartsMap.isEmpty()) {
- rootMimeBodyPart = getMimeBodyPart();
- bodyPartsMap.put(ROOT_PART, rootMimeBodyPart);
- } else {
- rootMimeBodyPart = (MimeBodyPart) bodyPartsMap.get(ROOT_PART);
- }
- return rootMimeBodyPart;
- }
-
- private Part getNextPart() throws OMException {
- MimeBodyPart nextMimeBodyPart;
- nextMimeBodyPart = getMimeBodyPart();
- if (nextMimeBodyPart != null) {
- String partContentID;
- try {
- partContentID = nextMimeBodyPart.getContentID();
- if (partContentID==null & partIndex==1)
- {
- bodyPartsMap.put("firstPart", nextMimeBodyPart);
- firstPartId = "firstPart";
- return nextMimeBodyPart;
- }
- else if (partIndex==1)
- {
- firstPartId = partContentID;
- }
- if (fileCacheEnable)
- {
- PartOnFile part = new PartOnFile(nextMimeBodyPart,partContentID,attachmentRepoDir);
- return part;
- }
- else{
- bodyPartsMap.put(partContentID, nextMimeBodyPart);
- return nextMimeBodyPart;
- }
- } catch (MessagingException e) {
- throw new OMException(
- "Error Reading Content-ID from Mime Part No "
- + partIndex + ". " + e);
- } catch (Exception e) {
- throw new OMException(
- "Error Creating File Storage Part"
- + partIndex + ". " + e);
- }
- } else
- return null;
- }
+ /**
+ * if the Message is MTOM optimised then <code>MTOM_TYPE</code>
+ */
+ public static final String MTOM_TYPE = "application/xop+xml";
+
+ /**
+ * If the message is Soap with Attachments <code>SwA_TYPE</code>
+ */
+ public static final String SWA_TYPE = "text/xml";
+
+ /**
+ * <code>rootPart</code> is used as the key for the root BodyPart in the
+ * Parts HashMap
+ */
+ public static final String ROOT_PART = "SoapPart";
+
+ /**
+ * <code>ContentType</code> of the MIME message
+ */
+ ContentType contentType;
+
+ /**
+ * Mime <code>boundary</code> which seperates mime parts
+ */
+ byte[] boundary;
+
+ /**
+ * <code>applicationType</code> used to distinguish between MTOM & SWA If
+ * the message is MTOM optimised type is application/xop+xml If the message
+ * is SWA, type is ??have to find out
+ */
+ String applicationType = null;
+
+ /**
+ * <code>pushbackInStream</code> stores the reference to the incoming
+ * stream A PushbackStream has the ability to "push back" or "unread" one
+ * byte.
+ */
+ PushbackInputStream pushbackInStream;
+
+ /**
+ * <code>mimeBodyPartsMap</code> stores the already parsed Mime Body
+ * Parts. This Map will be keyed using the content-ID's
+ */
+ HashMap bodyPartsMap;
+
+ /**
+ * <code>partIndex</code>- Number of Mime parts parsed
+ */
+ int partIndex = 0;
+
+ String firstPartId = null;
+
+ boolean fileCacheEnable = false;
+
+ String attachmentRepoDir = null;
+
+ public MIMEHelper(InputStream inStream, String contentTypeString,
+ boolean fileCacheEnable, String attachmentRepoDir)
+ throws OMException {
+ this.attachmentRepoDir = attachmentRepoDir;
+ this.fileCacheEnable = fileCacheEnable;
+ bodyPartsMap = new HashMap();
+ try {
+ contentType = new ContentType(contentTypeString);
+ } catch (ParseException e) {
+ throw new OMException("Invalid Content Type Field in the Mime Message"
+ + e.toString());
+ }
+ // Boundary always have the prefix "--".
+ this.boundary = ("--" + contentType.getParameter("boundary"))
+ .getBytes();
+
+ //TODO do we need to wrap InputStream from a BufferedInputStream before
+ // wrapping from PushbackStream
+ pushbackInStream = new PushbackInputStream(inStream,
+ (this.boundary.length + 2));
+
+ // Move the read pointer to the begining of the first part
+ // read till the end of first boundary
+ while (true) {
+ int value;
+ try {
+ value = pushbackInStream.read();
+ if ((byte) value == boundary[0]) {
+ int boundaryIndex = 0;
+ while ((boundaryIndex < boundary.length)
+ && ((byte) value == boundary[boundaryIndex])) {
+ value = pushbackInStream.read();
+ if (value == -1)
+ throw new OMException("Unexpected End of Stream while searching for first Mime Boundary");
+ boundaryIndex++;
+ }
+ if (boundaryIndex == boundary.length) { // boundary found
+ pushbackInStream.read();
+ break;
+ }
+ } else if ((byte) value == -1) {
+ throw new OMException("Mime parts not found. Stream ended while searching for the boundary");
+ }
+ } catch (IOException e1) {
+ throw new OMException("Stream Error" + e1.toString());
+ }
+ }
+ }
+
+ public MIMEHelper(InputStream inStream, String contentTypeString)
+ throws OMException {
+ this(inStream, contentTypeString, false, null);
+ }
+
+ /**
+ * @return whether Message Type is SOAP with Attachments or MTOM optimised
+ * by checking the application type parameter in the Contant Type
+ */
+ public String getAttachmentSpecType() {
+ if (this.applicationType == null) {
+ applicationType = contentType.getParameter("type");
+ if (applicationType.equalsIgnoreCase(MTOM_TYPE)) {
+ this.applicationType = MTOM_TYPE;
+ } else if (applicationType.equalsIgnoreCase(SWA_TYPE)) {
+ this.applicationType = SWA_TYPE;
+ } else {
+ throw new OMException("Invalid Application type. Support available for MTOM & SwA only.");
+ }
+ }
+ return this.applicationType;
+ }
+
+ /**
+ * @return the InputStream which includes the SOAP Envelope We assumes that
+ * the root mime part is always pointed by "start" parameter in
+ * content-type
+ */
+ public InputStream getSOAPPartInputStream() throws OMException {
+ String rootContentID = contentType.getParameter("start");
+ // to handle the Start parameter not mentioned situation
+ if (rootContentID == null) {
+ if (partIndex == 0) {
+ getNextPart();
+ }
+ rootContentID = firstPartId;
+ } else {
+ rootContentID.trim();
+ rootContentID = rootContentID
+ .substring(1, (rootContentID.length() - 1));
+ }
+ DataHandler dh;
+ try {
+ dh = getDataHandler(rootContentID);
+ if (dh == null) {
+ throw new OMException("Mandatory Root MIME part containing the SOAP Envelope is missing");
+ }
+ return dh.getInputStream();
+ } catch (IOException e) {
+ throw new OMException("Problem with DataHandler of the Root Mime Part. " + e);
+ }
+ }
+
+ /**
+ * @param blobContentID
+ * @return The DataHandler of the mime part refered by the content-Id
+ * @throws OMException First checks whether the MIME part is already parsed by
+ * checking the parts HashMap. If it is not parsed yet then call
+ * the getNextPart() till we find the required part.
+ */
+ public DataHandler getDataHandler(String blobContentID) throws OMException {
+
+ Part bodyPart;
+ blobContentID = "<" + blobContentID + ">";
+ boolean attachmentFound = false;
+
+ // // without the following part a Null Pointer Exception is thrown
+ //
+ if (bodyPartsMap.containsKey(blobContentID)) {
+ bodyPart = (Part) bodyPartsMap.get(blobContentID);
+ attachmentFound = true;
+ DataHandler dh;
+ try {
+ dh = bodyPart.getDataHandler();
+ } catch (MessagingException e) {
+ throw new OMException("Problem with Mime Body Part No "
+ + partIndex + ". " + e);
+ }
+ return dh;
+ } else {
+ try {
+ while (true) {
+ bodyPart = this.getNextPart();
+ if (bodyPart == null) {
+ return null;
+ }
+ if (bodyPartsMap.containsKey(blobContentID)) {
+ bodyPart = (Part) bodyPartsMap.get(blobContentID);
+ DataHandler dh = bodyPart.getDataHandler();
+ return dh;
+ }
+ }
+ } catch (MessagingException e) {
+ throw new OMException("Invalid Mime Message " + e.toString());
+ }
+ }
+
+ }
+
+ /**
+ * @return The next MIME Body part in the stream Uses the MimeBodyPartStream
+ * to obtain streams delimited by boundaries.
+ * @throws MessagingException
+ */
+ // TODO do we need Locking for this
+ private MimeBodyPart getMimeBodyPart() throws OMException {
+ MimeBodyPart mimeBodyPart = null;
+
+ MimeBodyPartInputStream partStream;
+ partStream = new MimeBodyPartInputStream(pushbackInStream,
+ boundary);
+ try {
+ mimeBodyPart = new MimeBodyPart(partStream);
+ } catch (MessagingException e) {
+ throw new OMException("Problem reading Mime Part No "
+ + (partIndex + 1) + ". " + e);
+ }
+
+ partIndex++;
+ return mimeBodyPart;
+ }
+
+ /**
+ * @return The Mime body part which contains the SOAP Envelope In MTOM case
+ * it is the first part In SwA case we assumes it to be first
+ * part.Have to FIX This
+ * @throws MessagingException
+ */
+ private MimeBodyPart getRootMimeBodyPart() throws OMException {
+ MimeBodyPart rootMimeBodyPart;
+ if (bodyPartsMap.isEmpty()) {
+ rootMimeBodyPart = getMimeBodyPart();
+ bodyPartsMap.put(ROOT_PART, rootMimeBodyPart);
+ } else {
+ rootMimeBodyPart = (MimeBodyPart) bodyPartsMap.get(ROOT_PART);
+ }
+ return rootMimeBodyPart;
+ }
+
+ private Part getNextPart() throws OMException {
+ MimeBodyPart nextMimeBodyPart;
+ nextMimeBodyPart = getMimeBodyPart();
+ if (nextMimeBodyPart != null) {
+ String partContentID;
+ try {
+ partContentID = nextMimeBodyPart.getContentID();
+ if (partContentID == null & partIndex == 1) {
+ bodyPartsMap.put("firstPart", nextMimeBodyPart);
+ firstPartId = "firstPart";
+ return nextMimeBodyPart;
+ } else if (partIndex == 1) {
+ firstPartId = partContentID;
+ }
+ if (fileCacheEnable) {
+ PartOnFile part = new PartOnFile(nextMimeBodyPart, partContentID, attachmentRepoDir);
+ return part;
+ } else {
+ bodyPartsMap.put(partContentID, nextMimeBodyPart);
+ return nextMimeBodyPart;
+ }
+ } catch (MessagingException e) {
+ throw new OMException("Error Reading Content-ID from Mime Part No "
+ + partIndex + ". " + e);
+ } catch (Exception e) {
+ throw new OMException("Error Creating File Storage Part"
+ + partIndex + ". " + e);
+ }
+ } else
+ return null;
+ }
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MimeBodyPartInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MimeBodyPartInputStream.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MimeBodyPartInputStream.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MimeBodyPartInputStream.java Mon Jul 11 08:49:30 2005
@@ -22,80 +22,80 @@
/**
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
- * This class provides input streams delimited by the mime boundaries.
+ * This class provides input streams delimited by the mime boundaries.
*/
public class MimeBodyPartInputStream extends InputStream {
- PushbackInputStream inStream;
+ PushbackInputStream inStream;
- boolean boundaryFound = false;
+ boolean boundaryFound = false;
- byte[] boundary;
+ byte[] boundary;
- public MimeBodyPartInputStream(PushbackInputStream inStream, byte[] boundary) {
- super();
- this.inStream = inStream;
- this.boundary = boundary;
- }
-
- public int read() throws IOException {
- if (boundaryFound) {
- return -1;
- }
- // read the next value from stream
- int value = inStream.read();
-
- // A problem occured because all the mime parts tends to have a /r/n at the end. Making it hard to transform them to correct DataSources.
- // This logic introduced to handle it
- //TODO look more in to this && for a better way to do this
- if (value == 13) {
- value = inStream.read();
- if (value != 10) {
- inStream.unread(value);
- return 13;
- } else {
- value = inStream.read();
- if ((byte) value != boundary[0]) {
- inStream.unread(value);
- inStream.unread(10);
- return 13;
- }
- }
- } else if ((byte) value != boundary[0]) {
- return value;
- }
-
- // read value is the first byte of the boundary. Start matching the
- // next characters to find a boundary
- int boundaryIndex = 0;
- while ((boundaryIndex < boundary.length)
- && ((byte) value == boundary[boundaryIndex])) {
- value = inStream.read();
- boundaryIndex++;
- }
-
- if (boundaryIndex == boundary.length) { // boundary found
- boundaryFound = true;
- // read the end of line character
- if (inStream.read() == 45) {
- //check whether end of stream
- //Last mime boundary should have a succeeding "--"
- if (!((value = inStream.read()) == 45)) {
- inStream.unread(value);
- }
-
- }
-
- return -1;
- }
-
- // Boundary not found. Restoring bytes skipped.
- // write first skipped byte, push back the rest
-
- if (value != -1) { // Stream might have ended
- inStream.unread(value);
- }
- inStream.unread(boundary, 1, boundaryIndex - 1);
- return boundary[0];
- }
+ public MimeBodyPartInputStream(PushbackInputStream inStream, byte[] boundary) {
+ super();
+ this.inStream = inStream;
+ this.boundary = boundary;
+ }
+
+ public int read() throws IOException {
+ if (boundaryFound) {
+ return -1;
+ }
+ // read the next value from stream
+ int value = inStream.read();
+
+ // A problem occured because all the mime parts tends to have a /r/n at the end. Making it hard to transform them to correct DataSources.
+ // This logic introduced to handle it
+ //TODO look more in to this && for a better way to do this
+ if (value == 13) {
+ value = inStream.read();
+ if (value != 10) {
+ inStream.unread(value);
+ return 13;
+ } else {
+ value = inStream.read();
+ if ((byte) value != boundary[0]) {
+ inStream.unread(value);
+ inStream.unread(10);
+ return 13;
+ }
+ }
+ } else if ((byte) value != boundary[0]) {
+ return value;
+ }
+
+ // read value is the first byte of the boundary. Start matching the
+ // next characters to find a boundary
+ int boundaryIndex = 0;
+ while ((boundaryIndex < boundary.length)
+ && ((byte) value == boundary[boundaryIndex])) {
+ value = inStream.read();
+ boundaryIndex++;
+ }
+
+ if (boundaryIndex == boundary.length) { // boundary found
+ boundaryFound = true;
+ // read the end of line character
+ if (inStream.read() == 45) {
+ //check whether end of stream
+ //Last mime boundary should have a succeeding "--"
+ if (!((value = inStream.read()) == 45)) {
+ inStream.unread(value);
+ }
+
+ }
+
+ return -1;
+ }
+
+ // Boundary not found. Restoring bytes skipped.
+ // write first skipped byte, push back the rest
+
+ if (value != -1) { // Stream might have ended
+ inStream.unread(value);
+ }
+ inStream.unread(boundary, 1, boundaryIndex - 1);
+ return boundary[0];
+ }
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java Mon Jul 11 08:49:30 2005
@@ -16,317 +16,309 @@
*/
package org.apache.axis2.attachments;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Enumeration;
+import org.apache.axis2.om.OMException;
import javax.activation.DataHandler;
-import javax.mail.BodyPart;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.internet.MimeBodyPart;
-
-import org.apache.axis2.om.OMException;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Enumeration;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class PartOnFile implements Part {
-
- String fileName;
-
- Part bodyPart;
-
- int size;
-
- String contentType;
-
- Enumeration headers;
-
- String contentID;
-
- public PartOnFile(Part bodyPart,String contentID, String repoDir) throws Exception {
- super();
- size = bodyPart.getSize();
- contentType = bodyPart.getContentType();
- headers = bodyPart.getAllHeaders();
- // TODO Find a better naming algorithm
- if (repoDir==null)
- {
- repoDir=".";
- }
- fileName = repoDir+(new Date()).getTime() + ".tmp";
- FileOutputStream outFileStream;
- outFileStream = new FileOutputStream(fileName);
- bodyPart.writeTo(outFileStream);
- outFileStream.close();
- }
-
- private Part getPartOnFile() {
- FileInputStream inFileStream;
- Part part=null;
- try {
- inFileStream = new FileInputStream(fileName);
-
- part = new MimeBodyPart(inFileStream);
- } catch (FileNotFoundException e) {
- throw new OMException("File Not Found"+e.toString());
- } catch (MessagingException e1) {
- throw new OMException("Cannot create MimePart from the Part read from file"+e1.toString());
- }
- return part;
- }
-
- public String getContentID()
- {
- return contentID;
- }
- public int getSize() throws MessagingException {
- return size;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getLineCount()
- */
- public int getLineCount() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getContentType()
- */
- public String getContentType() throws MessagingException {
- // TODO Auto-generated method stub
- return contentType;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#isMimeType(java.lang.String)
- */
- public boolean isMimeType(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getDisposition()
- */
- public String getDisposition() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setDisposition(java.lang.String)
- */
- public void setDisposition(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getDescription()
- */
- public String getDescription() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setDescription(java.lang.String)
- */
- public void setDescription(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getFileName()
- */
- public String getFileName() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setFileName(java.lang.String)
- */
- public void setFileName(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getInputStream()
- */
- public InputStream getInputStream() throws IOException, MessagingException {
- Part part = getPartOnFile();
- return part.getInputStream();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getDataHandler()
- */
- public DataHandler getDataHandler() throws MessagingException {
- Part part = getPartOnFile();
- return part.getDataHandler();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getContent()
- */
- public Object getContent() throws IOException, MessagingException {
- Part part = getPartOnFile();
- return part.getContent();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
- */
- public void setDataHandler(DataHandler arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
- */
- public void setContent(Object arg0, String arg1) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setText(java.lang.String)
- */
- public void setText(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setContent(javax.mail.Multipart)
- */
- public void setContent(Multipart arg0) throws MessagingException {
- throw new UnsupportedOperationException();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#writeTo(java.io.OutputStream)
- */
- public void writeTo(OutputStream outStream) throws IOException,
- MessagingException {
- Part part = getPartOnFile();
- part.writeTo(outStream);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getHeader(java.lang.String)
- */
- public String[] getHeader(String arg0) throws MessagingException {
- ArrayList selectedHeader = null;
- while (headers.hasMoreElements()) {
- String header = (String) headers.nextElement();
- if (arg0.equals(header)) {
- selectedHeader.add(header);
- }
- }
- String[] headerStrings = (String[]) selectedHeader.toArray();
- return headerStrings;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
- */
- public void setHeader(String arg0, String arg1) throws MessagingException {
- throw new UnsupportedOperationException();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
- */
- public void addHeader(String arg0, String arg1) throws MessagingException {
- throw new UnsupportedOperationException();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#removeHeader(java.lang.String)
- */
- public void removeHeader(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getAllHeaders()
- */
- public Enumeration getAllHeaders() throws MessagingException {
- return headers;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
- */
- public Enumeration getMatchingHeaders(String[] arg0)
- throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
- */
- public Enumeration getNonMatchingHeaders(String[] arg0)
- throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
+
+ String fileName;
+
+ Part bodyPart;
+
+ int size;
+
+ String contentType;
+
+ Enumeration headers;
+
+ String contentID;
+
+ public PartOnFile(Part bodyPart, String contentID, String repoDir) throws Exception {
+ super();
+ size = bodyPart.getSize();
+ contentType = bodyPart.getContentType();
+ headers = bodyPart.getAllHeaders();
+ // TODO Find a better naming algorithm
+ if (repoDir == null) {
+ repoDir = ".";
+ }
+ fileName = repoDir + (new Date()).getTime() + ".tmp";
+ FileOutputStream outFileStream;
+ outFileStream = new FileOutputStream(fileName);
+ bodyPart.writeTo(outFileStream);
+ outFileStream.close();
+ }
+
+ private Part getPartOnFile() {
+ FileInputStream inFileStream;
+ Part part = null;
+ try {
+ inFileStream = new FileInputStream(fileName);
+
+ part = new MimeBodyPart(inFileStream);
+ } catch (FileNotFoundException e) {
+ throw new OMException("File Not Found" + e.toString());
+ } catch (MessagingException e1) {
+ throw new OMException("Cannot create MimePart from the Part read from file" + e1.toString());
+ }
+ return part;
+ }
+
+ public String getContentID() {
+ return contentID;
+ }
+
+ public int getSize() throws MessagingException {
+ return size;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getLineCount()
+ */
+ public int getLineCount() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getContentType()
+ */
+ public String getContentType() throws MessagingException {
+ // TODO Auto-generated method stub
+ return contentType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#isMimeType(java.lang.String)
+ */
+ public boolean isMimeType(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getDisposition()
+ */
+ public String getDisposition() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setDisposition(java.lang.String)
+ */
+ public void setDisposition(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getDescription()
+ */
+ public String getDescription() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setDescription(java.lang.String)
+ */
+ public void setDescription(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getFileName()
+ */
+ public String getFileName() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setFileName(java.lang.String)
+ */
+ public void setFileName(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException, MessagingException {
+ Part part = getPartOnFile();
+ return part.getInputStream();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getDataHandler()
+ */
+ public DataHandler getDataHandler() throws MessagingException {
+ Part part = getPartOnFile();
+ return part.getDataHandler();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getContent()
+ */
+ public Object getContent() throws IOException, MessagingException {
+ Part part = getPartOnFile();
+ return part.getContent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
+ */
+ public void setDataHandler(DataHandler arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
+ */
+ public void setContent(Object arg0, String arg1) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setText(java.lang.String)
+ */
+ public void setText(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setContent(javax.mail.Multipart)
+ */
+ public void setContent(Multipart arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#writeTo(java.io.OutputStream)
+ */
+ public void writeTo(OutputStream outStream) throws IOException,
+ MessagingException {
+ Part part = getPartOnFile();
+ part.writeTo(outStream);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getHeader(java.lang.String)
+ */
+ public String[] getHeader(String arg0) throws MessagingException {
+ ArrayList selectedHeader = null;
+ while (headers.hasMoreElements()) {
+ String header = (String) headers.nextElement();
+ if (arg0.equals(header)) {
+ selectedHeader.add(header);
+ }
+ }
+ String[] headerStrings = (String[]) selectedHeader.toArray();
+ return headerStrings;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
+ */
+ public void setHeader(String arg0, String arg1) throws MessagingException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
+ */
+ public void addHeader(String arg0, String arg1) throws MessagingException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#removeHeader(java.lang.String)
+ */
+ public void removeHeader(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getAllHeaders()
+ */
+ public Enumeration getAllHeaders() throws MessagingException {
+ return headers;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
+ */
+ public Enumeration getMatchingHeaders(String[] arg0)
+ throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
+ */
+ public Enumeration getNonMatchingHeaders(String[] arg0)
+ throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java Mon Jul 11 08:49:30 2005
@@ -35,7 +35,6 @@
/**
- *
* @param loader
* @return
* @throws OMFactoryException