Author: batosai
Date: 2008-06-15 16:50:06 +0000 (Sun, 15 Jun 2008)
New Revision: 20355

Modified:
   trunk/apps/WoT/src/plugins/WoT/Identity.java
   trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
   trunk/apps/WoT/src/plugins/WoT/WoT.java
Log:
Beginning of the handler that will parse XML trustLists.

Modified: trunk/apps/WoT/src/plugins/WoT/Identity.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/Identity.java        2008-06-15 15:16:57 UTC 
(rev 20354)
+++ trunk/apps/WoT/src/plugins/WoT/Identity.java        2008-06-15 16:50:06 UTC 
(rev 20355)
@@ -5,8 +5,22 @@
  */
 package plugins.WoT;

+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;
+
 import com.db4o.ObjectContainer;

 /**
@@ -53,6 +67,19 @@
        }

        /**
+        * Parses an XML trustList file
+        * 
+        * @param pis InputStream containing the XML trustList
+        */
+       public void fromXML(InputStream pis) throws Exception {
+               
+               SAXParserFactory factory = SAXParserFactory.newInstance();
+               SAXParser saxParser = factory.newSAXParser();
+               saxParser.parse(pis,new IdentityParser());
+       }
+       
+       
+       /**
         * @return requestURI
         */
        public String getRequestURI() {
@@ -106,4 +133,15 @@
                this.edition = edition;
        }

+       public class IdentityParser extends DefaultHandler {
+               
+               public void startElement(String nameSpaceURI, String localName, 
String rawName, Attributes attrs) throws SAXException {
+                       if (rawName == null) {
+                               rawName = localName;
+                       }
+                       
+                       // TODO Do the actual parsing
+                       
+               }
+       }
 }

Modified: trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-06-15 15:16:57 UTC 
(rev 20354)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-06-15 16:50:06 UTC 
(rev 20355)
@@ -70,14 +70,14 @@
                fcp.addFcpListener(this);
        }

-       public void fetch(Identity identity) throws IOException, 
InterruptedException {
+       public void fetch(Identity identity) throws Exception {
                synchronized (this) {
                        fcp.sendMessage(new 
ClientGet(identity.getFullRequestURI(), identifier));
                        this.wait();
                }

                if(fileFetched) {
-                       // TODO Make the identity update itself from the file
+                       identity.fromXML(pis);
                }
        }


Modified: trunk/apps/WoT/src/plugins/WoT/WoT.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoT.java     2008-06-15 15:16:57 UTC (rev 
20354)
+++ trunk/apps/WoT/src/plugins/WoT/WoT.java     2008-06-15 16:50:06 UTC (rev 
20355)
@@ -80,7 +80,7 @@
        /**
         * Testing code goes here, nevermind what horrors you see below ;)
         */
-       public void testDrive() throws ParserConfigurationException, 
TransformerException, IOException,InterruptedException {
+       public void testDrive() throws Exception {

                //Empty the database
                ObjectSet<Object> result = db.queryByExample(new Object());


Reply via email to