cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1133057 - in /cxf/branches/2.3.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java
Date Tue, 07 Jun 2011 15:56:56 GMT
Author: dkulp
Date: Tue Jun  7 15:56:55 2011
New Revision: 1133057

URL: http://svn.apache.org/viewvc?rev=1133057&view=rev
Log:
Merged revisions 1129987 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1129987 | dkulp | 2011-05-31 23:06:39 -0400 (Tue, 31 May 2011) | 2 lines
  
  [CXF-3477] Stick a better error message in (rather than an NPE) if an
  attachment couldn't be found.
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java

Propchange: cxf/branches/2.3.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java?rev=1133057&r1=1133056&r2=1133057&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/LazyDataSource.java
Tue Jun  7 15:56:55 2011
@@ -22,7 +22,9 @@ package org.apache.cxf.attachment;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import javax.activation.DataSource;
 
@@ -53,6 +55,27 @@ public class LazyDataSource implements D
                 }
             }
         }
+        if (dataSource == null) {
+            //couldn't find it, build up error message
+            List<String> ids = new ArrayList<String>(10);
+            for (Attachment a : attachments) {
+                ids.add(a.getId());
+                if (a.getId().equals(id)) {
+                    this.dataSource = a.getDataHandler().getDataSource();
+                    if (dataSource != null) {
+                        ids = null;
+                        break;
+                    } else {
+                        throw new IllegalStateException("Could not get DataSource for "
+                                                        + "attachment of id " + id);
+                    }
+                }
+            }
+            if (ids != null) {
+                throw new IllegalStateException("No attachment for "
+                                                + " id " + id + " found in " + ids);
+            }
+        }
     }
     
     public String getContentType() {



Mime
View raw message