You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/03/11 08:17:35 UTC

svn commit: r1576203 [1/2] - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/cos/ pdfbox/src/main/java/org/apache/pdfbox/exceptions/ pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/m...

Author: jahewson
Date: Tue Mar 11 07:17:34 2014
New Revision: 1576203

URL: http://svn.apache.org/r1576203
Log:
PDFBOX-1973: Don't wrap Exceptions with COSVisitorException

Removed:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/exceptions/COSVisitorException.java
Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBase.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBoolean.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSNull.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSUnread.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/ICOSVisitor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSBase.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestPublicKeyEncryption.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocument.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/edit/TestPDPageContentStream.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestLayerUtility.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSArray.java Tue Mar 11 07:17:34 2014
@@ -16,12 +16,14 @@
  */
 package org.apache.pdfbox.cos;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
 /**
@@ -509,10 +511,11 @@ public class COSArray extends COSBase im
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
     @Override
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor)
+            throws IOException, CryptographyException, SignatureException
     {
         return visitor.visitFromArray(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBase.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBase.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBase.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBase.java Tue Mar 11 07:17:34 2014
@@ -16,9 +16,11 @@
  */
 package org.apache.pdfbox.cos;
 
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import java.io.IOException;
 
 /**
  * The base object that all objects in the PDF document will extend.
@@ -53,9 +55,11 @@ public abstract class COSBase implements
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
+     * @throws CryptographyException If an error occurs while visiting this object.
      */
-    public abstract Object accept(ICOSVisitor visitor) throws COSVisitorException;
+    public abstract Object accept(ICOSVisitor visitor)
+            throws IOException, CryptographyException, SignatureException;
     
     public void setNeedToBeUpdate(boolean flag) 
     {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBoolean.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBoolean.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBoolean.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSBoolean.java Tue Mar 11 07:17:34 2014
@@ -19,8 +19,6 @@ package org.apache.pdfbox.cos;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
-
 /**
  * This class represents a boolean value in the PDF document.
  *
@@ -109,9 +107,9 @@ public class COSBoolean extends COSBase
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept(ICOSVisitor  visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor  visitor) throws IOException
     {
         return visitor.visitFromBoolean(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDictionary.java Tue Mar 11 07:17:34 2014
@@ -25,7 +25,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.util.DateConverter;
 
@@ -1371,9 +1372,11 @@ public class COSDictionary extends COSBa
 	 * @param visitor The object to notify when visiting this object.
 	 * @return The object that the visitor returns.
 	 *
-	 * @throws COSVisitorException If there is an error visiting this object.
+	 * @throws IOException If there is an error visiting this object.
+     * @throws CryptographyException If there is an error visiting this object.
 	 */
-	public Object accept(ICOSVisitor  visitor) throws COSVisitorException
+	public Object accept(ICOSVisitor  visitor)
+            throws IOException, CryptographyException, SignatureException
 	{
 		return visitor.visitFromDictionary(this);
 	}

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Tue Mar 11 07:17:34 2014
@@ -28,7 +28,8 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.io.RandomAccess;
 import org.apache.pdfbox.io.RandomAccessBuffer;
 import org.apache.pdfbox.io.RandomAccessFile;
@@ -548,10 +549,11 @@ public class COSDocument extends COSBase
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
     @Override
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor)
+            throws IOException, CryptographyException, SignatureException
     {
         return visitor.visitFromDocument( this );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Tue Mar 11 07:17:34 2014
@@ -20,8 +20,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
-
 /**
  * This class represents a floating point number in a PDF document.
  *
@@ -158,9 +156,9 @@ public class COSFloat extends COSNumber
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor) throws IOException
     {
         return visitor.visitFromFloat(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java Tue Mar 11 07:17:34 2014
@@ -19,8 +19,6 @@ package org.apache.pdfbox.cos;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
-
 /**
  * This class represents an integer number in a PDF document.
  *
@@ -214,9 +212,9 @@ public class COSInteger extends COSNumbe
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor) throws IOException
     {
         return visitor.visitFromInt(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Tue Mar 11 07:17:34 2014
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.persistence.util.COSHEXTable;
 
 /**
@@ -1734,9 +1733,9 @@ public final class COSName extends COSBa
      * 
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor) throws IOException
     {
         return visitor.visitFromName(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSNull.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSNull.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSNull.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSNull.java Tue Mar 11 07:17:34 2014
@@ -16,13 +16,9 @@
  */
 package org.apache.pdfbox.cos;
 
-
-
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
-
 /**
  * This class represents a null PDF object.
  *
@@ -54,9 +50,9 @@ public class COSNull extends COSBase
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept( ICOSVisitor  visitor ) throws COSVisitorException
+    public Object accept( ICOSVisitor  visitor ) throws IOException
     {
         return visitor.visitFromNull( this );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObject.java Tue Mar 11 07:17:34 2014
@@ -16,7 +16,8 @@
  */
 package org.apache.pdfbox.cos;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 
 import java.io.IOException;
 
@@ -199,9 +200,9 @@ public class COSObject extends COSBase
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
      */
-    public Object accept( ICOSVisitor visitor ) throws COSVisitorException
+    public Object accept( ICOSVisitor visitor ) throws IOException, CryptographyException, SignatureException
     {
         return getObject() != null ? getObject().accept( visitor ) : COSNull.NULL.accept( visitor );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java Tue Mar 11 07:17:34 2014
@@ -26,12 +26,13 @@ import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.filter.DecodeResult;
 import org.apache.pdfbox.filter.Filter;
 import org.apache.pdfbox.filter.FilterFactory;
 import org.apache.pdfbox.io.*;
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.io.IOUtils;
 /**
  * This class represents a stream object in a PDF document.
@@ -246,9 +247,10 @@ public class COSStream extends COSDictio
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws CryptographyException If an error occurs while visiting this object.
      */
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor)
+            throws IOException, CryptographyException, SignatureException
     {
         return visitor.visitFromStream(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java Tue Mar 11 07:17:34 2014
@@ -21,7 +21,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 
 import org.apache.pdfbox.encoding.PdfDocEncoding;
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
 import org.apache.pdfbox.persistence.util.COSHEXTable;
 
 /**
@@ -469,14 +469,13 @@ public class COSString extends COSBase
     /**
      * visitor pattern double dispatch method.
      * 
-     * @param visitor
-     *            The object to notify when visiting this object.
+     * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException
-     *             If an error occurs while visiting this object.
+     * @throws IOException If an error occurs while visiting this object.
+     * @throws CryptographyException If an error occurs while visiting this object.
      */
     @Override
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor) throws IOException, CryptographyException
     {
         return visitor.visitFromString(this);
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSUnread.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSUnread.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSUnread.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSUnread.java Tue Mar 11 07:17:34 2014
@@ -17,7 +17,6 @@
 
 package org.apache.pdfbox.cos;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.pdfparser.ConformingPDFParser;
 
 /**
@@ -45,7 +44,7 @@ public class COSUnread extends COSBase {
     }
 
     @Override
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException {
+    public Object accept(ICOSVisitor visitor) {
         // TODO: read the object using the parser (if available) and visit that object
         throw new UnsupportedOperationException("COSUnread can not be written/visited.");
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/ICOSVisitor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/ICOSVisitor.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/ICOSVisitor.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/ICOSVisitor.java Tue Mar 11 07:17:34 2014
@@ -16,7 +16,10 @@
  */
 package org.apache.pdfbox.cos;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
+
+import java.io.IOException;
 
 /**
  * An interface for visiting a PDF document at the type (COS) level.
@@ -31,88 +34,95 @@ public interface ICOSVisitor
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromArray( COSArray obj ) throws COSVisitorException;
+    public Object visitFromArray( COSArray obj ) throws IOException, CryptographyException,
+                                                        SignatureException;
 
     /**
      * Notification of visit to boolean object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromBoolean( COSBoolean obj ) throws COSVisitorException;
+    public Object visitFromBoolean( COSBoolean obj ) throws IOException;
 
     /**
      * Notification of visit to dictionary object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromDictionary( COSDictionary obj ) throws COSVisitorException;
+    public Object visitFromDictionary( COSDictionary obj )
+            throws IOException, CryptographyException, SignatureException;
 
     /**
      * Notification of visit to document object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
+     * @throws SignatureException If there is an error while visiting this object.
      */
-    public Object visitFromDocument( COSDocument obj ) throws COSVisitorException;
+    public Object visitFromDocument( COSDocument obj )
+            throws IOException, CryptographyException, SignatureException;
 
     /**
      * Notification of visit to float object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromFloat( COSFloat obj ) throws COSVisitorException;
+    public Object visitFromFloat( COSFloat obj ) throws IOException;
 
     /**
      * Notification of visit to integer object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromInt( COSInteger obj ) throws COSVisitorException;
+    public Object visitFromInt( COSInteger obj ) throws IOException;
 
     /**
      * Notification of visit to name object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromName( COSName obj ) throws COSVisitorException;
+    public Object visitFromName( COSName obj ) throws IOException;
 
     /**
      * Notification of visit to null object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
      */
-    public Object visitFromNull( COSNull obj ) throws COSVisitorException;
+    public Object visitFromNull( COSNull obj ) throws IOException;
 
     /**
      * Notification of visit to stream object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
+     * @throws CryptographyException If there is an error while visiting this object.
      */
-    public Object visitFromStream( COSStream obj ) throws COSVisitorException;
+    public Object visitFromStream( COSStream obj )
+            throws IOException, CryptographyException, SignatureException;
 
     /**
      * Notification of visit to string object.
      *
      * @param obj The Object that is being visited.
      * @return any Object depending on the visitor implementation, or null
-     * @throws COSVisitorException If there is an error while visiting this object.
+     * @throws IOException If there is an error while visiting this object.
+     * @throws CryptographyException If there is an error while visiting this object.
      */
-    public Object visitFromString( COSString obj ) throws COSVisitorException;
+    public Object visitFromString( COSString obj ) throws IOException, CryptographyException;
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Tue Mar 11 07:17:34 2014
@@ -22,7 +22,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.text.DecimalFormat;
@@ -52,7 +51,6 @@ import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
 import org.apache.pdfbox.cos.ICOSVisitor;
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.exceptions.CryptographyException;
 import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdfparser.PDFXRefStream;
@@ -411,9 +409,8 @@ public class COSWriter implements ICOSVi
      * @param doc The document to write the body for.
      *
      * @throws IOException If there is an error writing the data.
-     * @throws COSVisitorException If there is an error generating the data.
      */
-    protected void doWriteBody(COSDocument doc) throws IOException, COSVisitorException
+    protected void doWriteBody(COSDocument doc) throws IOException, CryptographyException, SignatureException
     {
         COSDictionary trailer = doc.getTrailer();
         COSDictionary root = (COSDictionary)trailer.getDictionaryObject( COSName.ROOT );
@@ -494,43 +491,37 @@ public class COSWriter implements ICOSVi
      *
      * @param obj The object to write.
      *
-     * @throws COSVisitorException If there is an error visiting objects.
+     * @throws IOException if the output cannot be written
      */
-    public void doWriteObject( COSBase obj ) throws COSVisitorException
+    public void doWriteObject( COSBase obj )
+            throws IOException, CryptographyException, SignatureException
     {
-        try
+        writtenObjects.add( obj );
+        if(obj instanceof COSDictionary)
         {
-            writtenObjects.add( obj );
-            if(obj instanceof COSDictionary) 
+            COSDictionary dict = (COSDictionary)obj;
+            COSName item = (COSName)dict.getItem(COSName.TYPE);
+            if (COSName.SIG.equals(item) || COSName.DOC_TIME_STAMP.equals(item))
             {
-                COSDictionary dict = (COSDictionary)obj;
-                COSName item = (COSName)dict.getItem(COSName.TYPE);
-                if (COSName.SIG.equals(item) || COSName.DOC_TIME_STAMP.equals(item))
-                {
-                    reachedSignature = true;
-                }
+                reachedSignature = true;
             }
-            
-            // find the physical reference
-            currentObjectKey = getObjectKey( obj );
-            // add a x ref entry
-            addXRefEntry( new COSWriterXRefEntry(getStandardOutput().getPos(), obj, currentObjectKey));
-            // write the object
-            getStandardOutput().write(String.valueOf(currentObjectKey.getNumber()).getBytes("ISO-8859-1"));
-            getStandardOutput().write(SPACE);
-            getStandardOutput().write(String.valueOf(currentObjectKey.getGeneration()).getBytes("ISO-8859-1"));
-            getStandardOutput().write(SPACE);
-            getStandardOutput().write(OBJ);
-            getStandardOutput().writeEOL();
-            obj.accept( this );
-            getStandardOutput().writeEOL();
-            getStandardOutput().write(ENDOBJ);
-            getStandardOutput().writeEOL();
-        }
-        catch (IOException e)
-        {
-            throw new COSVisitorException(e);
         }
+
+        // find the physical reference
+        currentObjectKey = getObjectKey( obj );
+        // add a x ref entry
+        addXRefEntry( new COSWriterXRefEntry(getStandardOutput().getPos(), obj, currentObjectKey));
+        // write the object
+        getStandardOutput().write(String.valueOf(currentObjectKey.getNumber()).getBytes("ISO-8859-1"));
+        getStandardOutput().write(SPACE);
+        getStandardOutput().write(String.valueOf(currentObjectKey.getGeneration()).getBytes("ISO-8859-1"));
+        getStandardOutput().write(SPACE);
+        getStandardOutput().write(OBJ);
+        getStandardOutput().writeEOL();
+        obj.accept( this );
+        getStandardOutput().writeEOL();
+        getStandardOutput().write(ENDOBJ);
+        getStandardOutput().writeEOL();
     }
 
     /**
@@ -556,9 +547,9 @@ public class COSWriter implements ICOSVi
      * @param doc The document to create the trailer for.
      *
      * @throws IOException If there is an IOError while writing the document.
-     * @throws COSVisitorException If there is an error while generating the data.
      */
-    protected void doWriteTrailer(COSDocument doc) throws IOException, COSVisitorException
+    protected void doWriteTrailer(COSDocument doc)
+            throws IOException, CryptographyException, SignatureException
     {
         getStandardOutput().write(TRAILER);
         getStandardOutput().writeEOL();
@@ -656,7 +647,8 @@ public class COSWriter implements ICOSVi
         }
     }
 
-    private void doWriteXRefInc(COSDocument doc, long hybridPrev) throws IOException, COSVisitorException
+    private void doWriteXRefInc(COSDocument doc, long hybridPrev) throws IOException,
+            CryptographyException, SignatureException
     {
         if (doc.isXRefStream() || hybridPrev != -1)
         {
@@ -898,372 +890,249 @@ public class COSWriter implements ICOSVi
         return key;
     }
 
-    /**
-     * visitFromArray method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromArray( COSArray obj ) throws COSVisitorException
-    {
-        try
+    @Override
+    public Object visitFromArray( COSArray obj )
+            throws IOException, CryptographyException, SignatureException
+    {
+        int count = 0;
+        getStandardOutput().write(ARRAY_OPEN);
+        for (Iterator<COSBase> i = obj.iterator(); i.hasNext();)
         {
-            int count = 0;
-            getStandardOutput().write(ARRAY_OPEN);
-            for (Iterator<COSBase> i = obj.iterator(); i.hasNext();)
+            COSBase current = i.next();
+            if( current instanceof COSDictionary )
             {
-                COSBase current = i.next();
-                if( current instanceof COSDictionary )
+                if (current.isDirect())
                 {
-                	if (current.isDirect())
-                	{
-                		visitFromDictionary((COSDictionary)current);
-                	}
-                	else
-                	{
-                		addObjectToWrite( current );
-                		writeReference( current );
-                	}
+                    visitFromDictionary((COSDictionary)current);
                 }
-                else if( current instanceof COSObject )
+                else
                 {
-                    COSBase subValue = ((COSObject)current).getObject();
-                    if( subValue instanceof COSDictionary || subValue == null )
-                    {
-                        addObjectToWrite( current );
-                        writeReference( current );
-                    }
-                    else
-                    {
-                        subValue.accept( this );
-                    }
+                    addObjectToWrite( current );
+                    writeReference( current );
                 }
-                else if( current == null )
+            }
+            else if( current instanceof COSObject )
+            {
+                COSBase subValue = ((COSObject)current).getObject();
+                if( subValue instanceof COSDictionary || subValue == null )
                 {
-                    COSNull.NULL.accept( this );
+                    addObjectToWrite( current );
+                    writeReference( current );
                 }
-                else if( current instanceof COSString )
+                else
                 {
-                    COSString copy = new COSString(true);
-                    copy.append(((COSString)current).getBytes());
-                    copy.accept(this);
+                    subValue.accept( this );
                 }
-                else
+            }
+            else if( current == null )
+            {
+                COSNull.NULL.accept( this );
+            }
+            else if( current instanceof COSString )
+            {
+                COSString copy = new COSString(true);
+                copy.append(((COSString)current).getBytes());
+                copy.accept(this);
+            }
+            else
+            {
+                current.accept(this);
+            }
+            count++;
+            if (i.hasNext())
+            {
+                if (count % 10 == 0)
                 {
-                    current.accept(this);
+                    getStandardOutput().writeEOL();
                 }
-                count++;
-                if (i.hasNext())
+                else
                 {
-                    if (count % 10 == 0)
-                    {
-                        getStandardOutput().writeEOL();
-                    }
-                    else
-                    {
-                        getStandardOutput().write(SPACE);
-                    }
+                    getStandardOutput().write(SPACE);
                 }
             }
-            getStandardOutput().write(ARRAY_CLOSE);
-            getStandardOutput().writeEOL();
-            return null;
-        }
-        catch (IOException e)
-        {
-            throw new COSVisitorException(e);
         }
+        getStandardOutput().write(ARRAY_CLOSE);
+        getStandardOutput().writeEOL();
+        return null;
     }
 
-    /**
-     * visitFromBoolean method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromBoolean(COSBoolean obj) throws COSVisitorException
+    @Override
+    public Object visitFromBoolean(COSBoolean obj) throws IOException
     {
-
-        try
-        {
-            obj.writePDF( getStandardOutput() );
-            return null;
-        }
-        catch (IOException e)
-        {
-            throw new COSVisitorException(e);
-        }
+        obj.writePDF( getStandardOutput() );
+        return null;
     }
 
-    /**
-     * visitFromDictionary method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromDictionary(COSDictionary obj) throws COSVisitorException
+    @Override
+    public Object visitFromDictionary(COSDictionary obj)
+            throws IOException, CryptographyException, SignatureException
     {
-        try
+        getStandardOutput().write(DICT_OPEN);
+        getStandardOutput().writeEOL();
+        for (Map.Entry<COSName, COSBase> entry : obj.entrySet())
         {
-            getStandardOutput().write(DICT_OPEN);
-            getStandardOutput().writeEOL();
-            for (Map.Entry<COSName, COSBase> entry : obj.entrySet())
+            COSBase value = entry.getValue();
+            if (value != null)
             {
-                COSBase value = entry.getValue();
-                if (value != null)
+                entry.getKey().accept(this);
+                getStandardOutput().write(SPACE);
+                if( value instanceof COSDictionary )
                 {
-                    entry.getKey().accept(this);
-                    getStandardOutput().write(SPACE);
-                    if( value instanceof COSDictionary )
+                    COSDictionary dict = (COSDictionary)value;
+
+                    // write all XObjects as direct objects, this will save some size
+                    COSBase item = dict.getItem(COSName.XOBJECT);
+                    if(item!=null)
                     {
-                        COSDictionary dict = (COSDictionary)value;
-                        
-                        // write all XObjects as direct objects, this will save some size
-                        COSBase item = dict.getItem(COSName.XOBJECT);
-                        if(item!=null)
-                        {
-                            item.setDirect(true);
-                        }
-                        item = dict.getItem(COSName.RESOURCES);
-                        if(item!=null)
-                        {
-                            item.setDirect(true);
-                        }
-
-                        if(dict.isDirect()) 
-                        {
-                            // If the object should be written direct, we need
-                            // to pass the dictionary to the visitor again.
-                            visitFromDictionary(dict);
-                        }
-                        else 
-                        {
-                            addObjectToWrite( dict );
-                            writeReference( dict );
-                        }
+                        item.setDirect(true);
                     }
-                    else if( value instanceof COSObject )
+                    item = dict.getItem(COSName.RESOURCES);
+                    if(item!=null)
                     {
-                        COSBase subValue = ((COSObject)value).getObject();
-                        if( subValue instanceof COSDictionary || subValue == null )
-                        {
-                            addObjectToWrite( value );
-                            writeReference( value );
-                        }
-                        else
-                        {
-                            subValue.accept( this );                                
-                        }
+                        item.setDirect(true);
+                    }
+
+                    if(dict.isDirect())
+                    {
+                        // If the object should be written direct, we need
+                        // to pass the dictionary to the visitor again.
+                        visitFromDictionary(dict);
                     }
                     else
                     {
-                        // If we reach the pdf signature, we need to determinate the position of the
-                        // content and byterange
-                        if(reachedSignature && COSName.CONTENTS.equals(entry.getKey()))
-                        {
-                            signaturePosition = new int[2];
-                            signaturePosition[0] = (int)getStandardOutput().getPos();
-                            value.accept(this);
-                            signaturePosition[1] = (int)getStandardOutput().getPos();
-                        }
-                        else if(reachedSignature && COSName.BYTERANGE.equals(entry.getKey()))
-                        {
-                            byterangePosition = new int[2];
-                            byterangePosition[0] = (int)getStandardOutput().getPos()+1;
-                            value.accept(this);
-                            byterangePosition[1] = (int)getStandardOutput().getPos()-1;
-                            reachedSignature = false;
-                        }
-                        else
-                        {
-                            value.accept(this);
-                        }
+                        addObjectToWrite( dict );
+                        writeReference( dict );
+                    }
+                }
+                else if( value instanceof COSObject )
+                {
+                    COSBase subValue = ((COSObject)value).getObject();
+                    if( subValue instanceof COSDictionary || subValue == null )
+                    {
+                        addObjectToWrite( value );
+                        writeReference( value );
+                    }
+                    else
+                    {
+                        subValue.accept( this );
                     }
-                    getStandardOutput().writeEOL();
-
                 }
                 else
                 {
-                    //then we won't write anything, there are a couple cases
-                    //were the value of an entry in the COSDictionary will
-                    //be a dangling reference that points to nothing
-                    //so we will just not write out the entry if that is the case
+                    // If we reach the pdf signature, we need to determinate the position of the
+                    // content and byterange
+                    if(reachedSignature && COSName.CONTENTS.equals(entry.getKey()))
+                    {
+                        signaturePosition = new int[2];
+                        signaturePosition[0] = (int)getStandardOutput().getPos();
+                        value.accept(this);
+                        signaturePosition[1] = (int)getStandardOutput().getPos();
+                    }
+                    else if(reachedSignature && COSName.BYTERANGE.equals(entry.getKey()))
+                    {
+                        byterangePosition = new int[2];
+                        byterangePosition[0] = (int)getStandardOutput().getPos()+1;
+                        value.accept(this);
+                        byterangePosition[1] = (int)getStandardOutput().getPos()-1;
+                        reachedSignature = false;
+                    }
+                    else
+                    {
+                        value.accept(this);
+                    }
                 }
-            }
-            getStandardOutput().write(DICT_CLOSE);
-            getStandardOutput().writeEOL();
-            return null;
-        }
-        catch( IOException e )
-        {
-            throw new COSVisitorException(e);
-        }
-    }
-
-    /**
-     * The visit from document method.
-     *
-     * @param doc The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromDocument(COSDocument doc) throws COSVisitorException
-    {
-        try
-        {
-            if(!incrementalUpdate)
-            {
-                doWriteHeader(doc);
-            }
-            doWriteBody(doc);
-            
-            // get the previous trailer
-            COSDictionary trailer = doc.getTrailer();
-            long hybridPrev = -1;
+                getStandardOutput().writeEOL();
 
-            if (trailer != null)
-            {
-                hybridPrev = trailer.getLong(COSName.XREF_STM);
-            }
-            
-            if(incrementalUpdate)
-            {
-                doWriteXRefInc(doc, hybridPrev);
             }
             else
             {
-                doWriteXRef(doc);
-            }
-            
-            // the trailer section should only be used for xref tables not for xref streams
-            if (!incrementalUpdate || !doc.isXRefStream() || hybridPrev != -1)
-            {
-                doWriteTrailer(doc);
-            }
-            
-            // write endof
-            getStandardOutput().write(STARTXREF);
-            getStandardOutput().writeEOL();
-            getStandardOutput().write(String.valueOf(getStartxref()).getBytes("ISO-8859-1"));
-            getStandardOutput().writeEOL();
-            getStandardOutput().write(EOF);
-            getStandardOutput().writeEOL();
-            
-            if(incrementalUpdate)
-            {
-                doWriteSignature(doc);
+                //then we won't write anything, there are a couple cases
+                //were the value of an entry in the COSDictionary will
+                //be a dangling reference that points to nothing
+                //so we will just not write out the entry if that is the case
             }
-            
-            return null;
-        }
-        catch (IOException e)
-        {
-            throw new COSVisitorException(e);
-        }
-        catch (SignatureException e)
-        {
-            throw new COSVisitorException(e);
         }
+        getStandardOutput().write(DICT_CLOSE);
+        getStandardOutput().writeEOL();
+        return null;
     }
 
-    /**
-     * visitFromFloat method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromFloat(COSFloat obj) throws COSVisitorException
+    @Override
+    public Object visitFromDocument(COSDocument doc)
+            throws IOException, CryptographyException, SignatureException
     {
-
-        try
+        if(!incrementalUpdate)
         {
-            obj.writePDF( getStandardOutput() );
-            return null;
+            doWriteHeader(doc);
         }
-        catch (IOException e)
+        doWriteBody(doc);
+
+        // get the previous trailer
+        COSDictionary trailer = doc.getTrailer();
+        long hybridPrev = -1;
+
+        if (trailer != null)
         {
-            throw new COSVisitorException(e);
+            hybridPrev = trailer.getLong(COSName.XREF_STM);
         }
-    }
 
-    /**
-     * visitFromFloat method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromInt(COSInteger obj) throws COSVisitorException
-    {
-        try
+        if(incrementalUpdate)
         {
-            obj.writePDF( getStandardOutput() );
-            return null;
+            doWriteXRefInc(doc, hybridPrev);
         }
-        catch (IOException e)
+        else
         {
-            throw new COSVisitorException(e);
+            doWriteXRef(doc);
         }
-    }
 
-    /**
-     * visitFromName method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromName(COSName obj) throws COSVisitorException
-    {
-        try
+        // the trailer section should only be used for xref tables not for xref streams
+        if (!incrementalUpdate || !doc.isXRefStream() || hybridPrev != -1)
         {
-            obj.writePDF( getStandardOutput() );
-            return null;
+            doWriteTrailer(doc);
         }
-        catch (IOException e)
+
+        // write endof
+        getStandardOutput().write(STARTXREF);
+        getStandardOutput().writeEOL();
+        getStandardOutput().write(String.valueOf(getStartxref()).getBytes("ISO-8859-1"));
+        getStandardOutput().writeEOL();
+        getStandardOutput().write(EOF);
+        getStandardOutput().writeEOL();
+
+        if(incrementalUpdate)
         {
-            throw new COSVisitorException(e);
+            doWriteSignature(doc);
         }
+
+        return null;
     }
 
-    /**
-     * visitFromNull method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromNull(COSNull obj) throws COSVisitorException
+    @Override
+    public Object visitFromFloat(COSFloat obj) throws IOException
     {
-        try
-        {
-            obj.writePDF( getStandardOutput() );
-            return null;
-        }
-        catch (IOException e)
-        {
-            throw new COSVisitorException(e);
-        }
+        obj.writePDF( getStandardOutput() );
+        return null;
+    }
+
+    @Override
+    public Object visitFromInt(COSInteger obj) throws IOException
+    {
+        obj.writePDF( getStandardOutput() );
+        return null;
+    }
+
+    @Override
+    public Object visitFromName(COSName obj) throws IOException
+    {
+        obj.writePDF( getStandardOutput() );
+        return null;
+    }
+
+    @Override
+    public Object visitFromNull(COSNull obj) throws IOException
+    {
+        obj.writePDF( getStandardOutput() );
+        return null;
     }
 
     /**
@@ -1271,67 +1140,52 @@ public class COSWriter implements ICOSVi
      *
      * @param obj The object that is being visited.
      *
-     * @throws COSVisitorException If there is an exception while visiting this object.
+     * @throws IOException If there is an exception while visiting this object.
      */
-    public void writeReference(COSBase obj) throws COSVisitorException
+    public void writeReference(COSBase obj) throws IOException
     {
-        try
+        COSObjectKey key = getObjectKey(obj);
+        getStandardOutput().write(String.valueOf(key.getNumber()).getBytes("ISO-8859-1"));
+        getStandardOutput().write(SPACE);
+        getStandardOutput().write(String.valueOf(key.getGeneration()).getBytes("ISO-8859-1"));
+        getStandardOutput().write(SPACE);
+        getStandardOutput().write(REFERENCE);
+    }
+
+    @Override
+    public Object visitFromStream(COSStream obj)
+            throws IOException, CryptographyException, SignatureException
+    {
+        if (willEncrypt)
         {
-            COSObjectKey  key = getObjectKey(obj);
-            getStandardOutput().write(String.valueOf(key.getNumber()).getBytes("ISO-8859-1"));
-            getStandardOutput().write(SPACE);
-            getStandardOutput().write(String.valueOf(key.getGeneration()).getBytes("ISO-8859-1"));
-            getStandardOutput().write(SPACE);
-            getStandardOutput().write(REFERENCE);
+            document.getSecurityHandler().encryptStream(obj, currentObjectKey.getNumber(),
+                                                        currentObjectKey.getGeneration());
         }
-        catch (IOException e)
+
+        COSObject lengthObject = null;
+        // check if the length object is required to be direct, like in
+        // a cross reference stream dictionary
+        COSBase lengthEntry = obj.getDictionaryObject(COSName.LENGTH);
+        String type = obj.getNameAsString(COSName.TYPE);
+        if (lengthEntry != null && lengthEntry.isDirect() || "XRef".equals(type))
         {
-            throw new COSVisitorException(e);
+            // the length might be the non encoded length,
+            // set the real one as direct object
+            COSInteger cosInteger = COSInteger.get(obj.getFilteredLength());
+            cosInteger.setDirect(true);
+            obj.setItem(COSName.LENGTH, cosInteger);
+        }
+        else
+        {
+            // make the length an implicit indirect object
+            // set the length of the stream and write stream dictionary
+            lengthObject = new COSObject(null);
+            obj.setItem(COSName.LENGTH, lengthObject);
         }
-    }
 
-    /**
-     * visitFromStream method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     *
-     * @return null
-     */
-    public Object visitFromStream(COSStream obj) throws COSVisitorException
-    {
         InputStream input = null;
         try
         {
-            if (willEncrypt)
-            {
-                document.getSecurityHandler().encryptStream(obj, currentObjectKey.getNumber()
-                        , currentObjectKey.getGeneration());
-            }
-
-            COSObject lengthObject = null;
-            // check if the length object is required to be direct, like in
-            // a cross reference stream dictionary
-            COSBase lengthEntry = obj.getDictionaryObject(COSName.LENGTH);
-            String type = obj.getNameAsString(COSName.TYPE);
-            if (lengthEntry != null && lengthEntry.isDirect() || "XRef".equals(type))
-            {
-                // the length might be the non encoded length,
-                // set the real one as direct object
-                COSInteger cosInteger = COSInteger.get(obj.getFilteredLength());
-                cosInteger.setDirect(true);
-                obj.setItem(COSName.LENGTH, cosInteger);
-
-            }
-            else
-            {
-                // make the length an implicit indirect object
-                // set the length of the stream and write stream dictionary
-                lengthObject = new COSObject(null);
-
-                obj.setItem(COSName.LENGTH, lengthObject);
-            }
             input = obj.getFilteredStream();
             //obj.accept(this);
             // write the stream content
@@ -1356,64 +1210,38 @@ public class COSWriter implements ICOSVi
             getStandardOutput().writeEOL();
             return null;
         }
-        catch (Exception e)
-        {
-            throw new COSVisitorException(e);
-        }
         finally
         {
             if (input != null)
             {
-                try
-                {
-                    input.close();
-                }
-                catch (IOException e)
-                {
-                    throw new COSVisitorException(e);
-                }
+                input.close();
             }
         }
     }
 
-    /**
-     * visitFromString method comment.
-     *
-     * @param obj The object that is being visited.
-     *
-     * @return null
-     *
-     * @throws COSVisitorException If there is an exception while visiting this object.
-     */
-    public Object visitFromString(COSString obj) throws COSVisitorException
+    @Override
+    public Object visitFromString(COSString obj) throws IOException, CryptographyException
     {
-        try
+        if(willEncrypt)
         {
-            if(willEncrypt)
-            {
-                document.getSecurityHandler().decryptString(
+            document.getSecurityHandler().decryptString(
                     obj,
                     currentObjectKey.getNumber(),
                     currentObjectKey.getGeneration());
-            }
-
-            obj.writePDF( getStandardOutput() );
-        }
-        catch (Exception e)
-        {
-            throw new COSVisitorException(e);
         }
+
+        obj.writePDF( getStandardOutput() );
         return null;
     }
 
     /**
      * This will write the pdf document.
      *
+     * @throws IOException If an error occurs while generating the data.
      * @param doc The document to write.
-     *
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void write(COSDocument doc) throws COSVisitorException
+    public void write(COSDocument doc)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         PDDocument pdDoc = new PDDocument( doc );
         write( pdDoc );
@@ -1424,13 +1252,15 @@ public class COSWriter implements ICOSVi
      *
      * @param doc The document to write.
      *
-     * @throws COSVisitorException If an error occurs while generating the data.
+     * @throws IOException If an error occurs while generating the data.
+     * @throws CryptographyException If an error occurs while generating the data.
      */
-    public void write(PDDocument doc) throws COSVisitorException
+    public void write(PDDocument doc)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
 	{
         Long idTime = doc.getDocumentId() == null ? System.currentTimeMillis() : 
                                                     doc.getDocumentId();
-        
+
         document = doc;
         if(incrementalUpdate)
         {
@@ -1440,7 +1270,7 @@ public class COSWriter implements ICOSVi
         // if the document says we should remove encryption, then we shouldn't encrypt
         if(doc.isAllSecurityToBeRemoved())
         {
-            this.willEncrypt = false;
+            willEncrypt = false;
             // also need to get rid of the "Encrypt" in the trailer so readers 
             // don't try to decrypt a document which is not encrypted
             COSDocument cosDoc = doc.getDocument();
@@ -1452,23 +1282,12 @@ public class COSWriter implements ICOSVi
             SecurityHandler securityHandler = document.getSecurityHandler();
             if(securityHandler != null)
             {
-                try
-                {
-                    securityHandler.prepareDocumentForEncryption(document);
-                    this.willEncrypt = true;
-                }
-                catch(IOException e)
-                {
-                    throw new COSVisitorException( e );
-                }
-                catch(CryptographyException e)
-                {
-                    throw new COSVisitorException( e );
-                }
+                securityHandler.prepareDocumentForEncryption(document);
+                willEncrypt = true;
             }
             else
             {
-                    this.willEncrypt = false;
+                willEncrypt = false;
             }        
         }
 
@@ -1477,38 +1296,25 @@ public class COSWriter implements ICOSVi
         COSArray idArray = (COSArray)trailer.getDictionaryObject( COSName.ID );
         if( idArray == null || incrementalUpdate)
         {
-            try
+            //algorithm says to use time/path/size/values in doc to generate
+            //the id.  We don't have path or size, so do the best we can
+            MessageDigest md = MessageDigest.getInstance( "MD5" );
+            md.update( Long.toString(idTime).getBytes("ISO-8859-1") );
+            COSDictionary info = (COSDictionary)trailer.getDictionaryObject( COSName.INFO );
+            if( info != null )
             {
-
-                //algorithm says to use time/path/size/values in doc to generate
-                //the id.  We don't have path or size, so do the best we can
-                MessageDigest md = MessageDigest.getInstance( "MD5" );
-                md.update( Long.toString(idTime).getBytes("ISO-8859-1") );
-                COSDictionary info = (COSDictionary)trailer.getDictionaryObject( COSName.INFO );
-                if( info != null )
+                Iterator<COSBase> values = info.getValues().iterator();
+                while( values.hasNext() )
                 {
-                    Iterator<COSBase> values = info.getValues().iterator();
-                    while( values.hasNext() )
-                    {
-                        md.update( values.next().toString().getBytes("ISO-8859-1") );
-                    }
+                    md.update( values.next().toString().getBytes("ISO-8859-1") );
                 }
-                idArray = new COSArray();
-                COSString id = new COSString( md.digest() );
-                idArray.add( id );
-                idArray.add( id );
-                trailer.setItem( COSName.ID, idArray );
-            }
-            catch( NoSuchAlgorithmException e )
-            {
-                throw new COSVisitorException( e );
-            }
-            catch( UnsupportedEncodingException e )
-            {
-                throw new COSVisitorException( e );
             }
+            idArray = new COSArray();
+            COSString id = new COSString( md.digest() );
+            idArray.add( id );
+            idArray.add( id );
+            trailer.setItem( COSName.ID, idArray );
         }
         cosDoc.accept(this);
     }
 }
-

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Tue Mar 11 07:17:34 2014
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -39,7 +40,6 @@ import org.apache.pdfbox.cos.COSInteger;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.exceptions.COSVisitorException;
 import org.apache.pdfbox.exceptions.CryptographyException;
 import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.exceptions.SignatureException;
@@ -1192,11 +1192,14 @@ public class PDDocument implements Close
      * Save the document to a file.
      * 
      * @param fileName The file to save as.
-     * 
-     * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
+     *
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void save(String fileName) throws IOException, COSVisitorException
+    public void save(String fileName)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         save(new File(fileName));
     }
@@ -1205,11 +1208,14 @@ public class PDDocument implements Close
      * Save the document to a file.
      * 
      * @param file The file to save as.
-     * 
-     * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
+     *
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void save(File file) throws IOException, COSVisitorException
+    public void save(File file)
+        throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         save(new FileOutputStream(file));
     }
@@ -1218,11 +1224,14 @@ public class PDDocument implements Close
      * This will save the document to an output stream.
      * 
      * @param output The stream to write to.
-     * 
-     * @throws IOException If there is an error writing the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
+     *
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void save(OutputStream output) throws IOException, COSVisitorException
+    public void save(OutputStream output)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         // update the count in case any pages have been added behind the scenes.
         getDocumentCatalog().getPages().updateCount();
@@ -1246,10 +1255,13 @@ public class PDDocument implements Close
      * Save the pdf as incremental.
      * 
      * @param fileName the filename to be used
-     * @throws IOException if something went wrong
-     * @throws COSVisitorException if something went wrong
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void saveIncremental(String fileName) throws IOException, COSVisitorException
+    public void saveIncremental(String fileName)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         saveIncremental(new FileInputStream(fileName), new FileOutputStream(fileName, true));
     }
@@ -1257,12 +1269,15 @@ public class PDDocument implements Close
     /**
      * Save the pdf as incremental.
      * 
-     * @param input
-     * @param output
-     * @throws IOException if something went wrong
-     * @throws COSVisitorException if something went wrong
+     * @param input stream to read
+     * @param output stream to write
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void saveIncremental(FileInputStream input, OutputStream output) throws IOException, COSVisitorException
+    public void saveIncremental(FileInputStream input, OutputStream output)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         // update the count in case any pages have been added behind the scenes.
         getDocumentCatalog().getPages().updateCount();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java Tue Mar 11 07:17:34 2014
@@ -33,7 +33,8 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.ICOSVisitor;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.io.RandomAccess;
 
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
@@ -210,9 +211,12 @@ public class COSStreamArray extends COSS
      *
      * @param visitor The object to notify when visiting this object.
      * @return any object, depending on the visitor implementation, or null
-     * @throws COSVisitorException If an error occurs while visiting this object.
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
      */
-    public Object accept(ICOSVisitor visitor) throws COSVisitorException
+    public Object accept(ICOSVisitor visitor)
+            throws IOException, CryptographyException, SignatureException
     {
         return streams.accept( visitor );
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java Tue Mar 11 07:17:34 2014
@@ -26,13 +26,14 @@ import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
+import java.security.NoSuchAlgorithmException;
 
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSName;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
-
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdfparser.PDFParser;
 
 import org.apache.pdfbox.pdfwriter.COSWriter;
@@ -254,9 +255,9 @@ public class FDFDocument
      * @param fileName The file to save as.
      *
      * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void save( File fileName ) throws IOException, COSVisitorException
+    public void save( File fileName )
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         save( new FileOutputStream( fileName ) );
     }
@@ -267,9 +268,9 @@ public class FDFDocument
      * @param fileName The file to save as.
      *
      * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void save( String fileName ) throws IOException, COSVisitorException
+    public void save( String fileName )
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         save( new FileOutputStream( fileName ) );
     }
@@ -280,9 +281,11 @@ public class FDFDocument
      * @param output The stream to write to.
      *
      * @throws IOException If there is an error writing the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
+     * @throws CryptographyException If there is an error writing the document.
+     * @throws SignatureException If there is an error writing the document.
      */
-    public void save( OutputStream output ) throws IOException, COSVisitorException
+    public void save( OutputStream output )
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         COSWriter writer = null;
         try
@@ -306,9 +309,8 @@ public class FDFDocument
      * @param fileName The file to save as.
      *
      * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void saveXFDF( File fileName ) throws IOException, COSVisitorException
+    public void saveXFDF( File fileName ) throws IOException
     {
         saveXFDF( new BufferedWriter( new FileWriter( fileName ) ) );
     }
@@ -319,9 +321,8 @@ public class FDFDocument
      * @param fileName The file to save as.
      *
      * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void saveXFDF( String fileName ) throws IOException, COSVisitorException
+    public void saveXFDF( String fileName ) throws IOException
     {
         saveXFDF( new BufferedWriter( new FileWriter( fileName ) ) );
     }
@@ -332,9 +333,8 @@ public class FDFDocument
      * @param output The stream to write to.
      *
      * @throws IOException If there is an error writing the document.
-     * @throws COSVisitorException If an error occurs while generating the data.
      */
-    public void saveXFDF( Writer output ) throws IOException, COSVisitorException
+    public void saveXFDF( Writer output ) throws IOException
     {
         try
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java Tue Mar 11 07:17:34 2014
@@ -20,10 +20,12 @@ import java.awt.geom.AffineTransform;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -68,10 +70,9 @@ public class PDFTemplateCreator
      * @param properties
      * @return InputStream
      * @throws IOException
-     * @throws COSVisitorException
      */
-
-    public InputStream buildPDF(PDVisibleSignDesigner properties) throws IOException
+    public InputStream buildPDF(PDVisibleSignDesigner properties)
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         logger.info("pdf building has been started");
         PDFTemplateStructure pdfStructure = pdfBuilder.getStructure();
@@ -153,15 +154,7 @@ public class PDFTemplateCreator
         this.pdfBuilder.createVisualSignature(template);
         this.pdfBuilder.createWidgetDictionary(pdSignatureField, holderFormResources);
         
-        ByteArrayInputStream in = null;
-        try
-        {
-            in = pdfStructure.getTemplateAppearanceStream();
-        }
-        catch (COSVisitorException e)
-        {
-            logger.error("COSVisitorException: can't get apereance stream ", e);
-        }
+        ByteArrayInputStream in = pdfStructure.getTemplateAppearanceStream();
         logger.info("stream returning started, size= " + in.available());
         
         // we must close the document

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java Tue Mar 11 07:17:34 2014
@@ -20,12 +20,14 @@ import java.awt.geom.AffineTransform;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.List;
 
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdfwriter.COSWriter;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -574,9 +576,9 @@ public class PDFTemplateStructure
     * Gets AP of the created template
     * @return
     * @throws IOException
-    * @throws COSVisitorException
     */
-    public ByteArrayInputStream getTemplateAppearanceStream() throws IOException, COSVisitorException
+    public ByteArrayInputStream getTemplateAppearanceStream()
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         COSDocument visualSignature = getVisualSignature();
         ByteArrayOutputStream memoryOut = new ByteArrayOutputStream();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java Tue Mar 11 07:17:34 2014
@@ -16,8 +16,12 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible;
 
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
+
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
 
 /**
  * This builder class is in order to create visible signature properties.
@@ -39,10 +43,14 @@ public class PDVisibleSigProperties
 
     /**
      * start building of visible signature
-     * 
-     * @throws IOException
+     *
+     * @throws IOException if the output could not be written
+     * @throws CryptographyException if something went wrong during a cryptography operation
+     * @throws SignatureException if signing failed
+     * @throws NoSuchAlgorithmException if the cryptographic algorithm is not available
      */
-    public void buildSignature() throws IOException
+    public void buildSignature()
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         PDFTemplateBuilder builder = new PDVisibleSigBuilder();
         PDFTemplateCreator creator = new PDFTemplateCreator(builder);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java Tue Mar 11 07:17:34 2014
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -34,7 +35,8 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
@@ -173,9 +175,9 @@ public class PDFMergerUtility
      * Merge the list of source documents, saving the result in the destination file.
      * 
      * @throws IOException If there is an error saving the document.
-     * @throws COSVisitorException If an error occurs while saving the destination file.
      */
-    public void mergeDocuments() throws IOException, COSVisitorException
+    public void mergeDocuments()
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         PDDocument destination = null;
         InputStream sourceFile;

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSBase.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSBase.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSBase.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSBase.java Tue Mar 11 07:17:34 2014
@@ -19,8 +19,13 @@ package org.apache.pdfbox.cos;
 
 import junit.framework.TestCase;
 
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.filter.FilterFactory;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+
 /**
  * Test class for {@link COSBase}.
  */
@@ -40,7 +45,8 @@ public abstract class TestCOSBase extend
     /**
      * Test accept() - tests the interface for visiting a document at the COS level.
      */
-    public abstract void testAccept();
+    public abstract void testAccept()
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException;
 
     /**
      * Tests isNeedToBeUpdate() and setNeedToBeUpdate() - tests the getter/setter methods.

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java?rev=1576203&r1=1576202&r2=1576203&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java Tue Mar 11 07:17:34 2014
@@ -19,8 +19,10 @@ package org.apache.pdfbox.cos;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.security.NoSuchAlgorithmException;
 
-import org.apache.pdfbox.exceptions.COSVisitorException;
+import org.apache.pdfbox.exceptions.CryptographyException;
+import org.apache.pdfbox.exceptions.SignatureException;
 import org.apache.pdfbox.pdfwriter.COSWriter;
 
 import junit.framework.Test;
@@ -320,23 +322,17 @@ public class TestCOSString extends TestC
 
     @Override
     public void testAccept()
+            throws IOException, CryptographyException, SignatureException, NoSuchAlgorithmException
     {
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         ICOSVisitor visitor = new COSWriter(outStream);
         COSString testSubj = new COSString(ESC_CHAR_STRING);
-        try
-        {
-            testSubj.accept(visitor);
-            assertEquals("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", outStream.toString());
-            outStream.reset();
-            testSubj.setForceHexForm(true);
-            testSubj.accept(visitor);
-            assertEquals("<" + createHex(ESC_CHAR_STRING) + ">", outStream.toString());
-        }
-        catch (COSVisitorException e)
-        {
-            fail(e.getMessage());
-        }
+        testSubj.accept(visitor);
+        assertEquals("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", outStream.toString());
+        outStream.reset();
+        testSubj.setForceHexForm(true);
+        testSubj.accept(visitor);
+        assertEquals("<" + createHex(ESC_CHAR_STRING) + ">", outStream.toString());
     }
 
     /**