Skip to content

Commit

Permalink
pdfbox bump
Browse files Browse the repository at this point in the history
  • Loading branch information
GihanAyesh committed Mar 27, 2024
1 parent c26a4e9 commit 5f0c144
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions components/apimgt/org.wso2.carbon.apimgt.impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.apache.pdfbox</groupId>
<artifactId>pdfbox-io</artifactId>
</dependency>

<dependency>
<groupId>org.wso2.carbon.event-processing</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.cos.COSDocument;
import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
import org.apache.pdfbox.io.RandomAccessReadBuffer;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
Expand Down Expand Up @@ -181,9 +181,9 @@ private String fetchDocumentContent(Registry registry, Resource documentResource
inputStream = contentResource.getContentStream();
switch (extension) {
case APIConstants.PDF_EXTENSION:
PDFParser pdfParser = new PDFParser(new RandomAccessBufferedFileInputStream(inputStream));
PDFParser pdfParser = new PDFParser(new RandomAccessReadBuffer(inputStream));
pdfParser.parse();
COSDocument cosDocument = pdfParser.getDocument();
COSDocument cosDocument = pdfParser.parse().getDocument();
PDFTextStripper stripper = new PDFTextStripper();
contentString = stripper.getText(new PDDocument(cosDocument));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
import org.apache.pdfbox.io.RandomAccessReadBuffer;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.pdfbox.cos.COSDocument;
Expand All @@ -30,7 +30,7 @@ public IndexDocument getIndexedDocument(File2Index fileData) throws SolrExceptio
try {
PDFParser parser = getPdfParser(fileData);
parser.parse();
cosDoc = parser.getDocument();
cosDoc = parser.parse().getDocument();

PDFTextStripper stripper = getPdfTextStripper();
String docText = stripper.getText(new PDDocument(cosDoc));
Expand Down Expand Up @@ -70,7 +70,7 @@ protected PDFTextStripper getPdfTextStripper() throws IOException {
}

protected PDFParser getPdfParser(File2Index fileData) throws IOException {
return new PDFParser(new RandomAccessBufferedFileInputStream(new ByteArrayInputStream(fileData.data)));
return new PDFParser(new RandomAccessReadBuffer(new ByteArrayInputStream(fileData.data)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public void testShouldReturnIndexedDocumentWhenParameterCorrect() throws IOExcep
String mediaType = "application/pdf+test";
final String MEDIA_TYPE = "mediaType";
PDFParser parser = Mockito.mock(PDFParser.class);
PDDocument pdDocument = Mockito.mock(PDDocument.class);
COSDocument cosDoc = Mockito.mock(COSDocument.class);
PDFTextStripper pdfTextStripper = Mockito.mock(PDFTextStripper.class);
Mockito.doThrow(IOException.class).when(cosDoc).close();
Mockito.when(parser.getDocument()).thenReturn(new COSDocument()).thenReturn(cosDoc);
Mockito.when(parser.parse()).thenReturn(new PDDocument());

Mockito.when(pdDocument.getDocument()).thenReturn(new COSDocument()).thenReturn(cosDoc);
Mockito.when(pdfTextStripper.getText(new PDDocument())).thenReturn("");
PDFIndexer pdfIndexer = new PDFIndexerWrapper(parser, pdfTextStripper);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@
<importBundleDef>org.apache.pdfbox:pdfbox:${pdfbox.version}</importBundleDef>
<importBundleDef>org.apache.pdfbox:fontbox:${pdfbox.version}</importBundleDef>
<importBundleDef>org.apache.pdfbox:xmpbox:${pdfbox.version}</importBundleDef>
<importBundleDef>
org.wso2.orbit.org.apache.pdfbox:pdfbox-io:${pdfbox.io.version}
</importBundleDef>
<importBundleDef>
org.wso2.orbit.com.github.dblock.waffle:waffle-jna:${waffle-jna.version}
</importBundleDef>
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,12 @@
<version>${pdfbox.version}</version>
</dependency>

<dependency>
<groupId>org.wso2.orbit.org.apache.pdfbox</groupId>
<artifactId>pdfbox-io</artifactId>
<version>${pdfbox.io.version}</version>
</dependency>

<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
Expand Down Expand Up @@ -2166,8 +2172,9 @@
<cxf.version>3.6.2</cxf.version>
<carbon.metrics.version>1.3.12</carbon.metrics.version>
<!-- apache pdfbox version -->
<pdfbox.version>2.0.25</pdfbox.version>
<event.processor.version>2.3.10</event.processor.version>
<pdfbox.version>3.0.1</pdfbox.version>
<pdfbox.io.version>3.0.1.wso2v1</pdfbox.io.version>
<swagger.inflector.version>1.0.16.wso2v1</swagger.inflector.version>
<swagger.inflector.oas3.version>2.0.5.wso2v2</swagger.inflector.oas3.version>
<swagger.parser.v3.version>2.1.20.wso2v1</swagger.parser.v3.version>
Expand Down

0 comments on commit 5f0c144

Please sign in to comment.