Author: batosai
Date: 2008-08-12 16:19:05 +0000 (Tue, 12 Aug 2008)
New Revision: 21768

Modified:
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Handle trust setting through FCP.

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-12 16:08:12 UTC 
(rev 21767)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-12 16:19:05 UTC 
(rev 21768)
@@ -204,7 +204,7 @@
                                try {
                                        treeOwner = wot.getIdentityByURI(new 
FreenetURI(owner));
                                        if(treeOwner == null) return "Unknown 
URI";
-                               } catch (MalformedURLException e) {
+                               } catch (Exception e) {
                                        return e.getLocalizedMessage();
                                }       
                        }
@@ -347,11 +347,11 @@

                setTrust(       request.getPartAsString("truster", 1024),
                                        request.getPartAsString("trustee", 
1024),
-                                       
Integer.parseInt(request.getPartAsString("value", 1024)),
+                                       request.getPartAsString("value", 1024),
                                        request.getPartAsString("comment", 
1024));
        }

-       private void setTrust(String truster, String trustee, int value, String 
comment) throws Exception {
+       private void setTrust(String truster, String trustee, String value, 
String comment) throws Exception {

                Identity trusterId = wot.getIdentityByURI(new 
FreenetURI(truster));
                Identity trusteeId = wot.getIdentityByURI(new 
FreenetURI(trustee));
@@ -360,7 +360,7 @@
                if(trusterId == null) throw new Exception ("Truster doesn't 
exist");
                if(trusteeId == null) throw new Exception ("Trustee doesn't 
exist");

-               setTrust((OwnIdentity)trusterId, trusteeId, value, comment);
+               setTrust((OwnIdentity)trusterId, trusteeId, 
Integer.parseInt(value), comment);
 }      

        private void setTrust(OwnIdentity truster, Identity trustee, int value, 
String comment) throws Exception {
@@ -496,12 +496,15 @@
                return sfs;
        }

-       private SimpleFieldSet handleSetTrust(SimpleFieldSet params) {
+       private SimpleFieldSet handleSetTrust(SimpleFieldSet params) throws 
Exception {

                SimpleFieldSet sfs = new SimpleFieldSet(false);
+
+               if(params.get("truster") == null || params.get("trustee") == 
null || params.get("value") == null || params.get("comment") == null) throw new 
Exception("Missing parameter");

+               setTrust(params.get("truster"), params.get("trustee"), 
params.get("value"), params.get("comment"));

-               
+               sfs.putAppend("Message", "TrustSet");
                return sfs;
        }

@@ -509,7 +512,8 @@

                SimpleFieldSet sfs = new SimpleFieldSet(false);
                sfs.putAppend("Message", "Error");
-               sfs.putAppend("Value", e.getLocalizedMessage());
+               sfs.putAppend("Description", (e.getLocalizedMessage() == null) 
? "null" : e.getLocalizedMessage());
+               e.printStackTrace();
                return sfs;
        }
 }


Reply via email to