refacto: move file quality control into a service implementing an interface
2 unresolved threads
2 unresolved threads
Merge request reports
Activity
7 import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; 8 import org.apache.pdfbox.text.PDFTextStripper; 9 import org.springframework.stereotype.Service; 10 11 import ch.unige.aou.model.publication.DocumentFile; 12 13 /** 14 * FileMetadataExtractor implementation that supports only PDF files 15 */ 16 @Service 17 public class PdfBoxMetadataExtractor implements FileMetadataExtractor { 18 19 @Override 20 public boolean isPasswordProtected(DocumentFile pdfDocumentFile) throws IOException { 21 PDDocument doc = null; 22 try { changed this line in version 3 of the diff
23 doc = PDDocument.load(new File(pdfDocumentFile.getFinalData())); 24 return false; 25 } catch (InvalidPasswordException invalidPasswordException) { 26 return true; 27 } finally { 28 if (doc != null) { 29 doc.close(); 30 } 31 } 32 } 33 34 @Override 35 public String getText(DocumentFile pdfDocumentFile) throws IOException { 36 if (!this.isPasswordProtected(pdfDocumentFile)) { 37 PDDocument doc = null; 38 try { changed this line in version 3 of the diff
added 3 commits
-
43cf55b3...702249ab - 2 commits from branch
master
- ed5de69e - refacto: move file quality control into a service implementing an interface
-
43cf55b3...702249ab - 2 commits from branch
added 1 commit
- ecc44dbf - refacto(PdfBoxMetadataExtractor): open file by using try-with-resources
Please register or sign in to reply