Author: j16sdiz
Date: 2009-01-05 12:04:14 +0000 (Mon, 05 Jan 2009)
New Revision: 24915

Modified:
   trunk/plugins/XMLSpider/XMLSpider.java
   trunk/plugins/XMLSpider/web/ConfigPage.java
Log:
make config page actually works

Modified: trunk/plugins/XMLSpider/XMLSpider.java
===================================================================
--- trunk/plugins/XMLSpider/XMLSpider.java      2009-01-05 12:04:02 UTC (rev 
24914)
+++ trunk/plugins/XMLSpider/XMLSpider.java      2009-01-05 12:04:14 UTC (rev 
24915)
@@ -6,7 +6,6 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -71,8 +70,7 @@
  */
 public class XMLSpider implements FredPlugin, FredPluginHTTP, 
FredPluginThreadless, FredPluginVersioned, FredPluginL10n, USKCallback {
        public Config getConfig() {
-               // always return a clone, never allow changing directly
-               return getRoot().getConfig().clone();
+               return getRoot().getConfig();
        }
 
        // Set config asynchronously
@@ -327,7 +325,11 @@
 
                public void run() {
                        synchronized (getRoot()) {
-                               getRoot().getConfig().setValue(config);
+                               Config oldConfig = getRoot().getConfig();
+                               getRoot().setConfig(config);
+                               
+                               if (oldConfig.getMaxParallelRequests() < 
config.getMaxParallelRequests())
+                                       startSomeRequests();
                        }
                }
        }
@@ -350,13 +352,13 @@
                }
 
                private int getPriority(Runnable r) {
-                       if (r instanceof MakeIndexCallback)
+                       if (r instanceof SetConfigCallback)
                                return 0;
+                       else if (r instanceof MakeIndexCallback)
+                               return 1;
                        else if (r instanceof OnFailureCallback)
-                               return 1;
+                               return 2;
                        else if (r instanceof OnSuccessCallback)
-                               return 2;
-                       else if (r instanceof SetConfigCallback)
                                return 3;
                        else if (r instanceof StartSomeRequestsCallback)
                                return 4;

Modified: trunk/plugins/XMLSpider/web/ConfigPage.java
===================================================================
--- trunk/plugins/XMLSpider/web/ConfigPage.java 2009-01-05 12:04:02 UTC (rev 
24914)
+++ trunk/plugins/XMLSpider/web/ConfigPage.java 2009-01-05 12:04:14 UTC (rev 
24915)
@@ -12,7 +12,6 @@
 import freenet.support.api.HTTPRequest;
 
 class ConfigPage implements WebPage {
-
        private final XMLSpider xmlSpider;
        private final PageMaker pageMaker;
        private final PluginRespirator pr;
@@ -22,8 +21,8 @@
                this.xmlSpider = xmlSpider;
                pageMaker = xmlSpider.getPageMaker();
                pr = xmlSpider.getPluginRespirator();
-               
-               config = xmlSpider.getConfig(); 
+
+               config = xmlSpider.getConfig();
        }
 
        /*
@@ -32,13 +31,43 @@
         * @see 
plugins.XMLSpider.WebPage#processPostRequest(freenet.support.api.HTTPRequest,
         * freenet.support.HTMLNode)
         */
-       public void processPostRequest(HTTPRequest request, HTMLNode 
contentNode) {
-               // Create Index
-               if (request.isPartSet("testButton")) {
-                       HTMLNode infobox = pageMaker.getInfobox("infobox 
infobox-success", "Test Button Pressed!");
-                       infobox.addChild("#", "Test passed!");
-                       contentNode.addChild(infobox);
+       public synchronized void processPostRequest(HTTPRequest request, 
HTMLNode contentNode) {
+               config = xmlSpider.getConfig().clone();
+               
+               if (request.isPartSet("maxParallelRequests")) {
+                       int v = request.getIntPart("maxParallelRequests", 
config.getMaxParallelRequests());
+                       config.setMaxParallelRequests(v);
                }
+               if (request.isPartSet("badListedExtensions")) {
+                       String v = 
request.getPartAsString("badListedExtensions", 512);
+                       String[] v0 = v.split(",");
+                       for (int i = 0; i < v0.length; i++)
+                               v0[i] = v0[i].trim();
+                       config.setBadlistedExtensions(v0);
+               }
+               
+               if (request.isPartSet("indexDir")) {
+                       String v = request.getPartAsString("indexDir", 256);
+                       config.setIndexDir(v);
+               }
+               if (request.isPartSet("indexTitle")) {
+                       String v = request.getPartAsString("indexTitle", 256);
+                       config.setIndexTitle(v);
+               }
+               if (request.isPartSet("indexOwner")) {
+                       String v = request.getPartAsString("indexOwner", 256);
+                       config.setIndexOwner(v);
+               }
+               if (request.isPartSet("indexOwnerEmail")) {
+                       String v = request.getPartAsString("indexOwnerEmail", 
256);
+                       config.setIndexOwnerEmail(v);
+               }
+               if (request.isPartSet("debug")) {
+                       String v = request.getPartAsString("debug", 10);
+                       config.debug(Boolean.valueOf(v));
+               }
+               
+               xmlSpider.setConfig(config);
        }
 
        /*
@@ -47,7 +76,7 @@
         * @see 
plugins.XMLSpider.WebPage#writeContent(freenet.support.api.HTTPRequest,
         * freenet.support.HTMLNode)
         */
-       public void writeContent(HTTPRequest request, HTMLNode contentNode) {
+       public void writeContent(HTTPRequest request, HTMLNode contentNode) {   
                HTMLNode configBox = pageMaker.getInfobox("Configuration");
                HTMLNode configContent = pageMaker.getContentNode(configBox);
                HTMLNode configForm = pr.addFormChild(configContent, 
"plugins.XMLSpider.XMLSpider?ConfigPage", "configForm");

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to