pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1843687 - in /pdfbox/trunk/preflight: ./ src/main/java/org/apache/pdfbox/preflight/ src/main/java/org/apache/pdfbox/preflight/parser/ src/main/java/org/apache/pdfbox/preflight/utils/ src/test/java/org/apache/pdfbox/preflight/ src/test/java...
Date Fri, 12 Oct 2018 16:35:45 GMT
Author: tilman
Date: Fri Oct 12 16:35:44 2018
New Revision: 1843687

URL: http://svn.apache.org/viewvc?rev=1843687&view=rev
Log:
PDFBOX-4340: replace DataSource from java activation framework with reduced implementation

Added:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/DataSource.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/FileDataSource.java
Modified:
    pdfbox/trunk/preflight/pom.xml
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightContext.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java
    pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPDFBox3743.java
    pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java

Modified: pdfbox/trunk/preflight/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/pom.xml?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/pom.xml (original)
+++ pdfbox/trunk/preflight/pom.xml Fri Oct 12 16:35:44 2018
@@ -46,11 +46,6 @@
                         <artifactId>jaxb-api</artifactId>
                         <scope>provided</scope>
                     </dependency>
-                    <dependency>
-                        <groupId>javax.activation</groupId>
-                        <artifactId>activation</artifactId>
-                        <scope>provided</scope>
-                    </dependency>
                 </dependencies>
             </profile>
         </profiles>

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightContext.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightContext.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightContext.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightContext.java
Fri Oct 12 16:35:44 2018
@@ -26,14 +26,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.activation.DataSource;
-
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.pdfparser.XrefTrailerResolver;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.font.container.FontContainer;
 import org.apache.pdfbox.preflight.graphic.ICCProfileWrapper;
 import org.apache.pdfbox.preflight.utils.COSUtils;
+import org.apache.pdfbox.preflight.utils.DataSource;
 import org.apache.xmpbox.XMPMetadata;
 
 public class PreflightContext implements Closeable

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java Fri
Oct 12 16:35:44 2018
@@ -29,7 +29,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.activation.FileDataSource;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
@@ -44,6 +43,7 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
 import org.apache.pdfbox.preflight.parser.PreflightParser;
 import org.apache.pdfbox.preflight.parser.XmlResultParser;
+import org.apache.pdfbox.preflight.utils.FileDataSource;
 import org.apache.pdfbox.util.Version;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -149,7 +149,7 @@ public class Validator_A1b
             {
                 // generate xml output
                 XmlResultParser xrp = new XmlResultParser();
-                Element result = xrp.validate(new FileDataSource(args[posFile]));
+                Element result = xrp.validate(new FileDataSource(new File(args[posFile])));
                 Document document = result.getOwnerDocument();
                 document.appendChild(result);
                 Transformer transformer = TransformerFactory.newInstance().newTransformer();

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Fri Oct 12 16:35:44 2018
@@ -30,8 +30,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import javax.activation.DataSource;
-import javax.activation.FileDataSource;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
@@ -80,6 +78,8 @@ import static org.apache.pdfbox.prefligh
 import static org.apache.pdfbox.preflight.PreflightConstants.MAX_NEGATIVE_FLOAT;
 import static org.apache.pdfbox.preflight.PreflightConstants.MAX_POSITIVE_FLOAT;
 import static org.apache.pdfbox.preflight.PreflightConstants.MAX_STRING_LENGTH;
+import org.apache.pdfbox.preflight.utils.DataSource;
+import org.apache.pdfbox.preflight.utils.FileDataSource;
 
 public class PreflightParser extends PDFParser
 {

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/XmlResultParser.java
Fri Oct 12 16:35:44 2018
@@ -28,7 +28,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.activation.DataSource;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
@@ -36,6 +35,7 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
+import org.apache.pdfbox.preflight.utils.DataSource;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 

Added: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/DataSource.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/DataSource.java?rev=1843687&view=auto
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/DataSource.java
(added)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/DataSource.java
Fri Oct 12 16:35:44 2018
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+
+package org.apache.pdfbox.preflight.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 
+ * Reduced DataSource interface.
+ */
+public interface DataSource
+{
+    public InputStream getInputStream() throws IOException;
+
+    public String getName();
+}

Added: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/FileDataSource.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/FileDataSource.java?rev=1843687&view=auto
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/FileDataSource.java
(added)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/utils/FileDataSource.java
Fri Oct 12 16:35:44 2018
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ ****************************************************************************/
+package org.apache.pdfbox.preflight.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 
+ * Reduced FileDataSource class.
+ */
+public class FileDataSource implements DataSource
+{
+    private File file;
+
+    public FileDataSource(File file)
+    {
+        this.file = file;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException
+    {
+        return new FileInputStream(file);
+    }
+
+    @Override
+    public String getName()
+    {
+        return file.getAbsolutePath();
+    }
+}

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPDFBox3743.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPDFBox3743.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPDFBox3743.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/TestPDFBox3743.java Fri
Oct 12 16:35:44 2018
@@ -15,11 +15,12 @@
  */
 package org.apache.pdfbox.preflight;
 
+import java.io.File;
 import java.io.IOException;
-import javax.activation.DataSource;
-import javax.activation.FileDataSource;
 
 import org.apache.pdfbox.preflight.parser.PreflightParser;
+import org.apache.pdfbox.preflight.utils.DataSource;
+import org.apache.pdfbox.preflight.utils.FileDataSource;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -38,7 +39,7 @@ public class TestPDFBox3743
     @Test
     public void testPDFBox3743() throws IOException
     {
-        DataSource ds = new FileDataSource("src/test/resources/PDFBOX-3743.pdf");
+        DataSource ds = new FileDataSource(new File("src/test/resources/PDFBOX-3743.pdf"));
         PreflightParser parser = new PreflightParser(ds);
         parser.parse();
         ValidationResult result;

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java?rev=1843687&r1=1843686&r2=1843687&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java
(original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/action/pdfa1b/AbstractTestAction.java
Fri Oct 12 16:35:44 2018
@@ -21,9 +21,8 @@
 
 package org.apache.pdfbox.preflight.action.pdfa1b;
 
+import java.io.File;
 import java.util.List;
-import javax.activation.DataSource;
-import javax.activation.FileDataSource;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -35,6 +34,8 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.action.AbstractActionManager;
 import org.apache.pdfbox.preflight.action.ActionManagerFactory;
+import org.apache.pdfbox.preflight.utils.DataSource;
+import org.apache.pdfbox.preflight.utils.FileDataSource;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
@@ -49,7 +50,7 @@ public abstract class AbstractTestAction
      */
     protected PreflightContext createContext() throws Exception
     {
-        DataSource ds = new FileDataSource("src/test/resources/pdfa-with-annotations-square.pdf");
+        DataSource ds = new FileDataSource(new File("src/test/resources/pdfa-with-annotations-square.pdf"));
         PDDocument doc = PDDocument.load(ds.getInputStream());
         PreflightDocument preflightDocument = new PreflightDocument(doc.getDocument(), Format.PDF_A1B);
         PreflightContext ctx = new PreflightContext(ds);



Mime
View raw message