yeehah, got kona compiling again. didn't even know it was having issues.
authorChris Koeritz <fred@gruntose.com>
Sat, 8 Sep 2012 20:02:23 +0000 (16:02 -0400)
committerChris Koeritz <fred@gruntose.com>
Sat, 8 Sep 2012 20:02:23 +0000 (16:02 -0400)
kona/src/org/feistymeow/dragdrop/dragdrop_list_test.java
kona/src/org/feistymeow/networking/BasicWebServer.java
kona/src/org/feistymeow/process/ethread.java
kona/src/org/feistymeow/windowing/ExitListener.java

index afe630298f5e9aeab05ba5b800125af483ec8acb..2775560e6d6045b531c60e07b579755b80facc82 100644 (file)
@@ -21,14 +21,15 @@ import org.apache.log4j.PropertyConfigurator;
  * @license This file is free software; you can modify and redistribute it under the terms of the
  *          Apache License v2.0: http://www.apache.org/licenses/LICENSE-2.0
  */
-@SuppressWarnings("serial")
+@SuppressWarnings({"serial", "rawtypes"})
 public class dragdrop_list_test extends JFrame implements ListSelectionListener
 {
     private DraggableDroppableList list;
     private JTextField fileName;
     static private Log logger = LogFactory.getLog(dragdrop_list_test.DraggableDroppableList.class);
 
-    public dragdrop_list_test(String startPath)
+    @SuppressWarnings("unchecked")
+       public dragdrop_list_test(String startPath)
     {
         super("dragdrop_test");
 
@@ -97,7 +98,8 @@ public class dragdrop_list_test extends JFrame implements ListSelectionListener
 
     public class DraggableDroppableList extends JList implements IDragonDropDataProvider
     {
-        public DraggableDroppableList()
+        @SuppressWarnings("unchecked")
+               public DraggableDroppableList()
         {
             setModel(new DefaultListModel());
             setTransferHandler(new DragonTransferHandler(this));
index 7e374298ecc717af030d92c179b6c1c186de9b55..8e6685a9e1f11be7ad805ab0b71a0fc3bacef677 100644 (file)
@@ -7,8 +7,6 @@ import java.net.*;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.feistymeow.dragdrop.ListTransferable;
-
 /**
  * Provides a lightweight way for RNS structures to be accessible over http.
  * 
@@ -20,7 +18,8 @@ import org.feistymeow.dragdrop.ListTransferable;
  * http://cs.fit.edu/~mmahoney/cse3103/java/Webserver.java
  */
 
-public class BasicWebServer {
+public class BasicWebServer
+{
        static private Log logger = LogFactory.getLog(BasicWebServer.class);
 
        private int port;
@@ -28,11 +27,13 @@ public class BasicWebServer {
        servingThread socketThread;
        private ServerSocket realSocket;
 
-       BasicWebServer(int portIn) {
+       BasicWebServer(int portIn)
+       {
                port = portIn;
        }
 
-       public void shutDown() {
+       public void shutDown()
+       {
                leaving = true;
                if (realSocket != null) {
                        try {
@@ -45,18 +46,21 @@ public class BasicWebServer {
                }
        }
 
-       public class servingThread implements Runnable {
+       public class servingThread implements Runnable
+       {
                private Thread thread;
                private ServerSocket serverSocket;
 
-               servingThread(ServerSocket socket) {
+               servingThread(ServerSocket socket)
+               {
                        serverSocket = socket;
                        thread = new Thread(this);
                        thread.start();
                }
 
                @Override
-               public void run() {
+               public void run()
+               {
                        while (!leaving) {
                                try {
                                        logger.debug("about to accept on server socket.");
@@ -66,16 +70,15 @@ public class BasicWebServer {
                                        new ClientHandler(s); // Handle the client in a separate
                                                                                        // thread
                                } catch (Throwable cause) {
-                                       logger.error(
-                                                       "exception raised while handling accepted socket",
-                                                       cause);
+                                       logger.error("exception raised while handling accepted socket", cause);
                                }
                        }
                }
        }
 
        // enums for outcomes? really need better reporting.
-       public int startServing() {
+       public int startServing()
+       {
                if (socketThread != null)
                        return 1; // already running outcome.
                try {
@@ -89,42 +92,42 @@ public class BasicWebServer {
                return 0;
        }
 
-       public String predictMimeType(String filename) {
+       public String predictMimeType(String filename)
+       {
 
                // kludge to try one type:
                return "text/plain;charset=utf-8";
 
                /*
                 * 
-                * if (filename.endsWith(".html") || filename.endsWith(".htm")) return
-                * "text/html"; if (filename.endsWith(".jpg") ||
-                * filename.endsWith(".jpeg")) return "image/jpeg"; if
-                * (filename.endsWith(".gif")) return "image/gif"; if
-                * (filename.endsWith(".class")) return "application/octet-stream";
-                * return "text/plain";
+                * if (filename.endsWith(".html") || filename.endsWith(".htm")) return "text/html"; if
+                * (filename.endsWith(".jpg") || filename.endsWith(".jpeg")) return "image/jpeg"; if
+                * (filename.endsWith(".gif")) return "image/gif"; if (filename.endsWith(".class")) return
+                * "application/octet-stream"; return "text/plain";
                 */
        }
 
        // A ClientHandler reads an HTTP request and responds
-       class ClientHandler extends Thread {
+       class ClientHandler extends Thread
+       {
                private Socket socket; // The accepted socket from the Webserver
 
                // Start the thread in the constructor
-               public ClientHandler(Socket s) {
+               public ClientHandler(Socket s)
+               {
                        socket = s;
                        start();
                }
 
                // Read the HTTP request, respond, and close the connection
-               public void run() {
+               public void run()
+               {
                        try {
                                logger.debug("into client run(): listening for gets.");
 
                                // Open connections to the socket
-                               BufferedReader in = new BufferedReader(new InputStreamReader(
-                                               socket.getInputStream()));
-                               PrintStream out = new PrintStream(new BufferedOutputStream(
-                                               socket.getOutputStream()));
+                               BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+                               PrintStream out = new PrintStream(new BufferedOutputStream(socket.getOutputStream()));
 
                                // Read filename from first input line "GET /filename.html ..."
                                // or if not in this format, treat as a file not found.
@@ -142,12 +145,9 @@ public class BasicWebServer {
                                        // get the command first.
                                        String command = st.nextToken();
                                        // Parse the filename from the command.
-                                       if (st.hasMoreElements() && command.equalsIgnoreCase("GET")
-                                                       && st.hasMoreElements()) {
+                                       if (st.hasMoreElements() && command.equalsIgnoreCase("GET") && st.hasMoreElements()) {
                                                filename = st.nextToken();
-                                       } else if (st.hasMoreElements()
-                                                       && command.equalsIgnoreCase("HEAD")
-                                                       && st.hasMoreElements()) {
+                                       } else if (st.hasMoreElements() && command.equalsIgnoreCase("HEAD") && st.hasMoreElements()) {
                                                filename = st.nextToken();
                                                transferFile = false; // don't need to do that, just the
                                                                                                // header.
@@ -175,23 +175,18 @@ public class BasicWebServer {
 
                                        // Check for illegal characters to prevent access to
                                        // superdirectories
-                                       if (filename.indexOf("..") >= 0
-                                                       || filename.indexOf(':') >= 0
-                                                       || filename.indexOf('|') >= 0)
+                                       if (filename.indexOf("..") >= 0 || filename.indexOf(':') >= 0 || filename.indexOf('|') >= 0)
                                                throw new FileNotFoundException();
 
                                        logger.info("got past filename checks for: " + filename);
 
                                        /*
-                                        * this doesn't actually check that trailing slash is
-                                        * missing! // If a directory is requested and the trailing
-                                        * / is missing, // send the client an HTTP request to
-                                        * append it. (This is // necessary for relative links to
-                                        * work correctly in the client). if ((new
-                                        * GeniiPath(filename)).isDirectory()) {
-                                        * out.print("HTTP/1.0 301 Moved Permanently\r\n" +
-                                        * "Location: /" + filename + "/\r\n\r\n"); out.close();
-                                        * return; }
+                                        * this doesn't actually check that trailing slash is missing! // If a directory
+                                        * is requested and the trailing / is missing, // send the client an HTTP
+                                        * request to append it. (This is // necessary for relative links to work
+                                        * correctly in the client). if ((new GeniiPath(filename)).isDirectory()) {
+                                        * out.print("HTTP/1.0 301 Moved Permanently\r\n" + "Location: /" + filename +
+                                        * "/\r\n\r\n"); out.close(); return; }
                                         */
 
                                        // trying to get around worrying about mime types by saying
@@ -201,30 +196,26 @@ public class BasicWebServer {
 
                                        File source = new File(filename);
                                        if (!source.exists()) {
-                                               logger.error("source does not exist for serving: "
-                                                               + filename);
+                                               logger.error("source does not exist for serving: " + filename);
                                                // do something!
                                                // hmmm: below could be abstracted to more general
                                                // denial method.
-                                               out.println("HTTP/1.1 404 Not Found\r\n"
-                                                               + "Content-type: text/html\r\n\r\n"
-                                                               + "<html><head></head><body>" + filename
-                                                               + " not found</body></html>\n");
+                                               out.println("HTTP/1.1 404 Not Found\r\n" + "Content-type: text/html\r\n\r\n"
+                                                       + "<html><head></head><body>" + filename + " not found</body></html>\n");
                                                out.close();
 
                                        }
-                                       out.print("HTTP/1.1 200 OK\r\n" + "Content-type: "
-                                                       + mimeType + "\r\n" + "Connection: close" + "\r\n"
-                                                       // // + "\r\nContent-Length: " + source.size? +
-                                                       // "\r\n"
-                                                       + "\r\n");
+                                       out.print("HTTP/1.1 200 OK\r\n" + "Content-type: " + mimeType + "\r\n" + "Connection: close" + "\r\n"
+                                       // // + "\r\nContent-Length: " + source.size? +
+                                       // "\r\n"
+                                               + "\r\n");
                                        if (!transferFile) {
                                                logger.debug("closing stream for finished HEAD request.");
                                                out.close();
                                                return;
                                        }
                                        logger.debug("moving to handle GET request.");
-                                       InputStream f = source.openInputStream();
+                                       FileInputStream f = new FileInputStream(filename);
                                        logger.debug("opened stream on source");
                                        // Send file contents to client, then close the connection.
                                        byte[] a = new byte[4096];
@@ -235,15 +226,12 @@ public class BasicWebServer {
                                        out.close();
                                } catch (FileNotFoundException x) {
                                        logger.error("failed to find requested file: " + filename);
-                                       out.println("HTTP/1.1 404 Not Found\r\n"
-                                                       + "Content-type: text/html\r\n\r\n"
-                                                       + "<html><head></head><body>" + filename
-                                                       + " not found</body></html>\n");
+                                       out.println("HTTP/1.1 404 Not Found\r\n" + "Content-type: text/html\r\n\r\n" + "<html><head></head><body>"
+                                               + filename + " not found</body></html>\n");
                                        out.close();
                                }
                        } catch (IOException x) {
-                               logger.error("exception blew out in outer area of web server",
-                                               x);
+                               logger.error("exception blew out in outer area of web server", x);
                                // / System.out.println(x);
                        }
                }
index 0f2e860f987f316746187c2893766040f051106f..280a08305dd39d9495022ec86835c3b8155a1e06 100644 (file)
@@ -5,15 +5,6 @@ package org.feistymeow.process;
 // not compilable yet probably, 
 // plus missing the timed features of ethread.
 
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -32,6 +23,7 @@ class ethread implements Runnable
   // the only variable on which both synchronize is the "thread finished" variable.
   public ethread()
   {
+         c_logger.warn("this class needs to be implemented and used in an example.");
   }
 
   /**
index f53b0e29f2697d2f12ea29cf0d992e3c35109898..2dd19f397cee977c4a6bdbf0d0681b4f6049c795 100644 (file)
@@ -1,6 +1,5 @@
 package org.feistymeow.windowing;\r
 \r
-import java.awt.*;\r
 import java.awt.event.*;\r
 \r
 /** A listener that you attach to the top-level Frame or JFrame of\r