Index: src/edu/ucsb/nceas/metacat/MetacatReplication.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatReplication.java	(revision 553)
+++ src/edu/ucsb/nceas/metacat/MetacatReplication.java	(revision 554)
@@ -89,6 +89,7 @@
       { //stop the replication server
         replicationDaemon.cancel();
         out.println("Replication Handler Stopped");
+        System.out.println("Replication Handler Stopped");
       }
       else if(((String[])params.get("action"))[0].equals("start"))
       { //start the replication server
@@ -182,6 +183,13 @@
     sql.append("to_date('").append(dateString).append("','YY-MM-DD HH24:MI:SS')");
     //System.out.println("sql: " + sql.toString());
     
+    //get any recently deleted documents
+    StringBuffer delsql = new StringBuffer();
+    delsql.append("select docid, date_created, server_location from ");
+    delsql.append("xml_revisions where docid not in (select docid from ");
+    delsql.append("xml_documents) and date_created > to_date('");
+    delsql.append(dateString).append("','YY-MM-DD HH24:MI:SS')");
+
     try
     {
       Connection conn = util.openDBConnection();
@@ -210,6 +218,25 @@
         }
         tablehasrows = rs.next();
       }
+      
+      pstmt = conn.prepareStatement(delsql.toString());
+      pstmt.execute();
+      rs = pstmt.getResultSet();
+      tablehasrows = rs.next();
+      while(tablehasrows)
+      { //handle the deleted documents
+        String docid = rs.getString(1);
+        String dateUpdated = rs.getString(2);
+        int serverCode = rs.getInt(3);
+        if(serverCode == 1)
+        {
+          returnXML.append("<deletedDocument><docid>").append(docid);
+          returnXML.append("</docid><date_updated>").append(dateUpdated);
+          returnXML.append("</date_updated></deletedDocument>");
+        }
+        tablehasrows = rs.next();
+      }
+      
       returnXML.append("</updates></replication>");
       conn.close();
       //System.out.println(returnXML.toString());
Index: src/edu/ucsb/nceas/metacat/ReplMessageHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ReplMessageHandler.java	(revision 553)
+++ src/edu/ucsb/nceas/metacat/ReplMessageHandler.java	(revision 554)
@@ -34,7 +34,11 @@
 {
   private Vector updates = new Vector();
   private Vector indivUpdate = new Vector();
+  private Vector indivDelete = new Vector();
+  private Vector deletes = new Vector();
   private String server;
+  private boolean update = false;
+  private boolean delete = false;
   String currentTag = new String();
   
   public ReplMessageHandler()
@@ -51,7 +55,13 @@
     if(localName.equals("updatedDocument"))
     {
       indivUpdate = new Vector();
+      update = true;
     }
+    else if(localName.equals("deletedDocument"))
+    {
+      indivDelete = new Vector();
+      delete = true;
+    }
   }
   
   /**
@@ -63,7 +73,13 @@
     if(localName.equals("updatedDocument"))
     {
       updates.add(new Vector(indivUpdate));
+      update = false;
     }
+    else if(localName.equals("deletedDocument"))
+    {
+      deletes.add(new Vector(indivDelete));
+      delete = false;
+    }
   }
   
   /**
@@ -71,15 +87,26 @@
    */
   public void characters(char[] ch, int start, int length) throws SAXException
   {
-    if(currentTag.equals("docid"))
+    if(currentTag.equals("docid") && update)
     {
       indivUpdate.add(new String(ch, start, length));
     }
-    if(currentTag.equals("date_updated"))
+    else if(currentTag.equals("docid") && delete)
     {
+      indivDelete.add(new String(ch, start, length));
+    }
+    
+    if(currentTag.equals("date_updated") && update)
+    {
       indivUpdate.add(new String(ch, start, length));
       indivUpdate.add(server);
     }
+    else if(currentTag.equals("date_updated") && delete)
+    {
+      indivDelete.add(new String(ch, start, length));
+      indivDelete.add(server);
+    }
+    
     if(currentTag.equals("server"))
     {
       server = new String(ch, start, length);
@@ -86,9 +113,14 @@
     }
   }
   
-  public Vector getResultVect()
+  public Vector getUpdatesVect()
   {
     return updates;
   }
   
+  public Vector getDeletesVect()
+  {
+    return deletes;
+  }
+  
 }
Index: src/edu/ucsb/nceas/metacat/ReplicationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 553)
+++ src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 554)
@@ -132,7 +132,8 @@
         parser.parse(new InputSource(
                      new StringReader(
                      (String)(responses.elementAt(i)))));
-        Vector v = new Vector(message.getResultVect());
+        Vector v = new Vector(message.getUpdatesVect());
+        Vector d = new Vector(message.getDeletesVect());
         for(int j=0; j<v.size(); j++)
         { //go through each update vector and update or insert
           //a new document
@@ -193,6 +194,14 @@
             System.out.println("newDocid: " + newDocid + " " + action + "ED");
           }
         }
+        
+        for(int k=0; k<d.size(); k++)
+        {
+          Vector w = new Vector((Vector)d.elementAt(k));
+          String docid = (String)w.elementAt(0);
+          
+          DocumentImpl.delete(conn, docid, null, null);
+        }
       }
 
       //update the last_update field for each server to the current date/time      
