Revision 747
Added by bojilova almost 23 years ago
DocumentImpl.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
import java.net.URL; |
57 | 57 |
|
58 |
import edu.ucsb.nceas.dbadapter.DBAdapter; |
|
59 |
|
|
58 | 60 |
/** |
59 | 61 |
* A class that represents an XML document. It can be created with a simple |
60 | 62 |
* document identifier from a database connection. It also will write an |
... | ... | |
65 | 67 |
static final int ALL = 1; |
66 | 68 |
static final int WRITE = 2; |
67 | 69 |
static final int READ = 4; |
70 |
private static final DBAdapter dbAdapter = MetaCatUtil.dbAdapter; |
|
68 | 71 |
|
69 | 72 |
private Connection conn = null; |
70 | 73 |
private String docid = null; |
... | ... | |
637 | 640 |
private void writeDocumentToDB(String action, String user, String pub, |
638 | 641 |
String catalogid, int serverCode) |
639 | 642 |
throws SQLException, Exception { |
643 |
|
|
644 |
String sysdate = dbAdapter.getDateString(); |
|
645 |
|
|
640 | 646 |
try { |
641 | 647 |
PreparedStatement pstmt = null; |
642 | 648 |
|
... | ... | |
648 | 654 |
"(docid, rootnodeid, docname, doctype, " + |
649 | 655 |
"user_owner, user_updated, date_created, date_updated, " + |
650 | 656 |
"public_access, catalog_id, server_location) " + |
651 |
"VALUES (?, ?, ?, ?, ?, ?, sysdate, sysdate, ?, ?, ?)"); |
|
657 |
"VALUES (?, ?, ?, ?, ?, ?, " + sysdate + ", " + sysdate + |
|
658 |
", ?, ?, ?)"); |
|
652 | 659 |
//note that the server_location is set to 1. |
653 | 660 |
//this means that "localhost" in the xml_replication table must |
654 | 661 |
//always be the first entry!!!!! |
... | ... | |
687 | 694 |
pstmt = conn.prepareStatement( |
688 | 695 |
"UPDATE xml_documents " + |
689 | 696 |
"SET rootnodeid = ?, docname = ?, doctype = ?, " + |
690 |
"user_updated = ?, date_updated = sysdate, " +
|
|
697 |
"user_updated = ?, date_updated = " + sysdate + ", " +
|
|
691 | 698 |
"server_location = ?, rev = ?, public_access = ?, catalog_id = ? " + |
692 | 699 |
"WHERE docid LIKE ?"); |
693 | 700 |
// Bind the values to the query |
... | ... | |
1078 | 1085 |
private static void archiveDocRevision(Connection conn, String docid, |
1079 | 1086 |
String user) |
1080 | 1087 |
throws SQLException { |
1088 |
String sysdate = dbAdapter.getDateString(); |
|
1089 |
|
|
1081 | 1090 |
// create a record in xml_revisions table |
1082 | 1091 |
// for that document as selected from xml_documents |
1083 | 1092 |
PreparedStatement pstmt = conn.prepareStatement( |
... | ... | |
1086 | 1095 |
"user_owner, user_updated, date_created, date_updated, " + |
1087 | 1096 |
"server_location, rev, public_access, catalog_id) " + |
1088 | 1097 |
"SELECT null, ?, rootnodeid, docname, doctype, " + |
1089 |
"user_owner, ?, sysdate, sysdate, server_location, rev, " +
|
|
1090 |
"public_access, catalog_id " + |
|
1098 |
"user_owner, ?, " + sysdate + ", " + sysdate + ", "+
|
|
1099 |
"server_location, rev, public_access, catalog_id " +
|
|
1091 | 1100 |
"FROM xml_documents " + |
1092 | 1101 |
"WHERE docid = ?"); |
1093 | 1102 |
// Bind the values to the query and execute it |
... | ... | |
1228 | 1237 |
} catch (McdbException me) { |
1229 | 1238 |
me.toXml(new PrintWriter(System.err)); |
1230 | 1239 |
} catch (AccessionNumberException ane) { |
1231 |
System.out.println("ERROR: Couldn't delete document!!! "); |
|
1232 | 1240 |
System.out.println(ane.getMessage()); |
1233 | 1241 |
} catch (Exception e) { |
1234 | 1242 |
System.err.println("EXCEPTION HANDLING REQUIRED"); |
Also available in: Unified diff
- changed to use the DBAdapter uniform interface for all apperance of "sysdate"
and uniqueid generation from sequence
MetaCatUtil:
- reads from metacat.properties the dbadapter class implemented the interface
and creates an instance of that class (in static public variable named dbAdapter) for use.
So all the classes in the application can access the dbadapter obj by:
MetaCatUtil.dbAdapter