ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1728954 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl: common/ common/serializer/push/ common/serializer/push/sax/ common/serializer/push/stax/ mixin/
Date Sun, 07 Feb 2016 12:50:58 GMT
Author: veithen
Date: Sun Feb  7 12:50:58 2016
New Revision: 1728954

URL: http://svn.apache.org/viewvc?rev=1728954&view=rev
Log:
Simplify the exception hierarchy used by the serializer code.

Removed:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXOutputException.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXOutputException.java
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionTranslator.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSerializableSupport.aj

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionTranslator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionTranslator.java?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionTranslator.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionTranslator.java
Sun Feb  7 12:50:58 2016
@@ -18,8 +18,11 @@
  */
 package org.apache.axiom.om.impl.common;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.axiom.core.CoreModelException;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 
 public class AxiomExceptionTranslator {
     private AxiomExceptionTranslator() {}
@@ -27,4 +30,13 @@ public class AxiomExceptionTranslator {
     public static OMException translate(CoreModelException ex) {
         return new OMException(ex);
     }
+    
+    public static XMLStreamException toXMLStreamException(OutputException ex) {
+        Throwable cause = ex.getCause();
+        if (cause instanceof XMLStreamException) {
+            return (XMLStreamException)cause;
+        } else {
+            return new XMLStreamException(ex);
+        }
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/OutputException.java
Sun Feb  7 12:50:58 2016
@@ -19,13 +19,15 @@
 package org.apache.axiom.om.impl.common.serializer.push;
 
 /**
- * Wraps an exception thrown by the underlying API (StAX, SAX, etc.) while writing data.
This class
- * is abstract so that the type of the wrapped exception can be effectively restricted by
defining
- * an appropriate subclass.
+ * Wraps an exception thrown by the underlying API (StAX, SAX, etc.) while writing data.
  */
-public abstract class OutputException extends Exception {
+public class OutputException extends Exception {
     private static final long serialVersionUID = 7173617216602466028L;
 
+    public OutputException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
     public OutputException(Throwable cause) {
         super(cause);
     }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
Sun Feb  7 12:50:58 2016
@@ -60,7 +60,7 @@ public class SAXSerializer extends Seria
             contentHandler.startDocument();
             startDocumentWritten = true;
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
     
@@ -78,7 +78,7 @@ public class SAXSerializer extends Seria
                 lexicalHandler.startDTD(rootName, publicId, systemId);
                 lexicalHandler.endDTD();
             } catch (SAXException ex) {
-                throw new SAXOutputException(ex);
+                throw new OutputException(ex);
             }
         }
     }
@@ -98,7 +98,7 @@ public class SAXSerializer extends Seria
         try {
             contentHandler.startPrefixMapping(prefix, namespaceURI);
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
         // TODO: depending on the http://xml.org/sax/features/xmlns-uris feature, we also
need to add an attribute
     }
@@ -111,7 +111,7 @@ public class SAXSerializer extends Seria
         try {
             helper.finishStartElement(contentHandler);
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -122,7 +122,7 @@ public class SAXSerializer extends Seria
                 contentHandler.endDocument();
             }
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -146,7 +146,7 @@ public class SAXSerializer extends Seria
                     contentHandler.ignorableWhitespace(ch, 0, ch.length);
             }
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -156,7 +156,7 @@ public class SAXSerializer extends Seria
             try {
                 lexicalHandler.comment(ch, 0, ch.length);
             } catch (SAXException ex) {
-                throw new SAXOutputException(ex);
+                throw new OutputException(ex);
             }
         }
     }
@@ -165,7 +165,7 @@ public class SAXSerializer extends Seria
         try {
             contentHandler.processingInstruction(target, data);
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -173,7 +173,7 @@ public class SAXSerializer extends Seria
         try {
             contentHandler.skippedEntity(name);
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -190,7 +190,7 @@ public class SAXSerializer extends Seria
             } else {
                 saxException = new SAXException(ex);
             }
-            throw new SAXOutputException(saxException);
+            throw new OutputException(saxException);
         }
     }
 
@@ -211,11 +211,11 @@ public class SAXSerializer extends Seria
                 contentHandler.endDocument();
             }
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         } catch (SAXExceptionWrapper ex) {
-            throw new SAXOutputException((SAXException)ex.getCause());
+            throw new OutputException(ex.getCause());
         } catch (XMLStreamException ex) {
-            throw new SAXOutputException(new SAXException(ex));
+            throw new OutputException(ex);
         }
     }
 
@@ -223,7 +223,7 @@ public class SAXSerializer extends Seria
         try {
             contentHandler.endDocument();
         } catch (SAXException ex) {
-            throw new SAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/stax/StAXSerializer.java
Sun Feb  7 12:50:58 2016
@@ -55,7 +55,7 @@ public class StAXSerializer extends Seri
             // We cannot really differentiate between exceptions thrown by the XMLStreamWriter
             // and exceptions thrown by the data source itself. We wrap all XMLStreamExceptions
             // as OutputExceptions.
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -63,7 +63,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeStartDocument(version);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -71,7 +71,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeStartDocument(encoding, version);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -79,7 +79,7 @@ public class StAXSerializer extends Seri
         try {
             XMLStreamWriterUtils.writeDTD(writer, rootName, publicId, systemId, internalSubset);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -87,7 +87,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeStartElement(prefix, localName, namespaceURI);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -99,7 +99,7 @@ public class StAXSerializer extends Seri
                 writer.writeDefaultNamespace(namespaceURI);
             }
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -107,7 +107,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeAttribute(prefix, namespaceURI, localName, value);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -192,7 +192,7 @@ public class StAXSerializer extends Seri
                 return true;
             }
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -200,7 +200,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeEndElement();
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -212,7 +212,7 @@ public class StAXSerializer extends Seri
                 writer.writeCharacters(data);
             }
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -220,7 +220,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeComment(data);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -228,7 +228,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeProcessingInstruction(target, data);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -236,7 +236,7 @@ public class StAXSerializer extends Seri
         try {
             writer.writeEntityRef(name);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -252,9 +252,9 @@ public class StAXSerializer extends Seri
         try {
             getDataHandlerWriter().writeDataHandler(dataHandler, contentID, optimize);
         } catch (IOException ex) {
-            throw new StAXOutputException(new XMLStreamException("Error while reading data
handler", ex));
+            throw new OutputException("Error while reading data handler", ex);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 
@@ -262,9 +262,9 @@ public class StAXSerializer extends Seri
         try {
             getDataHandlerWriter().writeDataHandler(dataHandlerProvider, contentID, optimize);
         } catch (IOException ex) {
-            throw new StAXOutputException(new XMLStreamException("Error while reading data
handler", ex));
+            throw new OutputException("Error while reading data handler", ex);
         } catch (XMLStreamException ex) {
-            throw new StAXOutputException(ex);
+            throw new OutputException(ex);
         }
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
Sun Feb  7 12:50:58 2016
@@ -48,6 +48,7 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.builder.Builder;
+import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
 import org.apache.axiom.om.impl.common.NamespaceURIInterningXMLStreamReaderWrapper;
 import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
@@ -298,7 +299,7 @@ public aspect AxiomContainerSupport {
             try {
                 internalSerialize(new StAXSerializer(this, writer), format, true);
             } catch (OutputException ex) {
-                throw (XMLStreamException)ex.getCause();
+                throw AxiomExceptionTranslator.toXMLStreamException(ex);
             }
         } finally {
             writer.close();
@@ -313,7 +314,7 @@ public aspect AxiomContainerSupport {
             try {
                 internalSerialize(new StAXSerializer(this, writer), format, true);
             } catch (OutputException ex) {
-                throw (XMLStreamException)ex.getCause();
+                throw AxiomExceptionTranslator.toXMLStreamException(ex);
             }
         } finally {
             writer.close();
@@ -327,7 +328,7 @@ public aspect AxiomContainerSupport {
             try {
                 internalSerialize(new StAXSerializer(this, writer), format, false);
             } catch (OutputException ex) {
-                throw (XMLStreamException)ex.getCause();
+                throw AxiomExceptionTranslator.toXMLStreamException(ex);
             }
         } finally {
             writer.close();
@@ -343,7 +344,7 @@ public aspect AxiomContainerSupport {
             try {
                 internalSerialize(new StAXSerializer(this, writer), format, false);
             } catch (OutputException ex) {
-                throw (XMLStreamException)ex.getCause();
+                throw AxiomExceptionTranslator.toXMLStreamException(ex);
             }
         } finally {
             writer.close();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSerializableSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSerializableSupport.aj?rev=1728954&r1=1728953&r2=1728954&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSerializableSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSerializableSupport.aj
Sun Feb  7 12:50:58 2016
@@ -24,6 +24,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.builder.Builder;
+import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer;
 import org.apache.axiom.om.impl.intf.AxiomSerializable;
@@ -45,7 +46,7 @@ public aspect AxiomSerializableSupport {
         try {
             internalSerialize(new StAXSerializer(this, writer), writer.getOutputFormat(),
cache);
         } catch (OutputException ex) {
-            throw (XMLStreamException)ex.getCause();
+            throw AxiomExceptionTranslator.toXMLStreamException(ex);
         }
         writer.flush();
     }



Mime
View raw message