Author: batosai Date: 2008-08-14 17:26:47 +0000 (Thu, 14 Aug 2008) New Revision: 21852
Added: trunk/apps/WoT/src/plugins/WoT/WebInterface.java Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java Log: Moved web interface code in a dedicated class. Added: trunk/apps/WoT/src/plugins/WoT/WebInterface.java =================================================================== --- trunk/apps/WoT/src/plugins/WoT/WebInterface.java (rev 0) +++ trunk/apps/WoT/src/plugins/WoT/WebInterface.java 2008-08-14 17:26:47 UTC (rev 21852) @@ -0,0 +1,271 @@ +/** + * 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.util.Date; + +import com.db4o.ObjectContainer; +import com.db4o.ObjectSet; +import com.db4o.ext.DatabaseClosedException; +import com.db4o.ext.Db4oIOException; + +import freenet.client.HighLevelSimpleClient; +import freenet.clients.http.PageMaker; +import freenet.config.Config; +import freenet.config.SubConfig; +import freenet.keys.FreenetURI; +import freenet.pluginmanager.PluginRespirator; +import freenet.support.HTMLNode; +import freenet.support.api.HTTPRequest; + +/** + * @author Julien Cornuwel (batosai at freenetproject.org) + * + */ +public class WebInterface { + + private PluginRespirator pr; + private PageMaker pm; + private HighLevelSimpleClient client; + private String SELF_URI; + private WoT wot; + private ObjectContainer db; + + public WebInterface(PluginRespirator pr, ObjectContainer db, HighLevelSimpleClient client, String uri, WoT wot) { + this.pr = pr; + this.client = client; + this.SELF_URI = uri; + this.wot = wot; + this.db = db; + + Config nc = pr.getNode().config; + SubConfig fc = nc.get("fproxy"); + String cssName = fc.getString("css"); + + pm = new PageMaker(cssName); + pm.addNavigationLink(SELF_URI, "Home", "Home page", false, null); + pm.addNavigationLink(SELF_URI + "/ownidentities", "Own Identities", "Manage your own identities", false, null); + pm.addNavigationLink(SELF_URI + "/knownidentities", "Known Identities", "Manage others identities", false, null); + pm.addNavigationLink("/plugins/", "Plugins page", "Back to Phlugins page", false, null); + } + + public String makeHomePage() { + + HTMLNode list = new HTMLNode("ul"); + + list.addChild(new HTMLNode("li", "Own Identities : " + wot.getNbOwnIdentities())); + list.addChild(new HTMLNode("li", "Known Identities : " + wot.getNbIdentities())); + + HTMLNode pageNode = getPageNode(); + HTMLNode contentNode = pm.getContentNode(pageNode); + HTMLNode box = pm.getInfobox("Summary"); + + HTMLNode boxContent = pm.getContentNode(box); + boxContent.addChild(list); + + contentNode.addChild(box); + return pageNode.generate(); + } + + public String makeOwnIdentitiesPage() { + + HTMLNode pageNode = getPageNode(); + HTMLNode contentNode = pm.getContentNode(pageNode); + HTMLNode box = pm.getInfobox("Own Identities"); + HTMLNode boxContent = pm.getContentNode(box); + + ObjectSet<OwnIdentity> ownIdentities = db.queryByExample(OwnIdentity.class); + if(ownIdentities.size() == 0) { + boxContent.addChild("p", "You have no own identity yet, you should create one..."); + } + else { + + HTMLNode identitiesTable = boxContent.addChild("table", "border", "0"); + HTMLNode row=identitiesTable.addChild("tr"); + row.addChild("th", "Name"); + row.addChild("th", "Last change"); + row.addChild("th", "Last insert"); + row.addChild("th", "Publish TrustList ?"); + + while(ownIdentities.hasNext()) { + OwnIdentity id = ownIdentities.next(); + row=identitiesTable.addChild("tr"); + row.addChild("td", new String[] {"title", "style"}, new String[] {id.getRequestURI().toString(), "cursor: help;"}, id.getNickName()); + row.addChild("td",id.getLastChange().toString()); + HTMLNode cell = row.addChild("td"); + if(id.getLastInsert().equals(new Date(0))) { + cell.addChild("p", "Never"); + } + else { + cell.addChild(new HTMLNode("a", "href", "/"+id.getRequestURI().toString(), id.getLastInsert().toString())); + } + row.addChild("td", id.doesPublishTrustList() ? "Yes" : "No"); + } + } + + HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + "/createIdentity", "createForm"); + createForm.addChild("span", new String[] {"title", "style"}, new String[] { "No spaces or special characters.", "border-bottom: 1px dotted; cursor: help;"} , "NickName : "); + createForm.addChild("input", new String[] {"type", "name", "size"}, new String[] {"text", "nickName", "30"}); + createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "create", "Create a new identity !" }); + System.out.println("6"); + + contentNode.addChild(box); + return pageNode.generate(); + } + + public String makeKnownIdentitiesPage() throws Db4oIOException, DatabaseClosedException, InvalidParameterException, NotInTrustTreeException { + return makeKnownIdentitiesPage(""); + } + + public String makeKnownIdentitiesPage(HTTPRequest request) throws Db4oIOException, DatabaseClosedException, InvalidParameterException, NotInTrustTreeException { + return makeKnownIdentitiesPage(request.getPartAsString("ownerURI", 1024)); + } + + public String makeKnownIdentitiesPage(String owner) throws Db4oIOException, DatabaseClosedException, InvalidParameterException, NotInTrustTreeException { + + Identity treeOwner = null; + + HTMLNode pageNode = getPageNode(); + HTMLNode contentNode = pm.getContentNode(pageNode); + + // Add an identity form + HTMLNode addBox = pm.getInfobox("Add an identity"); + HTMLNode addBoxContent = pm.getContentNode(addBox); + + HTMLNode createForm = pr.addFormChild(addBoxContent, SELF_URI + "/addIdentity", "addForm"); + createForm.addChild("span", new String[] {"title", "style"}, new String[] { "This must be a valid Freenet URI.", "border-bottom: 1px dotted; cursor: help;"} , "Identity URI : "); + createForm.addChild("input", new String[] {"type", "name", "size"}, new String[] {"text", "identityURI", "70"}); + createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add this identity !" }); + + + // Known identities list + HTMLNode listBox = pm.getInfobox("Known Identities"); + HTMLNode listBoxContent = pm.getContentNode(listBox); + + int nbOwnIdentities = wot.getNbOwnIdentities(); + + if (nbOwnIdentities == 0) { + listBoxContent.addChild("p", "You should create an identity first..."); + contentNode.addChild(listBox); + return pageNode.generate(); + } + else if (nbOwnIdentities == 1) { + treeOwner = (OwnIdentity) db.queryByExample(OwnIdentity.class).next(); + } + else { + // Get the identity the user asked for, or the first one if he didn't + if(owner.equals("")) { + treeOwner = (OwnIdentity) db.queryByExample(OwnIdentity.class).next(); + } + else { + try { + treeOwner = wot.getIdentityByURI(owner); + } catch (Exception e) { + return e.getMessage(); + } + } + + // Display a form to select the tree owner + HTMLNode selectForm = pr.addFormChild(listBoxContent, SELF_URI + "/viewTree", "selectForm"); + HTMLNode selectBox = selectForm.addChild("select", "name", "ownerURI"); + + ObjectSet<OwnIdentity> ownIdentities = db.queryByExample(OwnIdentity.class); + while(ownIdentities.hasNext()) { + OwnIdentity ownIdentity = ownIdentities.next(); + if(ownIdentity == treeOwner) { + selectBox.addChild("option", new String [] {"value", "selected"}, new String [] {ownIdentity.getRequestURI().toString(), "selected"}, ownIdentity.getProp("nickName")); + } + else { + selectBox.addChild("option", "value", ownIdentity.getRequestURI().toString(), ownIdentity.getProp("nickName")); + } + } + selectForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "select", "View this identity's Web of Trust" }); + } + + // Display the list of known identities + HTMLNode identitiesTable = listBoxContent.addChild("table", "border", "0"); + HTMLNode row=identitiesTable.addChild("tr"); + row.addChild("th", "NickName"); + row.addChild("th", "Last update"); + row.addChild("th", "Publish TrustList ?"); + row.addChild("th", "Score (Rank)"); + row.addChild("th", "Trust/Comment"); + + ObjectSet<Identity> identities = db.queryByExample(Identity.class); + while(identities.hasNext()) { + Identity id = identities.next(); + + if(id == treeOwner) continue; + + row=identitiesTable.addChild("tr"); + + // NickName + row.addChild("td", new String[] {"title", "style"}, new String[] {id.getRequestURI().toString(), "cursor: help;"}, id.getNickName()); + + // Last Change + if (id.getLastChange().equals(new Date(0))) row.addChild("td", "Fetching..."); + else row.addChild("td", id.getLastChange().toString()); + + // Publish TrustList + row.addChild("td", id.doesPublishTrustList() ? "Yes" : "No"); + + //Score + row.addChild("td", String.valueOf(id.getScore((OwnIdentity)treeOwner, db).getScore())+" ("+id.getScore((OwnIdentity)treeOwner, db).getRank()+")"); + + // Trust + String trustValue = ""; + String trustComment = ""; + ObjectSet<Trust> trusts = db.queryByExample(new Trust(treeOwner, id, 0, null)); + if(trusts.hasNext()) { + Trust trust = trusts.next(); + trustValue = String.valueOf(trust.getValue()); + trustComment = trust.getComment(); + } + + HTMLNode cell = row.addChild("td"); + HTMLNode trustForm = pr.addFormChild(cell, SELF_URI + "/setTrust", "setTrustForm"); + trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "truster", treeOwner.getRequestURI().toString() }); + trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "trustee", id.getRequestURI().toString() }); + trustForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "value", "2", trustValue }); + trustForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "comment", "20", trustComment }); + trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "update", "Update !" }); + } + contentNode.addChild(addBox); + contentNode.addChild(listBox); + return pageNode.generate(); + } + + public String makeCreateIdentityPage(HTTPRequest request) { + + String nickName = request.getPartAsString("nickName",1024); + HTMLNode pageNode = getPageNode(); + HTMLNode contentNode = pm.getContentNode(pageNode); + HTMLNode box = pm.getInfobox("Identity creation"); + HTMLNode boxContent = pm.getContentNode(box); + + FreenetURI[] keypair = client.generateKeyPair("WoT"); + + HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + "/createIdentity2", "createForm"); + createForm.addChild("#", "Request URI : "); + createForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "requestURI", "70", keypair[1].toString() }); + createForm.addChild("br"); + createForm.addChild("#", "Insert URI : "); + createForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "insertURI", "70", keypair[0].toString() }); + createForm.addChild("br"); + createForm.addChild("#", "Publish trust list "); + createForm.addChild("input", new String[] { "type", "name", "value", "checked" }, new String[] { "checkbox", "publishTrustList", "true", "checked"}); + createForm.addChild("br"); + createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "nickName", nickName }); + createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "create", "Create a new identity !" }); + + contentNode.addChild(box); + return pageNode.generate(); + } + + private HTMLNode getPageNode() { + return pm.getPageNode("Web of Trust", null); + } +} Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java =================================================================== --- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-14 17:20:20 UTC (rev 21851) +++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java 2008-08-14 17:26:47 UTC (rev 21852) @@ -24,9 +24,6 @@ import freenet.client.FetchException; import freenet.client.HighLevelSimpleClient; import freenet.client.InsertException; -import freenet.clients.http.PageMaker; -import freenet.config.Config; -import freenet.config.SubConfig; import freenet.keys.FreenetURI; import freenet.pluginmanager.FredPlugin; import freenet.pluginmanager.FredPluginFCP; @@ -36,7 +33,6 @@ import freenet.pluginmanager.PluginHTTPException; import freenet.pluginmanager.PluginReplySender; import freenet.pluginmanager.PluginRespirator; -import freenet.support.HTMLNode; import freenet.support.Logger; import freenet.support.SimpleFieldSet; import freenet.support.api.Bucket; @@ -47,16 +43,14 @@ */ public class WoTplugin implements FredPlugin, FredPluginHTTP, FredPluginThreadless, FredPluginFCP, FredPluginVersioned { - public static String SELF_URI = "/plugins/plugins.WoT.WoTplugin"; private PluginRespirator pr; - private PageMaker pm; private HighLevelSimpleClient client; private ObjectContainer db; private WoT wot; + private WebInterface web; - //private IdentityInserter inserter; - private IdentityFetcher fetcher; + public static String SELF_URI = "/plugins/plugins.WoT.WoTplugin"; public void runPlugin(PluginRespirator pr) { @@ -66,19 +60,8 @@ db = Db4o.openFile("WoT.db4o"); wot = new WoT(db); client = pr.getHLSimpleClient(); - - fetcher = new IdentityFetcher(db, wot, client); - - Config nc = pr.getNode().config; - SubConfig fc = nc.get("fproxy"); - String cssName = fc.getString("css"); - pm = new PageMaker(cssName); - - pm.addNavigationLink(SELF_URI, "Home", "Home page", false, null); - pm.addNavigationLink(SELF_URI + "/ownidentities", "Own Identities", "Manage your own identities", false, null); - pm.addNavigationLink(SELF_URI + "/knownidentities", "Known Identities", "Manage others identities", false, null); - pm.addNavigationLink("/plugins/", "Plugins page", "Back to Phlugins page", false, null); + web = new WebInterface(pr, db, client, SELF_URI, wot); } public void terminate() { @@ -93,226 +76,19 @@ try { if(page.equals("/ownidentities")) { - return makeOwnIdentitiesPage(); + return web.makeOwnIdentitiesPage(); } if(page.equals("/knownidentities")) { - return makeKnownIdentitiesPage(); + return web.makeKnownIdentitiesPage(); } else { - return makeHomePage(); + return web.makeHomePage(); } } catch (Exception e) { return e.getMessage(); } } - private String makeHomePage() { - - HTMLNode list = new HTMLNode("ul"); - - list.addChild(new HTMLNode("li", "Own Identities : " + wot.getNbOwnIdentities())); - list.addChild(new HTMLNode("li", "Known Identities : " + wot.getNbIdentities())); - - HTMLNode pageNode = getPageNode(); - HTMLNode contentNode = pm.getContentNode(pageNode); - HTMLNode box = pm.getInfobox("Summary"); - - HTMLNode boxContent = pm.getContentNode(box); - boxContent.addChild(list); - - contentNode.addChild(box); - return pageNode.generate(); - } - - private String makeOwnIdentitiesPage() { - - HTMLNode pageNode = getPageNode(); - HTMLNode contentNode = pm.getContentNode(pageNode); - HTMLNode box = pm.getInfobox("Own Identities"); - HTMLNode boxContent = pm.getContentNode(box); - - ObjectSet<OwnIdentity> ownIdentities = db.queryByExample(OwnIdentity.class); - if(ownIdentities.size() == 0) { - boxContent.addChild("p", "You have no own identity yet, you should create one..."); - } - else { - HTMLNode identitiesTable = boxContent.addChild("table", "border", "0"); - HTMLNode row=identitiesTable.addChild("tr"); - row.addChild("th", "Name"); - row.addChild("th", "Last change"); - row.addChild("th", "Last insert"); - row.addChild("th", "Publish TrustList ?"); - - while(ownIdentities.hasNext()) { - OwnIdentity id = ownIdentities.next(); - row=identitiesTable.addChild("tr"); - row.addChild("td", new String[] {"title", "style"}, new String[] {id.getRequestURI().toString(), "cursor: help;"}, id.getNickName()); - row.addChild("td",id.getLastChange().toString()); - HTMLNode cell = row.addChild("td"); - if(id.getLastInsert().equals(new Date(0))) { - cell.addChild("p", "Never"); - } - else { - cell.addChild(new HTMLNode("a", "href", "/"+id.getRequestURI().toString(), id.getLastInsert().toString())); - } - row.addChild("td", id.doesPublishTrustList() ? "Yes" : "No"); - } - } - - HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + "/createIdentity", "createForm"); - createForm.addChild("span", new String[] {"title", "style"}, new String[] { "No spaces or special characters.", "border-bottom: 1px dotted; cursor: help;"} , "NickName : "); - createForm.addChild("input", new String[] {"type", "name", "size"}, new String[] {"text", "nickName", "30"}); - createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "create", "Create a new identity !" }); - - contentNode.addChild(box); - return pageNode.generate(); - } - - private String makeKnownIdentitiesPage() throws Db4oIOException, DatabaseClosedException, InvalidParameterException, NotInTrustTreeException { - return makeKnownIdentitiesPage(""); - } - - private String makeKnownIdentitiesPage(String owner) throws Db4oIOException, DatabaseClosedException, InvalidParameterException, NotInTrustTreeException { - - Identity treeOwner = null; - - HTMLNode pageNode = getPageNode(); - HTMLNode contentNode = pm.getContentNode(pageNode); - - // Add an identity form - HTMLNode addBox = pm.getInfobox("Add an identity"); - HTMLNode addBoxContent = pm.getContentNode(addBox); - - HTMLNode createForm = pr.addFormChild(addBoxContent, SELF_URI + "/addIdentity", "addForm"); - createForm.addChild("span", new String[] {"title", "style"}, new String[] { "This must be a valid Freenet URI.", "border-bottom: 1px dotted; cursor: help;"} , "Identity URI : "); - createForm.addChild("input", new String[] {"type", "name", "size"}, new String[] {"text", "identityURI", "70"}); - createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", "Add this identity !" }); - - - // Known identities list - HTMLNode listBox = pm.getInfobox("Known Identities"); - HTMLNode listBoxContent = pm.getContentNode(listBox); - - int nbOwnIdentities = wot.getNbOwnIdentities(); - - if (nbOwnIdentities == 0) { - listBoxContent.addChild("p", "You should create an identity first..."); - contentNode.addChild(listBox); - return pageNode.generate(); - } - else if (nbOwnIdentities == 1) { - treeOwner = (OwnIdentity) db.queryByExample(OwnIdentity.class).next(); - } - else { - // Get the identity the user asked for, or the first one if he didn't - if(owner.equals("")) { - treeOwner = (OwnIdentity) db.queryByExample(OwnIdentity.class).next(); - } - else { - try { - treeOwner = wot.getIdentityByURI(owner); - } catch (Exception e) { - return e.getMessage(); - } - } - - // Display a form to select the tree owner - HTMLNode selectForm = pr.addFormChild(listBoxContent, SELF_URI + "/viewTree", "selectForm"); - HTMLNode selectBox = selectForm.addChild("select", "name", "ownerURI"); - - ObjectSet<OwnIdentity> ownIdentities = db.queryByExample(OwnIdentity.class); - while(ownIdentities.hasNext()) { - OwnIdentity ownIdentity = ownIdentities.next(); - if(ownIdentity == treeOwner) { - selectBox.addChild("option", new String [] {"value", "selected"}, new String [] {ownIdentity.getRequestURI().toString(), "selected"}, ownIdentity.getProp("nickName")); - } - else { - selectBox.addChild("option", "value", ownIdentity.getRequestURI().toString(), ownIdentity.getProp("nickName")); - } - } - selectForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "select", "View this identity's Web of Trust" }); - } - - - // Display the list of known identities - HTMLNode identitiesTable = listBoxContent.addChild("table", "border", "0"); - HTMLNode row=identitiesTable.addChild("tr"); - row.addChild("th", "NickName"); - row.addChild("th", "Last update"); - row.addChild("th", "Publish TrustList ?"); - row.addChild("th", "Score (Rank)"); - row.addChild("th", "Trust/Comment"); - - ObjectSet<Identity> identities = db.queryByExample(Identity.class); - while(identities.hasNext()) { - Identity id = identities.next(); - - if(id == treeOwner) continue; - - row=identitiesTable.addChild("tr"); - - // NickName - row.addChild("td", new String[] {"title", "style"}, new String[] {id.getRequestURI().toString(), "cursor: help;"}, id.getNickName()); - - // Last Change - if (id.getLastChange().equals(new Date(0))) row.addChild("td", "Fetching..."); - else row.addChild("td", id.getLastChange().toString()); - - // Publish TrustList - row.addChild("td", id.doesPublishTrustList() ? "Yes" : "No"); - - //Score - row.addChild("td", String.valueOf(id.getScore((OwnIdentity)treeOwner, db).getScore())+" ("+id.getScore((OwnIdentity)treeOwner, db).getRank()+")"); - - // Trust - String trustValue = ""; - String trustComment = ""; - ObjectSet<Trust> trusts = db.queryByExample(new Trust(treeOwner, id, 0, null)); - if(trusts.hasNext()) { - Trust trust = trusts.next(); - trustValue = String.valueOf(trust.getValue()); - trustComment = trust.getComment(); - } - - HTMLNode cell = row.addChild("td"); - HTMLNode trustForm = pr.addFormChild(cell, SELF_URI + "/setTrust", "setTrustForm"); - trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "truster", treeOwner.getRequestURI().toString() }); - trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "trustee", id.getRequestURI().toString() }); - trustForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "value", "2", trustValue }); - trustForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "comment", "20", trustComment }); - trustForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "update", "Update !" }); - } - contentNode.addChild(addBox); - contentNode.addChild(listBox); - return pageNode.generate(); - } - - private String makeCreateIdentityPage(String nickName) { - - HTMLNode pageNode = getPageNode(); - HTMLNode contentNode = pm.getContentNode(pageNode); - HTMLNode box = pm.getInfobox("Identity creation"); - HTMLNode boxContent = pm.getContentNode(box); - - FreenetURI[] keypair = client.generateKeyPair("WoT"); - - HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + "/createIdentity2", "createForm"); - createForm.addChild("#", "Request URI : "); - createForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "requestURI", "70", keypair[1].toString() }); - createForm.addChild("br"); - createForm.addChild("#", "Insert URI : "); - createForm.addChild("input", new String[] { "type", "name", "size", "value" }, new String[] { "text", "insertURI", "70", keypair[0].toString() }); - createForm.addChild("br"); - createForm.addChild("#", "Publish trust list "); - createForm.addChild("input", new String[] { "type", "name", "value", "checked" }, new String[] { "checkbox", "publishTrustList", "true", "checked"}); - createForm.addChild("br"); - createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "nickName", nickName }); - createForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "create", "Create a new identity !" }); - - contentNode.addChild(box); - return pageNode.generate(); - } - @Override public String handleHTTPPost(HTTPRequest request) throws PluginHTTPException { @@ -325,26 +101,26 @@ try { if(page.equals("/createIdentity")) { - return makeCreateIdentityPage(request.getPartAsString("nickName",1024)); + return web.makeCreateIdentityPage(request); } else if(page.equals("/createIdentity2")) { createIdentity(request); - return makeOwnIdentitiesPage(); + return web.makeOwnIdentitiesPage(); } else if(page.equals("/addIdentity")) { addIdentity(request); - return makeKnownIdentitiesPage(); + return web.makeKnownIdentitiesPage(); } else if(page.equals("/viewTree")) { - return makeKnownIdentitiesPage(request.getPartAsString("ownerURI", 1024)); + return web.makeKnownIdentitiesPage(request); } else if (page.equals("/setTrust")) { setTrust(request); - return makeKnownIdentitiesPage(request.getPartAsString("truster", 1024)); + return web.makeKnownIdentitiesPage(request); } else { - return makeHomePage(); + return web.makeHomePage(); } } catch (Exception e) { return e.getLocalizedMessage(); @@ -396,7 +172,7 @@ identity = new Identity(requestURI, new Date(0), "Not found yet...", "false"); db.store(identity); db.commit(); - fetcher.fetch(identity); + new IdentityFetcher(db, wot, client).fetch(identity); } return identity; } @@ -437,11 +213,8 @@ public String handleHTTPPut(HTTPRequest request) throws PluginHTTPException { return null; } + - private HTMLNode getPageNode() { - return pm.getPageNode("Web of Trust", null); - } - public String getVersion() { return "0.0.1 r"+Version.getSvnRevision(); }
