Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 98779 invoked from network); 14 May 2009 15:10:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 May 2009 15:10:04 -0000 Received: (qmail 50185 invoked by uid 500); 14 May 2009 15:10:03 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 50116 invoked by uid 500); 14 May 2009 15:10:03 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 50107 invoked by uid 99); 14 May 2009 15:10:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2009 15:10:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2009 15:10:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0D4232388895; Thu, 14 May 2009 15:09:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r774803 - in /cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf: attachment/LazyAttachmentCollection.java databinding/source/XMLStreamDataReader.java Date: Thu, 14 May 2009 15:09:38 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090514150939.0D4232388895@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Thu May 14 15:09:38 2009 New Revision: 774803 URL: http://svn.apache.org/viewvc?rev=774803&view=rev Log: Pull some minor fixes for issues found while doing the Provider refactor Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java?rev=774803&r1=774802&r2=774803&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java (original) +++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyAttachmentCollection.java Thu May 14 15:09:38 2009 @@ -122,6 +122,9 @@ } public boolean isEmpty() { + if (attachments.isEmpty()) { + return !iterator().hasNext(); + } return attachments.isEmpty(); } Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=774803&r1=774802&r2=774803&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java (original) +++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Thu May 14 15:09:38 2009 @@ -19,9 +19,12 @@ package org.apache.cxf.databinding.source; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.Collection; import java.util.logging.Logger; +import javax.activation.DataSource; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -52,19 +55,11 @@ return read(null, input, part.getTypeClass()); } - public Object read(QName name, XMLStreamReader input, Class type) { + public Object read(final QName name, XMLStreamReader input, Class type) { if (type != null) { if (SAXSource.class.isAssignableFrom(type)) { try { - CachedOutputStream out = new CachedOutputStream(); - try { - XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out); - StaxUtils.copy(input, xsw); - xsw.close(); - return new SAXSource(new InputSource(out.getInputStream())); - } finally { - out.close(); - } + return new SAXSource(new InputSource(getInputStream(input))); } catch (IOException e) { throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e); } catch (XMLStreamException e) { @@ -72,25 +67,51 @@ } } else if (StreamSource.class.isAssignableFrom(type)) { try { - CachedOutputStream out = new CachedOutputStream(); - try { - XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out); - StaxUtils.copy(input, xsw); - xsw.close(); - return new StreamSource(out.getInputStream()); - } finally { - out.close(); - } + return new StreamSource(getInputStream(input)); } catch (IOException e) { throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e); } catch (XMLStreamException e) { throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e); } - } + } else if (DataSource.class.isAssignableFrom(type)) { + try { + final InputStream ins = getInputStream(input); + return new DataSource() { + public String getContentType() { + return "text/xml"; + } + public InputStream getInputStream() throws IOException { + return ins; + } + public String getName() { + return name.toString(); + } + public OutputStream getOutputStream() throws IOException { + return null; + } + }; + } catch (IOException e) { + throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e); + } catch (XMLStreamException e) { + throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e); + } + } } return read(input); } - + private InputStream getInputStream(XMLStreamReader input) + throws XMLStreamException, IOException { + + CachedOutputStream out = new CachedOutputStream(); + try { + XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out); + StaxUtils.copy(input, xsw); + xsw.close(); + return out.getInputStream(); + } finally { + out.close(); + } + } public Object read(XMLStreamReader reader) { // Use a DOMSource for now, we should really use a StaxSource/SAXSource though for // performance reasons