Index: src/edu/ucsb/nceas/metacat/IdentifierManager.java
===================================================================
--- src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6078)
+++ src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6079)
@@ -622,13 +622,38 @@
     }
     
     /**
-     * update a mapping
+     * update a system metadata mapping
      * @param guid
      * @param localId
      */
     public void updateSystemMetadataMapping(String guid, String localId)
     {
-        System.out.println("$$$$$$$$$$$$$$ updating systemmetadata table with additional info");
+    	updateMapping(guid, localId, TYPE_SYSTEM_METADATA);
+    }
+    
+    /**
+     * update a mapping
+     * @param guid
+     * @param localId
+     */
+    public void updateMapping(String guid, String localId)
+    {
+    	updateMapping(guid, localId, TYPE_IDENTIFIER);
+    }
+    
+    /**
+     * update a mapping
+     * @param guid
+     * @param localId
+     */
+    private void updateMapping(String guid, String localId, String type)
+    {
+    	if (!type.equals(TYPE_IDENTIFIER) && !type.equals(TYPE_SYSTEM_METADATA)) {
+    		throw new RuntimeException("Cannot create mapping for type " + type +
+    		            ".  Please choose 'identifier' or 'systemmetadata'.");
+    	}
+    	
+        System.out.println("$$$$$$$$$$$$$$ updating mapping table");
         int serialNumber = -1;
         DBConnection dbConn = null;
         try {
@@ -643,11 +668,11 @@
 
             // Get a database connection from the pool
             dbConn = 
-                DBConnectionPool.getDBConnection("IdentifierManager.createMapping");
+                DBConnectionPool.getDBConnection("IdentifierManager.updateMapping");
             serialNumber = dbConn.getCheckOutSerialNumber();
 
             // Execute the insert statement
-            String query = "update systemmetadata set (docid, rev) = (?, ?) where guid='" + guid + "'";
+            String query = "update " + type + " set (docid, rev) = (?, ?) where guid='" + guid + "'";
             //System.out.println("query: " + query + " for params: (guid:" + guid + ", docid=" + docid + ", rev=" + rev + ")");
             PreparedStatement stmt = dbConn.prepareStatement(query);
             stmt.setString(1, docid);
@@ -657,21 +682,21 @@
             stmt.close();
         } catch (SQLException e) {
             e.printStackTrace();
-            logMetacat.error("SQL error while updating a mapping to the system metadata identifier: " 
+            logMetacat.error("SQL error while updating a mapping identifier: " 
                     + e.getMessage());
         } catch (NumberFormatException e) {
             e.printStackTrace();
-            logMetacat.error("NumberFormat error while updating a mapping to the system metadata identifier: " 
+            logMetacat.error("NumberFormat error while updating a mapping identifier: " 
                     + e.getMessage());
         } catch (AccessionNumberException e) {
             e.printStackTrace();
-            logMetacat.error("AccessionNumber error while updating a mapping to the system metadata identifier: " 
+            logMetacat.error("AccessionNumber error while updating a mapping identifier: " 
                     + e.getMessage());
         } finally {
             // Return database connection to the pool
             DBConnectionPool.returnDBConnection(dbConn, serialNumber);
         }
-        System.out.println("done updating systemmetadata");
+        System.out.println("done updating mapping");
     }
     
     /**
Index: src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java	(revision 6078)
+++ src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java	(revision 6079)
@@ -445,8 +445,14 @@
       //handle systemMetadata
       if(docName.trim().equals("systemMetadata"))
       {
-          System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
-          idman.createSystemMetadataMapping(guid, docinfoHash.get("docid"));
+          if (actions.equalsIgnoreCase("UPDATE")) {
+        	  System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!update mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+              idman.updateSystemMetadataMapping(guid, docinfoHash.get("docid"));
+          } else { 
+	    	  System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+	          idman.createSystemMetadataMapping(guid, docinfoHash.get("docid"));
+          }
+          
           Long dateUploadedLong = new Long(docinfoHash.get("date_uploaded"));
           Long dateModifiedLong = new Long(docinfoHash.get("date_modified"));
           idman.insertAdditionalSystemMetadataFields(
Index: src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/replication/ReplicationService.java	(revision 6078)
+++ src/edu/ucsb/nceas/metacat/replication/ReplicationService.java	(revision 6079)
@@ -576,12 +576,17 @@
         logReplication.info("ZZZZZZZZZZZZ docName: " + docName);
         if(docName.trim().equals("systemMetadata"))
         {
-            logReplication.info("creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
-            idman.createSystemMetadataMapping(guid, docinfoHash.get("docid"));
-            logReplication.info("handleForceReplicateRequest: updating SM with additional info");
-            System.out.println("!!!!!!!!!!!!!handleForceReplicateRequest: updating SM with additional info");
-            Long dateUploadedLong = new Long(docinfoHash.get("date_uploaded"));
-            Long dateModifiedLong = new Long(docinfoHash.get("date_modified"));
+        	if (dbaction.equalsIgnoreCase("UPDATE")) {
+        		logReplication.info("update mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+	            idman.updateSystemMetadataMapping(guid, docinfoHash.get("docid"));
+	            logReplication.info("handleForceReplicateRequest: updating SM with additional info");
+        	} else { // insert
+	            logReplication.info("creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+	            idman.createSystemMetadataMapping(guid, docinfoHash.get("docid"));
+        	}
+        	logReplication.info("handleForceReplicateRequest: updating SM with additional info");
+        	Long dateUploadedLong = new Long(docinfoHash.get("date_uploaded"));
+	        Long dateModifiedLong = new Long(docinfoHash.get("date_modified"));
             idman.insertAdditionalSystemMetadataFields(
                     dateUploadedLong.longValue(), 
                     docinfoHash.get("rights_holder"),
@@ -597,8 +602,13 @@
         }
         else
         {
-            logReplication.info("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
-            idman.createMapping(guid, docinfoHash.get("docid"));
+        	if (dbaction.equalsIgnoreCase("UPDATE")) {
+        		logReplication.info("updating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+	            idman.updateMapping(guid, docinfoHash.get("docid"));
+        	} else { // insert
+	            logReplication.info("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
+	            idman.createMapping(guid, docinfoHash.get("docid"));
+        	}
         }
       }
       else
@@ -639,14 +649,12 @@
 			serialNumber = dbConn.getCheckOutSerialNumber();
 			// write the document to local database
 			DocumentImplWrapper wrapper = new DocumentImplWrapper(parserBase, false);
-			//try this independently so we can set
-//			Exception writeException = null;
+			//try this independently so we can set access even if the update action is invalid (i.e docid has not changed)
 			try {
 				wrapper.writeReplication(dbConn, xmldoc, null, null,
 						dbaction, docid, null, null, homeServer, server, createdDate,
 						updatedDate);
 			} finally {
-//				writeException = e;
 
 				//process extra access rules before dealing with the write exception (doc exist already)			
 		        Vector<XMLAccessDAO> accessControlList = dih.getAccessControlList();
@@ -682,8 +690,7 @@
                                 docid + ":");
                     }
                 }
-				EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid,
-						dbaction);
+				EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction);
 			}
 		} catch (SQLException sqle) {
 			logMetacat.error("ReplicationService.handleForceReplicateRequest - " + ReplicationService.METACAT_REPL_ERROR_MSG);                         
