Author: j16sdiz
Date: 2008-11-23 10:15:15 +0000 (Sun, 23 Nov 2008)
New Revision: 23824

Modified:
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
   trunk/freenet/src/freenet/clients/http/RedirectException.java
   trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java
Log:
simplify the code

Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2008-11-23 
02:48:39 UTC (rev 23823)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2008-11-23 
10:15:15 UTC (rev 23824)
@@ -100,15 +100,12 @@
                String ks = uri.getPath();
                
                if (ks.equals("/")||ks.startsWith("/servlet/")) {
-                       RedirectException re = new RedirectException();
                        try {
-                               re.newuri = new URI("/welcome/");
+                   throw new RedirectException("/welcome/");
                        } catch (URISyntaxException e) {
                                // HUH!?!
                        }
-                       throw re;
-               }
-               
+               }               
        }
 
        public static void handleDownload(ToadletContext context, Bucket data, 
BucketFactory bucketFactory, String mimeType, String requestedMimeType, String 
forceString, boolean forceDownload, String basePath, FreenetURI key, String 
extras, String referrer, boolean downloadLink, ToadletContext ctx, 
NodeClientCore core) throws ToadletContextClosedException, IOException {
@@ -355,21 +352,19 @@
                                return;
                        }
                        
-                       RedirectException re = new RedirectException();
                        try {
                                String querystring = uri.getQuery();
                                
                                if (querystring == null) {
-                                       re.newuri = welcome;
+                                       throw new RedirectException(welcome);
                                } else {
                                        // TODP possibly a proper URLEncode 
method
                                        querystring = querystring.replace(' ', 
'+');
-                                       re.newuri = new 
URI("/welcome/?"+querystring);
+                                       throw new 
RedirectException("/welcome/?" + querystring);
                                }
                        } catch (URISyntaxException e) {
                                // HUH!?!
                        }
-                       throw re;
                }else if(ks.equals("/favicon.ico")){
                        byte[] buf = new byte[1024];
                        int len;

Modified: trunk/freenet/src/freenet/clients/http/RedirectException.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/RedirectException.java       
2008-11-23 02:48:39 UTC (rev 23823)
+++ trunk/freenet/src/freenet/clients/http/RedirectException.java       
2008-11-23 10:15:15 UTC (rev 23824)
@@ -4,6 +4,7 @@
 package freenet.clients.http;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 
 public class RedirectException extends Exception {
        private static final long serialVersionUID = -1;
@@ -12,9 +13,12 @@
        public RedirectException() {
                super();
        }
+
+       public RedirectException(String newURI) throws URISyntaxException {
+               this.newuri = new URI(newURI);
+       }
        
        public RedirectException(URI newURI) {
                this.newuri = newURI;
        }
-
 }

Modified: trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java        
2008-11-23 02:48:39 UTC (rev 23823)
+++ trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java        
2008-11-23 10:15:15 UTC (rev 23824)
@@ -142,10 +142,8 @@
                }
                
                uri.getRawQuery();
-            
-               RedirectException re = new RedirectException();
-               re.newuri = outuri;
-               throw re;
+           
+               throw new RedirectException(outuri);
        }
        
 }

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

Reply via email to