Author: batosai
Date: 2008-09-26 19:09:14 +0000 (Fri, 26 Sep 2008)
New Revision: 22851
Modified:
trunk/plugins/WoT/Identity.java
trunk/plugins/WoT/IdentityParser.java
Log:
Don't create identities we found in trustlists from people that don't have a
positive score.
Modified: trunk/plugins/WoT/Identity.java
===================================================================
--- trunk/plugins/WoT/Identity.java 2008-09-26 18:42:28 UTC (rev 22850)
+++ trunk/plugins/WoT/Identity.java 2008-09-26 19:09:14 UTC (rev 22851)
@@ -207,6 +207,22 @@
query.descend("target").constrain(this);
return query.execute();
}
+
+ /**
+ * Gets the best score this Identity has in existing trust trees.
+ *
+ * @param db A reference to the database
+ * @return the best score this Identity has
+ */
+ public int getBestScore(ObjectContainer db) {
+ int bestScore = 0;
+ ObjectSet<Score> scores = getScores(db);
+ while(scores.hasNext()) {
+ Score score = scores.next();
+ if(score.getScore() > bestScore) bestScore =
score.getScore();
+ }
+ return bestScore;
+ }
/**
* Gets {@link Trust} this Identity receives from a specified truster
Modified: trunk/plugins/WoT/IdentityParser.java
===================================================================
--- trunk/plugins/WoT/IdentityParser.java 2008-09-26 18:42:28 UTC (rev
22850)
+++ trunk/plugins/WoT/IdentityParser.java 2008-09-26 19:09:14 UTC (rev
22851)
@@ -130,13 +130,14 @@
}
catch (UnknownIdentityException e) {
- // TODO Don't create Identity
object before we succesfully fetched it !
-
- trustee = new
Identity(attrs.getValue("uri"), "Not found yet...", "false");
- db.store(trustee);
- identity.setTrust(db, trustee,
value, comment);
- fetcher.fetch(trustee);
-
+ // Create trustee only if the
truster has a positive score.
+ // This is to avoid Identity
spam when announcements will be here.
+ if(identity.getBestScore(db) >
0) {
+ trustee = new
Identity(attrs.getValue("uri"), "Not found yet...", "false");
+ db.store(trustee);
+ identity.setTrust(db,
trustee, value, comment);
+ fetcher.fetch(trustee);
+ }
}
} else
Logger.error(this, "Unknown element in
identity " + identity.getId() + ": " + elt_name);