knguyen 2004/10/25 18:30:42 CEST
Modified files: (Branch: JAHIA-4-0-BRANCH)
src/java/org/jahia/utils/fileparsers PDFExtractor.java
Log:
fixe for JAHIA-179, avoid extracting again the content of a pdf file, if it has not
changed. Extracted content is serialized in tmp file and deserialized if needed.
Revision Changes Path
1.3.2.5 +1 -53 jahia/src/java/org/jahia/utils/fileparsers/PDFExtractor.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/utils/fileparsers/PDFExtractor.java.diff?r1=1.3.2.4&r2=1.3.2.5&f=h
Index: PDFExtractor.java
===================================================================
RCS file:
/home/cvs/repository/jahia/src/java/org/jahia/utils/fileparsers/Attic/PDFExtractor.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -r1.3.2.4 -r1.3.2.5
--- PDFExtractor.java 25 Oct 2004 16:22:52 -0000 1.3.2.4
+++ PDFExtractor.java 25 Oct 2004 16:30:42 -0000 1.3.2.5
@@ -24,11 +24,6 @@
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger (PDFExtractor.class);
- /**
- * Temp file directory.
- */
- private File tempDirectory = new File( System.getProperty( "java.io.tmpdir" ) );
-
public PDFExtractor(){
}
@@ -60,29 +55,7 @@
String charSet) throws Exception {
String strVal = null;
- // try to load previously extracted data if the file has not changed
-
- String formattedPath = JahiaTools.replacePattern(path,"/","\\");
- formattedPath = JahiaTools.replacePattern(formattedPath,"\\","_");
-
- String tmpFilePath = tempDirectory.getAbsolutePath()
- + File.separator + "jahia_pdf_tmpfile_" + lastModified + "_" +
formattedPath;
-
- try {
- // Deserialize from a file
- File file = new File(tmpFilePath);
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
- // Deserialize the object
- strVal = (String) in.readObject();
- in.close();
- logger.info("Use previous extracted pdf tmp file " + tmpFilePath);
- } catch (ClassNotFoundException e) {
- logger.debug(e);
- } catch (IOException e) {
- //logger.debug(e); file could not exist and it's not an error
- }
-
- if (strVal == null && fileStream != null) {
+ if (fileStream != null) {
Reader pdfReader = null;
try {
long startTime = System.currentTimeMillis();
@@ -97,31 +70,6 @@
elapsedTime = System.currentTimeMillis() - startTime;
logger.info("Finished reading pdf Reader to String in " +
elapsedTime + "ms.");
- if ( strVal != null ){
- try {
- // before creating a new tmp file, deleted old version if
any
- File[] files = tempDirectory.listFiles();
- int size = files.length;
- File f = null;
- for (int i = 0; i < size; i++) {
- f = (File) files[i];
- if (f.getName().endsWith(formattedPath)) {
- f.delete();
- }
- }
- }catch (Throwable t ){
- }
-
- try {
- // Serialize to a file
- ObjectOutput out = new ObjectOutputStream(new
- FileOutputStream(tmpFilePath));
- out.writeObject(strVal);
- out.close();
- }
- catch (IOException e) {
- }
- }
}
catch (Throwable t) {
logger.debug(t);