You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/03/14 06:53:09 UTC
svn commit: r157393 [2/3] - in
webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src:
java/org/apache/axis/impl/llom/ java/org/apache/axis/impl/llom/builder/
java/org/apache/axis/impl/llom/exception/
java/org/apache/axis/impl/llom/factory/ java/org/apache/axis/impl/llom/mtom/
java/org/apache/axis/impl/llom/serialize/
java/org/apache/axis/impl/llom/traverse/ test-resources/
test/org/apache/axis/mtom/
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/SOAPHeaderImpl.java Sun Mar 13 21:53:01 2005
@@ -1,145 +0,0 @@
-package org.apache.axis.impl.llom;
-
-import java.util.Iterator;
-
-import org.apache.axis.om.OMConstants;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMXMLParserWrapper;
-import org.apache.axis.om.SOAPEnvelope;
-import org.apache.axis.om.SOAPHeader;
-import org.apache.axis.om.SOAPHeaderBlock;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-public class SOAPHeaderImpl extends OMElementImpl implements SOAPHeader {
-
-
- /**
- * @param envelope
- */
- public SOAPHeaderImpl(SOAPEnvelope envelope) {
- super(envelope);
- //set the namespaces
- this.ns = envelope.getNamespace();
- this.localName = OMConstants.HEADER_LOCAL_NAME;
-
- }
-
- public SOAPHeaderImpl(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- super(localName, ns, parent, builder);
- }
-
- /**
- * Creates a new <CODE>SOAPHeaderBlock</CODE> object initialized with the
- * specified name and adds it to this <CODE>SOAPHeader</CODE> object.
- *
- * @return the new <CODE>SOAPHeaderBlock</CODE> object that was inserted
- * into this <CODE>SOAPHeader</CODE> object
- * @throws org.apache.axis.om.OMException if a SOAP error occurs
- */
- public SOAPHeaderBlock addHeaderBlock(String localName, OMNamespace ns) throws OMException {
- SOAPHeaderBlock soapHeaderBlock = new SOAPHeaderBlockImpl(localName, ns);
- this.addChild(soapHeaderBlock);
- soapHeaderBlock.setComplete(true);
- return soapHeaderBlock;
- }
-
- /**
- * Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
- * <CODE>SOAPHeader</CODE> object that have the the specified actor. An
- * actor is a global attribute that indicates the intermediate parties to
- * whom the message should be sent. An actor receives the message and then
- * sends it to the next actor. The default actor is the ultimate intended
- * recipient for the message, so if no actor attribute is included in a
- * <CODE>SOAPHeader</CODE> object, the message is sent to its ultimate
- * destination.
- *
- * @param actor a <CODE>String</CODE> giving the URI of the actor for which
- * to search
- * @return an <CODE>Iterator</CODE> object over all the <CODE>
- * SOAPHeaderBlock</CODE> objects that contain the specified actor
- * @see #extractHeaderBlocks(String) extractHeaderBlocks(java.lang.String)
- */
- public Iterator examineHeaderBlocks(String actor) {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-
- /**
- * Returns a list of all the <CODE>SOAPHeaderBlock</CODE> objects in this
- * <CODE>SOAPHeader</CODE> object that have the the specified actor and
- * detaches them from this <CODE> SOAPHeader</CODE> object.
- * <p/>
- * <P>This method allows an actor to process only the parts of the
- * <CODE>SOAPHeader</CODE> object that apply to it and to remove them before
- * passing the message on to the next actor.
- *
- * @param actor a <CODE>String</CODE> giving the URI of the actor for which
- * to search
- * @return an <CODE>Iterator</CODE> object over all the <CODE>
- * SOAPHeaderBlock</CODE> objects that contain the specified actor
- * @see #examineHeaderBlocks(String) examineHeaderBlocks(java.lang.String)
- */
- public Iterator extractHeaderBlocks(String actor) {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-
- /**
- * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
- * objects in this <code>SOAPHeader</code> object that have the specified
- * actor and that have a MustUnderstand attribute whose value is equivalent
- * to <code>true</code>.
- *
- * @param actor a <code>String</code> giving the URI of the actor for which
- * to search
- * @return an <code>Iterator</code> object over all the
- * <code>SOAPHeaderBlock</code> objects that contain the specified
- * actor and are marked as MustUnderstand
- */
- public Iterator examineMustUnderstandHeaderBlocks(String actor) {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-
- /**
- * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
- * objects in this <code>SOAPHeader</code> object.
- * <p/>
- * Not that this will return elements containing the QName
- * (http://schemas.xmlsoap.org/soap/envelope/, Header)
- *
- * @return an <code>Iterator</code> object over all the
- * <code>SOAPHeaderBlock</code> objects contained by this
- * <code>SOAPHeader</code>
- */
- public Iterator examineAllHeaderBlocks() {
- return this.getChildrenWithName(null);
- }
-
- /**
- * Returns an <code>Iterator</code> over all the <code>SOAPHeaderBlock</code>
- * objects in this <code>SOAPHeader </code> object and detaches them from
- * this <code>SOAPHeader</code> object.
- *
- * @return an <code>Iterator</code> object over all the
- * <code>SOAPHeaderBlock</code> objects contained by this
- * <code>SOAPHeader</code>
- */
- public Iterator extractAllHeaderBlocks() {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java Sun Mar 13 21:53:01 2005
@@ -1,257 +0,0 @@
-package org.apache.axis.impl.llom.builder;
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.axis.impl.llom.OMElementImpl;
-import org.apache.axis.impl.llom.OMNodeImpl;
-import org.apache.axis.impl.llom.OMTextImpl;
-import org.apache.axis.impl.llom.mtom.MTOMBuilder;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMFactory;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.OMXMLParserWrapper;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * OM should be able to built from any data source. And the model it builds may
- * be a SOAP specific one or just an XML model. This class will give some common
- * functionality of OM Building from StAX.
- */
-public abstract class StAXBuilder implements OMXMLParserWrapper {
- protected OMFactory ombuilderFactory;
- protected XMLStreamReader parser;
- MTOMBuilder MtomBuilder;
-
- protected OMNode lastNode;
-//returns the state of completion
- protected boolean done = false;
-
- //keeps the state of the cache
- protected boolean cache = true;
-
- //keeps the state of the parser access. if the parser is
- //accessed atleast once,this flag will be set
- protected boolean parserAccessed = false;
-
-/*
-* Edited by Thilina Gunarathne
-*/
- protected StAXBuilder(OMFactory ombuilderFactory, InputStream stream) {
- this.ombuilderFactory = ombuilderFactory;
- MtomBuilder = new MTOMBuilder(stream);
- try {
- this.parser = MtomBuilder.getParser();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-/*
- * Edit Over
-*/
-
-
- protected StAXBuilder(InputStream stream) {
- this(OMFactory.newInstance(), stream);
- }
-
- public void setOmbuilderFactory(OMFactory ombuilderFactory) {
- this.ombuilderFactory = ombuilderFactory;
- }
-
- protected abstract void processNamespaceData(OMElement node, boolean isSOAPElement);
- //since the behaviors are different when it comes to namespaces
- //this must be implemented differently
-
- protected void processAttributes(OMElement node) {
- int attribCount = parser.getAttributeCount();
- for (int i = 0; i < attribCount; i++) {
- OMNamespace ns = null;
- String uri = parser.getAttributeNamespace(i);
- if (uri.hashCode() != 0)
- ns = node.findInScopeNamespace(uri, parser.getAttributePrefix(i));
-
- //todo if the attributes are supposed to namespace qualified all the time
- //todo then this should throw an exception here
- node.insertAttribute(ombuilderFactory.createOMAttribute(parser.getAttributeLocalName(i),
- ns,
- parser.getAttributeValue(i)));
- }
- }
-
- protected OMNode createOMText() throws OMException {
- if (lastNode == null)
- throw new OMException();
- OMNodeImpl node;
- if (lastNode.isComplete()) {
- node = new OMTextImpl(lastNode.getParent(), parser.getText());
- lastNode.setNextSibling(node);
- node.setPreviousSibling(lastNode);
- } else {
- OMElementImpl e = (OMElementImpl) lastNode;
- node = new OMTextImpl(e, parser.getText());
- e.setFirstChild(node);
- }
- return node;
- }
-
- public void reset(OMNode node) throws OMException {
- lastNode = null;
- }
-
- public void discard(OMElement el) throws OMException {
-
- OMElementImpl elementImpl = null;
- if (el instanceof OMElementImpl) {
- elementImpl = (OMElementImpl) el;
- } else {
- throw new OMException();
- }
-
- if (elementImpl.isComplete() || !cache)
- throw new OMException();
- try {
- cache = false;
- do {
- while (parser.next() != XMLStreamConstants.END_ELEMENT) ;
- // TODO:
- } while (!parser.getName().equals(elementImpl.getLocalName()));
- lastNode = (OMNodeImpl) elementImpl.getPreviousSibling();
- if (lastNode != null)
- lastNode.setNextSibling(null);
- else {
- OMElement parent = elementImpl.getParent();
- if (parent == null)
- throw new OMException();
- parent.setFirstChild(null);
- lastNode = parent;
- }
- cache = true;
- } catch (OMException e) {
- throw e;
- } catch (Exception e) {
- throw new OMException(e);
- }
- }
-
- public String getText() throws OMException {
- return parser.getText();
- }
-
- public String getNamespace() throws OMException {
- return parser.getNamespaceURI();
- }
-
- public int getNamespaceCount() throws OMException {
- try {
- return parser.getNamespaceCount();
- } catch (Exception e) {
- throw new OMException(e);
- }
- }
-
- public String getNamespacePrefix(int index) throws OMException {
- try {
- return parser.getNamespacePrefix(index);
- } catch (Exception e) {
- throw new OMException(e);
- }
- }
-
- public String getNamespaceUri(int index) throws OMException {
- try {
- return parser.getNamespaceURI(index);
- } catch (Exception e) {
- throw new OMException(e);
- }
- }
-
- public void setCache(boolean b) {
- if (parserAccessed && b)
- throw new UnsupportedOperationException("parser accessed. cannot set cache");
- cache = b;
- }
-
- public String getName() throws OMException {
- return parser.getLocalName();
- }
-
- public String getPrefix() throws OMException {
- return parser.getPrefix();
- }
-
- public int getAttributeCount() throws OMException {
- return parser.getAttributeCount();
- }
-
- public String getAttributeNamespace(int arg) throws OMException {
- return parser.getAttributeNamespace(arg);
- }
-
- public String getAttributeName(int arg) throws OMException {
- return parser.getAttributeNamespace(arg);
- }
-
- public String getAttributePrefix(int arg) throws OMException {
- return parser.getAttributeNamespace(arg);
- }
-
- public Object getParser() {
- if (!cache) {
- parserAccessed = true;
- return parser;
- } else {
- throw new UnsupportedOperationException("cache must be switched off to access the parser");
- }
- }
-
- public boolean isCompleted() {
- return done;
- }
-
- /**
- * This method will be called with the XMLStreamConstants.START_ELEMENT
- * event
- *
- * @return
- * @throws OMException
- */
- protected abstract OMNode createOMElement() throws OMException;
-
- /**
- * This should proceed the parser one step further, if parser is not
- * completed yet. If this has been called whist parser is done, then throw
- * an OMException.
- * <p/>
- * If the cache is set to false, then should be return the event, *without*
- * building the OM tree.
- * <p/>
- * If the cache is set to true, then this should handle all the events
- * within this, and should build the object structure appropriately and
- * return the event.
- *
- * @return
- * @throws OMException
- */
- public abstract int next() throws OMException;
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/builder/StAXOMBuilder.java Sun Mar 13 21:53:01 2005
@@ -1,202 +0,0 @@
-package org.apache.axis.impl.llom.builder;
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamConstants;
-
-import org.apache.axis.impl.llom.OMDocument;
-import org.apache.axis.impl.llom.OMElementImpl;
-import org.apache.axis.impl.llom.mtom.OMBlob;
-import org.apache.axis.om.OMAttribute;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMFactory;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.OMXMLParserWrapper;
-import org.apache.axis.om.SOAPEnvelope;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * This will construct an OM without using SOAP specific classes like
- * SOAPEnvelope, SOAPHeader, SOAPHeaderBlock and SOAPBody. And this will habe
- * the Document concept also.
- */
-public class StAXOMBuilder extends StAXBuilder implements OMXMLParserWrapper {
- protected OMDocument document;
-
- /*
- * Edited by Thilina Gunarathne
- */
- public StAXOMBuilder(OMFactory ombuilderFactory, InputStream stream) {
- super(ombuilderFactory, stream);
- document = new OMDocument(this);
- }
-
- public StAXOMBuilder(InputStream stream) {
- super(stream);
- document = new OMDocument(this);
- }
-
- protected OMNode createOMElement() throws OMException {
-
- String elementName = parser.getLocalName();
- String namespaceURI = parser.getNamespaceURI();
-
- if (elementName.equalsIgnoreCase("Include")
- & namespaceURI
- .equalsIgnoreCase("http://www.w3.org/2004/08/xop/include")) {
- OMBlob node;
- String CID = null;
- String CIDName = null;
- boolean found = false;
- OMAttribute Attr;
-
- CID = parser.getAttributeValue(0);
- CID = CID.trim();
- CIDName = parser.getAttributeLocalName(0);
- if (CIDName.equalsIgnoreCase("href")
- & CID.substring(0, 3).equalsIgnoreCase("cid")) {
- CID = CID.substring(4);
- found = true;
- }
-
- if (found) {
- if (lastNode.isComplete()) {
- node = new OMBlob(CID, lastNode.getParent(), MtomBuilder);
- lastNode.setNextSibling(node);
- node.setPreviousSibling(lastNode);
- } else {
- OMElement e = (OMElement) lastNode;
- node = new OMBlob(CID, (OMElement) lastNode, MtomBuilder);
- e.setFirstChild(node);
- }
- } else {
- throw new OMException("CID not Found");
- }
- return node;
- } else {
- OMElement node;
- if (lastNode == null) {
- node = new OMElementImpl(elementName, null, null, this);
- document.setRootElement(node);
- } else if (lastNode.isComplete()) {
- node = new OMElementImpl(elementName, null, lastNode
- .getParent(), this);
- lastNode.setNextSibling(node);
- node.setPreviousSibling(lastNode);
- } else {
- OMElement e = (OMElement) lastNode;
- node = new OMElementImpl(elementName, null,
- (OMElement) lastNode, this);
- e.setFirstChild(node);
- }
-
- //create the namespaces
- processNamespaceData(node, false);
-
- //fill in the attributes
- processAttributes(node);
-
- return node;
- }
- }
-
- /*
- * Edit Over
- */
-
- public SOAPEnvelope getOMEnvelope() throws OMException {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-
- public int next() throws OMException {
- try {
-
- if (done)
- throw new OMException();
-
- int token = parser.next();
-
- if (!cache) {
- return token;
- }
-
- switch (token) {
- case XMLStreamConstants.START_ELEMENT:
- lastNode = createOMElement();
- break;
-
- case XMLStreamConstants.START_DOCUMENT:
- document = new OMDocument(this);
- break;
-
- case XMLStreamConstants.CHARACTERS:
- lastNode = createOMText();
- break;
-
- case XMLStreamConstants.END_ELEMENT:
- if (lastNode.isComplete()) {
- OMElement parent = lastNode.getParent();
- parent.setComplete(true);
- lastNode = parent;
- } else {
- OMNode e = (OMNode) lastNode;
- e.setComplete(true);
- }
- break;
-
- case XMLStreamConstants.END_DOCUMENT:
- done = true;
-
- break;
- case XMLStreamConstants.SPACE:
- next();
- break;
-
- default:
- throw new OMException();
- }
- return token;
- } catch (OMException e) {
- throw e;
- } catch (Exception e) {
- e.printStackTrace();
- throw new OMException(e);
- }
- }
-
- public OMElement getDocumentElement() {
- return document.getRootElement();
- }
-
- protected void processNamespaceData(OMElement node, boolean isSOAPElement) {
- int namespaceCount = parser.getNamespaceCount();
- for (int i = 0; i < namespaceCount; i++) {
- node.declareNamespace(parser.getNamespaceURI(i), parser
- .getNamespacePrefix(i));
- }
-
- //set the own namespace
- OMNamespace namespace = node.findInScopeNamespace(parser
- .getNamespaceURI(), parser.getPrefix());
- node.setNamespace(namespace);
- }
-
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/MTOMException.java Sun Mar 13 21:53:01 2005
@@ -1,11 +0,0 @@
-package org.apache.axis.impl.llom.exception;
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-
-public class MTOMException extends Exception {
- public MTOMException(String s) {
- super(s);
- }
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMBuilderException.java Sun Mar 13 21:53:01 2005
@@ -1,25 +0,0 @@
-package org.apache.axis.impl.llom.exception;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 22, 2004 Time:
- * 10:43:32 AM
- */
-public class OMBuilderException extends Exception {
- public OMBuilderException(String s) {
- super(s);
- }
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMSerializerException.java Sun Mar 13 21:53:01 2005
@@ -1,22 +0,0 @@
-package org.apache.axis.impl.llom.exception;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 18, 2004 Time:
- * 12:14:23 PM
- */
-public class OMSerializerException extends Exception {
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/OMStreamingException.java Sun Mar 13 21:53:01 2005
@@ -1,37 +0,0 @@
-package org.apache.axis.impl.llom.exception;
-
-import org.apache.axis.om.OMException;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- *
- * @author Axis team Date: Nov 18, 2004 Time: 1:54:11 PM
- */
-public class OMStreamingException extends OMException {
- public OMStreamingException() {
- }
-
- public OMStreamingException(String message) {
- super(message);
- }
-
- public OMStreamingException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public OMStreamingException(Throwable cause) {
- super(cause);
- }
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/exception/XMLStreamException.java Sun Mar 13 21:53:01 2005
@@ -1,22 +0,0 @@
-package org.apache.axis.impl.llom.exception;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- * User: Eran Chinthaka - Lanka Software Foundation Date: Nov 18, 2004 Time:
- * 12:13:54 PM
- */
-public class XMLStreamException extends Exception {
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java Sun Mar 13 21:53:01 2005
@@ -1,155 +0,0 @@
-package org.apache.axis.impl.llom.factory;
-
-import org.apache.axis.impl.llom.OMAttributeImpl;
-import org.apache.axis.impl.llom.OMElementImpl;
-import org.apache.axis.impl.llom.OMNamedNodeImpl;
-import org.apache.axis.impl.llom.OMNamespaceImpl;
-import org.apache.axis.impl.llom.OMNodeImpl;
-import org.apache.axis.impl.llom.OMTextImpl;
-import org.apache.axis.impl.llom.SOAPBodyImpl;
-import org.apache.axis.impl.llom.SOAPEnvelopeImpl;
-import org.apache.axis.impl.llom.SOAPFaultImpl;
-import org.apache.axis.impl.llom.SOAPHeaderBlockImpl;
-import org.apache.axis.impl.llom.SOAPHeaderImpl;
-import org.apache.axis.om.OMAttribute;
-import org.apache.axis.om.OMConstants;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMFactory;
-import org.apache.axis.om.OMNamedNode;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.OMText;
-import org.apache.axis.om.OMXMLParserWrapper;
-import org.apache.axis.om.SOAPBody;
-import org.apache.axis.om.SOAPEnvelope;
-import org.apache.axis.om.SOAPFault;
-import org.apache.axis.om.SOAPHeader;
-import org.apache.axis.om.SOAPHeaderBlock;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-public class OMLinkedListImplFactory extends OMFactory {
- public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) {
- return new OMAttributeImpl(localName, ns, value);
- }
-
- public OMElement createOMElement(OMElement parent) {
- return new OMElementImpl(parent);
- }
-
- public OMElement createOMElement(String localName, OMNamespace ns) {
- return new OMElementImpl(localName, ns);
- }
-
- public OMElement createOMElement(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- return new OMElementImpl(localName, ns, parent, builder);
- }
-
- public OMNamedNode createOMNamedNode(String localName, OMNamespace ns, OMElement parent) {
- return new OMNamedNodeImpl(localName, ns, parent);
- }
-
- public OMNamedNode createOMNamedNode(OMElement parent) {
- return new OMNamedNodeImpl(parent);
- }
-
- public OMNamespace createOMNamespace(String uri, String prefix) {
- return new OMNamespaceImpl(uri, prefix);
- }
-
- public OMNode createOMNode(OMElement parent) {
- return new OMNodeImpl(parent);
- }
-
- public OMText createText(OMElement parent, String text) {
- return new OMTextImpl(parent, text);
- }
-
- public OMText createText(String s) {
- return new OMTextImpl(s);
- }
-
- public SOAPBody createSOAPBody(SOAPEnvelope envelope) {
- return new SOAPBodyImpl(envelope);
- }
-
- public SOAPBody createSOAPBody(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- return new SOAPBodyImpl(localName, ns, parent, builder);
- }
-
- public SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- if (!localName.equals(OMConstants.SOAPENVELOPE_LOCAL_NAME)) {
- throw new OMException("wrong name for the envelope!");
- }
- return new SOAPEnvelopeImpl(localName, ns, parent, builder);
-
- }
-
- public SOAPEnvelope createSOAPEnvelope(String localName, OMNamespace ns) {
- return new SOAPEnvelopeImpl(localName, ns);
- }
-
- public SOAPEnvelope createOMEnvelope(OMXMLParserWrapper parserWrapper) {
- throw new UnsupportedOperationException(); //TODO implement this
- }
-
- //TODO there should be a method to create an SOAPEnvelope giving OMXMLParserWrapper, as OMMessage is no longer there
-
- public SOAPHeader createSOAPHeader(SOAPEnvelope envelope) {
- return new SOAPHeaderImpl(envelope);
- }
-
- public SOAPHeader createSOAPHeader(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- return new SOAPHeaderImpl(localName, ns, parent, builder);
- }
-
- public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns) {
- return new SOAPHeaderBlockImpl(localName, ns);
- }
-
- public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMElement parent, OMXMLParserWrapper builder) {
- return new SOAPHeaderBlockImpl(localName, ns, parent, builder);
- }
-
- public SOAPFault createSOAPFault(SOAPBody parent, Exception e) {
- return new SOAPFaultImpl(parent, e);
- }
-
- public SOAPFault createSOAPFault(OMNamespace ns, SOAPBody parent, OMXMLParserWrapper builder) {
- return new SOAPFaultImpl(ns, parent, builder);
- }
-
- public SOAPEnvelope getDefaultEnvelope() {
- //Create an envelop
- OMNamespace ns = new OMNamespaceImpl(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.SOAPENVELOPE_NAMESPACE_PREFIX);
- SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(OMConstants.SOAPENVELOPE_LOCAL_NAME, ns);
-
- SOAPBodyImpl bodyImpl = new SOAPBodyImpl(env);
- bodyImpl.setComplete(true);
- env.addChild(bodyImpl);
-
- SOAPHeaderImpl headerImpl = new SOAPHeaderImpl(env);
- headerImpl.setComplete(true);
- env.addChild(headerImpl);
-
- return env;
-
-
- }
-
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/AttachmentPart.java Sun Mar 13 21:53:01 2005
@@ -1,32 +0,0 @@
-/*
- * Created on Mar 2, 2005
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.apache.axis.impl.llom.mtom;
-
-/**
- * @author THilina Gunarathne
- * <p/>
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class AttachmentPart {
- String cid;
- OMBlob blob;
-
- public AttachmentPart(String cid, OMBlob blob) {
- this.cid = cid;
- this.blob = blob;
- }
-
- public String getCid() {
- return cid;
- }
-
- public OMBlob getBlob() {
- return blob;
- }
-
-}
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/ByteArrayDataSource.java Sun Mar 13 21:53:01 2005
@@ -1,62 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.activation.DataSource;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne
- */
-public class ByteArrayDataSource implements DataSource {
-
- private byte[] data;
-
- private String type;
-
- public ByteArrayDataSource(byte[] data, String type) {
- super();
- this.data = data;
- 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/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEBodyPartInputStream.java Sun Mar 13 21:53:01 2005
@@ -1,83 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-
-public class MIMEBodyPartInputStream extends InputStream {
-
- MIMEInputStream inStream;
-
- String boundry;
-
- boolean done = false;
-
- boolean began = false;
-
- public MIMEBodyPartInputStream(MIMEInputStream inStream, String boundry) {
- super();
- this.inStream = inStream;
- this.boundry = boundry;
-
- }
-
- public int read() throws IOException {
-
- if (done) {
- return -1;
- } else {
- int value = 0;
- String line = "";
-
- value = inStream.read();
-
- while (value == 13 & !began) {
- value = inStream.read();
- value = inStream.read();
- }
- began = true;
-
- char readChar = (char) value;
- if (readChar == '-') {
- inStream.mark();
- char readNextChar = ' ';
-
- readNextChar = (char) inStream.read();
-
- if (readNextChar == '-') {
- line = inStream.read(boundry.length());
- if (line.equals(boundry)) {
- done = true;
- return -1;
-
- } else {
- inStream.reset();
- }
- } else {
- inStream.reset();
- }
- }
- return value;
- }
- }
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEInputStream.java Sun Mar 13 21:53:01 2005
@@ -1,121 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedList;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-
-public class MIMEInputStream extends InputStream {
-
- InputStream inStream;
-
- LinkedList buffer;
-
- boolean mark = false;
-
- boolean reset = false;
-
- int point = 0;
-
- public MIMEInputStream(InputStream inStream) {
- super();
- this.inStream = inStream;
- buffer = new LinkedList();
- }
-
- public int read() throws IOException {
- int temp = readMain();
- return temp;
- }
-
- public String readLine() throws IOException {
- String line = "";
- char character = ' ';
- do {
- try {
- character = (char) readMain();
- line += character;
- } catch (IOException e) {
- e.printStackTrace();
- }
- } while (character != '\n');
-
- return line;
- }
-
- public String read(int length) throws IOException {
- String line = "";
- char character = ' ';
- for (int i = 0; i < length; i++) {
- character = (char) readMain();
- line += character;
- }
- return line;
- }
-
- public int readMain() throws IOException {
- int temp;
- if (mark & reset) {
- Integer byteOb = (Integer) buffer.get(point);
- temp = byteOb.intValue();
- if (buffer.get(point).equals(buffer.getLast())) {
- reset = false;
- point = 0;
- } else {
- point++;
- }
- } else if (mark) {
- temp = inStream.read();
- buffer.add(new Integer(temp));
- } else if (reset) {
- if (buffer.isEmpty()) {
- reset = false;
- temp = inStream.read();
- } else {
- Integer byteOb = (Integer) buffer.getFirst();
- temp = byteOb.intValue();
- buffer.removeFirst();
- }
- } else {
- temp = inStream.read();
- }
- return temp;
- }
-
- public void mark() {
- if (!reset) {
- buffer.clear();
- }
- mark = true;
- }
-
- public void reset() throws IOException {
- if (mark) {
- reset = true;
- mark = false;
- point = 0;
- } else {
- throw new IOException("not marked");
- }
- }
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MIMEParser.java Sun Mar 13 21:53:01 2005
@@ -1,132 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.activation.DataHandler;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMultipart;
-import javax.mail.internet.MimePartDataSource;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-public class MIMEParser {
-
- int partIndex = 0;
-
- MIMEInputStream in;
-
- String mimeVersion;
-
- String contentType;
-
- boolean messageMime;
-
- String boundry;
-
- boolean complete = false;
-
- String start;
-
- MimeMessage message;
-
- public MIMEParser(InputStream inStream) {
-
- Properties props = new Properties();
- javax.mail.Session session = javax.mail.Session
- .getInstance(props, null);
- try {
- message = new MimeMessage(session, inStream);
- messageMime = true;
- //in = new MIMEInputStream(inStream);
- } catch (MessagingException e) {
- messageMime = false;
- }
- }
-
- public boolean mimeMessage() {
- return messageMime;
- /*
- * String line = null; char readChar = ' '; boolean found = false; int
- * startIndex, finishIndex, valueFinishIndex;
- *
- * //Start processing the Mime Header try { in.readLine(); line =
- * in.readLine(); } catch (Exception e) { System.out.println(e); }
- *
- * line = line.trim(); String[] versionArray = line.split(":");
- *
- * //Extracts and stores MIME version information if
- * (versionArray[0].equalsIgnoreCase("MIME-Version")) { mimeVersion =
- * versionArray[1];
- * /* extract the Mime boundry
- */
- /*
- * do { try { line = in.readLine(); } catch (Exception e) {
- * System.out.println(e); }
- *
- * //extracting the mime boundry string startIndex =
- * line.indexOf("boundary="); } while (startIndex == -1);
- *
- * finishIndex = (startIndex + ("boundary=").length()); valueFinishIndex =
- * line.indexOf(";", finishIndex);
- *
- * if (valueFinishIndex > 0) { boundry = line.substring(finishIndex,
- * valueFinishIndex); } else { boundry = line.substring(finishIndex); }
- * boundry = boundry.replace('"', ' '); boundry = boundry.trim();
- * /* Move the input stream to the begining of the MIME root part
- */
- /*
- * do { try { in.mark(boundry.length() + 5); readChar = (char)
- * in.read(); } catch (Exception e) { System.out.println(e); } if
- * (readChar == '-') { char readNextChar = ' '; try { readNextChar =
- * (char) in.read(); } catch (IOException e3) { e3.printStackTrace(); }
- *
- * if (readNextChar == '-') { char[] cBuf = new char[boundry.length()];
- *
- * try { line = in.read(boundry.length()); } catch (IOException e1) {
- * e1.printStackTrace(); }
- *
- * if (line.equals(boundry)) { found = true; } else { try { in.reset(); }
- * catch (IOException e2) { e2.printStackTrace(); } } } } } while
- * (!found); return true; } else { return false; }
- */
- }
-
- public MimeBodyPart getPart() throws Exception {
- MimeBodyPart part = null;
- /*
- * if (!complete) {
- *
- * MIMEBodyPartInputStream partStream = new MIMEBodyPartInputStream( in,
- * boundry); part = new MimeBodyPart(partStream); if (part.getSize() ==
- * 0 | part.getSize() < 0) { complete = true; return null; } }
- */
- DataHandler dh = message.getDataHandler();
- MimeMultipart multiPart = new MimeMultipart((MimePartDataSource) dh
- .getDataSource());
- part = (MimeBodyPart) multiPart.getBodyPart(partIndex);
-
- partIndex++;
- return part;
- }
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMBuilder.java Sun Mar 13 21:53:01 2005
@@ -1,117 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.InputStream;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.MimeBodyPart;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-public class MTOMBuilder {
- LinkedList parts;
-
- InputStream inStream;
-
- MIMEParser parser;
-
- public MTOMBuilder(InputStream inStream) {
- this.inStream = inStream;
- this.parser = new MIMEParser(inStream);
- parts = new LinkedList();
- }
-
- public DataHandler getDataHandler(String cid) throws Exception {
- /*
- * First checks whether the part is already parsed by checking the parts
- * linked list. If it is not parsed yet then call the getnextPart() till
- * we find the required part.
- */
- MimeBodyPart part;
-
- boolean found = false;
- ListIterator partsIterator = parts.listIterator();
- while (partsIterator.hasNext()) {
- part = (MimeBodyPart) partsIterator.next();
- if (cid.equals(part.getContentID())) {
- found = true;
- DataHandler dh = part.getDataHandler();
- return dh;
- }
- }
- while (!found) {
- part = this.getNextPart();
-
- if (part == null) {
- break;
- }
- String partCid = part.getContentID();
- String cida = "<" + cid + ">";
- if (cida.equals(partCid)) {
- found = true;
- DataHandler dh = part.getDataHandler();
- return dh;
- }
- }
- return null;
- }
-
- public XMLStreamReader getParser() throws Exception {
-
- if (parser.mimeMessage()) {
- MimeBodyPart root = getRoot();
- return XMLInputFactory.newInstance().createXMLStreamReader(
- root.getInputStream());
- } else {
- return XMLInputFactory.newInstance()
- .createXMLStreamReader(inStream);
- }
- }
-
- public MimeBodyPart getRoot() throws Exception {
- MimeBodyPart root;
- if (parts.isEmpty()) {
- root = parser.getPart();
- parts.add(root);
- } else {
- root = (MimeBodyPart) parts.getFirst();
- }
- System.out.println("MIME root parsed. NO of parts parsed :"
- + parts.size());
- return root;
- }
-
- public MimeBodyPart getNextPart() throws Exception {
- MimeBodyPart nextPart;
- nextPart = parser.getPart();
- if (nextPart != null) {
- parts.add(nextPart);
- System.out.println("Next part parsed. NO of parts parsed :"
- + parts.size());
- return nextPart;
- } else
- return null;
- }
-
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/MTOMXMLStreamWriter.java Sun Mar 13 21:53:01 2005
@@ -1,452 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Properties;
-import java.util.Random;
-import java.util.*;
-
-import javax.activation.DataHandler;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMultipart;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne
- */
-public class MTOMXMLStreamWriter implements XMLStreamWriter {
-
- OutputStream outStream;
-
- BufferedOutputStream soapStream;
-
- XMLStreamWriter writer;
-
- Random rnd;
- HashMap partMap;
-
- LinkedList partList;
-
- ByteArrayOutputStream byteStream;
-
- public static String[] filter = new String[] { "Message-ID" };
-
- public MTOMXMLStreamWriter(OutputStream out) throws XMLStreamException,
- FactoryConfigurationError {
- super();
- this.outStream = out;
-
- byteStream = new ByteArrayOutputStream();
-
- writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
- byteStream);
- partMap = new HashMap();
- rnd = new Random();
-
- }
-
- public String createPart(OMBlob blob) {
- String cid = "http://example.org/my.hsh" + (rnd.nextInt());
-
- partMap.put(cid,blob);
-
- return cid;
- }
-
- public MimeBodyPart createMimePart(String cid, OMBlob blob)
- throws Exception {
- MimeBodyPart mb = new MimeBodyPart();
- mb.setDataHandler(blob.getDataHandler());
- mb.addHeader("Content-Transfer-Encoding", "binary");
- mb.addHeader("Content-ID", "<" + cid + ">");
- return mb;
-
- }
-
- public void complete() throws Exception {
- DataHandler dh = new DataHandler(byteStream.toString(), "text/xml");
- MimeBodyPart mb = new MimeBodyPart();
- mb.setDataHandler(dh);
- mb.addHeader("Content-Type", "application/xop+xml");
- mb.addHeader("Content-Transfer-Encoding", "8bit");
- String cid = "<http://example.org/my.hsh>";
- mb.addHeader("Content-ID", cid);
-
- //MimeMessage message = new MimeMessage(Session.getDefaultInstance(new
- // java.util.Properties()));
-
- Properties props = new Properties();
- javax.mail.Session session = javax.mail.Session
- .getInstance(props, null);
- javax.mail.internet.MimeMessage message = new javax.mail.internet.MimeMessage(
- session);
- MimeMultipart mes = new MimeMultipart("Related");
- mes.addBodyPart(mb);
- Set keys = partMap.keySet();
-
-
- Iterator keyIterator = keys.iterator();
- while (keyIterator.hasNext()) {
- String key = (String) keyIterator.next();
- OMBlob blob = (OMBlob) partMap.get(key);
-
- mes.addBodyPart(createMimePart(key, blob));
- }
- mes.writeTo(System.out);
- System.out.println("----------------------------");
- message.setContent(mes);
- message.removeHeader("Message-Id");
- message.writeTo(System.out);
- message.writeTo(outStream, filter);
- }
-
- public void writeStartElement(String localName) throws XMLStreamException {
- writer.writeStartElement(localName);
- }
-
- public void writeStartElement(String namespaceURI, String localName)
- throws XMLStreamException {
- writer.writeStartElement(namespaceURI, localName);
-
- }
-
- public void writeStartElement(String prefix, String localName,
- String namespaceURI) throws XMLStreamException {
- writer.writeStartElement(prefix, localName, namespaceURI);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
- * java.lang.String)
- */
- public void writeEmptyElement(String namespaceURI, String localName)
- throws XMLStreamException {
- writer.writeEmptyElement(namespaceURI, localName);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String,
- * java.lang.String, java.lang.String)
- */
- public void writeEmptyElement(String prefix, String localName,
- String namespaceURI) throws XMLStreamException {
- writer.writeEmptyElement(prefix, localName, namespaceURI);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEmptyElement(java.lang.String)
- */
- public void writeEmptyElement(String localName) throws XMLStreamException {
- writer.writeEmptyElement(localName);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEndElement()
- */
- public void writeEndElement() throws XMLStreamException {
- writer.writeEndElement();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEndDocument()
- */
- public void writeEndDocument() throws XMLStreamException {
- writer.writeEndDocument();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#close()
- */
- public void close() throws XMLStreamException {
- writer.close();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#flush()
- */
- public void flush() throws XMLStreamException {
- writer.flush();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
- * java.lang.String)
- */
- public void writeAttribute(String localName, String value)
- throws XMLStreamException {
- writer.writeAttribute(localName, value);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String)
- */
- public void writeAttribute(String prefix, String namespaceURI,
- String localName, String value) throws XMLStreamException {
- writer.writeAttribute(prefix, namespaceURI, localName, value);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeAttribute(java.lang.String,
- * java.lang.String, java.lang.String)
- */
- public void writeAttribute(String namespaceURI, String localName,
- String value) throws XMLStreamException {
- writer.writeAttribute(namespaceURI, localName, value);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeNamespace(java.lang.String,
- * java.lang.String)
- */
- public void writeNamespace(String prefix, String namespaceURI)
- throws XMLStreamException {
- writer.writeNamespace(prefix, namespaceURI);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeDefaultNamespace(java.lang.String)
- */
- public void writeDefaultNamespace(String namespaceURI)
- throws XMLStreamException {
- writer.writeDefaultNamespace(namespaceURI);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeComment(java.lang.String)
- */
- public void writeComment(String data) throws XMLStreamException {
- writer.writeComment(data);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String)
- */
- public void writeProcessingInstruction(String target)
- throws XMLStreamException {
- writer.writeProcessingInstruction(target);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeProcessingInstruction(java.lang.String,
- * java.lang.String)
- */
- public void writeProcessingInstruction(String target, String data)
- throws XMLStreamException {
- writer.writeProcessingInstruction(target, data);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeCData(java.lang.String)
- */
- public void writeCData(String data) throws XMLStreamException {
- writer.writeCData(data);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeDTD(java.lang.String)
- */
- public void writeDTD(String dtd) throws XMLStreamException {
- writer.writeDTD(dtd);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeEntityRef(java.lang.String)
- */
- public void writeEntityRef(String name) throws XMLStreamException {
- writer.writeEntityRef(name);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeStartDocument()
- */
- public void writeStartDocument() throws XMLStreamException {
- writer.writeStartDocument();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String)
- */
- public void writeStartDocument(String version) throws XMLStreamException {
- writer.writeStartDocument(version);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeStartDocument(java.lang.String,
- * java.lang.String)
- */
- public void writeStartDocument(String encoding, String version)
- throws XMLStreamException {
- writer.writeStartDocument(encoding, version);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeCharacters(java.lang.String)
- */
- public void writeCharacters(String text) throws XMLStreamException {
- writer.writeCharacters(text);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#writeCharacters(char[], int, int)
- */
- public void writeCharacters(char[] text, int start, int len)
- throws XMLStreamException {
- writer.writeCharacters(text, start, len);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#getPrefix(java.lang.String)
- */
- public String getPrefix(String uri) throws XMLStreamException {
-
- return writer.getPrefix(uri);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#setPrefix(java.lang.String,
- * java.lang.String)
- */
- public void setPrefix(String prefix, String uri) throws XMLStreamException {
- writer.setPrefix(prefix, uri);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#setDefaultNamespace(java.lang.String)
- */
- public void setDefaultNamespace(String uri) throws XMLStreamException {
- writer.setDefaultNamespace(uri);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#setNamespaceContext(javax.xml.namespace.NamespaceContext)
- */
- public void setNamespaceContext(NamespaceContext context)
- throws XMLStreamException {
- writer.setNamespaceContext(context);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#getNamespaceContext()
- */
- public NamespaceContext getNamespaceContext() {
-
- return writer.getNamespaceContext();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.xml.stream.XMLStreamWriter#getProperty(java.lang.String)
- */
- public Object getProperty(String name) throws IllegalArgumentException {
-
- return writer.getProperty(name);
- }
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/mtom/OMBlob.java Sun Mar 13 21:53:01 2005
@@ -1,124 +0,0 @@
-package org.apache.axis.impl.llom.mtom;
-
-import javax.activation.DataHandler;
-
-import org.apache.axis.impl.llom.OMNodeImpl;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMNode;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
- */
-
-/**
- * @author Thilina Gunarathne thil747@yahoo.com
- */
-
-public class OMBlob extends OMNodeImpl {
-
- private String cid = null;
-
- private MTOMBuilder builder;
-
- private DataHandler DH = null;
-
- // boolean MTOMable = true;
-
- public OMBlob(DataHandler DH) {
- this.DH = DH;
- // this.MTOMable = MTOMable;
- }
-
- public OMBlob(String cid, OMElement parent, MTOMBuilder mimeParser) {
- super(parent);
- this.cid = cid;
- this.builder = mimeParser;
- }
-
- public java.io.OutputStream getStream() throws Exception {
- if (DH == null) {
- getDataHandler();
- }
- return DH.getOutputStream();
- }
-
- public String getValue() throws OMException {
- throw new OMException(
- "Blob contains Binary data. Returns Stream or Datahandler only");
- }
-
- public DataHandler getDataHandler() throws Exception {
- if (DH == null) {
- DH = builder.getDataHandler(cid);
- }
- return DH;
- }
-
- public short getType() throws OMException {
- return OMNode.BLOB_NODE;
- }
-
- public boolean isComplete() {
- return done;
- }
- // Decided to let user select whether to optimise or not only when he
- // creates OMBlob
- /*
- * public void setMTOMable(boolean MTOMable) { this.MTOMable = MTOMable; }
- *
- * public boolean isMTOMable() { return MTOMable; }
- */
-
- // decided to provide only the Datahandler
- /* public/*Serializable *//*
- * Object getObject() throws Exception { if
- * ((binaryObject == null) & (cid != null)) { if
- * (DH == null) { getDataHandler(); } // /*
- *
- *
- * javax.activation.DataSource ds =
- * datahandler.getDataSource(); InputStream is =
- * null; try { is = ds.getInputStream();; } catch
- * (java.io.IOException io) {
- * log.error(Messages.getMessage("javaIOException00"),
- * io); throw new SOAPException(io); } if
- * (ds.getContentType().equals("text/plain")) { try {
- * byte[] bytes = new byte[is.available()];
- * IOUtils.readFully(is, bytes); return new
- * String(bytes); } catch (java.io.IOException io) {
- * log.error(Messages.getMessage("javaIOException00"),
- * io); throw new SOAPException(io); } } else if
- * (ds.getContentType().equals("text/xml")) {
- * return new StreamSource(is); } else if
- * (ds.getContentType().equals("image/gif") ||
- * ds.getContentType().equals("image/jpeg")) { try {
- * return
- * ImageIOFactory.getImageIO().loadImage(is); }
- * catch (Exception ex) {
- * log.error(Messages.getMessage("javaIOException00"),
- * ex); throw new SOAPException(ex); } } return is; //
- */
- /*
- * Object in = DH.getContent(); if (in instanceof InputStream) {
- * ObjectInputStream ois = new ObjectInputStream((InputStream) in);
- * binaryObject = ois.readObject(); } else binaryObject = in; return
- * binaryObject; } else if ((binaryObject == null) & (cid == null)) { throw
- * new MTOMException("OMBlob not initialised Properly"); } return
- * binaryObject; }
- */
-
-}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java?view=diff&r1=157392&r2=157393
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java (original)
+++ webservices/axis/trunk/archive/java/scratch/Thilina/MTOM/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java Sun Mar 13 21:53:01 2005
@@ -1,233 +0,0 @@
-package org.apache.axis.impl.llom.serialize;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-import java.util.Vector;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.axis.encoding.Base64;
-import org.apache.axis.impl.llom.OMAttributeImpl;
-import org.apache.axis.impl.llom.OMNamespaceImpl;
-import org.apache.axis.impl.llom.mtom.MTOMXMLStreamWriter;
-import org.apache.axis.impl.llom.mtom.OMBlob;
-import org.apache.axis.om.OMAttribute;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.OMText;
-
-/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- */
-public class SimpleOMSerializer {
-
- private Vector prefixList = new Vector();
-
- public void serialize(Object omNode, XMLStreamWriter writer)
- throws XMLStreamException {
-
- if (!(omNode instanceof OMNode)) {
- throw new UnsupportedOperationException("Unsupported input object. Must be of the the type OMNode");
- }
-
- OMNode node = (OMNode) omNode;
- serializeNode(node, writer);
- }
-
- protected void serializeNode(OMNode node, XMLStreamWriter writer)
- throws XMLStreamException {
- short nodeType = node.getType();
- if (nodeType == OMNode.ELEMENT_NODE) {
- serializeElement((OMElement) node, writer);
- } else if (nodeType == OMNode.ATTRIBUTE_NODE) {
- serializeAttribute((OMAttribute) node, writer);
- } else if (nodeType == OMNode.TEXT_NODE) {
- serializeText((OMText) node, writer);
- } else if (nodeType == OMNode.COMMENT_NODE) {
- serializeComment((OMText) node, writer);
- } else if (nodeType == OMNode.CDATA_SECTION_NODE) {
- serializeCData((OMText) node, writer);
- // added by Thilina
- } else if (nodeType == OMNode.BLOB_NODE) {
- serializeBlob((OMBlob) node, writer);
- }
- writer.flush();
- }
-
- /**
- * @param element
- */
- protected void serializeElement(OMElement element, XMLStreamWriter writer)
- throws XMLStreamException {
-
- OMNamespace ns = element.getNamespace();
- String prefix = null;
- String nameSpaceName = null;
- if (ns != null) {
- prefix = ns.getPrefix();
- nameSpaceName = ns.getName();
- if (prefix != null) {
- writer.writeStartElement(prefix, element.getLocalName(),
- nameSpaceName);
- if (!prefixList.contains(prefix)) {
- writer.writeNamespace(prefix, nameSpaceName);
- prefixList.add(prefix);
- }
- } else {
- writer.writeStartElement(nameSpaceName, element.getLocalName());
- //add the own namespace
- writer.writeDefaultNamespace(nameSpaceName);
-
- }
- }
-
- //add the elements attributes
- Iterator attributes = element.getAttributes();
- while (attributes.hasNext()) {
- serializeAttribute((OMAttribute) attributes.next(), writer);
- }
-
- //add the namespaces
- Iterator namespaces = element.getAllDeclaredNamespaces();
- if (namespaces != null) {
- while (namespaces.hasNext()) {
- serializeNamespace((OMNamespace) namespaces.next(), writer);
- }
- }
-
- //add the children
- Iterator children = element.getChildren();
-
- while (children.hasNext()) {
- Object node = children.next();
- if (node != null) {
- serializeNode((OMNode) node, writer);
- }
- }
-
- writer.writeEndElement();
-
- }
-
- /*
- * Edited by Thilina Gunarathne
- */
- protected void serializeBlob(OMBlob blob, XMLStreamWriter xmlWriter)
- throws XMLStreamException {
-
- if (xmlWriter instanceof MTOMXMLStreamWriter) {
- MTOMXMLStreamWriter writer = (MTOMXMLStreamWriter) xmlWriter;
- OMNamespace ns = new OMNamespaceImpl("http://www.w3.org/2004/08/xop/Include", "xop");
- String prefix = null;
- String nameSpaceName = null;
- if (ns != null) {
- prefix = ns.getPrefix();
- nameSpaceName = ns.getName();
- if (prefix != null) {
- writer.writeStartElement(prefix, "Include", nameSpaceName);
- //if (!prefixList.contains(prefix)) {
- writer.writeNamespace(prefix, nameSpaceName);
- // prefixList.add(prefix);
- //}
- }
- }
-
- //get the Cid from the MTOMwriter
- String cid;
- try {
- cid = writer.createPart(blob);
- OMAttribute href = new OMAttributeImpl("href",
- new OMNamespaceImpl("", ""), "cid:" + cid.trim());
- serializeAttribute(href, writer);
- } catch (Exception e) {
- e.printStackTrace();
- }
- writer.writeEndElement();
- } else {
- ByteArrayOutputStream byteStream;
- try {
- byteStream = (ByteArrayOutputStream) blob.getStream();
- xmlWriter.writeCharacters(Base64.encode(byteStream
- .toByteArray()));
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- }
-
- /*
- * Edit over
- */
-
- protected void serializeText(OMText text, XMLStreamWriter writer)
- throws XMLStreamException {
- writer.writeCharacters(text.getValue());
- }
-
- protected void serializeCData(OMText text, XMLStreamWriter writer)
- throws XMLStreamException {
- writer.writeCData(text.getValue());
- }
-
- protected void serializeComment(OMText text, XMLStreamWriter writer)
- throws XMLStreamException {
- writer.writeComment(text.getValue());
- }
-
- /**
- * @param attr
- * @param writer
- * @throws XMLStreamException
- */
-
- protected void serializeAttribute(OMAttribute attr, XMLStreamWriter writer)
- throws XMLStreamException {
-
- //first check whether the attribute is associated with a namespace
- OMNamespace ns = attr.getNamespace();
- String prefix = null;
- String namespaceName = null;
- if (ns != null) {
- //add the prefix if it's availble
- prefix = ns.getPrefix();
- namespaceName = ns.getName();
-
- if (prefix != null)
- writer.writeAttribute(prefix, namespaceName, attr
- .getLocalName(), attr.getValue());
- else
- writer.writeAttribute(namespaceName, attr.getLocalName(), attr
- .getValue());
- } else {
- writer.writeAttribute(attr.getLocalName(), attr.getValue());
- }
-
- }
-
- protected void serializeNamespace(OMNamespace namespace,
- XMLStreamWriter writer) throws XMLStreamException {
- if (namespace != null) {
- String prefix = namespace.getPrefix();
- if (!prefixList.contains(prefix))
- writer.writeNamespace(prefix, namespace.getName());
-
- }
- }
-
-}
\ No newline at end of file