- 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
pull/1/head
orbiter 16 years ago
parent 9db928ce53
commit cee7a05ff2

@ -109,7 +109,6 @@ public class pdfParser extends AbstractParser implements Idiom {
checkInterruption(); checkInterruption();
// creating a text stripper // creating a text stripper
synchronized (SUPPORTED_MIME_TYPES) {
final PDFTextStripper stripper = new PDFTextStripper(); final PDFTextStripper stripper = new PDFTextStripper();
theDocument = parser.getPDDocument(); theDocument = parser.getPDDocument();
@ -183,7 +182,6 @@ public class pdfParser extends AbstractParser implements Idiom {
return theDoc; return theDoc;
} }
}
catch (final Exception e) { catch (final Exception e) {
if (e instanceof InterruptedException) throw (InterruptedException) e; if (e instanceof InterruptedException) throw (InterruptedException) e;
if (e instanceof ParserException) throw (ParserException) e; if (e instanceof ParserException) throw (ParserException) e;

@ -77,12 +77,20 @@ public class DocumentIndex extends Segment {
class Worker extends Thread { class Worker extends Thread {
public void run() { public void run() {
File f; File f;
URIMetadataRow resultRow;
try { try {
while ((f = queue.take()) != poison) try { while ((f = queue.take()) != poison) try {
add(f); resultRow = add(f);
if (callback != null) callback.commitIndex(f); if (callback != null) {
if (resultRow == null) {
callback.fail(f, "result is null");
} else {
callback.commit(f, resultRow);
}
}
} catch (IOException e) { } catch (IOException e) {
if (e.getMessage().indexOf("cannot parse") < 0) e.printStackTrace(); if (e.getMessage().indexOf("cannot parse") < 0) e.printStackTrace();
callback.fail(f, e.getMessage());
} }
} catch (InterruptedException e) {} } catch (InterruptedException e) {}
} }
@ -229,7 +237,8 @@ public class DocumentIndex extends Segment {
} }
public interface CallbackListener { 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) { public static void main(String[] args) {
@ -245,9 +254,12 @@ public class DocumentIndex extends Segment {
File segmentPath = new File(args[0]); File segmentPath = new File(args[0]);
System.out.println("using index files at " + segmentPath.getAbsolutePath()); System.out.println("using index files at " + segmentPath.getAbsolutePath());
CallbackListener callback = new CallbackListener() { CallbackListener callback = new CallbackListener() {
public void commitIndex(File f) { public void commit(File f, URIMetadataRow resultRow) {
System.out.println("indexed: " + f.toString()); System.out.println("indexed: " + f.toString());
} }
public void fail(File f, String failReason) {
System.out.println("not indexed " + f.toString() + ": " + failReason);
}
}; };
try { try {
if (args[1].equals("add")) { if (args[1].equals("add")) {

Loading…
Cancel
Save