Author: jolantern
Date: 2007-12-27 13:33:29 +0000 (Thu, 27 Dec 2007)
New Revision: 16820

Modified:
   branches/legacy/stable/src/freenet/node/http/NodeInfoServlet.java
   branches/legacy/stable/src/freenet/node/http/infolets/DefaultInfolet.java
Log:
indent

Modified: branches/legacy/stable/src/freenet/node/http/NodeInfoServlet.java
===================================================================
--- branches/legacy/stable/src/freenet/node/http/NodeInfoServlet.java   
2007-12-27 12:36:22 UTC (rev 16819)
+++ branches/legacy/stable/src/freenet/node/http/NodeInfoServlet.java   
2007-12-27 13:33:29 UTC (rev 16820)
@@ -41,252 +41,236 @@
  */
 public class NodeInfoServlet extends HttpServlet {

-  private static Node node;
+       private static Node node;

-  private static Vector groups = new Vector();
+       private static Vector groups = new Vector();

-  private static Hashtable lookupTable = new Hashtable();
+       private static Hashtable lookupTable = new Hashtable();

-  private static Infolet defaultInfolet = null;
+       private static Infolet defaultInfolet = null;

-  private static Object staticSync = new Object();
+       private static Object staticSync = new Object();

-  private static boolean staticInitted = false;
+       private static boolean staticInitted = false;

-  private HtmlTemplate pageTemplate, titleBoxTemplate;
+       private HtmlTemplate pageTemplate, titleBoxTemplate;

-  private static HtmlTemplate basePageTemplate, baseTitleBoxTemplate;
+       private static HtmlTemplate basePageTemplate, baseTitleBoxTemplate;

-  private static String path;
-  
-    public final void init() {
-    try {
-       synchronized(staticSync) {
-           if(!staticInitted) {
-               staticInitted = true;
-                    node = (Node) 
getServletContext().getAttribute("freenet.node.Node");
-               Core.logger.log(this, "Initializing Infolets", Logger.DEBUG);
-               
-               path = 
getServletConfig().getInitParameter("servletContextPath");
-               
-               staticInit();
-           }
+       private static String path;
+       
+       public final void init() {
+               try {
+                       synchronized(staticSync) {
+                               if(!staticInitted) {
+                                       staticInitted = true;
+                                       node = (Node) 
getServletContext().getAttribute("freenet.node.Node");
+                                       Core.logger.log(this, "Initializing 
Infolets", Logger.DEBUG);
+                                       path = 
getServletConfig().getInitParameter("servletContextPath");
+                                       staticInit();
+                               }
+                       }
+                       // Initialize templates
+                       pageTemplate = new HtmlTemplate(basePageTemplate);
+                       titleBoxTemplate = new 
HtmlTemplate(baseTitleBoxTemplate);
+               } catch (IOException e) {
+                       Core.logger.log(this, "Failed to Initialize 
HtmlTemplate", e, Logger.ERROR);
+               }
        }
-       // Initialize templates
-       pageTemplate = new HtmlTemplate(basePageTemplate);
-       titleBoxTemplate = new HtmlTemplate(baseTitleBoxTemplate);
-    } catch (IOException e) {
-       Core.logger.log(this, "Failed to Initialize HtmlTemplate", e, 
Logger.ERROR);
-    }
-    
-  }
-  
-  protected static void staticInit() throws IOException {
-      basePageTemplate = HtmlTemplate.createTemplate("InfoServletTmpl.html");
-        baseTitleBoxTemplate = HtmlTemplate.createTemplate("titleBox.tpl");
-      
-      /*
-         * Construct menu ============== Create the group, register it, and
-         * then register the Infolets which are to be part of that group in the
-         * order you want to see them in the menu. The long group name should
-         * be the name which will appear in the menu, the short group name will
-         * be the name that will appear in the URL (so it should basically be
-         * nothing but lower-case alphanumeric characters). The same is true
-         * for the long and short names of the Infolets themselves. For
-         * example: Group testGroup = new Group("Long Group Name",
-         * "briefgroupname"); registerGroup(testGroup);
-       *  registerInfolet(testGroup, new TestInfolet());
-         * registerInfolet(testGroup, new TestInfolet2()); ... Group 
testGroup2 =
-         * new Group("Second Long Group Name", "briefgroupname2"); ...
-       */
-      Group performance = new Group("Performance", "performance");
-      registerGroup(performance);
-      registerInfolet(performance, new GeneralInfolet());
-      Group network = new Group("Networking", "networking");
-      registerGroup(network);
-      if(!Main.publicNode) {
-         registerInfolet(network, new DownloadsInfolet());
-         registerInfolet(network, new OpenConnections());
-         registerInfolet(network, new DistributionServletInfolet());
-      }
-      registerInfolet(network, new LoadStatsInfolet());
-      Group internal = new Group("Internals", "internal");
-      registerGroup(internal);
-      registerInfolet(internal, new NodeStatusInfolet()); // placeholder only
-      registerInfolet(internal, new LoggerInfolet());
-      registerInfolet(internal, new TickerContents());
-      registerInfolet(internal, new FailureTableInfolet());
-      registerInfolet(internal, new EnvironmentInfolet());
-               
-      Group docs = new Group("Documentation", "documentation");
-      registerGroup(docs);
-      // REDUNDANT    registerInfolet(internal, new ThreadFactoryInfolet());
-      registerInfolet(docs, new ReadMeInfolet());
-      registerInfolet(docs, new ManualInfolet());
-      defaultInfolet = new DefaultInfolet(path);
-      defaultInfolet.init(node);
-  }
-  
-  /**
-   * Render a Html page
-   *
-   * @param  req
-   * @param  resp
-   * @exception  IOException
-   */
-    // We synchronize this method because use of the HtmlTemplate renders this
-    // code
-  // thread-unsafe
-    public synchronized void doGet(HttpServletRequest req, HttpServletResponse 
resp) throws IOException {
+       
+       protected static void staticInit() throws IOException {
+               basePageTemplate = 
HtmlTemplate.createTemplate("InfoServletTmpl.html");
+               baseTitleBoxTemplate = 
HtmlTemplate.createTemplate("titleBox.tpl");
+           
+               /*
+                * Construct menu ============== Create the group, register it, 
and
+                * then register the Infolets which are to be part of that 
group in the
+                * order you want to see them in the menu. The long group name 
should
+                * be the name which will appear in the menu, the short group 
name will
+                * be the name that will appear in the URL (so it should 
basically be
+                * nothing but lower-case alphanumeric characters). The same is 
true
+                * for the long and short names of the Infolets themselves. For
+                * example: Group testGroup = new Group("Long Group Name", 
"briefgroupname"); registerGroup(testGroup);
+                * registerInfolet(testGroup, new TestInfolet());
+                * registerInfolet(testGroup, new TestInfolet2()); ... Group 
testGroup2 = new Group("Second Long Group Name", "briefgroupname2"); ...
+                */
+               Group performance = new Group("Performance", "performance");
+               registerGroup(performance);
+               registerInfolet(performance, new GeneralInfolet());
+               Group network = new Group("Networking", "networking");
+               registerGroup(network);
+               if(!Main.publicNode) {
+                       registerInfolet(network, new DownloadsInfolet());
+                       registerInfolet(network, new OpenConnections());
+                       registerInfolet(network, new 
DistributionServletInfolet());
+               }
+               registerInfolet(network, new LoadStatsInfolet());
+               Group internal = new Group("Internals", "internal");
+               registerGroup(internal);
+               registerInfolet(internal, new NodeStatusInfolet()); // 
placeholder only
+               registerInfolet(internal, new LoggerInfolet());
+               registerInfolet(internal, new TickerContents());
+               registerInfolet(internal, new FailureTableInfolet());
+               registerInfolet(internal, new EnvironmentInfolet());

-      if (StupidBrowserCheck.didWarning(req, resp, Core.logger, this)) return;
-      String path = req.getPathInfo();
-      Core.logger.log(this, "getPathInfo returned " + path, Logger.DEBUG);
-      
-      int x = (path == null) ? -1 : path.indexOf('/');
-      int y = (path == null) ? -1 : path.lastIndexOf('/');
-      String subset = null;
-      if(x != y) {
-         subset = path.substring(y+1);
-         path = path.substring(0, y);
-            Core.logger.log(this, "Broken: subset=" + subset + ", path=" + 
path, Logger.DEBUG);
-      }
-      
-      // Obtain Infolet
-      Infolet i = null;
-      if (path != null) {
-          try {
-              i = (Infolet) lookupTable.get(path);
-            } catch (ClassCastException e) {
-            }
-      }
-      if (i == null) {
-          i = defaultInfolet;
-      }
-      
-        SimpleAdvanced_ModeUtils.handleRequestedParams(req, resp); //Parse a
-                                                                   // possible
-                                                                   // requested
-                                                                   // 
modechange
-                                                                   // & co
-      
-      Core.logger.log(this, "i is "+i, Logger.DEBUG);
-        if (subset != null && i instanceof MultipleFileInfolet && 
((MultipleFileInfolet) i).write(subset, req, resp)) {
-      } else {
-         PrintWriter pw = resp.getWriter();
-         resp.setContentType("text/html");
-         
-         pageTemplate.set("TITLE", i.longName());
-      pageTemplate.set("TOPRIGHTLINK", 
SimpleAdvanced_ModeUtils.renderModeSwitchLink(req.getRequestURI(),req));
-         
-         StringWriter swMenu = new StringWriter(100);
-         PrintWriter pwMenu = new PrintWriter(swMenu);
-         // Display menu
-         String servletPath = req.getServletPath();
-         if (!servletPath.endsWith("/")) {
-             servletPath = servletPath + "/";
-         }
-            pwMenu.println("<p>");
-         pwMenu.println("<a href=\"" + servletPath + "\">Web Interface</a>");
-            if (!Main.publicNode) pwMenu.println("<br /><a 
href=\"/servlet/bookmarkmanager\">" + "Bookmark Manager</a>");
-            pwMenu.println("</p>");
-         for (Enumeration e = groups.elements(); e.hasMoreElements(); ) {
-             Group g = (Group) e.nextElement();
-             g.toHtml(pwMenu, req);
-         }
-         pwMenu.flush();
-         titleBoxTemplate.set("TITLE", "Node Information");
-         titleBoxTemplate.set("CONTENT", swMenu.toString());
-         pageTemplate.set("MENU", titleBoxTemplate);
-         pageTemplate.set("BODY", i, req);
-         pageTemplate.toHtml(pw, req);
-      }
-      
-      try {
-         resp.flushBuffer();
-      } catch (IOException e) {
-            Core.logger.log(this, "I/O error (" + e + ") flushing buffer... 
probably harmless", e, Logger.MINOR);
-      }
-  }
-  
-  /**
-   *  Gets the servletInfo attribute of the NodeInfoServlet object
-   *
-   * @return    The servletInfo value
-   */
-  public String getServletInfo() {
-    return "Information on the nodes current internals.";
-  }
+               Group docs = new Group("Documentation", "documentation");
+               registerGroup(docs);
+               // REDUNDANT    registerInfolet(internal, new 
ThreadFactoryInfolet());
+               registerInfolet(docs, new ReadMeInfolet());
+               registerInfolet(docs, new ManualInfolet());
+               defaultInfolet = new DefaultInfolet(path);
+               defaultInfolet.init(node);
+       }
+       
+       /**
+        * Render a Html page
+        *
+        * @param  req
+        * @param  resp
+        * @exception  IOException
+        */
+       // We synchronize this method because use of the HtmlTemplate renders 
this
+       // code thread-unsafe
+       public synchronized void doGet(HttpServletRequest req, 
HttpServletResponse resp) throws IOException {
+               if (StupidBrowserCheck.didWarning(req, resp, Core.logger, this))
+                       return;
+               String path = req.getPathInfo();
+               Core.logger.log(this, "getPathInfo returned " + path, 
Logger.DEBUG);
+           
+               int x = (path == null) ? -1 : path.indexOf('/');
+               int y = (path == null) ? -1 : path.lastIndexOf('/');
+               String subset = null;
+               if(x != y) {
+                       subset = path.substring(y + 1);
+                       path = path.substring(0, y);
+                       Core.logger.log(this, "Broken: subset=" + subset + ", 
path=" + path, Logger.DEBUG);
+               }
+           
+               // Obtain Infolet
+               Infolet i = null;
+               if (path != null) {
+                       try {
+                               i = (Infolet) lookupTable.get(path);
+                       } catch (ClassCastException e) {
+                       }
+               }
+               if (i == null) {
+                       i = defaultInfolet;
+               }

-  /**
-   *  Gets the servletName attribute of the NodeInfoServlet object
-   *
-   * @return    The servletName value
-   */
-  public String getServletName() {
-    return "Node Information";
-  }
+               SimpleAdvanced_ModeUtils.handleRequestedParams(req, resp); // 
Parse a possible requested modechange & co
+           
+               Core.logger.log(this, "i is "+i, Logger.DEBUG);
+               if (subset != null && i instanceof MultipleFileInfolet && 
((MultipleFileInfolet) i).write(subset, req, resp)) {
+               } else {
+                       PrintWriter pw = resp.getWriter();
+                       resp.setContentType("text/html");

-  private static void registerGroup(Group g) {
-    groups.addElement(g);
-    lookupTable.put(g.shortName, g);
-  }
+                       pageTemplate.set("TITLE", i.longName());
+                       pageTemplate.set("TOPRIGHTLINK", 
SimpleAdvanced_ModeUtils.renderModeSwitchLink(req.getRequestURI(),req));

-  private static void registerInfolet(Group g, Infolet i) {
-    g.register(i);
-    lookupTable.put(g.shortName + "/" + i.shortName(), i);
-    i.init(node);
-  }
+                       StringWriter swMenu = new StringWriter(100);
+                       PrintWriter pwMenu = new PrintWriter(swMenu);
+                       // Display menu
+                       String servletPath = req.getServletPath();
+                       if (!servletPath.endsWith("/")) {
+                               servletPath = servletPath + "/";
+                       }
+                       pwMenu.println("<p>");
+                       pwMenu.println("<a href=\"" + servletPath + "\">Web 
Interface</a>");
+                       if (!Main.publicNode)
+                               pwMenu.println("<br /><a 
href=\"/servlet/bookmarkmanager\">" + "Bookmark Manager</a>");
+                       pwMenu.println("</p>");
+                       for (Enumeration e = groups.elements(); 
e.hasMoreElements(); ) {
+                               Group g = (Group) e.nextElement();
+                               g.toHtml(pwMenu, req);
+                       }
+                       pwMenu.flush();
+                       titleBoxTemplate.set("TITLE", "Node Information");
+                       titleBoxTemplate.set("CONTENT", swMenu.toString());
+                       pageTemplate.set("MENU", titleBoxTemplate);
+                       pageTemplate.set("BODY", i, req);
+                       pageTemplate.toHtml(pw, req);
+               }
+           
+               try {
+                       resp.flushBuffer();
+               } catch (IOException e) {
+                       Core.logger.log(this, "I/O error (" + e + ") flushing 
buffer... probably harmless", e, Logger.MINOR);
+               }
+       }
+       
+       /**
+        *  Gets the servletInfo attribute of the NodeInfoServlet object
+        *
+        * @return    The servletInfo value
+        */
+       public String getServletInfo() {
+               return "Information on the nodes current internals.";
+       }

-  /**
-   * @author     ian
-   */
-  private static class Group {
+       /**
+        *  Gets the servletName attribute of the NodeInfoServlet object
+        *
+        * @return    The servletName value
+        */
+       public String getServletName() {
+               return "Node Information";
+       }

-    public String longName;
+       private static void registerGroup(Group g) {
+               groups.addElement(g);
+               lookupTable.put(g.shortName, g);
+       }

-    public String shortName;
+       private static void registerInfolet(Group g, Infolet i) {
+               g.register(i);
+               lookupTable.put(g.shortName + "/" + i.shortName(), i);
+               i.init(node);
+       }

-    private Vector infolets = new Vector();
+       /**
+        * @author     ian
+        */
+       private static class Group {

-        public Group(String longName, String shortName) {
-      this.longName = longName;
-      this.shortName = shortName;
-    }
+               public String longName;

-    public final void register(Infolet l) {
-      infolets.addElement(l);
-    }
+               public String shortName;

-    public final void toHtml(PrintWriter pw,HttpServletRequest req) {
-               StringWriter swGroup = new StringWriter(100);
-               PrintWriter pwGroup = new PrintWriter(swGroup);
-               boolean anyPrinted = false; 
-            pwGroup.println("<h3>" + longName + "</h3>");
-            pwGroup.println("<ul>");
-       for (Enumeration e = infolets.elements(); e.hasMoreElements(); ) {
-               Infolet l = (Infolet) e.nextElement();
-                // this should really check to see if the Node Status Servlet
-                // is running,
-                // but its not that easy to get a reference to
-                // MultipleHttpServletContainer
-                // to check whether the Serlvet will be run (it doesn't get run
-                // until the first
-               // access)
-                // anyone who turns nodestatus off in the config will know what
-                // they're doing
-               if(l.visibleFor(req)) {
+               private Vector infolets = new Vector();

-                    pwGroup.println("<li><a href=\"" + 
l.target(req.getServletPath(), shortName) + "\">" + l.longName().replaceAll(" 
", "&nbsp;")
-                            + "</a></li>");
-                               anyPrinted = true;
-               }
-       }
-            pwGroup.println("</ul>");
-       if(anyPrinted) {
-               pwGroup.flush();
-               pw.print(swGroup.getBuffer());
-               }
-       }
-  }
+               public Group(String longName, String shortName) {
+                       this.longName = longName;
+                       this.shortName = shortName;
+               }
+
+               public final void register(Infolet l) {
+                       infolets.addElement(l);
+               }
+
+               public final void toHtml(PrintWriter pw,HttpServletRequest req) 
{
+                       StringWriter swGroup = new StringWriter(100);
+                       PrintWriter pwGroup = new PrintWriter(swGroup);
+                       boolean anyPrinted = false; 
+                       pwGroup.println("<h3>" + longName + "</h3>");
+                       pwGroup.println("<ul>");
+                       for (Enumeration e = infolets.elements(); 
e.hasMoreElements();) {
+                               Infolet l = (Infolet) e.nextElement();
+                               // this should really check to see if the Node 
Status Servlet is running,
+                               // but its not that easy to get a reference to 
MultipleHttpServletContainer
+                               // to check whether the Serlvet will be run (it 
doesn't get run until the first access)
+                               // anyone who turns nodestatus off in the 
config will know what they're doing
+                               if(l.visibleFor(req)) {
+                                       pwGroup.println("<li><a href=\"" + 
l.target(req.getServletPath(), shortName) + "\">" + l.longName().replaceAll(" 
", "&nbsp;") + "</a></li>");
+                                       anyPrinted = true;
+                               }
+                       }
+                       pwGroup.println("</ul>");
+                       if(anyPrinted) {
+                               pwGroup.flush();
+                               pw.print(swGroup.getBuffer());
+                       }
+               }
+       }
 }

Modified: 
branches/legacy/stable/src/freenet/node/http/infolets/DefaultInfolet.java
===================================================================
--- branches/legacy/stable/src/freenet/node/http/infolets/DefaultInfolet.java   
2007-12-27 12:36:22 UTC (rev 16819)
+++ branches/legacy/stable/src/freenet/node/http/infolets/DefaultInfolet.java   
2007-12-27 13:33:29 UTC (rev 16820)
@@ -38,7 +38,7 @@

        static boolean sentFirstTimeWarning = false;

-    HtmlTemplate titleBoxTmp,insertTmp;
+       HtmlTemplate titleBoxTmp,insertTmp;

        private volatile Params bookmarks;

@@ -53,10 +53,10 @@
                this();
                bookmarks = null;
                if (logDEBUG) {
-            Core.logger.log(DefaultInfolet.class, "Registering the 
defaultInfolet as a listener on " + path, Logger.DEBUG);
+                       Core.logger.log(DefaultInfolet.class, "Registering the 
defaultInfolet as a listener on " + path, Logger.DEBUG);
                }
                NodeConfigUpdater.addUpdateListener(path, this);
-        if (bookmarks == null) throw new IllegalStateException("Bookmarks NOT 
INITIALIZED!");
+               if (bookmarks == null) throw new 
IllegalStateException("Bookmarks NOT INITIALIZED!");
        }

        public String longName() {
@@ -69,14 +69,14 @@

        public void init(Node n) {
                try {
-            //relBarTmp = HtmlTemplate.createTemplate("relbar.tpl");
-            //barTmp = HtmlTemplate.createTemplate("bar.tpl");
-            titleBoxTmp = HtmlTemplate.createTemplate("titleBox.tpl");
+                       // relBarTmp = 
HtmlTemplate.createTemplate("relbar.tpl");
+                       // barTmp = HtmlTemplate.createTemplate("bar.tpl");
+                       titleBoxTmp = 
HtmlTemplate.createTemplate("titleBox.tpl");
                        insertTmp = 
HtmlTemplate.createTemplate("fproxyInsert.tpl");
                } catch (java.io.IOException e) {
                        ///BAD BOY!!!
                }
-        
+
                node = n;
                factory = new InternalClient(n);
                backgroundFetch();
@@ -91,20 +91,14 @@
                if (bytes == 0)
                        return "None";
                if (bytes > (2L << 32))
-                       return (nf.format(bytes >> 30) + " GiB").replaceAll(
-                               " ",
-                               "&nbsp;");
+                       return (nf.format(bytes >> 30) + " GiB").replaceAll(" 
", "&nbsp;");
                if (bytes > (2 << 22))
-                       return (nf.format(bytes >> 20) + " MiB").replaceAll(
-                               " ",
-                               "&nbsp;");
+                       return (nf.format(bytes >> 20) + " MiB").replaceAll(" 
", "&nbsp;");
                if (bytes > (2 << 12))
-                       return (nf.format(bytes >> 10) + " KiB").replaceAll(
-                               " ",
-                               "&nbsp;");
+                       return (nf.format(bytes >> 10) + " KiB").replaceAll(" 
", "&nbsp;");
                return (nf.format(bytes) + " Bytes").replaceAll(" ", "&nbsp;");
        }
-       
+
        public void toHtml(PrintWriter pw, HttpServletRequest req) {
                // Copy local versions for thread safety
                HtmlTemplate titleBoxTmp = new HtmlTemplate(this.titleBoxTmp);
@@ -117,9 +111,12 @@
                if (Node.firstTime && !sentFirstTimeWarning) {
                        ssw = new StringWriter(100);
                        sw = new PrintWriter(ssw);
-            sw.println("Click one of the links below to start browsing 
Freenet. " + "As this is your first time using Freenet, please be patient "
-                    + "as pages can sometimes take several minutes to appear.  
You " + "will find that Freenet gets much faster over time as your "
-                    + "node learns how to find information more effectively. 
Using " + "this software may be illegal under some jurisdictions.");
+                       sw.println("Click one of the links below to start 
browsing Freenet. "
+                               + "As this is your first time using Freenet, 
please be patient "
+                               + "as pages can sometimes take several minutes 
to appear.  You "
+                               + "will find that Freenet gets much faster over 
time as your "
+                               + "node learns how to find information more 
effectively. Using "
+                               + "this software may be illegal under some 
jurisdictions.");
                        titleBoxTmp.set("TITLE", "Please be patient");
                        titleBoxTmp.set("CONTENT", ssw.toString());
                        titleBoxTmp.toHtml(pw);
@@ -130,13 +127,19 @@
                if (Node.badAddress) {
                        ssw = new StringWriter(100);
                        sw = new PrintWriter(ssw);
-            sw.println("Freenet cannot find a valid internet address. " + 
"This means that requests to other nodes will get "
-                    + "lost sometimes, and your node will be unable to " + 
"serve requests for other nodes. Your computer may "
-                    + "not be online, or for some reason could not be " + 
"autodetected; the most common reason for this is "
-                    + "that you are using a NAT router/firewall. If so, you " 
+ "need to configure it to forward port " + Node.listenPort
-                    + " to this machine, and set ipAddress in the config " + 
"file (" + Main.paramFile + ") to the external internet "
-                    + "address of the NAT router. If you don't understand " + 
"what was just said, don't use a NAT router! Another "
-                    + "possibility is that ipAddress is set in your config " + 
"file to an invalid address.");
+                       sw.println("Freenet cannot find a valid internet 
address. "
+                               + "This means that requests to other nodes will 
get "
+                               + "lost sometimes, and your node will be unable 
to "
+                               + "serve requests for other nodes. Your 
computer may "
+                               + "not be online, or for some reason could not 
be "
+                               + "autodetected; the most common reason for 
this is "
+                               + "that you are using a NAT router/firewall. If 
so, you "
+                               + "need to configure it to forward port " + 
Node.listenPort
+                               + " to this machine, and set ipAddress in the 
config "
+                               + "file (" + Main.paramFile + ") to the 
external internet "
+                               + "address of the NAT router. If you don't 
understand "
+                               + "what was just said, don't use a NAT router! 
Another "
+                               + "possibility is that ipAddress is set in your 
config " + "file to an invalid address.");
                        titleBoxTmp.set("TITLE", "Bad IP address setting");
                        titleBoxTmp.set("CONTENT", ssw.toString());
                        titleBoxTmp.toHtml(pw);
@@ -145,21 +148,22 @@
                // Status Bar
                ssw = new StringWriter(100);
                sw = new PrintWriter(ssw);
-        sw.println("<TABLE align = 'center'><TR align = 'left'><TD 
colspan=2>Build " + Version.buildNumber);
-        if (node.getHighestSeenBuild() > Version.buildNumber) sw.println(" 
(<b>Latest: " + Version.highestSeenBuild + "</b>)");
-        //sw.println("</TD></TR><TR><TD align='center'>");
-                       sw.println("&nbsp;&nbsp;Load: ");
-        //sw.println("</TD><TD align='center'>");
-        renderLoadBar(sw);
-        if (Node.logOutputBytes) {
+               sw.println("<TABLE align = 'center'><TR align = 'left'><TD 
colspan=2>Build " + Version.buildNumber);
+               if (node.getHighestSeenBuild() > Version.buildNumber)
+                       sw.println(" (<b>Latest: " + Version.highestSeenBuild + 
"</b>)");
+               // sw.println("</TD></TR><TR><TD align='center'>");
+               sw.println("&nbsp;&nbsp;Load: ");
+               // sw.println("</TD><TD align='center'>");
+               renderLoadBar(sw);
+               if (Node.logOutputBytes) {
                        sw.println("</TD></TR><TR><TD align='left' 
colspan=2>&nbsp;</TD</TR>");
                        sw.println("</TD></TR><TR><TD align='left' colspan=2>");
                        sw.println("Outbound message overhead:");
                        sw.println("</TD></TR><TR><TD align='center' 
colspan=2>");
                        renderMessageOverheadBar(sw);
                }
-        sw.println("</TD></TR></TABLE>");
-        
+               sw.println("</TD></TR></TABLE>");
+
                titleBoxTmp.set("TITLE", "Status");
                titleBoxTmp.set("CONTENT", ssw.toString());
                titleBoxTmp.toHtml(pw);
@@ -171,7 +175,7 @@
                String bookmarkHTML = getBookmarkHTML();
                sw.print(bookmarkHTML);

-        sw.println("<p><small><b>Note</b>: These sites and their thumbnail 
images are published anonymously. We take no responsibility for the contents 
therein; links are provided as a convenience. If the thumbnail image loads, the 
site probably will.</small></p>");
+               sw.println("<p><small><b>Note</b>: These sites and their 
thumbnail images are published anonymously. We take no responsibility for the 
contents therein; links are provided as a convenience. If the thumbnail image 
loads, the site probably will.</small></p>");
                titleBoxTmp.set("TITLE", "Bookmarks");
                titleBoxTmp.set("CONTENT", ssw.toString());
                titleBoxTmp.toHtml(pw);
@@ -182,12 +186,12 @@
                sw.println("<form action=\"" + fproxyAddr + "\">");
                sw.println("<table><tr><td>Key</td><td align=\"left\">");
                if (Node.firstTime) {
-            sw.println("<input size=\"50\" name=\"key\" value=\"Enter a 
Freesite URI here\">");
+                       sw.println("<input size=\"50\" name=\"key\" 
value=\"Enter a Freesite URI here\">");
                } else {
                        sw.println("<input size=\"50\" name=\"key\">");
                }
                sw.println("</td></tr></table>");
-        sw.println("<div align=\"right\"><input type=\"submit\" 
value=\"Request\"></div>");
+               sw.println("<div align=\"right\"><input type=\"submit\" 
value=\"Request\"></div>");
                sw.println("</form>");
                if (SimpleAdvanced_ModeUtils.isAdvancedMode(req)) {
                        titleBoxTmp.set("TITLE", "Request Freesite by URI");
@@ -209,47 +213,44 @@
                }
        }

-    private void renderMessageOverheadBar(PrintWriter sw) {
+       private void renderMessageOverheadBar(PrintWriter sw) {
                double trailerChunkBytes = 
Core.diagnostics.getCountingValue("outputBytesTrailerChunks",Diagnostics.HOUR,Diagnostics.COUNT_CHANGE);
-        double totalBytes = 
Core.diagnostics.getCountingValue("outputBytes",Diagnostics.HOUR,Diagnostics.COUNT_CHANGE);
-        double bytesWasted = totalBytes-trailerChunkBytes;
-        long overhead = Math.round((bytesWasted/totalBytes)*100);
-        HTMLProgressBar overheadBar = new HTMLProgressBar(overhead,100);
-        overheadBar.setLowColorThreshold(20,HTMLProgressBar.COLOR_YELLOW);
-        overheadBar.setHighColorThreshold(40,HTMLProgressBar.COLOR_RED);
-        sw.println(overheadBar.render());
-        sw.println(" " + overhead + "% ("+format(Math.round(bytesWasted))+" 
wasted in the last hour)");
+               double totalBytes = 
Core.diagnostics.getCountingValue("outputBytes",Diagnostics.HOUR,Diagnostics.COUNT_CHANGE);
+               double bytesWasted = totalBytes-trailerChunkBytes;
+               long overhead = Math.round((bytesWasted/totalBytes)*100);
+               HTMLProgressBar overheadBar = new HTMLProgressBar(overhead,100);
+               
overheadBar.setLowColorThreshold(20,HTMLProgressBar.COLOR_YELLOW);
+               overheadBar.setHighColorThreshold(40,HTMLProgressBar.COLOR_RED);
+               sw.println(overheadBar.render());
+               sw.println(" " + overhead + "% 
("+format(Math.round(bytesWasted))+" wasted in the last hour)");
        }

        private void renderLoadBar(PrintWriter sw) {
                int load = (int) (node.estimatedLoad(false) * 100);
-        int overloadLow = (int) (Node.overloadLow * 100);
-        int overloadHigh = (int) (Node.overloadHigh * 100);
-        HTMLProgressBar progress = new HTMLProgressBar(load,100);
-        
progress.setLowColorThreshold(overloadLow,HTMLProgressBar.COLOR_YELLOW);
-        progress.setHighColorThreshold(overloadHigh,HTMLProgressBar.COLOR_RED);
-        sw.println(progress.render());
-        sw.println(" " + load + "%");
+               int overloadLow = (int) (Node.overloadLow * 100);
+               int overloadHigh = (int) (Node.overloadHigh * 100);
+               HTMLProgressBar progress = new HTMLProgressBar(load,100);
+               
progress.setLowColorThreshold(overloadLow,HTMLProgressBar.COLOR_YELLOW);
+               
progress.setHighColorThreshold(overloadHigh,HTMLProgressBar.COLOR_RED);
+               sw.println(progress.render());
+               sw.println(" " + load + "%");
        }

        private String getBookmarkHTML() {
                StringBuffer link = new StringBuffer(512);
                link.append("<table border=\"0\">\n");
                if (bookmarks != null) {
-
-               int maxCount = -1;
-               try {
-                       maxCount = bookmarks.getInt("count");
-               } catch (Exception e) {
-                       maxCount = -1;
-               }
-
+                       int maxCount = -1;
+                       try {
+                               maxCount = bookmarks.getInt("count");
+                       } catch (Exception e) {
+                               maxCount = -1;
+                       }
                        int i = 0;
                        while (!((maxCount != -1) && (maxCount <= i))) {
-
-                Params bookmark = (Params) 
bookmarks.getSet(Integer.toString(i));
+                               Params bookmark = (Params) 
bookmarks.getSet(Integer.toString(i));
                                if (logDEBUG) {
-                    Core.logger.log(DefaultInfolet.class, "looking for 
bookmark [" + i + "]: getSet: " + bookmark, Logger.DEBUG);
+                                       Core.logger.log(DefaultInfolet.class, 
"looking for bookmark [" + i + "]: getSet: " + bookmark, Logger.DEBUG);
                                }
                                if (bookmark == null) {
                                        break;
@@ -261,25 +262,40 @@
                                String description = 
bookmark.getString("description");

                                String activelink = null;
-                if ((activelinkFile != null) && 
(activelinkFile.trim().length() > 0)) {
+                               if ((activelinkFile != null) && 
(activelinkFile.trim().length() > 0)) {
                                        if (key.endsWith("/"))
                                                activelink = key + 
activelinkFile;
-                    else if (key.indexOf('/') > 0) activelink = 
key.substring(0, key.lastIndexOf('/') + 1) + activelinkFile;
+                                       else if (key.indexOf('/') > 0)
+                                               activelink = key.substring(0, 
key.lastIndexOf('/') + 1) + activelinkFile;
                                }

                                if (logDEBUG) {
-                    Core.logger.log(DefaultInfolet.class, "Found full bookmark 
[" + i + "]: " + key + "/" + title + "/" + activelink + "/"
-                            + description, Logger.DEBUG);
+                                       Core.logger.log(DefaultInfolet.class, 
"Found full bookmark [" + i + "]: " + key + "/" + title + "/" + activelink + 
"/" + description, Logger.DEBUG);
                                }

-                               link.append("<tr><td><a 
href=\"/").append(key).append("\">\n");
+                               link
+                                       .append("<tr><td><a href=\"/")
+                                       .append(key)
+                                       .append("\">\n");
                                if (activelink != null)
-                        link.append("<img 
src=\"/").append(activelink).append("\" alt=\"").append(title).append(
-                                "\" width=\"95\" height=\"32\" />");
-                link.append("</a></td>\n");
-                link.append("<td><a 
href=\"/").append(key).append("\">").append(title).append("</a></td>\n");
+                                       link
+                                               .append("<img src=\"/")
+                                               .append(activelink)
+                                               .append("\" alt=\"")
+                                               .append(title)
+                                               .append("\" width=\"95\" 
height=\"32\" />");
+                               link.append("</a></td>\n");
+                               link
+                                       .append("<td><a href=\"/")
+                                       .append(key)
+                                       .append("\">")
+                                       .append(title)
+                                       .append("</a></td>\n");
                                if (description != null) {
-                    link.append("<td>").append(description).append("</td>\n");
+                                       link
+                                               .append("<td>")
+                                               .append(description)
+                                               .append("</td>\n");
                                }
                                link.append("</tr>\n");
                                i++;
@@ -290,24 +306,25 @@
        }

        private void backgroundFetch() {
-        Core.logger.log(this, "Starting background bookmark fetch", 
Logger.DEBUG);
-        if (bookmarks == null) Core.logger.log(DefaultInfolet.class, 
"Bookmarks null", Logger.DEBUG);
-        if (factory == null) Core.logger.log(DefaultInfolet.class, "Factory 
null", Logger.DEBUG);
+               Core.logger.log(this, "Starting background bookmark fetch", 
Logger.DEBUG);
+               if (bookmarks == null)
+                       Core.logger.log(DefaultInfolet.class, "Bookmarks null", 
Logger.DEBUG);
+               if (factory == null)
+                       Core.logger.log(DefaultInfolet.class, "Factory null", 
Logger.DEBUG);
                if (bookmarks != null && factory != null) {
+                       // Start background requests - we do not care whether 
they succeed
+                       int maxCount = -1;
+                       try {
+                               maxCount = bookmarks.getInt("count");
+                       } catch (Exception e) {
+                               maxCount = -1;
+                       }
+                       Core.logger.log(DefaultInfolet.class, "Bookmark max 
count: " + maxCount, Logger.DEBUG);

-               // Start background requests - we do not care whether they 
succeed
-               int maxCount = -1;
-               try {
-                       maxCount = bookmarks.getInt("count");
-               } catch (Exception e) {
-                       maxCount = -1;
-               }
-            Core.logger.log(DefaultInfolet.class, "Bookmark max count: " + 
maxCount, Logger.DEBUG);
-
                        int i = 0;
                        while (!((maxCount != -1) && (maxCount <= i))) {
-                Params bookmark = (Params) 
bookmarks.getSet(Integer.toString(i));
-                Core.logger.log(DefaultInfolet.class, "looking for bookmark [" 
+ i + "]: exists: " + (bookmark != null), Logger.DEBUG);
+                               Params bookmark = (Params) 
bookmarks.getSet(Integer.toString(i));
+                               Core.logger.log(DefaultInfolet.class, "looking 
for bookmark [" + i + "]: exists: " + (bookmark != null), Logger.DEBUG);
                                if (bookmark == null) {
                                        break;
                                }
@@ -322,12 +339,12 @@
                                        a.doGet(uri, new NullBucket(), 
Node.maxHopsToLive, true);
                                        // Now forget about it
                                } catch (MalformedURLException e) {
-                    Core.logger.log(this, "Malformed URI in bookmarks: " + 
key, Logger.NORMAL);
+                                       Core.logger.log(this, "Malformed URI in 
bookmarks: " + key, Logger.NORMAL);
                                }
                                i++;
                        }
                }
-        Core.logger.log(this, "Started background bookmark fetch", 
Logger.DEBUG);
+               Core.logger.log(this, "Started background bookmark fetch", 
Logger.DEBUG);
        }

        public void configPropertyUpdated(String path, String val) {
@@ -335,16 +352,16 @@
        }

        public void configPropertyUpdated(String path, Params fs) {
-        if (logDEBUG) Core.logger.log(DefaultInfolet.class, 
"configPropertyUpdated " + "called w/ path [" + path + "]: fs = " + fs, 
Logger.DEBUG);
+               if (logDEBUG)
+                       Core.logger.log(DefaultInfolet.class, 
"configPropertyUpdated " + "called w/ path [" + path + "]: fs = " + fs, 
Logger.DEBUG);
                Params newBookmarks = (Params) fs.getSet("bookmarks");
                if (newBookmarks != null) {
                        bookmarks = newBookmarks;
-            Core.logger.log(DefaultInfolet.class, "Bookmarks updated on 
request: new bookmarks: " + bookmarks.toString(), Logger.MINOR);
+                       Core.logger.log(DefaultInfolet.class, "Bookmarks 
updated on request: new bookmarks: " + bookmarks.toString(), Logger.MINOR);
                        backgroundFetch();
                } else {
                        bookmarks = null;
-            Core.logger.log(DefaultInfolet.class, "No bookmarks found!", new 
Exception("grrr"), Logger.ERROR);
+                       Core.logger.log(DefaultInfolet.class, "No bookmarks 
found!", new Exception("grrr"), Logger.ERROR);
                }
        }
-
 }


Reply via email to