Author: batosai
Date: 2008-08-04 20:04:32 +0000 (Mon, 04 Aug 2008)
New Revision: 21601

Removed:
   trunk/apps/WoT/README
   trunk/apps/WoT/src/plugins/WoT/FCPHandler.java
   trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
   trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
Modified:
   trunk/apps/WoT/src/plugins/WoT/Identity.java
   trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java
   trunk/apps/WoT/src/plugins/WoT/Trust.java
   trunk/apps/WoT/src/plugins/WoT/WoT.java
Log:
Refactor : We now use FreenetURIs instead of Strings.
Code cleanup : We don't use jFCPlib anymore, as a plugin has direct access to 
the node.

Deleted: trunk/apps/WoT/README
===================================================================
--- trunk/apps/WoT/README       2008-08-04 18:59:59 UTC (rev 21600)
+++ trunk/apps/WoT/README       2008-08-04 20:04:32 UTC (rev 21601)
@@ -1,34 +0,0 @@
-COPYRIGHT
-=========
-
-WoT copyright is held by Freenet Project Incorporated.  WoT is
-distributed under the GPL license. You can find it in the file called
-"gpl.txt".
-----------------
-
-WoT
-Copyright (C) 2007 Freenet Project Incorporated
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-COMPILATION
-===========
-
-You need to link to db4o.jar AND jFCPlib for this program to work.
-
-
-RUNNING
-=======
-
-For now, it only works inside of Eclipse.
\ No newline at end of file

Deleted: trunk/apps/WoT/src/plugins/WoT/FCPHandler.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/FCPHandler.java      2008-08-04 18:59:59 UTC 
(rev 21600)
+++ trunk/apps/WoT/src/plugins/WoT/FCPHandler.java      2008-08-04 20:04:32 UTC 
(rev 21601)
@@ -1,101 +0,0 @@
-package plugins.WoT;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.UnknownHostException;
-
-import net.pterodactylus.fcp.AllData;
-import net.pterodactylus.fcp.ClientGet;
-import net.pterodactylus.fcp.ClientHello;
-import net.pterodactylus.fcp.ClientPutDiskDir;
-import net.pterodactylus.fcp.FcpAdapter;
-import net.pterodactylus.fcp.FcpConnection;
-import net.pterodactylus.fcp.GenerateSSK;
-import net.pterodactylus.fcp.NodeHello;
-import net.pterodactylus.fcp.PutFailed;
-import net.pterodactylus.fcp.PutSuccessful;
-import net.pterodactylus.fcp.SSKKeypair;
-
-/**
- * This class will only exist until Bombe finishes his high-level FCP API
- * 
- * @author Julien Cornuwel (batosai at freenetproject.org)
- *
- */
-public class FCPHandler extends FcpAdapter {
-       
-       private FcpConnection fcp;
-       private SSKKeypair sskKeypair;
-       private boolean insertSuccessfull;
-       private IdentityFetcher fetcher;
-       private InputStream pis;
-       
-       public FCPHandler(String host, int port) throws UnknownHostException, 
IOException, InterruptedException {
-               
-               fcp = new FcpConnection(host,port);
-               fcp.connect();
-               fcp.addFcpListener(this);
-               synchronized (this) {
-                       fcp.sendMessage(new ClientHello("WoT"));
-                       this.wait();
-               }
-       }
-
-       public void close() {
-               
-               fcp.disconnect();
-       }
-       
-       public SSKKeypair getSSKKeypair() throws IOException, 
InterruptedException {
-               
-               synchronized (this) {
-                       fcp.sendMessage(new GenerateSSK());
-                       this.wait();
-               }
-               return sskKeypair;
-       }
-       
-       public boolean insertDir (String dir, String uri) throws IOException, 
InterruptedException {
-
-               synchronized (this) {
-                       fcp.sendMessage(new ClientPutDiskDir(uri, 
"WoTinserter", dir));
-                       this.wait();
-               }
-               
-               return insertSuccessfull;
-       }
-       
-       // This is lame, I'll find a better way to notify it later
-       public void addIdentityFetcher(IdentityFetcher id) {
-               fetcher = id;
-       }
-       
-       public void receivedNodeHello(FcpConnection fcpConnection, NodeHello 
nodeHello) {
-               synchronized (this) {
-                       notify();
-               }
-       }
-       
-       public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair 
sskKeypair) {
-               this.sskKeypair = sskKeypair;
-               synchronized (this) {
-                       notify();
-               }
-       }
-       
-       public void receivedPutSuccessful(FcpConnection fcpConnection, 
PutSuccessful putSuccessful) {
-               insertSuccessfull = true;
-               synchronized (this) {
-                       notify();
-               }
-       }
-       
-       public void receivedPutFailed(FcpConnection fcpConnection, PutFailed 
putFailed) {
-               insertSuccessfull = false;
-               synchronized (this) {
-                       notify();
-               }
-       }
-       
-
-}

Modified: trunk/apps/WoT/src/plugins/WoT/Identity.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/Identity.java        2008-08-04 18:59:59 UTC 
(rev 21600)
+++ trunk/apps/WoT/src/plugins/WoT/Identity.java        2008-08-04 20:04:32 UTC 
(rev 21601)
@@ -8,15 +8,9 @@
 import java.io.InputStream;
 import java.util.Date;

-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;

-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.xml.sax.helpers.DefaultHandler;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -25,6 +19,8 @@
 import com.db4o.ObjectSet;
 import com.db4o.query.Query;

+import freenet.keys.FreenetURI;
+
 /**
  * An identity as handled by the WoT (a SSK)
  * 
@@ -33,15 +29,10 @@
  */
 public class Identity {

-       String requestURI;
-       int edition = 0;
+       FreenetURI requestURI;
        Date lastChange;
        boolean publishTrustList;

-       public Identity() {
-               
-       }
-       
        /**
         * Create an identity with the given parameters
         * 
@@ -49,10 +40,9 @@
         * @param lastChange Last time the Identity has been updated
         * @param publishTrustList Whether the identity publishes its trustList 
or not
         */
-       public Identity (String requestURI, Date lastChange, int edition, 
boolean publishTrustList) {
+       public Identity (FreenetURI requestURI, Date lastChange, boolean 
publishTrustList) {
                this.requestURI = requestURI;
                this.lastChange = lastChange;
-               this.edition = edition;
                this.publishTrustList = publishTrustList;
        }

@@ -81,7 +71,7 @@
        }

        public String toString() {
-               return getRequestURI();
+               return getRequestURI().toString();
        }

        public Score getScore(OwnIdentity treeOwner, ObjectContainer db) {
@@ -103,18 +93,14 @@
        /**
         * @return requestURI
         */
-       public String getRequestURI() {
+       public FreenetURI getRequestURI() {
                return requestURI;
        }
-       
-       public String getFullRequestURI() {
-               return requestURI + "wot/" + edition + "/identity.xml"; 
-       }

        /**
         * @param requestURI The RequestURI of the Identity
         */
-       public void setRequestURI(String requestURI) {
+       public void setRequestURI(FreenetURI requestURI) {
                this.requestURI = requestURI;
        }

@@ -146,14 +132,6 @@
                this.publishTrustList = publishTrustList;
        }

-       public int getEdition() {
-               return edition;
-       }
-
-       public void setEdition(int edition) {
-               this.edition = edition;
-       }
-
        public class IdentityParser extends DefaultHandler {

                public void startElement(String nameSpaceURI, String localName, 
String rawName, Attributes attrs) throws SAXException {

Deleted: trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-04 18:59:59 UTC 
(rev 21600)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-04 20:04:32 UTC 
(rev 21601)
@@ -1,386 +0,0 @@
-package plugins.WoT;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-
-import net.pterodactylus.fcp.AllData;
-import net.pterodactylus.fcp.ClientGet;
-import net.pterodactylus.fcp.CloseConnectionDuplicateClientName;
-import net.pterodactylus.fcp.ConfigData;
-import net.pterodactylus.fcp.DataFound;
-import net.pterodactylus.fcp.EndListPeerNotes;
-import net.pterodactylus.fcp.EndListPeers;
-import net.pterodactylus.fcp.EndListPersistentRequests;
-import net.pterodactylus.fcp.FCPPluginReply;
-import net.pterodactylus.fcp.FcpConnection;
-import net.pterodactylus.fcp.FcpListener;
-import net.pterodactylus.fcp.FcpMessage;
-import net.pterodactylus.fcp.FinishedCompression;
-import net.pterodactylus.fcp.GetFailed;
-import net.pterodactylus.fcp.IdentifierCollision;
-import net.pterodactylus.fcp.NodeData;
-import net.pterodactylus.fcp.NodeHello;
-import net.pterodactylus.fcp.Peer;
-import net.pterodactylus.fcp.PeerNote;
-import net.pterodactylus.fcp.PeerRemoved;
-import net.pterodactylus.fcp.PersistentGet;
-import net.pterodactylus.fcp.PersistentPut;
-import net.pterodactylus.fcp.PersistentPutDir;
-import net.pterodactylus.fcp.PersistentRequestModified;
-import net.pterodactylus.fcp.PersistentRequestRemoved;
-import net.pterodactylus.fcp.PluginInfo;
-import net.pterodactylus.fcp.ProtocolError;
-import net.pterodactylus.fcp.PutFailed;
-import net.pterodactylus.fcp.PutFetchable;
-import net.pterodactylus.fcp.PutSuccessful;
-import net.pterodactylus.fcp.SSKKeypair;
-import net.pterodactylus.fcp.SimpleProgress;
-import net.pterodactylus.fcp.StartedCompression;
-import net.pterodactylus.fcp.SubscribedUSKUpdate;
-import net.pterodactylus.fcp.TestDDAComplete;
-import net.pterodactylus.fcp.TestDDAReply;
-import net.pterodactylus.fcp.URIGenerated;
-import net.pterodactylus.fcp.UnknownNodeIdentifier;
-import net.pterodactylus.fcp.UnknownPeerNoteType;
-
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
-import com.db4o.query.Predicate;
-
-/**
- * @author Julien Cornuwel (batosai at freenetproject.org)
- *
- */
-public class IdentityFetcher implements FcpListener{
-
-       private ObjectContainer db;
-       private FcpConnection fcp;
-       
-       private boolean fileFetched;
-       private String identifier = "WoTfetcher"; 
-       File tempfile = new File("tempfile");
-       
-       /**
-        * Creates the IdentityInserter
-        * 
-        * @param db Connection to the database
-        */
-       public IdentityFetcher(ObjectContainer db, FcpConnection fcp) {
-               this.db = db;
-               this.fcp = fcp;
-               
-               fcp.addFcpListener(this);
-       }
-       
-       public void fetch(Identity identity) throws Exception {
-               synchronized (this) {
-                       fcp.sendMessage(new 
ClientGet(identity.getFullRequestURI(), identifier));
-                       this.wait();
-               }
-               if(fileFetched) {
-                       identity.fromXML(new FileInputStream(tempfile));
-                       tempfile.delete();
-               }
-       }
-       
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedNodeHello(FcpConnection fcpConnection, NodeHello 
nodeHello) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedCloseConnectionDuplicateClientName(FcpConnection 
fcpConnection, CloseConnectionDuplicateClientName 
closeConnectionDuplicateClientName) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair 
sskKeypair) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPeer(FcpConnection fcpConnection, Peer peer) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedEndListPeers(FcpConnection fcpConnection, 
EndListPeers endListPeers) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPeerNote(FcpConnection fcpConnection, PeerNote 
peerNote) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedEndListPeerNotes(FcpConnection fcpConnection, 
EndListPeerNotes endListPeerNotes) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPeerRemoved(FcpConnection fcpConnection, 
PeerRemoved peerRemoved) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        * 
-        * @see FcpListener#receivedNodeData(FcpConnection, NodeData)
-        */
-       public void receivedNodeData(FcpConnection fcpConnection, NodeData 
nodeData) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        * 
-        * @see FcpListener#receivedTestDDAReply(FcpConnection, TestDDAReply)
-        */
-       public void receivedTestDDAReply(FcpConnection fcpConnection, 
TestDDAReply testDDAReply) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedTestDDAComplete(FcpConnection fcpConnection, 
TestDDAComplete testDDAComplete) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPersistentGet(FcpConnection fcpConnection, 
PersistentGet persistentGet) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPersistentPut(FcpConnection fcpConnection, 
PersistentPut persistentPut) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedEndListPersistentRequests(FcpConnection 
fcpConnection, EndListPersistentRequests endListPersistentRequests) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedURIGenerated(FcpConnection fcpConnection, 
URIGenerated uriGenerated) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedDataFound(FcpConnection fcpConnection, DataFound 
dataFound) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedAllData(FcpConnection fcpConnection, AllData 
allData) {
-               
-               if(allData.getIdentifier().equals(identifier)) {
-                       
-                       // Ugly workaround, as the InputStream only lives as 
long as the request.
-                       // TODO Clean this when the high-level API comes out !
-                       try {
-                           final int bufferSize = 1000;
-                           FileOutputStream fout = new 
FileOutputStream(tempfile);
-                           byte[] buffer = new byte[bufferSize];
-                           int readCount = 0;
-                           while ((readCount = 
allData.getPayloadInputStream().read(buffer)) != -1) { 
-                             if (readCount < bufferSize) {
-                               fout.write(buffer, 0, readCount);
-                             } else {
-                               fout.write(buffer);
-                             }
-                           }
-                       }
-                       catch (Exception e) {
-                               e.printStackTrace();
-                       }
-                   fileFetched = true;
-               }
-               
-               synchronized (this) {
-                       notify();
-               }
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedSimpleProgress(FcpConnection fcpConnection, 
SimpleProgress simpleProgress) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedStartedCompression(FcpConnection fcpConnection, 
StartedCompression startedCompression) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receviedFinishedCompression(FcpConnection fcpConnection, 
FinishedCompression finishedCompression) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, 
UnknownPeerNoteType unknownPeerNoteType) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, 
UnknownNodeIdentifier unknownNodeIdentifier) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedConfigData(FcpConnection fcpConnection, ConfigData 
configData) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedGetFailed(FcpConnection fcpConnection, GetFailed 
getFailed) {
-               if(getFailed.getIdentifier().equals(identifier)) {
-                       fileFetched = false;
-                       synchronized (this) {
-                               notify();
-                       }
-               }
-               // TODO Re-launch the request if getFailed contains a 
RedirectURI. That means we missed an edition but the data is available.
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPutFailed(FcpConnection fcpConnection, PutFailed 
putFailed) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedIdentifierCollision(FcpConnection fcpConnection, 
IdentifierCollision identifierCollision) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPersistentPutDir(FcpConnection fcpConnection, 
PersistentPutDir persistentPutDir) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPersistentRequestRemoved(FcpConnection 
fcpConnection, PersistentRequestRemoved persistentRequestRemoved) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, 
SubscribedUSKUpdate subscribedUSKUpdate) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo 
pluginInfo) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedFCPPluginReply(FcpConnection fcpConnection, 
FCPPluginReply fcpPluginReply) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPersistentRequestModified(FcpConnection 
fcpConnection, PersistentRequestModified persistentRequestModified) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPutSuccessful(FcpConnection fcpConnection, 
PutSuccessful putSuccessful) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedPutFetchable(FcpConnection fcpConnection, 
PutFetchable putFetchable) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedProtocolError(FcpConnection fcpConnection, 
ProtocolError protocolError) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void receivedMessage(FcpConnection fcpConnection, FcpMessage 
fcpMessage) {
-               /* empty. */
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       public void connectionClosed(FcpConnection fcpConnection, Throwable 
throwable) {
-               /* empty. */
-       }
-
-}

Deleted: trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java        2008-08-04 
18:59:59 UTC (rev 21600)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java        2008-08-04 
20:04:32 UTC (rev 21601)
@@ -1,108 +0,0 @@
-/**
- * This code is part of WoT, a plugin for Freenet. It is distributed 
- * under the GNU General Public License, version 2 (or at your option
- * any later version). See http://www.gnu.org/ for details of the GPL.
- */
-package plugins.WoT;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import com.db4o.ObjectContainer;
-import com.db4o.query.Predicate;
-
-/**
- * @author Julien Cornuwel (batosai at freenetproject.org)
- *
- * Inserts updated identities.
- */
-public class IdentityInserter implements Runnable{
-       
-       private ObjectContainer db;
-       private FCPHandler fcp;
-       private Thread inserter;
-       
-       /**
-        * Creates the IdentityInserter
-        * 
-        * @param db Connection to the database
-        */
-       public IdentityInserter(ObjectContainer db, FCPHandler fcp) {
-               this.db = db;
-               this.fcp = fcp;
-       }
-       
-       /**
-        * Periodically checks what identities have been updated and inserts 
them
-        */
-       public void run() {
-               
-               while(Thread.currentThread() == inserter) {
-                       
-                       try {
-                               Thread.sleep(1000);
-                       }
-                       catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-                       
-                       List<OwnIdentity> identitiesToInsert = db.query(new 
Predicate<OwnIdentity> () {
-                               public boolean match (OwnIdentity identity) {
-                                       return (identity.needsInsert());
-                               }
-                       });
-                       
-                       Iterator<OwnIdentity> it = 
identitiesToInsert.iterator();
-                       
-                       while(it.hasNext()) {
-                               OwnIdentity identityToInsert = it.next();
-                               insert(db, fcp, identityToInsert);              
        
-                       }
-               }
-       }
-       
-       /**
-        * Creates a new Thread and launch the IdentityInserter
-        */
-       public void start() {
-               if (inserter == null) {
-                       inserter = new Thread(this);
-                       inserter.start();
-               }
-       }
-       
-       /**
-        * Cleanly stops the IdentityInserter thread
-        */
-       public void stop() {
-               inserter = null;
-       }
-
-       public void insert(ObjectContainer db, FCPHandler fcp, OwnIdentity 
identity) {
-               
-               /* We set the date now, so that if changes are made between now 
and the actual insert, 
-                * we are going for another insert.
-                */
-               identity.setLastInsert(new Date());
-               
-               try {
-                       File exportDir = new File("exportWOT");
-                       identity.exportToXML(db, exportDir);
-                       
-                       while(!fcp.insertDir(exportDir.getCanonicalPath(), 
identity.getFullInsertURI())) {
-                               // We just keep trying until the insert succeeds
-                       }
-               }
-               catch (Exception e) {
-                       // TODO Find a way to warn the user of the problem. As 
we are implementing Runnable, we can't throw anything from here :/
-                       e.printStackTrace();
-                       stop();
-               }
-               
-               identity.setEdition(identity.getEdition() + 1);
-               db.store(identity);
-       
-       }
-}

Modified: trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java     2008-08-04 18:59:59 UTC 
(rev 21600)
+++ trunk/apps/WoT/src/plugins/WoT/OwnIdentity.java     2008-08-04 20:04:32 UTC 
(rev 21601)
@@ -23,14 +23,14 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;

-import net.pterodactylus.fcp.SSKKeypair;
-
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;

 import com.db4o.ObjectContainer;

+import freenet.keys.FreenetURI;
+
 /**
  * A local Identity (it belongs to the user)
  * 
@@ -39,7 +39,7 @@
  */
 public class OwnIdentity extends Identity {

-       private String insertURI;
+       private FreenetURI insertURI;
        private Date lastInsert;


@@ -52,34 +52,15 @@
         * @param lastChange Last time the identity (or its trustList) has been 
updated
         * @param publishTrustList Whether the Identity publishes its trustList 
or not
         */
-       public OwnIdentity(String insertURI, String requestURI, Date 
lastInsert, Date lastChange, int edition, boolean publishTrustList) {
+       public OwnIdentity(FreenetURI insertURI, FreenetURI requestURI, Date 
lastInsert, Date lastChange, boolean publishTrustList) {

-               super(requestURI, lastChange, edition, publishTrustList);
+               super(requestURI, lastChange, publishTrustList);
                this.insertURI = insertURI;
                this.lastInsert = lastInsert;

        }

        /**
-        * Creates a new local identity from scratch (generates a new SSK 
Keypair)
-        * 
-        * @param fcp Connection to the Freenet node
-        * @throws IOException
-        * @throws InterruptedException
-        */
-       public OwnIdentity(FCPHandler fcp) throws 
IOException,InterruptedException {
-               
-               lastInsert = new Date(0);
-               lastChange = new Date();
-               publishTrustList = true;
-               
-               SSKKeypair ssk = fcp.getSSKKeypair();
-               requestURI = ssk.getRequestURI();
-               insertURI = ssk.getInsertURI();
-
-       }
-       
-       /**
         * Generates a XML file describing the identity
         * 
         * @param db Connection to the database
@@ -140,23 +121,14 @@
        /**
         * @return insertURI
         */
-       public String getInsertURI() {
+       public FreenetURI getInsertURI() {
                return insertURI;
        }
-
-       /**
-        * Returns the full insert URI (with edition number and path)
-        */
-       public String getFullInsertURI() {
-               return getInsertURI() + "wot-" + edition;
-               //return getInsertURI() + "wot-" + edition + "/identity.xml";
-       }

-       
        /**
         * @param insertURI InsertURI of the Identity
         */
-       public void setInsertURI(String insertURI) {
+       public void setInsertURI(FreenetURI insertURI) {
                this.insertURI = insertURI;
        }


Modified: trunk/apps/WoT/src/plugins/WoT/Trust.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/Trust.java   2008-08-04 18:59:59 UTC (rev 
21600)
+++ trunk/apps/WoT/src/plugins/WoT/Trust.java   2008-08-04 20:04:32 UTC (rev 
21601)
@@ -55,8 +55,7 @@
                Element elem = xmlDoc.createElement("trust");
                elem.setAttribute("value", String.valueOf(value));
                elem.setAttribute("comment", comment);
-               elem.setAttribute("uri", trustee.getRequestURI());
-               elem.setAttribute("edition", 
String.valueOf(trustee.getEdition()));
+               elem.setAttribute("uri", trustee.getRequestURI().toString());

                return elem;
        }

Modified: trunk/apps/WoT/src/plugins/WoT/WoT.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoT.java     2008-08-04 18:59:59 UTC (rev 
21600)
+++ trunk/apps/WoT/src/plugins/WoT/WoT.java     2008-08-04 20:04:32 UTC (rev 
21601)
@@ -5,11 +5,6 @@
  */
 package plugins.WoT;

-import java.util.Date;
-
-import net.pterodactylus.fcp.FcpConnection;
-
-import com.db4o.Db4o;
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectSet;

@@ -139,74 +134,5 @@
                        }
                }
        }
-       
-       public void stressTest(int nbIdentities, int nbTrustPerIdentity) {
-               
-               ObjectSet<Identity> search;
-               
-               for(int i = 1 ; i != nbIdentities ; i++) {
-                       Identity id = new Identity(String.valueOf(i), new 
Date(), 0, true);
-                       db.store(id);
-               }
-               
-               for(int i = 0 ; i != nbIdentities ; i++) {
-                       for(int j = 0 ; j != nbTrustPerIdentity ; j++) {
-                               search = db.queryByExample(new 
Identity(String.valueOf(i), null, 0, true));
-                               Identity truster = search.next();
-                               
-                               double trusteeId = Math.random() * nbIdentities;
-                               double value =  Math.random() * 100;
-                               
-                               search = db.queryByExample(new 
Identity(String.valueOf((int) trusteeId), null, 0, true));
-                               Identity trustee = search.next();
-                               
-                               setTrust(new Trust(truster, trustee, (int) 
value)); 
-                       }
-                       System.out.println(i);
-               }
-       }
-       
-       /**
-        * This code will have to move in the plugin methods.
-        */
-       public static void main(String[] args) {
-
-               IdentityInserter identityInserter;
-               FcpConnection fcp;
-               ObjectContainer db;
-               
-               try {
-                       db = Db4o.openFile("WoT.db4o");
-
-                       //Empty the database
-                       ObjectSet<Object> result = db.queryByExample(new 
Object());
-                       while (result.hasNext()) { db.delete(result.next()); }
-
-                       OwnIdentity root = new OwnIdentity("0", "0", new 
Date(), new Date(), 0, true);
-                       Score initScore = new Score(root,root,100,0,100);
-                       db.store(root);
-                       db.store(initScore);
-
-                       WoT wot = new WoT(db);
-                       
-                       wot.stressTest(100, 5);
-                       
-                       System.out.println("\n***** Trust objects in the 
database :");
-                       ObjectSet<Trust> trustList = 
db.queryByExample(Trust.class);
-                       System.out.println(trustList.size());
-                       
-                       System.out.println("\n***** Score objects in the 
database :");
-                       ObjectSet<Score> scoreList = 
db.queryByExample(Score.class);
-                       while(scoreList.hasNext()) {
-                               System.out.println(scoreList.next());
-                       }
-
-                       db.close();
-               }
-               catch (Exception e) {
-                       // We catch everything here as there is not yet an 
interface to warn the user of the problems 
-                       e.printStackTrace();
-               }
-       }
 }



Reply via email to