- 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();
// 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;

@ -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")) {

Loading…
Cancel
Save