Index: src/edu/ucsb/nceas/metacat/DocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 4466)
+++ src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 4467)
@@ -28,10 +28,8 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
@@ -104,18 +102,18 @@
     public static final String NAMESPACEFEATURE = "http://xml.org/sax/features/namespaces";
     public static final String NAMESPACEPREFIXESFEATURE = "http://xml.org/sax/features/namespace-prefixes";
     
+    public static final String EML2_0_0NAMESPACE;
+    public static final String EML2_0_1NAMESPACE;
     public static final String EML2_1_0NAMESPACE;
-    public static final String EML2_0_1NAMESPACE;
-    public static final String EML2_0_0NAMESPACE;
     
     static {
+    	String eml200NameSpace = null;
+    	String eml201NameSpace = null;
     	String eml210NameSpace = null;
-    	String eml201NameSpace = null;
-    	String eml200NameSpace = null;
     	try {
+    		eml200NameSpace = PropertyService.getProperty("xml.eml2_0_0namespace");
+    		eml201NameSpace = PropertyService.getProperty("xml.eml2_0_1namespace");
     		eml210NameSpace = PropertyService.getProperty("xml.eml2_1_0namespace");
-    		eml200NameSpace = PropertyService.getProperty("xml.eml2_0_1namespace");
-    		eml201NameSpace = PropertyService.getProperty("xml.eml2_0_0namespace");
     	} catch (PropertyNotFoundException pnfe) {
     		System.err.println("Could not get property in static block: " 
 					+ pnfe.getMessage());
@@ -152,9 +150,8 @@
     private String publicaccess;
     protected long rootnodeid;
     private ElementNode rootNode = null;
-    private TreeSet nodeRecordList = null;
-
-    
+    private TreeSet<NodeRecord> nodeRecordList = null;
+  
     private static Logger logMetacat = Logger.getLogger(DocumentImpl.class);
 
     /**
@@ -625,6 +622,7 @@
         {
           ForceReplicationHandler forceReplication = new ForceReplicationHandler(
                 accnum, false, notificationServer);
+          logMetacat.debug("ForceReplicationHandler created: " + forceReplication.toString());
         }
     }
     
@@ -642,7 +640,7 @@
         int revInDataBase =DBUtil.getLatestRevisionInDocumentTable(docid);
         logMetacat.warn("The rev in data base: " + revInDataBase);
         // String to store the revision
-        String rev = null;
+//        String rev = null;
 
         //revIndataBase=-1, there is no record in xml_documents table
         //the document is a new one for local server, inert it into table
@@ -649,7 +647,7 @@
         //user specified rev should be great than 0
         if (revInDataBase == -1 && userSpecifyRev >= 0) {
             // rev equals user specified
-            rev = (new Integer(userSpecifyRev)).toString();
+//            rev = (new Integer(userSpecifyRev)).toString();
             // action should be INSERT
             action = "INSERT";
         }
@@ -657,7 +655,7 @@
         // it is a updated file
         else if (userSpecifyRev > revInDataBase && revInDataBase >= 0) {
             // rev equals user specified
-            rev = (new Integer(userSpecifyRev)).toString();
+//            rev = (new Integer(userSpecifyRev)).toString();
             // action should be update
             action = "UPDATE";
         }
@@ -684,7 +682,7 @@
      private static String checkXMLRevisionTable(String docid, int rev) throws Exception
      {
          String action = "INSERT";
-         Vector localrev = null;
+         Vector<Integer> localrev = null;
            
          try
          {
@@ -999,9 +997,9 @@
             proccessEml2 = true;
         }
         // flag for process inline data
-        boolean prcocessInlineData = false;
+        boolean processInlineData = false;
 
-        TreeSet nodeRecordLists = null;
+        TreeSet<NodeRecord> nodeRecordLists = null;
         PrintWriter out = null;
         if (pw instanceof PrintWriter) {
             out = (PrintWriter) pw;
@@ -1027,17 +1025,17 @@
         } else {
         	nodeRecordLists = this.nodeRecordList;
         }
-        Stack openElements = new Stack();
+        Stack<NodeRecord> openElements = new Stack<NodeRecord>();
         boolean atRootElement = true;
         boolean previousNodeWasElement = false;
 
         // Step through all of the node records we were given
 
-        Iterator it = nodeRecordLists.iterator();
+        Iterator<NodeRecord> it = nodeRecordLists.iterator();
 
         while (it.hasNext()) {
 
-            NodeRecord currentNode = (NodeRecord) it.next();
+            NodeRecord currentNode = it.next();
             logMetacat.debug("[Got Node ID: " + currentNode.getNodeId() + " ("
                     + currentNode.getParentNodeId() + ", " + currentNode.getNodeIndex()
                     + ", " + currentNode.getNodeType() + ", " + currentNode.getNodeName()
@@ -1059,7 +1057,7 @@
             // having been sorted in a depth first traversal of the nodes, which
             // is handled by the NodeComparator class used by the TreeSet
             if (!atRootElement) {
-                NodeRecord currentElement = (NodeRecord) openElements.peek();
+                NodeRecord currentElement = openElements.peek();
                 if (currentNode.getParentNodeId() != currentElement.getNodeId()) {
                     while (currentNode.getParentNodeId() != currentElement.getNodeId()) {
                         currentElement = (NodeRecord) openElements.pop();
@@ -1075,7 +1073,7 @@
                         } else {
                             out.print("</" + currentElement.getNodeName() + ">");
                         }
-                        currentElement = (NodeRecord) openElements.peek();
+                        currentElement = openElements.peek();
                     }
                 }
             }
@@ -1120,12 +1118,12 @@
                     out.print("<" + currentNode.getNodeName());
                 }
 
-                // if currentNode is inline and handle eml2, set flag proccess
-                // in
+                // if currentNode is inline and handle eml2, set flag process
+                // on
                 if (currentNode.getNodeName() != null
                         && currentNode.getNodeName().equals(Eml200SAXHandler.INLINE)
                         && proccessEml2) {
-                    prcocessInlineData = true;
+                	processInlineData = true;
                 }
 
                 // Handle the ATTRIBUTE nodes
@@ -1155,7 +1153,7 @@
                 if (previousNodeWasElement) {
                     out.print(">");
                 }
-                if (!prcocessInlineData) {
+                if (!processInlineData) {
                     // if it is not inline data just out put data
                     out.print(currentNode.getNodeData());
                 } else {
@@ -1167,7 +1165,7 @@
                     // check if user has read permision for this inline data
                     boolean readInlinedata = false;
                     try {
-                        Hashtable unReadableInlineDataList =
+                        Hashtable<String, String> unReadableInlineDataList =
                             PermissionController
                                 .getUnReadableInlineDataIdList(accessfileName,
                                         user, groups, true);
@@ -1179,12 +1177,10 @@
                     }
 
                     if (readInlinedata) {
-                        //user want to see it, pull out from
-                        // file system and output it
-                        // for inline data, the data base only store the file
-                        // name, so we
-                        // can combine the file name and inline data file path,
-                        // to get it
+                        //user want to see it, pull out from file system and 
+                    	// output it for inline data, the data base only store 
+                    	// the file name, so we can combine the file name and
+                    	// inline data file path, to get it
 
                         Reader reader = Eml200SAXHandler
                                 .readInlineDataFromFileSystem(fileName);
@@ -1192,8 +1188,7 @@
                         try {
                             int length = reader.read(characterArray);
                             while (length != -1) {
-                                out
-                                        .print(new String(characterArray, 0,
+                                out.print(new String(characterArray, 0,
                                                 length));
                                 out.flush();
                                 length = reader.read(characterArray);
@@ -1205,12 +1200,11 @@
                     }//if can read inline data
                     else {
                         // if user can't read it, we only send it back a empty
-                        // string
-                        // in inline element.
+                        // string in inline element.
                         out.print("");
                     }// else can't read inlinedata
                     // reset proccess inline data false
-                    prcocessInlineData = false;
+                    processInlineData = false;
                 }// in inlinedata part
                 previousNodeWasElement = false;
                 // Handle the COMMENT nodes
@@ -1299,29 +1293,15 @@
 	 */
     public void readFromFileSystem(Writer pw, String user, String[] groups,
             String documentPath) throws McdbException {
-    	
-    	boolean proccessEml2 = false;
-        boolean readInlinedata = false;
-    	
-        // if this is not EML version 2.x, we do not need to worry about 
-        // inline data
-        if (doctype != null
-                && (doctype.equals(EML2_0_0NAMESPACE)
-                        || doctype.equals(EML2_0_1NAMESPACE) 
-                        || doctype.equals(EML2_1_0NAMESPACE))) {
-            proccessEml2 = true;
-        }
         
-        // create a printwriter
-        PrintWriter out = null;
-        if (pw instanceof PrintWriter) {
-            out = (PrintWriter) pw;
-        } else {
-            out = new PrintWriter(pw);
-        }
+//        // create a printwriter
+//        PrintWriter out = null;
+//        if (pw instanceof PrintWriter) {
+//            out = (PrintWriter) pw;
+//        } else {
+//            out = new PrintWriter(pw);
+//        }
         
-
-		String xmlFileLine;
 		String xmlFileContents = "";
 		
 		try {			
@@ -1334,16 +1314,29 @@
                     .getUnReadableInlineDataIdList(docid,
                             user, groups, true);
             
-            // for each unreadable section, strip the inline data from the doc
-            if (proccessEml2 && unReadableInlineDataList.size() > 0) {
-                Set<String> inlineKeySet = unReadableInlineDataList.keySet();
-            	for(String inlineKey : inlineKeySet) {
-            		String inlineValue = unReadableInlineDataList.get(inlineKey);
-            		if (inlineValue.startsWith(docid)) {
-            			xmlFileContents = stripInlineData(xmlFileContents, inlineKey);
-            		}
-            	}
-            }
+            // If this is for each unreadable section, strip the inline data
+			// from the doc
+			if (unReadableInlineDataList.size() > 0 && doctype != null) {
+				Set<String> inlineKeySet = unReadableInlineDataList.keySet();
+				
+				boolean pre210Doc = doctype.equals(EML2_0_0NAMESPACE)
+						|| doctype.equals(EML2_0_1NAMESPACE);
+
+				for (String inlineKey : inlineKeySet) {
+					String inlineValue = unReadableInlineDataList.get(inlineKey);
+					if (inlineValue.startsWith(docid)) {
+						// There are two different methods of stripping inline data depending
+						// on whether this is a 2.0.1 or earlier doc or 2.1.0 and later.  This 
+						// is because of eml schema changes for inline access.
+						if (pre210Doc) {
+							xmlFileContents = stripInline20XData(xmlFileContents,
+									inlineKey);
+						} else {
+							xmlFileContents = stripInline21XData(xmlFileContents, inlineKey);
+						}
+					}
+				}
+			}
             
             // write the doc
 			pw.write(xmlFileContents);
@@ -1358,8 +1351,8 @@
     }
     
     /**
-	 * Strip out an inline data section from a document. This assumes that the
-	 * inline element is within a distribution element and the key for the
+	 * Strip out an inline data section from a 2.0.X version document. This assumes 
+	 * that the inline element is within a distribution element and the id for the
 	 * distribution is the same as the subtreeid in the xml_access table.
 	 * 
 	 * @param xmlFileContents
@@ -1367,15 +1360,96 @@
 	 * @param inLineKey
 	 *            the unique key for this inline element
 	 */
-    private String stripInlineData(String xmlFileContents, String inLineKey) {
+    private String stripInline20XData(String xmlFileContents, String inLineId)
+			throws Exception {
+		String changedString = xmlFileContents;
+		
+    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
+    	Pattern distEndPattern = Pattern.compile("</distribution>", Pattern.CASE_INSENSITIVE);
+    	Pattern idPattern = Pattern.compile("id=\"" + inLineId);
+    	Pattern inlinePattern = Pattern.compile("<inline>.*</inline>");
+    	
+    	Matcher distStartMatcher = distStartPattern.matcher(xmlFileContents);
+    	Matcher distEndMatcher = distEndPattern.matcher(xmlFileContents);
+    	Matcher idMatcher = idPattern.matcher(xmlFileContents);
+    	Matcher inlineMatcher = inlinePattern.matcher(xmlFileContents);
+    	 
+    	// loop through the document looking for distribution elements
+    	while (distStartMatcher.find()) {
+    		// find the index of the corresponding end element
+    		int distStart = distStartMatcher.end();
+        	if (!distEndMatcher.find(distStart)) {
+        		throw new Exception("Could not find end tag for distribution");
+        	}
+        	int distEnd = distEndMatcher.start();
+        	
+        	// look for our inline id within the range of this distribution.
+        	idMatcher.region(distStart, distEnd);
+        	if (idMatcher.find()) {
+        		// if this distribution has the desired id, replace any 
+        		// <inline>.*</inline> in this distribution with <inline></inline>
+        		inlineMatcher.region(distStart, distEnd);
+            	if (inlineMatcher.find()) {
+            		changedString = inlineMatcher.replaceAll("<inline></inline>");
+            	} else {
+            		logMetacat.warn("Could not find an inline element for distribution: " + inLineId);
+            	}
+        	}
+    		
+    	}
+
+		return changedString;
+	}
+    
+    /**
+	 * Strip out an inline data section from a 2.1.X version document. This
+	 * assumes that the inline element is within a distribution element and the
+	 * subtreeid in the xml_access table is an integer that represents the nth
+	 * distribution element in the document.
+	 * 
+	 * @param xmlFileContents
+	 *            the contents of the file
+	 * @param inLineKey
+	 *            the unique key for this inline element
+	 */
+    private String stripInline21XData(String xmlFileContents, String inLineId) throws Exception {
+    	int distributionIndex = Integer.valueOf(inLineId);
     	String changedString = xmlFileContents;
-    	String regex = "(<distribution .*id=\"" + inLineKey + "\">.*)<inline>.*</inline>(.*</distribution>)";
-    	Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); 
-    	Matcher matcher = pattern.matcher(xmlFileContents);
-    	if (matcher.find()) {
-    		changedString = matcher.replaceFirst(matcher.group(1) + "<inline></inline>" + matcher.group(2));
+    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
+    	Pattern distEndPattern = Pattern.compile("</distribution>", Pattern.CASE_INSENSITIVE); 
+    	Pattern inlinePattern = Pattern.compile("<inline>.*</inline>");
+    	Matcher matcher = distStartPattern.matcher(xmlFileContents);
+    	
+    	// iterate through distributions until we find the nth match.  The nth match 
+    	// corresponds to the inLineKey that was passed in.  Use the end of that match
+    	// to set the start range we will search for the inline element.
+    	for (int i = 0; i < distributionIndex; i++) {
+    		if (!matcher.find()) {
+    			throw new Exception("Could not find distribution number " + (i + 1));
+    		}
     	}	
+    	int distStart = matcher.end();
     	
+    	// find the end tag for the distribution.  Use the beginning of that match to set
+    	// the end range we will search for the inline element
+    	matcher.usePattern(distEndPattern);
+    	if (!matcher.find(distStart)) {
+    		throw new Exception("Could not find end tag for distribution");
+    	}
+    	int distEnd = matcher.start();
+    	
+    	// set the inline search range
+    	matcher.region(distStart, distEnd);
+    	
+    	// match any inline elements and replace with an empty inline element
+    	matcher.usePattern(inlinePattern);  	
+    	if (matcher.find()) {
+    		changedString = matcher.replaceAll("<inline></inline>");
+    	} else {
+    		logMetacat.warn("Could not find an inline element for distribution: " 
+    				+ inLineId);
+    	}
+    	
     	return changedString;
     }
 
@@ -1392,14 +1466,14 @@
     {
     	logMetacat.warn("buildIndex called on docid " + docid);
     	double start = System.currentTimeMillis()/1000;
-        TreeSet nodeRecordLists = getNodeRecordList(rootnodeid);
+        TreeSet<NodeRecord> nodeRecordLists = getNodeRecordList(rootnodeid);
         boolean atRootElement = true;
         long rootNodeId = -1;
 
         // Build a map of the same records that are present in the
         // TreeSet so that any node can be easily accessed by nodeId
-        HashMap nodeRecordMap = new HashMap();
-        Iterator it = nodeRecordLists.iterator();
+        HashMap<Long, NodeRecord> nodeRecordMap = new HashMap<Long, NodeRecord>();
+        Iterator<NodeRecord> it = nodeRecordLists.iterator();
         while (it.hasNext()) {
             NodeRecord currentNode = (NodeRecord) it.next();
             Long nodeId = new Long(currentNode.getNodeId());
@@ -1406,7 +1480,7 @@
             nodeRecordMap.put(nodeId, currentNode);
         }
 
-        String doc = docid;
+//        String doc = docid;
       double afterPutNode = System.currentTimeMillis()/1000;
       logMetacat.info("The time for put node id into map is "+(afterPutNode - start));
       double afterDelete = 0;
@@ -1429,10 +1503,10 @@
             // TEXT nodes with their parent ELEMENT node ids to associate the
             // element with it's node data (stored in the text node)
             it = nodeRecordLists.iterator();
-            HashMap pathsFound = new HashMap();
+            HashMap<String, PathIndexEntry> pathsFound = new HashMap<String, PathIndexEntry>();
             while (it.hasNext()) {
                 NodeRecord currentNode = (NodeRecord) it.next();
-                HashMap pathList = new HashMap();
+                HashMap<String, PathIndexEntry> pathList = new HashMap<String, PathIndexEntry>();
                 if ( currentNode.getNodeType().equals("ELEMENT") ||
                      currentNode.getNodeType().equals("ATTRIBUTE") ){
 
@@ -1453,7 +1527,7 @@
                   // with ELEMENT paths with TEXT nodedata (since it's modeled 
                   // this way in the DOM)
                   NodeRecord parentNode = 
-                   (NodeRecord) nodeRecordMap.get(new Long(currentNode.getParentNodeId()));
+                	  nodeRecordMap.get(new Long(currentNode.getParentNodeId()));
 
                   if ( parentNode.getNodeType().equals("ELEMENT") ) {
                     
@@ -1534,15 +1608,16 @@
 	 * @param nodedata
 	 *            the nodedata for the current node
 	 */
-    private void traverseParents(HashMap records, long rootNodeId,
-            long leafNodeId, long id,
-            String children, HashMap pathList, HashMap pathsFoundForIndexing) {
-    	  Long nodeId = new Long(id);
+    private void traverseParents(HashMap<Long,NodeRecord> records, long rootNodeId,
+            long leafNodeId, long id,String children, 
+            HashMap<String, PathIndexEntry> pathList, 
+            HashMap<String, PathIndexEntry> pathsFoundForIndexing) {
+    	Long nodeId = new Long(id);
         NodeRecord current = (NodeRecord)records.get(nodeId);
         long parentId = current.getParentNodeId();
         String currentName = current.getNodeName();
-        String nodeData = current.getNodeData();
-        float nodeDataNumerical = current.getNodeDataNumerical();
+//        String nodeData = current.getNodeData();
+//        float nodeDataNumerical = current.getNodeDataNumerical();
         NodeRecord leafRecord = (NodeRecord)records.get(new Long(leafNodeId));
         String leafData = leafRecord.getNodeData();
         long leafParentId = leafRecord.getParentNodeId();
@@ -1677,7 +1752,7 @@
      * @param pathList the hash of paths to insert
      * @throws SQLException if there is an error inserting into the db
      */
-    private void updateNodeIndex(DBConnection conn, HashMap pathList)
+    private void updateNodeIndex(DBConnection conn, HashMap<String, PathIndexEntry> pathList)
     	throws SQLException
     {
         // Create an insert statement to reuse for all of the path
@@ -1692,7 +1767,7 @@
         pstmt.setString(4, doctype);
 
         // Step through the hashtable and insert each of the path values
-        Iterator it = pathList.values().iterator();
+        Iterator<PathIndexEntry> it = pathList.values().iterator();
         while (it.hasNext()) {
         	 PathIndexEntry entry = (PathIndexEntry)it.next();
         	 logMetacat.debug("Inserting: " + entry.nodeId +
@@ -1714,7 +1789,7 @@
      * @param pathList the hash of paths to insert
      * @throws SQLException if there is an error inserting into the db
      */
-    private void updatePathIndex(DBConnection conn, HashMap pathsFound)
+    private void updatePathIndex(DBConnection conn, HashMap<String, PathIndexEntry> pathsFound)
         throws SQLException {
         // Increase usage count for the connection
         conn.increaseUsageCount(1);
@@ -1727,7 +1802,7 @@
                 + " VALUES (?, ?, ?, ?, ?)");
         
         // Step through the hashtable and insert each of the path values
-        Iterator it = pathsFound.values().iterator();
+        Iterator<PathIndexEntry> it = pathsFound.values().iterator();
          while (it.hasNext()) {
              PathIndexEntry entry = (PathIndexEntry)it.next();
              pstmt.setString(1,entry.docid);
@@ -1785,11 +1860,11 @@
                 //System.out.println("in revision table branch -------");
                 // if we couldn't find it in xml_documents we 
                 // need to find it in xml_revision table
-                Vector revList = DBUtil.getRevListFromRevisionTable(docid);
+                Vector<Integer> revList = DBUtil.getRevListFromRevisionTable(docid);
                 for (int i=0; i<revList.size(); i++)
                 {
-                    Integer k = (Integer) revList.elementAt(i);
-                    //System.out.println("The rev in xml_revision talbe "+ k.toString());
+                    //  Integer k = (Integer) revList.elementAt(i);
+                    // System.out.println("The rev in xml_revision table "+ k.toString());
                 }
                 
                 if (revList.contains(new Integer(revision)))
@@ -1953,12 +2028,12 @@
      * @param rootnodeid
      *            the id of the root node of the node tree to look up
      */
-    private TreeSet getNodeRecordList(long rootnodeid) throws McdbException
+    private TreeSet<NodeRecord> getNodeRecordList(long rootnodeid) throws McdbException
     {
         PreparedStatement pstmt = null;
         DBConnection dbconn = null;
         int serialNumber = -1;
-        TreeSet nodeRecordList = new TreeSet(new NodeComparator());
+        TreeSet<NodeRecord> nodeRecordList = new TreeSet<NodeRecord>(new NodeComparator());
         long nodeid = 0;
         long parentnodeid = 0;
         long nodeindex = 0;
@@ -1967,7 +2042,7 @@
         String nodeprefix = null;
         String nodedata = null;
         float nodedatanumerical = -1;
-        String quotechar = DatabaseService.getDBAdapter().getStringDelimiter();
+//        String quotechar = DatabaseService.getDBAdapter().getStringDelimiter();
         String table = "xml_nodes";
         //System.out.println("in getNodeREcorelist !!!!!!!!!!!for root node id "+rootnodeid);
         try {
@@ -2362,8 +2437,8 @@
             // 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.
-            int istreamInt;
-            char istreamChar;
+//            int istreamInt;
+//            char istreamChar;
 
             // check for 'write' permission for 'user' to update this document
             if (!hasWritePermission(user, groups, accnum)) {
@@ -2430,6 +2505,7 @@
                 // Force replication the docid
                 ForceReplicationHandler frh = new ForceReplicationHandler(
                         accnum, true, null);
+                logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
                 return (accnum);
 
             }
@@ -2529,6 +2605,7 @@
         // metacat notify the force replication.
         ForceReplicationHandler frh = new ForceReplicationHandler(accnum,
                 action, true, null);
+        logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
         // clear cache after inserting or updating a document
         if (PropertyService.getProperty("database.queryCacheOn").equals("true"))
         {
@@ -2714,6 +2791,7 @@
         {
           ForceReplicationHandler forceReplication = new ForceReplicationHandler(
                 accnum, action, true, notifyServer);
+          logMetacat.debug("ForceReplicationHandler created: " + forceReplication.toString());
         }
         
         // clear cache after inserting or updating a document
@@ -2732,11 +2810,11 @@
     {
         DBConnection dbconn = null;
         int serialNumber = -1;
-        PreparedStatement pstmt = null;
+//        PreparedStatement pstmt = null;
         String documenttype = getDocTypeFromDBForCurrentDocument(accnumber);
         try {
             String packagedoctype = PropertyService.getProperty("xml.packagedoctype");
-            Vector packagedoctypes = new Vector();
+            Vector<String> packagedoctypes = new Vector<String>();
             packagedoctypes = MetaCatUtil.getOptionList(packagedoctype);
             String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnumber);
             int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnumber);
@@ -2919,8 +2997,8 @@
             double afterArchiveDocAndNode = System.currentTimeMillis()/1000;
             logMetacat.info("The time for archiveDocAndNodesRevision is "+(afterArchiveDocAndNode - start));
             // Now delete it from the xml_index table
-            boolean useXMLIndex = (new Boolean(PropertyService
-                    .getProperty("database.usexmlindex"))).booleanValue();
+//            boolean useXMLIndex = (new Boolean(PropertyService
+//                    .getProperty("database.usexmlindex"))).booleanValue();
 
 
 
@@ -3029,6 +3107,7 @@
             // add force delete replcation document here.
             ForceReplicationHandler frh = new ForceReplicationHandler(
                              accnum, ForceReplicationHandler.DELETE, isXML, notifyServer);
+            logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
             // clear cache after inserting or updating a document
             if (PropertyService.getProperty("database.queryCacheOn").equals("true"))
             {
@@ -3939,9 +4018,9 @@
     {
         DBConnection dbconn = null;
         int serialNumber = -1;
-        AccessionNumber ac;
-        PreparedStatement pstmt = null;
-        String action = null;
+//        AccessionNumber ac;
+//        PreparedStatement pstmt = null;
+//        String action = null;
         try 
         {
             //dbconn = util.openDBConnection();
@@ -3973,7 +4052,7 @@
      */
     static private void deleteXMLNodes(DBConnection dbconn, long rootId) throws Exception
     {
-        AccessionNumber ac;
+//        AccessionNumber ac;
         PreparedStatement pstmt = null;
         double start = System.currentTimeMillis()/1000;
         String sql = "DELETE FROM xml_nodes WHERE rootnodeid ="+ rootId;
