Author: veithen
Date: Sun May 23 13:42:49 2010
New Revision: 947411

URL: http://svn.apache.org/viewvc?rev=947411&view=rev
Log:
Reviewed the MimePartProvider contract.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMAttachmentAccessorMimePartProvider.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/MimePartProvider.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamWrapper.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPUtils.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/AttachmentUnmarshallerImpl.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMAttachmentAccessorMimePartProvider.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMAttachmentAccessorMimePartProvider.java?rev=947411&r1=947410&r2=947411&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMAttachmentAccessorMimePartProvider.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMAttachmentAccessorMimePartProvider.java
 Sun May 23 13:42:49 2010
@@ -44,7 +44,7 @@ public class OMAttachmentAccessorMimePar
     public DataHandler getDataHandler(String contentID) throws IOException {
         DataHandler dh = attachments.getDataHandler(contentID);
         if (dh == null) {
-            throw new IOException("No attachment found for content ID '" + 
contentID + "'");
+            throw new IllegalArgumentException("No attachment found for 
content ID '" + contentID + "'");
         } else {
             return dh;
         }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/MimePartProvider.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/MimePartProvider.java?rev=947411&r1=947410&r2=947411&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/MimePartProvider.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/MimePartProvider.java
 Sun May 23 13:42:49 2010
@@ -36,17 +36,24 @@ public interface MimePartProvider {
      * 
      * @return <code>true</code> if the MIME part has already been loaded; 
<code>false</code>
      *         otherwise
+     * @throws IllegalArgumentException
+     *             Thrown if the MIME part specified by the content ID doesn't 
exist. Note that the
+     *             implementation may be unable to determine this without 
loading all the MIME
+     *             parts. In this case, it should return <code>false</code>.
      */
     boolean isLoaded(String contentID);
     
     /**
      * Get the {...@link DataHandler} for the MIME part identified by a given 
content ID.
      * 
-     * @param contentID a content ID referenced in an <tt>xop:Include</tt> 
element
-     * @return the {...@link DataHandler} for the MIME part identified by the 
content ID; may not
-     *         be <code>null</code>
-     * @throws IOException if the MIME part was not found or if an error 
occurred while
-     *         loading the part
+     * @param contentID
+     *            a content ID referenced in an <tt>xop:Include</tt> element
+     * @return the {...@link DataHandler} for the MIME part identified by the 
content ID; may not be
+     *         <code>null</code>
+     * @throws IllegalArgumentException
+     *             if the MIME part was not found
+     * @throws IOException
+     *             if an error occurred while loading the part
      */
     DataHandler getDataHandler(String contentID) throws IOException;
 }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamWrapper.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamWrapper.java?rev=947411&r1=947410&r2=947411&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamWrapper.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamWrapper.java
 Sun May 23 13:42:49 2010
@@ -84,8 +84,8 @@ public abstract class XOPEncodingStreamW
     public boolean isLoaded(String contentID) {
         Object dataHandlerObject = dataHandlerObjects.get(contentID);
         if (dataHandlerObject == null) {
-            // We should never get here, so the return value actually doesn't 
matter
-            return false;
+            throw new IllegalArgumentException("No DataHandler object found 
for content ID '" +
+                    contentID + "'");
         } else if (dataHandlerObject instanceof DataHandler) {
             return true;
         } else {
@@ -96,7 +96,7 @@ public abstract class XOPEncodingStreamW
     public DataHandler getDataHandler(String contentID) throws IOException {
         Object dataHandlerObject = dataHandlerObjects.get(contentID);
         if (dataHandlerObject == null) {
-            throw new IOException("No DataHandler object found for content ID 
'" +
+            throw new IllegalArgumentException("No DataHandler object found 
for content ID '" +
                     contentID + "'");
         } else if (dataHandlerObject instanceof DataHandler) {
             return (DataHandler)dataHandlerObject;

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPUtils.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPUtils.java?rev=947411&r1=947410&r2=947411&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPUtils.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPUtils.java
 Sun May 23 13:42:49 2010
@@ -29,11 +29,11 @@ import org.apache.axiom.om.impl.builder.
 public class XOPUtils {
     private static final MimePartProvider nullMimePartProvider = new 
MimePartProvider() {
         public boolean isLoaded(String contentID) {
-            return false;
+            throw new IllegalArgumentException("There are no MIME parts!");
         }
         
         public DataHandler getDataHandler(String contentID) throws IOException 
{
-            throw new IOException("There are no MIME parts!");
+            throw new IllegalArgumentException("There are no MIME parts!");
         }
     };
     

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/AttachmentUnmarshallerImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/AttachmentUnmarshallerImpl.java?rev=947411&r1=947410&r2=947411&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/AttachmentUnmarshallerImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/builder/AttachmentUnmarshallerImpl.java
 Sun May 23 13:42:49 2010
@@ -47,9 +47,7 @@ public class AttachmentUnmarshallerImpl 
             accessed = true;
             return 
mimePartProvider.getDataHandler(ElementHelper.getContentIDFromHref(cid));
         } catch (IOException ex) {
-            ex.printStackTrace();
-            // TODO: we should distinguish I/O errors from non existing 
attachments
-            throw new UnsupportedOperationException();
+            throw new RuntimeException(ex);
         }
     }
 


Reply via email to