Index: src/edu/ucsb/nceas/metacat/ReplicationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 1010)
+++ src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 1011)
@@ -114,7 +114,7 @@
     }
     catch (Exception e)
     {
-      System.out.println("Error in replicationHandler.run(): " + e.getMessage());
+      //System.out.println("Error in replicationHandler.run():"+e.getMessage());
     }
   }
   
@@ -159,9 +159,9 @@
           }
           catch(SQLException sqleee)
           {
-            System.out.println("error getting db connection in " + 
+            /*System.out.println("error getting db connection in " + 
                                "ReplicationHandler.update: " +
-                               sqleee.getMessage());
+                               sqleee.getMessage());*/
           }
         }
       }
@@ -168,8 +168,8 @@
     }
     catch(Exception e)
     {
-      System.out.println("error in ReplicationHandler.update: " + 
-                          e.getMessage());
+      /*System.out.println("error in ReplicationHandler.update: " + 
+                          e.getMessage());*/
     }
     
     Enumeration keys;
@@ -194,8 +194,9 @@
       {
         server = (String)(keys.nextElement());
         MetacatReplication.replLog("full update started to: " + server);
-        u = new URL("https://" + server + "?action=update");
-        System.out.println("Sending Message: " + u.toString());
+        u = new URL("https://" + server + "?server="
+        +getLocalReplicationServerName()+"&action=update");
+        //System.out.println("Sending Message: " + u.toString());
         String result = MetacatReplication.getURLContent(u);
         responses.add(result);
       }
@@ -253,21 +254,25 @@
           
           if(flag)
           { //if the document needs to be updated or inserted, this is executed
-            u = new URL("https://" + docServer + "?action=read&docid=" +
-                          docid);
-            System.out.println("Sending message: " + u.toString());
+            u = new URL("https://" + docServer + "?server="+
+                  getLocalReplicationServerName()+"&action=read&docid="+docid);
+            //System.out.println("Sending message: " + u.toString());
             String newxmldoc = MetacatReplication.getURLContent(u);
             DocInfoHandler dih = new DocInfoHandler();
             XMLReader docinfoParser = initParser(dih);
             URL docinfoUrl = new URL("https://" + docServer + 
-                                   "?action=getdocumentinfo&docid=" +
-                                   docid);
-            System.out.println("Sending message: " + docinfoUrl.toString());
+                  "?server="+getLocalReplicationServerName()+
+                  "&action=getdocumentinfo&docid="+docid);
+            //System.out.println("Sending message: " + docinfoUrl.toString());
             String docInfoStr = MetacatReplication.getURLContent(docinfoUrl);
             docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
             Hashtable docinfoHash = dih.getDocInfo();
             int serverCode = MetacatReplication.getServerCode(docServer);
-            System.out.println("updating doc: " + docid + " action: "+ action);
+            //System.out.println("updating doc: " + docid +" action: "+ action);
+            //docid should include rev number too
+            String accnum=docid+util.getOption("accNumSeparator")+
+                                              (String)docinfoHash.get("rev");
+            //System.out.println("accnum: "+accnum);
             try
             {
               String newDocid = DocumentImpl.write(conn, 
@@ -275,7 +280,7 @@
                               (String)docinfoHash.get("public_access"),
                               null,  /* the dtd text */
                               action, 
-                              docid, 
+                              accnum, 
                               (String)docinfoHash.get("user_owner"),
                               null, /* null for groups[] */
                               serverCode, 
@@ -283,8 +288,8 @@
                               false /* validate */);
               MetacatReplication.replLog("wrote doc " + docid + " from " + 
                                          docServer);
-              System.out.println("wrote doc " + docid + " from " + 
-                                 docServer);
+              /*System.out.println("wrote doc " + docid + " from " + 
+                                 docServer);*/
             }
             catch(Exception e)
             {
@@ -311,7 +316,8 @@
         while(keys.hasMoreElements())
         {
           server = (String)(keys.nextElement()); 
-          URL dateurl = new URL("https://" + server + "?action=gettime");
+          URL dateurl = new URL("https://" + server + "?server="+
+          getLocalReplicationServerName()+"&action=gettime");
           String datexml = MetacatReplication.getURLContent(dateurl);
           String datestr = datexml.substring(11, datexml.indexOf('<', 11));
           StringBuffer sql = new StringBuffer();
@@ -330,8 +336,8 @@
     }
     catch(Exception e)
     {
-      System.out.println("error in ReplicationHandler.update: " + 
-                          e.getMessage());
+      /*System.out.println("error in ReplicationHandler.update: " + 
+                          e.getMessage());*/
       e.printStackTrace(System.out);
     }
     finally
@@ -382,7 +388,8 @@
       while(keys.hasMoreElements())
       { //go through each server
         server = (String)(keys.nextElement());
-        URL u = new URL("https://" + server + "?action=getcatalog");
+        URL u = new URL("https://" + server + "?server="+
+        getLocalReplicationServerName()+"&action=getcatalog");
         System.out.println("sending message " + u.toString());
         String catxml = MetacatReplication.getURLContent(u);
         //System.out.println("catxml: " + catxml);
@@ -628,4 +635,20 @@
 
     return parser;
   }
+  
+  /**
+   * Method to get the name of local replication server
+   */
+   private String getLocalReplicationServerName()
+   {
+     String replicationServerName=null;
+     String serverHost=null;
+     serverHost=util.getOption("server");
+     // append "context/servelet/replication" to the host name
+     replicationServerName=serverHost+"/"+util.getOption("context")+
+                                            "/servlet/replication";
+     return replicationServerName;
+       
+   }
 }
+   
