Author: batosai
Date: 2008-08-11 02:00:21 +0000 (Mon, 11 Aug 2008)
New Revision: 21733
Modified:
trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
trunk/apps/WoT/src/plugins/WoT/IdentityParser.java
Log:
Fetch identities discovered when parsing an XML file.
Modified: trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-11 01:34:29 UTC
(rev 21732)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-11 02:00:21 UTC
(rev 21733)
@@ -31,19 +31,11 @@
private WoT wot;
private HighLevelSimpleClient client;
- private IdentityParser parser;
-
public IdentityFetcher(ObjectContainer db, WoT wot,
HighLevelSimpleClient client) {
this.db = db;
this.wot = wot;
this.client = client;
-
- try {
- parser = new IdentityParser(db, wot);
- } catch (Exception e) {
- e.printStackTrace();
- }
}
public void fetch(Identity identity) throws FetchException {
@@ -88,10 +80,11 @@
System.out.println("Error, identity not found");
return;
}
-
+
+ // Parse it
try {
+ IdentityParser parser = new IdentityParser(db, wot,
this);
parser.parse(result.asBucket().getInputStream(),
identity);
-
} catch (Exception e) {
e.printStackTrace();
}
Modified: trunk/apps/WoT/src/plugins/WoT/IdentityParser.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityParser.java 2008-08-11 01:34:29 UTC
(rev 21732)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityParser.java 2008-08-11 02:00:21 UTC
(rev 21733)
@@ -21,6 +21,7 @@
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
+import freenet.client.FetchException;
import freenet.keys.FreenetURI;
/**
@@ -31,13 +32,15 @@
ObjectContainer db;
WoT wot;
+ IdentityFetcher fetcher;
SAXParser saxParser;
Identity identity;
- public IdentityParser(ObjectContainer db, WoT wot) throws
ParserConfigurationException, SAXException {
+ public IdentityParser(ObjectContainer db, WoT wot, IdentityFetcher
fetcher) throws ParserConfigurationException, SAXException {
this.db = db;
this.wot = wot;
+ this.fetcher = fetcher;
SAXParserFactory factory = SAXParserFactory.newInstance();
saxParser = factory.newSAXParser();
}
@@ -77,6 +80,7 @@
if (trustee == null) {
trustee = new Identity(new
FreenetURI(attrs.getValue("uri")), new Date(0));
db.store(trustee);
+ fetcher.fetch(trustee);
}
int value =
Integer.parseInt(attrs.getValue("value"));
String comment =
attrs.getValue("comment");
@@ -84,6 +88,8 @@
wot.setTrust(new Trust(identity,
trustee, value, comment));
} catch (MalformedURLException e) {
System.out.println(e.getLocalizedMessage());
+ } catch (FetchException e) {
+
System.out.println(e.getLocalizedMessage());
}
}
}