Index: src/edu/ucsb/nceas/metacat/DeletedDocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DeletedDocumentImpl.java	(nonexistent)
+++ src/edu/ucsb/nceas/metacat/DeletedDocumentImpl.java	(revision 2596)
@@ -0,0 +1,166 @@
+/**
+ *    '$RCSfile$'
+ *
+ *     '$Author$'
+ *       '$Date$'
+ *   '$Revision$'
+ *
+ *  For Details: http://kepler.ecoinformatics.org
+ *
+ * Copyright (c) 2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
+ * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
+ * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
+ * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+package edu.ucsb.nceas.metacat;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * @author tao
+ * This class represents a deleted document. It will be used when timed replication
+ * try to insert a deleted document into metacat. The document will be insert into
+ * xml_revisions table rather than xml_documents table.
+ */
+public class DeletedDocumentImpl extends DocumentImpl
+{
+    
+    /**
+     * Contructor of this class.
+     * @param conn
+     * @param rootNodeId
+     * @param docName
+     * @param docType
+     * @param docId
+     * @param newRevision
+     * @param action
+     * @param user
+     * @param pub
+     * @param catalogId
+     * @param serverCode
+     * @throws Exception
+     */
+    public DeletedDocumentImpl(DBConnection conn, long rootNodeId, String docName,
+            String docType, String docId, String newRevision, String action,
+            String user, String pub, String catalogId, int serverCode)
+            throws  Exception
+    {
+        this.connection = conn;
+        this.rootnodeid = rootNodeId;
+        this.docname = docName;
+        this.doctype = docType;
+        this.docid = docId;
+        this.updatedVersion = newRevision;
+        String sysdate = dbAdapter.getDateTimeFunction();
+        writeDocumentToRevisionTable(connection, docid, updatedVersion, doctype, 
+                docname,user, pub, catalogId, serverCode, rootnodeid, sysdate);
+    }
+    
+    /*
+     * This method will write a record to revision table base on given
+     * info. The create date and update will be current time.
+     * If rootNodeId < 0, this means it has not rootid
+     */
+    private static void writeDocumentToRevisionTable(DBConnection con, String docId, 
+            String rev, String docType, String docName, String user, String pub,
+            String catalogid, int serverCode, long rootNodeId, String sysdate) throws SQLException, Exception
+    {
+        
+        try 
+        {
+            PreparedStatement pstmt = null;
+            pstmt = con.prepareStatement("INSERT INTO xml_revisions "
+                        + "(docid, rootnodeid, docname, doctype, user_owner, "
+                        + "user_updated, date_created, date_updated, "
+                        + "public_access, catalog_id, server_location, rev) "
+                        + "VALUES (?, ?, ?, ?, ?, ?, " + sysdate + ", "
+                        + sysdate + ", ?, ?, ?, ?)");
+             // Increase dbconnection usage count
+            con.increaseUsageCount(1);
+
+            // Bind the values to the query
+            pstmt.setString(1, docId);
+            if (rootNodeId >0 )
+            {
+              pstmt.setLong(2, rootNodeId);
+            }
+            pstmt.setString(3, docName);
+            pstmt.setString(4, docType);
+            pstmt.setString(5, user);
+            pstmt.setString(6, user);
+            pstmt.setString(7, null);
+            pstmt.setString(8, catalogid);
+            pstmt.setInt(9, serverCode);
+            pstmt.setInt(10, Integer.parseInt(rev));
+            
+            // Do the insertion
+            pstmt.execute();
+            pstmt.close();
+
+           
+        } 
+        catch (SQLException sqle) 
+        {
+            throw sqle;
+        } 
+        catch (Exception e) 
+        {
+            throw e;
+        }
+    }
+    
+    /**
+     * This method will generate record in xml_revision table for a data file
+     * The reason why we need this method is because data file would be parsed by 
+     * xml parser. So the constructor would be called for data file and this
+     * method will replace the function
+     */
+    static public void registerDeletedDataFile(String docname,
+            String doctype, String accnum, String user, int serverCode) throws Exception
+    {
+        DBConnection dbconn = null;
+        int serialNumber = -1;
+        //MetaCatUtil util = new MetaCatUtil();
+        AccessionNumber ac;
+        PreparedStatement pstmt = null;
+        String action = null;
+        String sysdate = dbAdapter.getDateTimeFunction();
+        try 
+        {
+            //dbconn = util.openDBConnection();
+            dbconn = DBConnectionPool.getDBConnection(
+                    "DeletedDocumentImpl.registerDeletedDataFile");
+            serialNumber = dbconn.getCheckOutSerialNumber();
+            String docIdWithoutRev = MetaCatUtil
+                    .getDocIdFromAccessionNumber(accnum);
+            String rev = MetaCatUtil.getRevisionStringFromString(accnum);
+            writeDocumentToRevisionTable(dbconn, docIdWithoutRev, 
+                    rev, doctype, docname, user, null,
+                    null, serverCode, -1, sysdate); 
+            dbconn.close();
+        } 
+        finally 
+        {
+            
+            DBConnectionPool.returnDBConnection(dbconn, serialNumber);
+        }
+    }
+}

Property changes on: src/edu/ucsb/nceas/metacat/DeletedDocumentImpl.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
