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 di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [117/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/a...
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java Thu Sep 15 11:52:11 2005
@@ -1,399 +1,399 @@
-/**
- * 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/>
- */
-package org.apache.axis2.attachments;
-
-import org.apache.axis2.om.OMException;
-import org.apache.axis2.om.impl.MTOMConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.activation.DataHandler;
-import javax.mail.MessagingException;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.ParseException;
-import java.io.ByteArrayInputStream;
-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 {
-
- /**
- * <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;
-
- /**
- * <code>endOfStreamReached</code> flag which is to be set by
- * MIMEBodyPartStream when MIME message terminator is found.
- */
- boolean endOfStreamReached = false;
-
- String firstPartId = null;
-
- boolean fileCacheEnable = false;
-
- String attachmentRepoDir = null;
-
- int fileStorageThreshold;
-
- protected Log log = LogFactory.getLog(getClass());
-
-
- /**
- * @param inStream
- * @param contentTypeString
- * @param fileCacheEnable
- * @param attachmentRepoDir
- * @throws OMException
- * Will move the pointer to the begining of the first MIME part. Will
- * read till first MIME boundary is found or end of stream reached.
- */
- public MIMEHelper(InputStream inStream, String contentTypeString,
- boolean fileCacheEnable, String attachmentRepoDir,
- String fileThreshold) throws OMException {
- this.attachmentRepoDir = attachmentRepoDir;
- this.fileCacheEnable = fileCacheEnable;
- if (fileThreshold != null && (!fileThreshold.equals(""))) {
- this.fileStorageThreshold = Integer.parseInt(fileThreshold);
- } else {
- this.fileStorageThreshold = 1;
- }
- bodyPartsMap = new HashMap();
- try {
- contentType = new ContentType(contentTypeString);
- } catch (ParseException e) {
- throw new OMException(
- "Invalid Content Type Field in the Mime Message"
- ,e);
- }
- // Boundary always have the prefix "--".
- this.boundary = ("--" + contentType.getParameter("boundary"))
- .getBytes();
-
- // 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(), e1);
- }
- }
- }
-
- /**
- * @param inStream
- * @param contentTypeString
- * @throws OMException
- * Will set file cache to false
- */
- public MIMEHelper(InputStream inStream, String contentTypeString)
- throws OMException {
- this(inStream, contentTypeString, false, null, 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(MTOMConstants.MTOM_TYPE)) {
- this.applicationType = MTOMConstants.MTOM_TYPE;
- } else if (applicationType.equalsIgnoreCase(MTOMConstants.SWA_TYPE)) {
- this.applicationType = MTOMConstants.SWA_TYPE;
- } else {
- throw new OMException(
- "Invalid Application type. Support available for MTOM/SOAP 1.2 & SwA/SOAP 1.l 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 {
- DataHandler dh;
- try {
- dh = getDataHandler(getSOAPPartContentID());
- 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);
- }
- }
-
- /**
- * @return the Content-ID of the SOAP part It'll be the value Start
- * Parameter of Content-Type header if given in the Content type of
- * the MIME message. Else it'll be the content-id of the first MIME
- * part of the MIME message
- */
- private String getSOAPPartContentID() {
- 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();
-
- if ((rootContentID.indexOf("<") > -1)
- & (rootContentID.indexOf(">") > -1))
- rootContentID = rootContentID.substring(1, (rootContentID
- .length() - 1));
- }
- // Strips off the "cid" part from content-id
- if (rootContentID.substring(0, 3).equalsIgnoreCase("cid")) {
- rootContentID = rootContentID.substring(4);
- }
- return rootContentID;
- }
-
- public String getSOAPPartContentType() {
- Part soapPart = getPart(getSOAPPartContentID());
- try {
- return soapPart.getContentType();
- } catch (MessagingException e) {
- log.error(e.getMessage());
- throw new OMException(e);
- }
- }
-
- /**
- * @param blobContentID
- * (without the surrounding angle brackets and "cid:" prefix)
- * @return The DataHandler of the mime part refered by the content-Id
- * @throws OMException
- */
- public DataHandler getDataHandler(String blobContentID) throws OMException {
-
- try {
- return getPart(blobContentID).getDataHandler();
- } catch (MessagingException e) {
- throw new OMException("Problem with Mime Body Part No " + partIndex
- + ". ", e);
- }
-
- }
-
- /**
- * @param blobContentID
- * @return The 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 Part getPart(String blobContentID) {
- Part bodyPart;
- boolean attachmentFound = false;
- if (bodyPartsMap.containsKey(blobContentID)) {
- bodyPart = (Part) bodyPartsMap.get(blobContentID);
- return bodyPart;
- } else {
- //This loop will be terminated by the Exceptions thrown if the Mime
- // part searching was not found
- while (true) {
- bodyPart = this.getNextPart();
- if (bodyPart == null) {
- return null;
- }
- if (bodyPartsMap.containsKey(blobContentID)) {
- bodyPart = (Part) bodyPartsMap.get(blobContentID);
- return bodyPart;
- }
- }
- }
- }
-
- protected void setEndOfStream(boolean value) {
- this.endOfStreamReached = value;
-
- }
-
- /**
- * @return the Next valid MIME part + store the Part in the Parts List
- * @throws OMException
- * throw if cotent id is null or if two MIME parts contain the
- * same content-ID & the exceptions throws by getPart()
- */
- private Part getNextPart() throws OMException {
- Part nextPart;
- nextPart = getPart();
- if (nextPart != null) {
- String partContentID;
- try {
- partContentID = nextPart.getContentID();
-
- if (partContentID == null & partIndex == 1) {
- bodyPartsMap.put("firstPart", nextPart);
- firstPartId = "firstPart";
- return nextPart;
- }
- if (partContentID == null) {
- throw new OMException(
- "Part content ID cannot be blank for non root MIME parts");
- }
- if ((partContentID.indexOf("<") > -1)
- & (partContentID.indexOf(">") > -1)) {
- partContentID = partContentID.substring(1, (partContentID
- .length() - 1));
-
- } else if (partIndex == 1) {
- firstPartId = partContentID;
- }
- if (bodyPartsMap.containsKey(partContentID)) {
- throw new OMException(
- "Two MIME parts with the same Content-ID not allowed.");
- }
- bodyPartsMap.put(partContentID, nextPart);
- return nextPart;
- } catch (MessagingException e) {
- throw new OMException("Error reading Content-ID from the Part."
- + e);
- }
- } else
- return null;
- }
-
- /**
- * @return This will return the next available MIME part in the stream.
- * @throws OMException
- * if Stream ends while reading the next part...
- */
- private Part getPart() throws OMException {
- // endOfStreamReached will be set to true if the message ended in MIME
- // Style having "--" suffix with the last mime boundary
- if (endOfStreamReached)
- throw new OMException(
- "Referenced MIME part not found.End of Stream reached.");
-
- Part part = null;
-
- try {
- if (fileCacheEnable) {
- try {
- MIMEBodyPartInputStream partStream;
- byte[] buffer = new byte[fileStorageThreshold];
- partStream = new MIMEBodyPartInputStream(pushbackInStream,
- boundary, this);
- int count = 0;
- int value;
- // Make sure not to modify this to a Short Circuit "&". If
- // removed a byte will be lost
- while (count != fileStorageThreshold
- && (!partStream.getBoundaryStatus())) {
- value = partStream.read();
- buffer[count] = (byte) value;
- count++;
- }
- if (count == fileStorageThreshold) {
- PushbackFilePartInputStream filePartStream = new PushbackFilePartInputStream(
- partStream, buffer);
- part = new PartOnFile(filePartStream, attachmentRepoDir);
- } else {
- ByteArrayInputStream byteArrayInStream = new ByteArrayInputStream(
- buffer,0,count-1);
- part = new PartOnMemory(byteArrayInStream);
- }
- } catch (Exception e) {
- throw new OMException("Error creating temporary File.", e);
- }
- } else {
- MIMEBodyPartInputStream partStream;
- partStream = new MIMEBodyPartInputStream(pushbackInStream,
- boundary, this);
- part = new PartOnMemory(partStream);
- }
- // This will take care if stream ended without having MIME
- // message terminator
- if (part.getSize() <= 0) {
- throw new OMException(
- "Referenced MIME part not found.End of Stream reached.");
- }
- } catch (MessagingException e) {
- throw new OMException(e);
- }
- partIndex++;
- return part;
- }
+/**
+ * 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/>
+ */
+package org.apache.axis2.attachments;
+
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.impl.MTOMConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+import javax.mail.internet.ContentType;
+import javax.mail.internet.ParseException;
+import java.io.ByteArrayInputStream;
+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 {
+
+ /**
+ * <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;
+
+ /**
+ * <code>endOfStreamReached</code> flag which is to be set by
+ * MIMEBodyPartStream when MIME message terminator is found.
+ */
+ boolean endOfStreamReached = false;
+
+ String firstPartId = null;
+
+ boolean fileCacheEnable = false;
+
+ String attachmentRepoDir = null;
+
+ int fileStorageThreshold;
+
+ protected Log log = LogFactory.getLog(getClass());
+
+
+ /**
+ * @param inStream
+ * @param contentTypeString
+ * @param fileCacheEnable
+ * @param attachmentRepoDir
+ * @throws OMException
+ * Will move the pointer to the begining of the first MIME part. Will
+ * read till first MIME boundary is found or end of stream reached.
+ */
+ public MIMEHelper(InputStream inStream, String contentTypeString,
+ boolean fileCacheEnable, String attachmentRepoDir,
+ String fileThreshold) throws OMException {
+ this.attachmentRepoDir = attachmentRepoDir;
+ this.fileCacheEnable = fileCacheEnable;
+ if (fileThreshold != null && (!fileThreshold.equals(""))) {
+ this.fileStorageThreshold = Integer.parseInt(fileThreshold);
+ } else {
+ this.fileStorageThreshold = 1;
+ }
+ bodyPartsMap = new HashMap();
+ try {
+ contentType = new ContentType(contentTypeString);
+ } catch (ParseException e) {
+ throw new OMException(
+ "Invalid Content Type Field in the Mime Message"
+ ,e);
+ }
+ // Boundary always have the prefix "--".
+ this.boundary = ("--" + contentType.getParameter("boundary"))
+ .getBytes();
+
+ // 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(), e1);
+ }
+ }
+ }
+
+ /**
+ * @param inStream
+ * @param contentTypeString
+ * @throws OMException
+ * Will set file cache to false
+ */
+ public MIMEHelper(InputStream inStream, String contentTypeString)
+ throws OMException {
+ this(inStream, contentTypeString, false, null, 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(MTOMConstants.MTOM_TYPE)) {
+ this.applicationType = MTOMConstants.MTOM_TYPE;
+ } else if (applicationType.equalsIgnoreCase(MTOMConstants.SWA_TYPE)) {
+ this.applicationType = MTOMConstants.SWA_TYPE;
+ } else {
+ throw new OMException(
+ "Invalid Application type. Support available for MTOM/SOAP 1.2 & SwA/SOAP 1.l 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 {
+ DataHandler dh;
+ try {
+ dh = getDataHandler(getSOAPPartContentID());
+ 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);
+ }
+ }
+
+ /**
+ * @return the Content-ID of the SOAP part It'll be the value Start
+ * Parameter of Content-Type header if given in the Content type of
+ * the MIME message. Else it'll be the content-id of the first MIME
+ * part of the MIME message
+ */
+ private String getSOAPPartContentID() {
+ 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();
+
+ if ((rootContentID.indexOf("<") > -1)
+ & (rootContentID.indexOf(">") > -1))
+ rootContentID = rootContentID.substring(1, (rootContentID
+ .length() - 1));
+ }
+ // Strips off the "cid" part from content-id
+ if (rootContentID.substring(0, 3).equalsIgnoreCase("cid")) {
+ rootContentID = rootContentID.substring(4);
+ }
+ return rootContentID;
+ }
+
+ public String getSOAPPartContentType() {
+ Part soapPart = getPart(getSOAPPartContentID());
+ try {
+ return soapPart.getContentType();
+ } catch (MessagingException e) {
+ log.error(e.getMessage());
+ throw new OMException(e);
+ }
+ }
+
+ /**
+ * @param blobContentID
+ * (without the surrounding angle brackets and "cid:" prefix)
+ * @return The DataHandler of the mime part refered by the content-Id
+ * @throws OMException
+ */
+ public DataHandler getDataHandler(String blobContentID) throws OMException {
+
+ try {
+ return getPart(blobContentID).getDataHandler();
+ } catch (MessagingException e) {
+ throw new OMException("Problem with Mime Body Part No " + partIndex
+ + ". ", e);
+ }
+
+ }
+
+ /**
+ * @param blobContentID
+ * @return The 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 Part getPart(String blobContentID) {
+ Part bodyPart;
+ boolean attachmentFound = false;
+ if (bodyPartsMap.containsKey(blobContentID)) {
+ bodyPart = (Part) bodyPartsMap.get(blobContentID);
+ return bodyPart;
+ } else {
+ //This loop will be terminated by the Exceptions thrown if the Mime
+ // part searching was not found
+ while (true) {
+ bodyPart = this.getNextPart();
+ if (bodyPart == null) {
+ return null;
+ }
+ if (bodyPartsMap.containsKey(blobContentID)) {
+ bodyPart = (Part) bodyPartsMap.get(blobContentID);
+ return bodyPart;
+ }
+ }
+ }
+ }
+
+ protected void setEndOfStream(boolean value) {
+ this.endOfStreamReached = value;
+
+ }
+
+ /**
+ * @return the Next valid MIME part + store the Part in the Parts List
+ * @throws OMException
+ * throw if cotent id is null or if two MIME parts contain the
+ * same content-ID & the exceptions throws by getPart()
+ */
+ private Part getNextPart() throws OMException {
+ Part nextPart;
+ nextPart = getPart();
+ if (nextPart != null) {
+ String partContentID;
+ try {
+ partContentID = nextPart.getContentID();
+
+ if (partContentID == null & partIndex == 1) {
+ bodyPartsMap.put("firstPart", nextPart);
+ firstPartId = "firstPart";
+ return nextPart;
+ }
+ if (partContentID == null) {
+ throw new OMException(
+ "Part content ID cannot be blank for non root MIME parts");
+ }
+ if ((partContentID.indexOf("<") > -1)
+ & (partContentID.indexOf(">") > -1)) {
+ partContentID = partContentID.substring(1, (partContentID
+ .length() - 1));
+
+ } else if (partIndex == 1) {
+ firstPartId = partContentID;
+ }
+ if (bodyPartsMap.containsKey(partContentID)) {
+ throw new OMException(
+ "Two MIME parts with the same Content-ID not allowed.");
+ }
+ bodyPartsMap.put(partContentID, nextPart);
+ return nextPart;
+ } catch (MessagingException e) {
+ throw new OMException("Error reading Content-ID from the Part."
+ + e);
+ }
+ } else
+ return null;
+ }
+
+ /**
+ * @return This will return the next available MIME part in the stream.
+ * @throws OMException
+ * if Stream ends while reading the next part...
+ */
+ private Part getPart() throws OMException {
+ // endOfStreamReached will be set to true if the message ended in MIME
+ // Style having "--" suffix with the last mime boundary
+ if (endOfStreamReached)
+ throw new OMException(
+ "Referenced MIME part not found.End of Stream reached.");
+
+ Part part = null;
+
+ try {
+ if (fileCacheEnable) {
+ try {
+ MIMEBodyPartInputStream partStream;
+ byte[] buffer = new byte[fileStorageThreshold];
+ partStream = new MIMEBodyPartInputStream(pushbackInStream,
+ boundary, this);
+ int count = 0;
+ int value;
+ // Make sure not to modify this to a Short Circuit "&". If
+ // removed a byte will be lost
+ while (count != fileStorageThreshold
+ && (!partStream.getBoundaryStatus())) {
+ value = partStream.read();
+ buffer[count] = (byte) value;
+ count++;
+ }
+ if (count == fileStorageThreshold) {
+ PushbackFilePartInputStream filePartStream = new PushbackFilePartInputStream(
+ partStream, buffer);
+ part = new PartOnFile(filePartStream, attachmentRepoDir);
+ } else {
+ ByteArrayInputStream byteArrayInStream = new ByteArrayInputStream(
+ buffer,0,count-1);
+ part = new PartOnMemory(byteArrayInStream);
+ }
+ } catch (Exception e) {
+ throw new OMException("Error creating temporary File.", e);
+ }
+ } else {
+ MIMEBodyPartInputStream partStream;
+ partStream = new MIMEBodyPartInputStream(pushbackInStream,
+ boundary, this);
+ part = new PartOnMemory(partStream);
+ }
+ // This will take care if stream ended without having MIME
+ // message terminator
+ if (part.getSize() <= 0) {
+ throw new OMException(
+ "Referenced MIME part not found.End of Stream reached.");
+ }
+ } catch (MessagingException e) {
+ throw new OMException(e);
+ }
+ partIndex++;
+ return part;
+ }
}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/Part.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java Thu Sep 15 11:52:11 2005
@@ -1,176 +1,176 @@
-/**
- * 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/>
- */
-package org.apache.axis2.attachments;
-
-import org.apache.axis2.om.OMException;
-
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.mail.MessagingException;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-
-public class PartOnFile implements Part {
-
- File cacheFile;
-
- Part bodyPart;
-
- String contentType;
-
- String contentID;
-
- HashMap headers;
-
- public PartOnFile(PushbackFilePartInputStream inStream, String repoDir) {
- super();
-
- headers = new HashMap();
-
- if (repoDir == null) {
- repoDir = ".";
- }
- try {
- cacheFile = java.io.File.createTempFile("Axis2", ".att",
- (repoDir == null) ? null : new File(repoDir));
-
- FileOutputStream fileOutStream = new FileOutputStream(cacheFile);
- int value;
- value = parseTheHeaders(inStream);
- fileOutStream.write(value);
- while (!inStream.getBoundaryStatus()) {
- value = inStream.read();
- if (!inStream.getBoundaryStatus()) {
- fileOutStream.write(value);
- }
-
- }
-
- fileOutStream.flush();
- fileOutStream.close();
- } catch (IOException e) {
- throw new OMException("Error creating temporary File.", e);
- }
- }
-
- private int parseTheHeaders(InputStream inStream) throws IOException {
- int value;
- boolean readingHeaders = true;
- StringBuffer header = new StringBuffer();
- while (readingHeaders & (value = inStream.read()) != -1) {
- if (value == 13) {
- if ((value = inStream.read()) == 10) {
- if ((value = inStream.read()) == 13) {
- if ((value = inStream.read()) == 10) {
- putToMap(header);
- readingHeaders = false;
- }
- } else {
- putToMap(header);
- header = new StringBuffer();
- header.append((char) value);
- }
- } else {
- header.append(13);
- header.append(value);
- }
- } else {
- header.append((char) value);
- }
- }
- return value;
- }
-
- private void putToMap(StringBuffer header) {
- String headerString = header.toString();
- int delimiter = headerString.indexOf(":");
- headers.put(headerString.substring(0, delimiter).trim(), headerString
- .substring(delimiter + 1, headerString.length()).trim());
- }
-
- public String getContentID() {
- String cID = (String) headers.get("Content-ID");
- ;
- if (cID == null) {
- cID = (String) headers.get("Content-Id");
- if (cID == null) {
- cID = (String) headers.get("Content-id");
- if (cID == null) {
- cID = (String) headers.get("content-id");
- }
- }
-
- }
- return cID;
- }
-
- public int getSize() throws MessagingException {
- return (int) cacheFile.length();
- }
-
- public int getLineCount() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- public String getDescription() throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- public void setDescription(String arg0) throws MessagingException {
- throw new UnsupportedOperationException();
- }
-
- public String getFileName() throws MessagingException {
- return cacheFile.getAbsolutePath();
- }
-
- public InputStream getInputStream() throws IOException, MessagingException {
- return new FileInputStream(cacheFile);
- }
-
- public DataHandler getDataHandler() throws MessagingException {
- return new DataHandler(new FileDataSource(cacheFile));
- }
-
- public Object getContent() throws IOException, MessagingException {
- return getDataHandler().getContent();
- }
-
- public void writeTo(OutputStream outStream) throws IOException,
- MessagingException {
- getDataHandler().writeTo(outStream);
- }
-
- public String getHeader(String arg0) throws MessagingException {
- ArrayList selectedHeader = null;
- String header;
- header = (String) headers.get(arg0);
- return header;
- }
-
- public Enumeration getAllHeaders() throws MessagingException {
- return null;
- }
-
- public String getContentType() throws MessagingException {
- String cType = (String) headers.get("Content-Type");
- if (cType == null) {
- cType = (String) headers.get("Content-type");
- if (cType == null) {
- cType = (String) headers.get("content-type");
- }
- }
- return cType;
- }
-
+/**
+ * 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/>
+ */
+package org.apache.axis2.attachments;
+
+import org.apache.axis2.om.OMException;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.mail.MessagingException;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+
+public class PartOnFile implements Part {
+
+ File cacheFile;
+
+ Part bodyPart;
+
+ String contentType;
+
+ String contentID;
+
+ HashMap headers;
+
+ public PartOnFile(PushbackFilePartInputStream inStream, String repoDir) {
+ super();
+
+ headers = new HashMap();
+
+ if (repoDir == null) {
+ repoDir = ".";
+ }
+ try {
+ cacheFile = java.io.File.createTempFile("Axis2", ".att",
+ (repoDir == null) ? null : new File(repoDir));
+
+ FileOutputStream fileOutStream = new FileOutputStream(cacheFile);
+ int value;
+ value = parseTheHeaders(inStream);
+ fileOutStream.write(value);
+ while (!inStream.getBoundaryStatus()) {
+ value = inStream.read();
+ if (!inStream.getBoundaryStatus()) {
+ fileOutStream.write(value);
+ }
+
+ }
+
+ fileOutStream.flush();
+ fileOutStream.close();
+ } catch (IOException e) {
+ throw new OMException("Error creating temporary File.", e);
+ }
+ }
+
+ private int parseTheHeaders(InputStream inStream) throws IOException {
+ int value;
+ boolean readingHeaders = true;
+ StringBuffer header = new StringBuffer();
+ while (readingHeaders & (value = inStream.read()) != -1) {
+ if (value == 13) {
+ if ((value = inStream.read()) == 10) {
+ if ((value = inStream.read()) == 13) {
+ if ((value = inStream.read()) == 10) {
+ putToMap(header);
+ readingHeaders = false;
+ }
+ } else {
+ putToMap(header);
+ header = new StringBuffer();
+ header.append((char) value);
+ }
+ } else {
+ header.append(13);
+ header.append(value);
+ }
+ } else {
+ header.append((char) value);
+ }
+ }
+ return value;
+ }
+
+ private void putToMap(StringBuffer header) {
+ String headerString = header.toString();
+ int delimiter = headerString.indexOf(":");
+ headers.put(headerString.substring(0, delimiter).trim(), headerString
+ .substring(delimiter + 1, headerString.length()).trim());
+ }
+
+ public String getContentID() {
+ String cID = (String) headers.get("Content-ID");
+ ;
+ if (cID == null) {
+ cID = (String) headers.get("Content-Id");
+ if (cID == null) {
+ cID = (String) headers.get("Content-id");
+ if (cID == null) {
+ cID = (String) headers.get("content-id");
+ }
+ }
+
+ }
+ return cID;
+ }
+
+ public int getSize() throws MessagingException {
+ return (int) cacheFile.length();
+ }
+
+ public int getLineCount() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getDescription() throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDescription(String arg0) throws MessagingException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getFileName() throws MessagingException {
+ return cacheFile.getAbsolutePath();
+ }
+
+ public InputStream getInputStream() throws IOException, MessagingException {
+ return new FileInputStream(cacheFile);
+ }
+
+ public DataHandler getDataHandler() throws MessagingException {
+ return new DataHandler(new FileDataSource(cacheFile));
+ }
+
+ public Object getContent() throws IOException, MessagingException {
+ return getDataHandler().getContent();
+ }
+
+ public void writeTo(OutputStream outStream) throws IOException,
+ MessagingException {
+ getDataHandler().writeTo(outStream);
+ }
+
+ public String getHeader(String arg0) throws MessagingException {
+ ArrayList selectedHeader = null;
+ String header;
+ header = (String) headers.get(arg0);
+ return header;
+ }
+
+ public Enumeration getAllHeaders() throws MessagingException {
+ return null;
+ }
+
+ public String getContentType() throws MessagingException {
+ String cType = (String) headers.get("Content-Type");
+ if (cType == null) {
+ cType = (String) headers.get("Content-type");
+ if (cType == null) {
+ cType = (String) headers.get("content-type");
+ }
+ }
+ return cType;
+ }
+
}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/PushbackFilePartInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/IOUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/IOUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/IOUtils.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/IOUtils.java Thu Sep 15 11:52:11 2005
@@ -1,64 +1,64 @@
-/*
- * 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.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Utility class containing IO helper methods
- */
-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 {
- 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/>
- *
- * @returns the number of bytes read, or -1 if the end of file is
- * reached before any bytes are read
- */
- public static int readFully(InputStream in, byte[] b, int off, int len)
- throws IOException {
- int total = 0;
- for (; ;) {
- int got = in.read(b, off + total, len - total);
- if (got < 0) {
- return (total == 0) ? -1 : total;
- } else {
- total += got;
- if (total == len)
- return total;
- }
- }
- }
+/*
+ * 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.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utility class containing IO helper methods
+ */
+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 {
+ 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/>
+ *
+ * @returns the number of bytes read, or -1 if the end of file is
+ * reached before any bytes are read
+ */
+ public static int readFully(InputStream in, byte[] b, int off, int len)
+ throws IOException {
+ int total = 0;
+ for (; ;) {
+ int got = in.read(b, off + total, len - total);
+ if (got < 0) {
+ return (total == 0) ? -1 : total;
+ } else {
+ total += got;
+ if (total == len)
+ return total;
+ }
+ }
+ }
}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/IOUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/ImageDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/ImageDataSource.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/ImageDataSource.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/ImageDataSource.java Thu Sep 15 11:52:11 2005
@@ -1,74 +1,74 @@
-/*
- * 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.utils;
-
-import javax.activation.DataSource;
-import java.awt.*;
-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) throws Exception {
- this(name, CONTENT_TYPE, data);
- } // ctor
-
- public ImageDataSource(String name, String contentType, Image data) throws Exception {
- this.name = name;
- this.contentType = contentType == null ? CONTENT_TYPE : contentType;
- os = new ByteArrayOutputStream();
- try {
- if (data != null) {
- new ImageIO().saveImage(this.contentType, data, os);
- }
- } catch (Exception e) {
- throw e;
- }
- }
-
- public String getName() {
- return name;
- } // getName
-
- public String getContentType() {
- return contentType;
- } // getOptimizedContentType
-
- 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
+/*
+ * 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.utils;
+
+import javax.activation.DataSource;
+import java.awt.*;
+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) throws Exception {
+ this(name, CONTENT_TYPE, data);
+ } // ctor
+
+ public ImageDataSource(String name, String contentType, Image data) throws Exception {
+ this.name = name;
+ this.contentType = contentType == null ? CONTENT_TYPE : contentType;
+ os = new ByteArrayOutputStream();
+ try {
+ if (data != null) {
+ new ImageIO().saveImage(this.contentType, data, os);
+ }
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ public String getName() {
+ return name;
+ } // getName
+
+ public String getContentType() {
+ return contentType;
+ } // getOptimizedContentType
+
+ 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
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/attachments/utils/ImageDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java Thu Sep 15 11:52:11 2005
@@ -1,123 +1,123 @@
-/*
- * Copyright 2004,2005 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.om;
-
-import org.apache.axis2.soap.SOAPFactory;
-
-
-/**
- * Class FactoryFinder
- */
-class FactoryFinder {
- private static final String DEFAULT_OM_FACTORY_CLASS_NAME =
- "org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory";
- private static final String DEFAULT_SOAP11_FACTORY_CLASS_NAME =
- "org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory";
- private static final String DEFAULT_SOAP12_FACTORY_CLASS_NAME =
- "org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory";
-
- private static final String OM_FACTORY_NAME_PROPERTY = "om.factory";
- private static final String SOAP11_FACTORY_NAME_PROPERTY = "soap11.factory";
- private static final String SOAP12_FACTORY_NAME_PROPERTY = "soap12.factory";
-
-
- /**
- * @param loader
- * @return
- * @throws OMFactoryException
- */
-
-
- private static Object findFactory(ClassLoader loader,
- String factoryClass,
- String systemPropertyName)
- throws OMFactoryException {
-
- String factoryClassName = factoryClass;
-
- //first look for a java system property
- if (System.getProperty(systemPropertyName) != null) {
- factoryClassName = systemPropertyName;
- }
- ;
-
- Object factory = null;
- try {
- if (loader == null) {
- factory = Class.forName(factoryClassName).newInstance();
- } else {
- factory = loader.loadClass(factoryClassName).newInstance();
- }
- } catch (Exception e) {
- throw new OMFactoryException(e);
- }
- return factory;
- }
-
- /**
- * The searching for the factory class happens in the following order
- * 1. look for a system property called <b>soap11.factory</b>. this can be set by
- * passing the -Dsoap11.factory="classname"
- * 2. Pick the default factory class.
- * it is the class hardcoded at the constant DEFAULT_SOAP11_FACTORY_CLASS_NAME
- *
- * @param loader
- * @return
- * @throws OMFactoryException
- */
- public static SOAPFactory findSOAP11Factory(ClassLoader loader)
- throws OMFactoryException {
- return (SOAPFactory) findFactory(loader,
- DEFAULT_SOAP11_FACTORY_CLASS_NAME,
- SOAP11_FACTORY_NAME_PROPERTY);
- }
-
- /**
- * The searching for the factory class happens in the following order
- * 1. look for a system property called <b>soap12.factory</b>. this can be set by
- * passing the -Dsoap12.factory="classname"
- * 2. Pick the default factory class.
- * it is the class hardcoded at the constant DEFAULT_SOAP12_FACTORY_CLASS_NAME
- *
- * @param loader
- * @return
- * @throws OMFactoryException
- */
- public static SOAPFactory findSOAP12Factory(ClassLoader loader)
- throws OMFactoryException {
- return (SOAPFactory) findFactory(loader,
- DEFAULT_SOAP12_FACTORY_CLASS_NAME,
- SOAP12_FACTORY_NAME_PROPERTY);
- }
-
- /**
- * The searching for the factory class happens in the following order
- * 1. look for a system property called <b>om.factory</b>. this can be set by
- * passing the -Dom.factory="classname"
- * 2. Pick the default factory class.
- * it is the class hardcoded at the constant DEFAULT_OM_FACTORY_CLASS_NAME
- *
- * @param loader
- * @return
- * @throws OMFactoryException
- */
- public static OMFactory findOMFactory(ClassLoader loader)
- throws OMFactoryException {
- return (OMFactory) findFactory(loader,
- DEFAULT_OM_FACTORY_CLASS_NAME,
- OM_FACTORY_NAME_PROPERTY);
- }
-}
+/*
+ * Copyright 2004,2005 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.om;
+
+import org.apache.axis2.soap.SOAPFactory;
+
+
+/**
+ * Class FactoryFinder
+ */
+class FactoryFinder {
+ private static final String DEFAULT_OM_FACTORY_CLASS_NAME =
+ "org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory";
+ private static final String DEFAULT_SOAP11_FACTORY_CLASS_NAME =
+ "org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory";
+ private static final String DEFAULT_SOAP12_FACTORY_CLASS_NAME =
+ "org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory";
+
+ private static final String OM_FACTORY_NAME_PROPERTY = "om.factory";
+ private static final String SOAP11_FACTORY_NAME_PROPERTY = "soap11.factory";
+ private static final String SOAP12_FACTORY_NAME_PROPERTY = "soap12.factory";
+
+
+ /**
+ * @param loader
+ * @return
+ * @throws OMFactoryException
+ */
+
+
+ private static Object findFactory(ClassLoader loader,
+ String factoryClass,
+ String systemPropertyName)
+ throws OMFactoryException {
+
+ String factoryClassName = factoryClass;
+
+ //first look for a java system property
+ if (System.getProperty(systemPropertyName) != null) {
+ factoryClassName = systemPropertyName;
+ }
+ ;
+
+ Object factory = null;
+ try {
+ if (loader == null) {
+ factory = Class.forName(factoryClassName).newInstance();
+ } else {
+ factory = loader.loadClass(factoryClassName).newInstance();
+ }
+ } catch (Exception e) {
+ throw new OMFactoryException(e);
+ }
+ return factory;
+ }
+
+ /**
+ * The searching for the factory class happens in the following order
+ * 1. look for a system property called <b>soap11.factory</b>. this can be set by
+ * passing the -Dsoap11.factory="classname"
+ * 2. Pick the default factory class.
+ * it is the class hardcoded at the constant DEFAULT_SOAP11_FACTORY_CLASS_NAME
+ *
+ * @param loader
+ * @return
+ * @throws OMFactoryException
+ */
+ public static SOAPFactory findSOAP11Factory(ClassLoader loader)
+ throws OMFactoryException {
+ return (SOAPFactory) findFactory(loader,
+ DEFAULT_SOAP11_FACTORY_CLASS_NAME,
+ SOAP11_FACTORY_NAME_PROPERTY);
+ }
+
+ /**
+ * The searching for the factory class happens in the following order
+ * 1. look for a system property called <b>soap12.factory</b>. this can be set by
+ * passing the -Dsoap12.factory="classname"
+ * 2. Pick the default factory class.
+ * it is the class hardcoded at the constant DEFAULT_SOAP12_FACTORY_CLASS_NAME
+ *
+ * @param loader
+ * @return
+ * @throws OMFactoryException
+ */
+ public static SOAPFactory findSOAP12Factory(ClassLoader loader)
+ throws OMFactoryException {
+ return (SOAPFactory) findFactory(loader,
+ DEFAULT_SOAP12_FACTORY_CLASS_NAME,
+ SOAP12_FACTORY_NAME_PROPERTY);
+ }
+
+ /**
+ * The searching for the factory class happens in the following order
+ * 1. look for a system property called <b>om.factory</b>. this can be set by
+ * passing the -Dom.factory="classname"
+ * 2. Pick the default factory class.
+ * it is the class hardcoded at the constant DEFAULT_OM_FACTORY_CLASS_NAME
+ *
+ * @param loader
+ * @return
+ * @throws OMFactoryException
+ */
+ public static OMFactory findOMFactory(ClassLoader loader)
+ throws OMFactoryException {
+ return (OMFactory) findFactory(loader,
+ DEFAULT_OM_FACTORY_CLASS_NAME,
+ OM_FACTORY_NAME_PROPERTY);
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/FactoryFinder.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAbstractFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAbstractFactory.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAbstractFactory.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAbstractFactory.java Thu Sep 15 11:52:11 2005
@@ -1,95 +1,95 @@
-package org.apache.axis2.om;
-
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.impl.llom.factory.SOAPLinkedListImplFactory;
-
-/**
- * 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 OMAbstractFactory {
- /**
- * Eran Chinthaka (chinthaka@apache.org)
- */
- /**
- * Constructor OMFactory
- */
- protected OMAbstractFactory() {
- }
-
- /**
- * This will pick up the default factory implementation from the classpath
- *
- * @return
- */
- public static OMFactory getOMFactory() {
- return FactoryFinder.findOMFactory(null);
- }
-
- /**
- * If user needs to provide his own factory implementation, here provide the
- * Class Loader for that.
- *
- * @param classLoader
- * @return
- */
- public static OMFactory getOMFactory(ClassLoader classLoader) {
- return FactoryFinder.findOMFactory(classLoader);
- }
-
- /**
- * This will pick up the default factory implementation from the classpath
- *
- * @return
- */
- public static SOAPFactory getSOAP11Factory() {
- return FactoryFinder.findSOAP11Factory(null);
- }
-
- /**
- * If user needs to provide his own factory implementation, here provide the
- * Class Loader for that.
- *
- * @param classLoader
- * @return
- */
- public static SOAPFactory getSOAP11Factory(ClassLoader classLoader) {
- return FactoryFinder.findSOAP11Factory(classLoader);
- }
-
- /**
- * This will pick up the default factory implementation from the classpath
- *
- * @return
- */
- public static SOAPFactory getSOAP12Factory() {
- return FactoryFinder.findSOAP12Factory(null);
- }
-
- /**
- * If user needs to provide his own factory implementation, here provide the
- * Class Loader for that.
- *
- * @param classLoader
- * @return
- */
- public static SOAPFactory getSOAP12Factory(ClassLoader classLoader) {
- return FactoryFinder.findSOAP12Factory(classLoader);
- }
-
- public static SOAPFactory getDefaultSOAPFactory() {
- return new SOAPLinkedListImplFactory();
- }
-}
+package org.apache.axis2.om;
+
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.factory.SOAPLinkedListImplFactory;
+
+/**
+ * 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 OMAbstractFactory {
+ /**
+ * Eran Chinthaka (chinthaka@apache.org)
+ */
+ /**
+ * Constructor OMFactory
+ */
+ protected OMAbstractFactory() {
+ }
+
+ /**
+ * This will pick up the default factory implementation from the classpath
+ *
+ * @return
+ */
+ public static OMFactory getOMFactory() {
+ return FactoryFinder.findOMFactory(null);
+ }
+
+ /**
+ * If user needs to provide his own factory implementation, here provide the
+ * Class Loader for that.
+ *
+ * @param classLoader
+ * @return
+ */
+ public static OMFactory getOMFactory(ClassLoader classLoader) {
+ return FactoryFinder.findOMFactory(classLoader);
+ }
+
+ /**
+ * This will pick up the default factory implementation from the classpath
+ *
+ * @return
+ */
+ public static SOAPFactory getSOAP11Factory() {
+ return FactoryFinder.findSOAP11Factory(null);
+ }
+
+ /**
+ * If user needs to provide his own factory implementation, here provide the
+ * Class Loader for that.
+ *
+ * @param classLoader
+ * @return
+ */
+ public static SOAPFactory getSOAP11Factory(ClassLoader classLoader) {
+ return FactoryFinder.findSOAP11Factory(classLoader);
+ }
+
+ /**
+ * This will pick up the default factory implementation from the classpath
+ *
+ * @return
+ */
+ public static SOAPFactory getSOAP12Factory() {
+ return FactoryFinder.findSOAP12Factory(null);
+ }
+
+ /**
+ * If user needs to provide his own factory implementation, here provide the
+ * Class Loader for that.
+ *
+ * @param classLoader
+ * @return
+ */
+ public static SOAPFactory getSOAP12Factory(ClassLoader classLoader) {
+ return FactoryFinder.findSOAP12Factory(classLoader);
+ }
+
+ public static SOAPFactory getDefaultSOAPFactory() {
+ return new SOAPLinkedListImplFactory();
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAbstractFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAttribute.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAttribute.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAttribute.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAttribute.java Thu Sep 15 11:52:11 2005
@@ -1,58 +1,58 @@
-/*
- * Copyright 2004,2005 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.om;
-
-import javax.xml.namespace.QName;
-
-/**
- * Interface OMAttribute
- */
-public interface OMAttribute {
- /**
- * @return localName
- */
- public String getLocalName();
-
- /**
- * @param localName
- */
- public void setLocalName(String localName);
-
- /**
- * @return
- */
- public String getValue();
-
- /**
- * @param value
- */
- public void setValue(String value);
-
- /**
- * @param omNamespace
- */
- public void setOMNamespace(OMNamespace omNamespace);
-
- /**
- * @return OMNamespace
- */
- public OMNamespace getNamespace();
-
- /**
- * @return javax.xml.namespace.QName
- */
- public QName getQName();
-}
+/*
+ * Copyright 2004,2005 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.om;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface OMAttribute
+ */
+public interface OMAttribute {
+ /**
+ * @return localName
+ */
+ public String getLocalName();
+
+ /**
+ * @param localName
+ */
+ public void setLocalName(String localName);
+
+ /**
+ * @return
+ */
+ public String getValue();
+
+ /**
+ * @param value
+ */
+ public void setValue(String value);
+
+ /**
+ * @param omNamespace
+ */
+ public void setOMNamespace(OMNamespace omNamespace);
+
+ /**
+ * @return OMNamespace
+ */
+ public OMNamespace getNamespace();
+
+ /**
+ * @return javax.xml.namespace.QName
+ */
+ public QName getQName();
+}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java Thu Sep 15 11:52:11 2005
@@ -1,64 +1,64 @@
-/*
- * Copyright 2004,2005 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.om;
-
-/**
- * Interface OMConstants
- */
-public interface OMConstants {
-
-
- // OMBuilder constants
- /**
- * Field PUSH_TYPE_BUILDER
- */
- public static final short PUSH_TYPE_BUILDER = 0;
-
- /**
- * Field PULL_TYPE_BUILDER
- */
- public static final short PULL_TYPE_BUILDER = 1;
-
- /**
- * Field ARRAY_ITEM_NSURI
- */
- public static final String ARRAY_ITEM_NSURI =
- "http://axis.apache.org/encoding/Arrays";
-
- /**
- * Field ARRAY_ITEM_LOCALNAME
- */
- public static final String ARRAY_ITEM_LOCALNAME = "item";
-
- /**
- * Field ARRAY_ITEM_NS_PREFIX
- */
- public static final String ARRAY_ITEM_NS_PREFIX = "arrays";
-
- /**
- * Field ARRAY_ITEM_QNAME
- */
- public static final String ARRAY_ITEM_QNAME =
- OMConstants.ARRAY_ITEM_NS_PREFIX + ':'
- + OMConstants.ARRAY_ITEM_LOCALNAME;
-
- /**
- * Field DEFAULT_CHAR_SET_ENCODING specifies the default
- * character encoding scheme to be used
- */
- public static final String DEFAULT_CHAR_SET_ENCODING = "utf-8";
- public static final String DEFAULT_XML_VERSION = "1.0";
-}
+/*
+ * Copyright 2004,2005 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.om;
+
+/**
+ * Interface OMConstants
+ */
+public interface OMConstants {
+
+
+ // OMBuilder constants
+ /**
+ * Field PUSH_TYPE_BUILDER
+ */
+ public static final short PUSH_TYPE_BUILDER = 0;
+
+ /**
+ * Field PULL_TYPE_BUILDER
+ */
+ public static final short PULL_TYPE_BUILDER = 1;
+
+ /**
+ * Field ARRAY_ITEM_NSURI
+ */
+ public static final String ARRAY_ITEM_NSURI =
+ "http://axis.apache.org/encoding/Arrays";
+
+ /**
+ * Field ARRAY_ITEM_LOCALNAME
+ */
+ public static final String ARRAY_ITEM_LOCALNAME = "item";
+
+ /**
+ * Field ARRAY_ITEM_NS_PREFIX
+ */
+ public static final String ARRAY_ITEM_NS_PREFIX = "arrays";
+
+ /**
+ * Field ARRAY_ITEM_QNAME
+ */
+ public static final String ARRAY_ITEM_QNAME =
+ OMConstants.ARRAY_ITEM_NS_PREFIX + ':'
+ + OMConstants.ARRAY_ITEM_LOCALNAME;
+
+ /**
+ * Field DEFAULT_CHAR_SET_ENCODING specifies the default
+ * character encoding scheme to be used
+ */
+ public static final String DEFAULT_CHAR_SET_ENCODING = "utf-8";
+ public static final String DEFAULT_XML_VERSION = "1.0";
+}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMContainer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMContainer.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMContainer.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMContainer.java Thu Sep 15 11:52:11 2005
@@ -1,40 +1,40 @@
-/*
- * Copyright 2004,2005 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.om;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-
-public interface OMContainer {
-
- public void addChild(OMNode omNode);
-
- public Iterator getChildrenWithName(QName elementQName) throws OMException;
-
- public OMElement getFirstChildWithName(QName elementQName) throws OMException;
-
- public Iterator getChildren();
-
- public void setFirstChild(OMNode omNode);
-
- public OMNode getFirstChild();
-
- public boolean isComplete();
-
- public void setComplete(boolean state);
-
- public void buildNext();
-}
+/*
+ * Copyright 2004,2005 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.om;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public interface OMContainer {
+
+ public void addChild(OMNode omNode);
+
+ public Iterator getChildrenWithName(QName elementQName) throws OMException;
+
+ public OMElement getFirstChildWithName(QName elementQName) throws OMException;
+
+ public Iterator getChildren();
+
+ public void setFirstChild(OMNode omNode);
+
+ public OMNode getFirstChild();
+
+ public boolean isComplete();
+
+ public void setComplete(boolean state);
+
+ public void buildNext();
+}
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMDocument.java
------------------------------------------------------------------------------
svn:eol-style = native