Index: src/edu/ucsb/nceas/metacat/DocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 1068)
+++ src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 1069)
@@ -504,8 +504,8 @@
     }
     
     //make sure user have file lock grant(local metacat means have it too)
-    if (getDataFileLockGrant(accnum))
-    {
+    //if (getDataFileLockGrant(accnum))
+    //{
       //register data file into xml_documents table
       registerDocumentInReplication(docname, doctype, accnum, user, serverCode);
       //write inputstream into file system.
@@ -531,7 +531,7 @@
 	    outPut.close();
 	    fos.close();
     
-    }//if
+    //}//if
  }
   
 
@@ -1187,6 +1187,7 @@
       if (action.equals("INSERT")) {
         //AccessionNumber ac = new AccessionNumber();
         //this.docid = ac.generate(docid, "INSERT");
+        System.out.println("before pstmt");
         pstmt = conn.prepareStatement(
                 "INSERT INTO xml_documents " +
                 "(docid, rootnodeid, docname, doctype, " + 
@@ -1205,13 +1206,15 @@
         pstmt.setString(4, doctype);
         pstmt.setString(5, user);
         pstmt.setString(6, user);
-        if ( pub == null ) {
+        //public access is usefulless, so set it to null
+        pstmt.setString(7, null);
+        /*if ( pub == null ) {
           pstmt.setString(7, null);
         } else if ( pub.toUpperCase().equals("YES") || pub.equals("1") ) {
           pstmt.setInt(7, 1);
         } else if ( pub.toUpperCase().equals("NO") || pub.equals("0") ) {
           pstmt.setInt(7, 0);
-        }
+        }*/
         pstmt.setString(8, catalogid);
         pstmt.setInt(9, serverCode);
       } else if (action.equals("UPDATE")) {
@@ -1255,13 +1258,14 @@
         pstmt.setString(4, user);
         pstmt.setInt(5, serverCode);
         pstmt.setInt(6, thisrev);
-        if ( pub == null ) {
+        pstmt.setString(7, null);
+        /*if ( pub == null ) {
           pstmt.setString(7, null);
         } else if ( pub.toUpperCase().equals("YES") || pub.equals("1") ) {
           pstmt .setInt(7, 1);
         } else if ( pub.toUpperCase().equals("NO") || pub.equals("0") ) {
           pstmt.setInt(7, 0);
-        }
+        }*/
         pstmt.setString(8, catalogid);
         pstmt.setString(9, this.docid);
 
@@ -1271,6 +1275,7 @@
 
       // Do the insertion
       pstmt.execute();
+      System.out.println("after excecute");
       pstmt.close();
 
     } catch (SQLException sqle) {
@@ -1541,9 +1546,19 @@
   {
     // NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT
     MetaCatUtil util = new MetaCatUtil();
-    AccessionNumber ac = new AccessionNumber(conn, accnum, action);
-    String docid = ac.getDocid();
-    String rev = ac.getRev();
+    //AccessionNumber ac = new AccessionNumber(conn, accnum, action);
+    //String docid = ac.getDocid();
+    // String rev = ac.getRev();
+    String docid=util.getDocIdFromString(accnum);
+    String rev=(new Integer(util.getVersionFromString(accnum))).toString();
+    
+    //check if xml_documents table has the document or not
+    //if not, set action to insert
+    if (getLatestRevisionNumber(conn,docid)==-1)
+    {
+      action="INSERT";
+    }
+    
     int serverCode=-2;
     //get server code for the home server
     serverCode=getServerCode(homeServer);
@@ -1558,12 +1573,8 @@
     MetaCatUtil.debugMessage("action: " + action + " servercode: " + 
                              serverCode, 10);
                         
-    if((serverCode != 1 && action.equals("UPDATE")) )
-    { //if this document being written is not a resident of this server then
-      //we need to try to get a lock from it's resident server.  If the
-      //resident server will not give a lock then we send the user a message
-      //saying that he/she needs to download a new copy of the file and
-      //merge the differences manually.
+    /*if((serverCode != 1 && action.equals("UPDATE")) )
+    { 
       int istreamInt; 
       char istreamChar;
       DocumentIdentifier id = new DocumentIdentifier(accnum);
@@ -1573,14 +1584,14 @@
       URL u = new URL("https://" + server + "?server="
            +util.getLocalReplicationServerName()+"&action=getlock&updaterev=" 
            +updaterev + "&docid=" + docid);
-      //System.out.println("sending message: " + u.toString());
+     
       String serverResStr = MetacatReplication.getURLContent(u);
       String openingtag =serverResStr.substring(0, serverResStr.indexOf(">")+1);
       if(openingtag.equals("<lockgranted>"))
-      {//the lock was granted go ahead with the insert
+      {
         try 
         {
-          //System.out.println("In lockgranted");
+          
           MetacatReplication.replLog("lock granted for " + accnum + " from " +
                                       server);
           XMLReader parser = initializeParser(conn, action, docid, updaterev,
@@ -1600,10 +1611,7 @@
       }
 
       else if(openingtag.equals("<filelocked>"))
-      {//the file is currently locked by another user
-       //notify our user to wait a few minutes, check out a new copy and try
-       //again.
-        //System.out.println("file locked");
+      {
         MetacatReplication.replLog("lock denied for " + accnum + " on " +
                                    server + " reason: file already locked");
         throw new Exception("The file specified is already locked by another " +
@@ -1612,9 +1620,7 @@
                             "again.");
       }
       else if(openingtag.equals("<outdatedfile>"))
-      {//our file is outdated.  notify our user to check out a new copy of the
-       //file and merge his version with the new version.
-        //System.out.println("outdated file");
+      {
         MetacatReplication.replLog("lock denied for " + accnum + " on " +
                                     server + " reason: local file outdated");
         throw new Exception("The file you are trying to update is an outdated" +
@@ -1621,16 +1627,15 @@
                             " version.  Please checkout the newest document, " +
                             "merge your changes and try again.");
       }
-    }
+    }*/
     
-    if ( action.equals("UPDATE") ) {
-      // check for 'write' permission for 'user' to update this document
-
+    /*if ( action.equals("UPDATE") ) {
+      
       if ( !hasPermission(conn, user, groups, docid) ) {
         throw new Exception("User " + user + 
               " does not have permission to update XML Document #" + accnum);
       }          
-    }
+    }*/
 
     try 
     { 
