From cee7a05ff25d271a81b607826d50c16c769fbd99 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 15 Oct 2009 10:47:29 +0000 Subject: [PATCH] - de-serialized the pdf parser - added fail callback for file indexer git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6415 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../de/anomic/document/parser/pdfParser.java | 2 -- source/de/anomic/search/DocumentIndex.java | 20 +++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/source/de/anomic/document/parser/pdfParser.java b/source/de/anomic/document/parser/pdfParser.java index a391ab44b..bb446a4da 100644 --- a/source/de/anomic/document/parser/pdfParser.java +++ b/source/de/anomic/document/parser/pdfParser.java @@ -109,7 +109,6 @@ public class pdfParser extends AbstractParser implements Idiom { checkInterruption(); // creating a text stripper - synchronized (SUPPORTED_MIME_TYPES) { final PDFTextStripper stripper = new PDFTextStripper(); theDocument = parser.getPDDocument(); @@ -182,7 +181,6 @@ public class pdfParser extends AbstractParser implements Idiom { } return theDoc; - } } catch (final Exception e) { if (e instanceof InterruptedException) throw (InterruptedException) e; diff --git a/source/de/anomic/search/DocumentIndex.java b/source/de/anomic/search/DocumentIndex.java index c2ceaa52c..727c406e4 100644 --- a/source/de/anomic/search/DocumentIndex.java +++ b/source/de/anomic/search/DocumentIndex.java @@ -77,12 +77,20 @@ public class DocumentIndex extends Segment { class Worker extends Thread { public void run() { File f; + URIMetadataRow resultRow; try { while ((f = queue.take()) != poison) try { - add(f); - if (callback != null) callback.commitIndex(f); + resultRow = add(f); + if (callback != null) { + if (resultRow == null) { + callback.fail(f, "result is null"); + } else { + callback.commit(f, resultRow); + } + } } catch (IOException e) { if (e.getMessage().indexOf("cannot parse") < 0) e.printStackTrace(); + callback.fail(f, e.getMessage()); } } catch (InterruptedException e) {} } @@ -229,7 +237,8 @@ public class DocumentIndex extends Segment { } public interface CallbackListener { - public void commitIndex(File f); + public void commit(File f, URIMetadataRow resultRow); + public void fail(File f, String failReason); } public static void main(String[] args) { @@ -245,9 +254,12 @@ public class DocumentIndex extends Segment { File segmentPath = new File(args[0]); System.out.println("using index files at " + segmentPath.getAbsolutePath()); CallbackListener callback = new CallbackListener() { - public void commitIndex(File f) { + public void commit(File f, URIMetadataRow resultRow) { System.out.println("indexed: " + f.toString()); } + public void fail(File f, String failReason) { + System.out.println("not indexed " + f.toString() + ": " + failReason); + } }; try { if (args[1].equals("add")) {