Author: nextgens
Date: 2007-12-03 11:12:23 +0000 (Mon, 03 Dec 2007)
New Revision: 16213

Modified:
   trunk/apps/Echo/src/plugins/echo/Echo.java
Log:
Echo: some refactoring

Modified: trunk/apps/Echo/src/plugins/echo/Echo.java
===================================================================
--- trunk/apps/Echo/src/plugins/echo/Echo.java  2007-12-03 11:08:26 UTC (rev 
16212)
+++ trunk/apps/Echo/src/plugins/echo/Echo.java  2007-12-03 11:12:23 UTC (rev 
16213)
@@ -140,9 +140,39 @@

        }

+       public String handleHTTPGet(HTTPRequest request) throws 
PluginHTTPException {
+               if ("/plugins/plugins.echo.Echo".equals(request.getPath()))
+                       throw new RedirectPluginHTTPException("", 
"/plugins/plugins.echo.Echo/");
+                       
+               String fileName = (new File(request.getPath())).getName();
+               
+               if ("edit.css".equals(fileName) || 
"echo-logo-small-0.1.png".equals(fileName)) {
+                       
+                       try {
+                               InputStream in = 
getClass().getResourceAsStream("/" + fileName);

-       private String handleHTTPRequest(HTTPRequest request) {
+                               int read;
+                               int off = 0;
+                               byte[] buffer = new byte[in.available()];
+                               while((read = in.read(buffer, off, 
in.available())) != 0) {
+                                       off+=read;
+                               }
+
+                               throw new DownloadPluginHTTPException(buffer, 
fileName, ("edit.css".equals(fileName)) ? "text/css" : "image/png");
+                       } catch (IOException ioe) {
+                               return ioe.getMessage();
+                       }
+                       
+               }

+               throw new PluginHTTPException("Unable to handle the request!", 
"/plugins/plugins.echo.Echo/");
+       }
+       
+       public String handleHTTPPut(HTTPRequest request) throws 
PluginHTTPException {
+               return "Put";
+       }
+       
+       public String handleHTTPPost(HTTPRequest request) throws 
PluginHTTPException {  
                try {
                        String fileName = (new 
File(request.getPath())).getName();
                        Page p;
@@ -172,40 +202,4 @@
                        return e.toString();
                }
        }
-       
-       public String handleHTTPGet(HTTPRequest request) throws 
PluginHTTPException {
-
-               if ("/plugins/plugins.echo.Echo".equals(request.getPath()))
-                       throw new RedirectPluginHTTPException("", 
"/plugins/plugins.echo.Echo/");
-                       
-               String fileName = (new File(request.getPath())).getName();
-               
-               if ("edit.css".equals(fileName) || 
"echo-logo-small-0.1.png".equals(fileName)) {
-                       
-                       try {
-                               InputStream in = 
getClass().getResourceAsStream("/" + fileName);
-
-                               int read;
-                               int off = 0;
-                               byte[] buffer = new byte[in.available()];
-                               while((read = in.read(buffer, off, 
in.available())) != 0) {
-                                       off+=read;
-                               }
-
-                               throw new DownloadPluginHTTPException(buffer, 
fileName, ("edit.css".equals(fileName)) ? "text/css" : "image/png");
-                       } catch (IOException ioe) {
-                               return ioe.getMessage();
-                       }
-                       
-               } else
-                       return handleHTTPRequest(request);
-       }
-       
-       public String handleHTTPPut(HTTPRequest request) throws 
PluginHTTPException {
-               return "Put";
-       }
-       
-       public String handleHTTPPost(HTTPRequest request) throws 
PluginHTTPException {          
-               return handleHTTPRequest(request);
-       }
 }
\ No newline at end of file


Reply via email to