Index: src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2101)
+++ src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2102)
@@ -402,19 +402,19 @@
                 }
             } else if (action.equals("export")) {
 
-                handleExportAction(params, response, username, groupnames,
-                        password);
+                handleExportAction(params, response, username, 
+                        groupnames, password);
             } else if (action.equals("read")) {
-                handleReadAction(params, response, username, password,
+                handleReadAction(params, request, response, username, password,
                         groupnames);
             } else if (action.equals("readinlinedata")) {
-                handleReadInlineDataAction(params, response, username,
+                handleReadInlineDataAction(params, request, response, username,
                         password, groupnames);
             } else if (action.equals("insert") || action.equals("update")) {
                 PrintWriter out = response.getWriter();
                 if ((username != null) && !username.equals("public")) {
-                    handleInsertOrUpdateAction(out, params, username,
-                            groupnames);
+                    handleInsertOrUpdateAction(request, response,
+                            out, params, username, groupnames);
                 } else {
                     out.println("Permission denied for user " + username + " "
                             + action);
@@ -423,7 +423,7 @@
             } else if (action.equals("delete")) {
                 PrintWriter out = response.getWriter();
                 if ((username != null) && !username.equals("public")) {
-                    handleDeleteAction(out, params, response, username,
+                    handleDeleteAction(out, params, request, response, username,
                             groupnames);
                 } else {
                     out.println("Permission denied for " + action);
@@ -695,9 +695,9 @@
      * @param user the username sent the request
      * @param groups the user's groupnames
      */
-    private void handleExportAction(Hashtable params,
-            HttpServletResponse response, String user, String[] groups,
-            String passWord)
+    private void handleExportAction(Hashtable params, 
+            HttpServletResponse response, 
+            String user, String[] groups, String passWord)
     {
         // Output stream
         ServletOutputStream out = null;
@@ -786,8 +786,8 @@
      * @param groups the user's groupnames
      */
     private void handleReadInlineDataAction(Hashtable params,
-            HttpServletResponse response, String user, String passWord,
-            String[] groups)
+            HttpServletRequest request, HttpServletResponse response, 
+            String user, String passWord, String[] groups)
     {
         String[] docs = new String[10];
         String inlineDataId = null;
@@ -816,15 +816,16 @@
                         + " doesn't have permission " + " to read document "
                         + docId);
             } else if (controller.hasSubTreeAccessControl()) {
-                // if the document has subtree control, we need to check subtree
-                // control
+                // if the document has subtree control, we need to check 
+                // subtree control
                 // get node id for inlinedata
                 long nodeId = getInlineDataNodeId(inlineDataId, docId);
                 if (!controller.hasPermissionForSubTreeNode(user, groups,
-                        AccessControlInterface.READSTRING, nodeId)) { throw new Exception(
-                        "User " + user + " doesn't have permission "
-                                + " to read inlinedata " + inlineDataId); }//if
-
+                    AccessControlInterface.READSTRING, nodeId)) { 
+                    throw new Exception(
+                    "User " + user + " doesn't have permission "
+                    + " to read inlinedata " + inlineDataId); 
+                }
             }
 
             // Get output stream
@@ -841,6 +842,8 @@
             }
             out.close();
 
+            EventLog.getInstance().log(request.getRemoteAddr(), user, 
+                    inlineDataId, "readinlinedata");
         } catch (Exception e) {
             try {
                 PrintWriter pw = null;
@@ -928,11 +931,12 @@
      * presentation if requested; zip files when more than one were requested.
      * 
      * @param params the Hashtable of HTTP request parameters
+     * @param request the HTTP request object linked to the client
      * @param response the HTTP response object linked to the client
      * @param user the username sent the request
      * @param groups the user's groupnames
      */
-    private void handleReadAction(Hashtable params,
+    private void handleReadAction(Hashtable params, HttpServletRequest request,
             HttpServletResponse response, String user, String passWord,
             String[] groups)
     {
@@ -982,9 +986,9 @@
                         // get only docid, eliminate the rest
                         docid = (String) murlQueryStr.get("docid");
                         if (zip) {
-                            addDocToZip(docid, zout, user, groups);
+                            addDocToZip(request, docid, zout, user, groups);
                         } else {
-                            readFromMetacat(response, docid, qformat,
+                            readFromMetacat(request, response, docid, qformat,
                                     abstrpath, user, groups, zip, zout,
                                     withInlineData, params);
                         }
@@ -993,7 +997,7 @@
                     } else {
                         docid = docs[i];
                         if (zip) {
-                            addDocToZip(docid, zout, user, groups);
+                            addDocToZip(request, docid, zout, user, groups);
                         } else {
                             readFromURLConnection(response, docid);
                         }
@@ -1000,13 +1004,13 @@
                     }
                     
                 } catch (MalformedURLException mue) {
-                    MetaCatUtil.debugMessage("MUE handleReadAction", 5);
                     docid = docs[i];
                     if (zip) {
-                        addDocToZip(docid, zout, user, groups);
+                        addDocToZip(request, docid, zout, user, groups);
                     } else {
-                        readFromMetacat(response, docid, qformat, abstrpath,
-                            user, groups, zip, zout, withInlineData, params);
+                        readFromMetacat(request, response, docid, qformat, 
+                                abstrpath, user, groups, zip, zout, 
+                                withInlineData, params);
                     }
                 }
             }
@@ -1122,11 +1126,12 @@
 
     /** read metadata or data from Metacat 
      */
-    private void readFromMetacat(HttpServletResponse response, String docid,
-            String qformat, String abstrpath, String user, String[] groups,
-            boolean zip, ZipOutputStream zout, boolean withInlineData,
-            Hashtable params) throws ClassNotFoundException, IOException,
-            SQLException, McdbException, Exception
+    private void readFromMetacat(HttpServletRequest request, 
+            HttpServletResponse response, String docid, String qformat,
+            String abstrpath, String user, String[] groups, boolean zip,
+            ZipOutputStream zout, boolean withInlineData, Hashtable params)
+            throws ClassNotFoundException, IOException, SQLException,
+            McdbException, Exception
     {
 
         try {
@@ -1202,7 +1207,7 @@
                 }
 
             }
-            EventLog.getInstance().log("192.168.1.103", "public", 
+            EventLog.getInstance().log(request.getRemoteAddr(), user, 
                     docid, "read");
         } catch (Exception except) {
             throw except;
@@ -1272,9 +1277,10 @@
      * @throws McdbException
      * @throws Exception
      */
-    private void addDocToZip(String docid, ZipOutputStream zout, String user,
-            String[] groups) throws ClassNotFoundException, IOException,
-            SQLException, McdbException, Exception
+    private void addDocToZip(HttpServletRequest request, String docid, 
+            ZipOutputStream zout, String user, String[] groups) throws
+            ClassNotFoundException, IOException, SQLException, McdbException,
+            Exception
     {
         byte[] bytestring = null;
         ZipEntry zentry = null;
@@ -1347,7 +1353,7 @@
                     zout.write(bytestring, 0, bytestring.length);
                     zout.closeEntry();
                 }
-                EventLog.getInstance().log("192.168.1.103", "public", 
+                EventLog.getInstance().log(request.getRemoteAddr(), user, 
                         docid, "read");
             } catch (Exception except) {
                 throw except;
@@ -1390,7 +1396,8 @@
      * Handle the database putdocument request and write an XML document to the
      * database connection
      */
-    private void handleInsertOrUpdateAction(PrintWriter out, Hashtable params,
+    private void handleInsertOrUpdateAction(HttpServletRequest request,
+            HttpServletResponse response, PrintWriter out, Hashtable params,
             String user, String[] groups)
     {
         DBConnection dbConn = null;
@@ -1469,17 +1476,18 @@
                                 + accNumber + "...", 10);
                         if (accNumber.equals("")) {
                             accNumber = null;
-                        }//if
+                        }
                         newdocid = documentWrapper.write(dbConn, xml, pub, dtd,
                                 doAction, accNumber, user, groups);
-
-                    }//try
-                    catch (NullPointerException npe) {
+                        EventLog.getInstance().log(request.getRemoteAddr(), 
+                                user, accNumber, action[0]);
+                    } catch (NullPointerException npe) {
                         newdocid = documentWrapper.write(dbConn, xml, pub, dtd,
                                 doAction, null, user, groups);
-                    }//catch
-
-                }//try
+                        EventLog.getInstance().log(request.getRemoteAddr(), 
+                                user, "", action[0]);
+                    }
+                }
                 finally {
                     // Return db connection
                     DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1700,7 +1708,8 @@
      * database connection
      */
     private void handleDeleteAction(PrintWriter out, Hashtable params,
-            HttpServletResponse response, String user, String[] groups)
+            HttpServletRequest request, HttpServletResponse response, 
+            String user, String[] groups)
     {
 
         String[] docid = (String[]) params.get("docid");
@@ -1713,6 +1722,8 @@
             // BEFORE ACCESSING ARRAY
             try {
                 DocumentImpl.delete(docid[0], user, groups);
+                EventLog.getInstance().log(request.getRemoteAddr(), 
+                    user, docid[0], "delete");
                 response.setContentType("text/xml");
                 out.println("<?xml version=\"1.0\"?>");
                 out.println("<success>");
@@ -2148,6 +2159,8 @@
                         File newFile = new File(dataDirectory, docid);
                         long size = filePart.writeTo(newFile);
 
+                        EventLog.getInstance().log(request.getRemoteAddr(), 
+                                username, docid, "upload");
                         // Force replication this data file
                         // To data file, "insert" and update is same
                         // The fourth parameter is null. Because it is
