Revision 2621
Added by Jing Tao about 19 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
226 | 226 |
*/ |
227 | 227 |
public DocumentImpl(DBConnection conn, long rootNodeId, String docName, |
228 | 228 |
String docType, String docId, String newRevision, String action, |
229 |
String user, String pub, String catalogId, int serverCode) |
|
229 |
String user, String pub, String catalogId, int serverCode, |
|
230 |
String createDate, String updateDate) |
|
230 | 231 |
throws SQLException, Exception |
231 | 232 |
{ |
232 | 233 |
this.connection = conn; |
... | ... | |
235 | 236 |
this.doctype = docType; |
236 | 237 |
this.docid = docId; |
237 | 238 |
this.updatedVersion = newRevision; |
238 |
writeDocumentToDB(action, user, pub, catalogId, serverCode); |
|
239 |
writeDocumentToDB(action, user, pub, catalogId, serverCode, createDate, updateDate);
|
|
239 | 240 |
} |
240 | 241 |
|
241 | 242 |
/** |
... | ... | |
306 | 307 |
|
307 | 308 |
String rev = Integer.toString(userSpecifyRev); |
308 | 309 |
modifyRecordsInGivenTable(DOCUMENTTABLE, action,docIdWithoutRev, doctype, docname, |
309 |
user, rev, serverCode); |
|
310 |
user, rev, serverCode, null, null); |
|
311 |
// null and null is createdate and updatedate |
|
312 |
// null will create current time |
|
310 | 313 |
} |
311 | 314 |
|
312 | 315 |
/** |
... | ... | |
339 | 342 |
* resides. |
340 | 343 |
*/ |
341 | 344 |
public static void registerDocumentInReplication(String docname, |
342 |
String doctype, String accnum, String user, int serverCode, String tableName) |
|
345 |
String doctype, String accnum, String user, int serverCode, |
|
346 |
String tableName, String createDate, String updateDate) |
|
343 | 347 |
throws SQLException, AccessionNumberException, Exception |
344 | 348 |
{ |
345 | 349 |
|
... | ... | |
366 | 370 |
|
367 | 371 |
String rev = Integer.toString(userSpecifyRev); |
368 | 372 |
modifyRecordsInGivenTable(tableName, action,docIdWithoutRev, doctype, docname, |
369 |
user, rev, serverCode); |
|
373 |
user, rev, serverCode, createDate, updateDate);
|
|
370 | 374 |
|
371 | 375 |
} |
372 | 376 |
|
... | ... | |
375 | 379 |
*/ |
376 | 380 |
private static void modifyRecordsInGivenTable(String tableName, String action, |
377 | 381 |
String docid, String doctype, String docname, String user, |
378 |
String rev, int serverCode) throws Exception |
|
382 |
String rev, int serverCode, String createDate, String updateDate) throws Exception
|
|
379 | 383 |
{ |
380 | 384 |
DBConnection dbconn = null; |
381 | 385 |
PreparedStatement pstmt = null; |
382 | 386 |
int serialNumber = -1; |
383 | 387 |
String sqlDateString = dbAdapter.getDateTimeFunction(); |
388 |
if (createDate == null) |
|
389 |
{ |
|
390 |
createDate = sqlDateString; |
|
391 |
} |
|
392 |
|
|
393 |
if (updateDate == null) |
|
394 |
{ |
|
395 |
updateDate = sqlDateString; |
|
396 |
} |
|
384 | 397 |
try |
385 | 398 |
{ |
386 | 399 |
dbconn = DBConnectionPool.getDBConnection( |
... | ... | |
402 | 415 |
sql.append(user).append("','"); |
403 | 416 |
sql.append(serverCode).append("','"); |
404 | 417 |
sql.append(rev).append("',"); |
405 |
sql.append(sqlDateString).append(",");
|
|
406 |
sql.append(sqlDateString).append(",");
|
|
418 |
sql.append(createDate).append(",");
|
|
419 |
sql.append(updateDate).append(",");
|
|
407 | 420 |
sql.append("'0')"); |
408 | 421 |
} else if (action != null && action.equals("UPDATE")) { |
409 | 422 |
sql.append("update xml_documents set docname ='"); |
... | ... | |
415 | 428 |
sql.append("rev='"); |
416 | 429 |
sql.append(rev).append("',"); |
417 | 430 |
sql.append("date_updated="); |
418 |
sql.append(sqlDateString);
|
|
431 |
sql.append(updateDate);
|
|
419 | 432 |
sql.append(" where docid='"); |
420 | 433 |
sql.append(docid).append("'"); |
421 | 434 |
} |
... | ... | |
458 | 471 |
*/ |
459 | 472 |
public static void writeDataFileInReplication(InputStream input, |
460 | 473 |
String filePath, String docname, String doctype, String accnum, |
461 |
String user, String docHomeServer, String notificationServer, String tableName, boolean timedReplication) |
|
474 |
String user, String docHomeServer, String notificationServer, |
|
475 |
String tableName, boolean timedReplication, String createDate, String updateDate) |
|
462 | 476 |
throws SQLException, AccessionNumberException, Exception |
463 | 477 |
{ |
464 | 478 |
int serverCode = -2; |
... | ... | |
478 | 492 |
|
479 | 493 |
//register data file into xml_documents table |
480 | 494 |
registerDocumentInReplication(docname, doctype, accnum, user, |
481 |
serverCode, tableName); |
|
495 |
serverCode, tableName, createDate, updateDate);
|
|
482 | 496 |
//write inputstream into file system. |
483 | 497 |
File dataDirectory = new File(filePath); |
484 | 498 |
File newFile = new File(dataDirectory, accnum); |
... | ... | |
1829 | 1843 |
|
1830 | 1844 |
/** creates SQL code and inserts new document into DB connection */ |
1831 | 1845 |
private void writeDocumentToDB(String action, String user, String pub, |
1832 |
String catalogid, int serverCode) throws SQLException, Exception |
|
1846 |
String catalogid, int serverCode, String createDate, String updateDate) throws SQLException, Exception
|
|
1833 | 1847 |
{ |
1834 | 1848 |
String sysdate = dbAdapter.getDateTimeFunction(); |
1849 |
if (createDate == null) |
|
1850 |
{ |
|
1851 |
createDate = sysdate; |
|
1852 |
} |
|
1853 |
if (updateDate == null) |
|
1854 |
{ |
|
1855 |
updateDate = sysdate; |
|
1856 |
} |
|
1835 | 1857 |
DocumentImpl thisdoc = null; |
1836 | 1858 |
|
1837 | 1859 |
try { |
... | ... | |
1846 | 1868 |
+ "(docid, rootnodeid, docname, doctype, user_owner, " |
1847 | 1869 |
+ "user_updated, date_created, date_updated, " |
1848 | 1870 |
+ "public_access, catalog_id, server_location, rev) " |
1849 |
+ "VALUES (?, ?, ?, ?, ?, ?, " + sysdate + ", "
|
|
1850 |
+ sysdate + ", ?, ?, ?, ?)");
|
|
1871 |
+ "VALUES (?, ?, ?, ?, ?, ?, " + createDate + ", "
|
|
1872 |
+ updateDate + ", ?, ?, ?, ?)");
|
|
1851 | 1873 |
// Increase dbconnection usage count |
1852 | 1874 |
connection.increaseUsageCount(1); |
1853 | 1875 |
|
... | ... | |
1917 | 1939 |
.prepareStatement("UPDATE xml_documents " |
1918 | 1940 |
+ "SET rootnodeid = ?, docname = ?, doctype = ?, " |
1919 | 1941 |
+ "user_updated = ?, date_updated = " |
1920 |
+ sysdate
|
|
1942 |
+ updateDate
|
|
1921 | 1943 |
+ ", " |
1922 | 1944 |
+ "server_location = ?, rev = ?, public_access = ?, " |
1923 | 1945 |
+ "catalog_id = ? " |
... | ... | |
2103 | 2125 |
*/ |
2104 | 2126 |
parser = initializeParser(conn, action, docid, updaterev, |
2105 | 2127 |
user, groups, pub, serverCode, dtd, ruleBase, |
2106 |
needValidation, false);// false means it is not a revision doc |
|
2128 |
needValidation, false, null, null);// false means it is not a revision doc |
|
2129 |
//null, null are createdate and updatedate |
|
2130 |
//null will use current time as create date time |
|
2107 | 2131 |
conn.setAutoCommit(false); |
2108 | 2132 |
parser.parse(new InputSource(xml)); |
2109 | 2133 |
conn.commit(); |
... | ... | |
2171 | 2195 |
XMLReader parser = null; |
2172 | 2196 |
try { |
2173 | 2197 |
parser = initializeParser(conn, action, docid, rev, user, groups, |
2174 |
pub, serverCode, dtd, ruleBase, needValidation, false); |
|
2175 |
//false means it is not a revision doc |
|
2198 |
pub, serverCode, dtd, ruleBase, needValidation, false, null, null); |
|
2199 |
// null and null are createtime and updatetime |
|
2200 |
// null will create current time |
|
2201 |
//false means it is not a revision doc |
|
2176 | 2202 |
|
2177 | 2203 |
conn.setAutoCommit(false); |
2178 | 2204 |
parser.parse(new InputSource(xml)); |
... | ... | |
2266 | 2292 |
public static String writeReplication(DBConnection conn, Reader xml, |
2267 | 2293 |
String pub, Reader dtd, String action, String accnum, String user, |
2268 | 2294 |
String[] groups, String homeServer, String notifyServer, |
2269 |
String ruleBase, boolean needValidation, String tableName, boolean timedReplication) throws Exception |
|
2295 |
String ruleBase, boolean needValidation, String tableName, |
|
2296 |
boolean timedReplication, String createDate, String updateDate) throws Exception |
|
2270 | 2297 |
{ |
2271 | 2298 |
long rootId; |
2299 |
String docType = null; |
|
2300 |
String docName = null; |
|
2301 |
String catalogId = null; |
|
2272 | 2302 |
MetaCatUtil.debugMessage("user in replication" + user, 30); |
2273 | 2303 |
// Docid without revision |
2274 | 2304 |
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum); |
... | ... | |
2317 | 2347 |
isRevision = true; |
2318 | 2348 |
} |
2319 | 2349 |
parser = initializeParser(conn, action, docid, rev, user, groups, |
2320 |
pub, serverCode, dtd, ruleBase, needValidation, isRevision); |
|
2350 |
pub, serverCode, dtd, ruleBase, needValidation, |
|
2351 |
isRevision, createDate, updateDate); |
|
2321 | 2352 |
|
2322 | 2353 |
conn.setAutoCommit(false); |
2323 | 2354 |
parser.parse(new InputSource(xml)); |
... | ... | |
2332 | 2363 |
dbx.runIndexingThread(); |
2333 | 2364 |
} |
2334 | 2365 |
rootId = dbx.getRootNodeId(); |
2366 |
docType = dbx.getDocumentType(); |
|
2367 |
docName = dbx.getDocumentName(); |
|
2368 |
catalogId = dbx.getCatalogId(); |
|
2335 | 2369 |
|
2336 | 2370 |
} catch (Exception e) { |
2337 | 2371 |
conn.rollback(); |
... | ... | |
2348 | 2382 |
|
2349 | 2383 |
// run write into access db base on relation table and access rule |
2350 | 2384 |
try { |
2385 |
conn.setAutoCommit(false); |
|
2351 | 2386 |
if (!tableName.equals(REVISIONTABLE)) |
2352 | 2387 |
{ |
2353 | 2388 |
runRelationAndAccessHandler(accnum, user, groups, serverCode); |
2354 | 2389 |
} |
2355 | 2390 |
else |
2356 | 2391 |
{ |
2392 |
// in replicate revision documents, |
|
2393 |
// we need to move nodes from xml_nodes to xml_nodes_revision and register the record |
|
2394 |
// into xml_revision table |
|
2357 | 2395 |
moveNodesToNodesRevision(conn, rootId); |
2396 |
writeDocumentToRevisionTable(conn, docid, rev, docType, docName, user, |
|
2397 |
catalogId, serverCode, rootId, createDate, updateDate); |
|
2358 | 2398 |
} |
2399 |
|
|
2359 | 2400 |
} catch (Exception ee) { |
2401 |
conn.rollback(); |
|
2402 |
conn.setAutoCommit(true); |
|
2360 | 2403 |
MetacatReplication.replErrorLog("Failed to " + "create access " |
2361 | 2404 |
+ "rule for package: " + accnum + " because " |
2362 | 2405 |
+ ee.getMessage()); |
... | ... | |
2737 | 2780 |
private static XMLReader initializeParser(DBConnection dbconn, |
2738 | 2781 |
String action, String docid, String rev, String user, |
2739 | 2782 |
String[] groups, String pub, int serverCode, Reader dtd, |
2740 |
String ruleBase, boolean needValidation, boolean isRevision) throws Exception |
|
2783 |
String ruleBase, boolean needValidation, boolean isRevision, |
|
2784 |
String createDate, String updateDate) throws Exception |
|
2741 | 2785 |
{ |
2742 | 2786 |
XMLReader parser = null; |
2743 | 2787 |
try { |
... | ... | |
2751 | 2795 |
if (ruleBase != null && ruleBase.equals(EML200)) { |
2752 | 2796 |
MetaCatUtil.debugMessage("eml 2.0.0 parser", 20); |
2753 | 2797 |
chandler = new Eml200SAXHandler(dbconn, action, docid, rev, |
2754 |
user, groups, pub, serverCode); |
|
2798 |
user, groups, pub, serverCode, createDate, updateDate);
|
|
2755 | 2799 |
chandler.setIsRevisionDoc(isRevision); |
2756 | 2800 |
parser.setContentHandler((ContentHandler) chandler); |
2757 | 2801 |
parser.setErrorHandler((ErrorHandler) chandler); |
... | ... | |
2776 | 2820 |
} else if (ruleBase != null && ruleBase.equals(EML210)) { |
2777 | 2821 |
MetaCatUtil.debugMessage("eml 2.1.0 parser", 20); |
2778 | 2822 |
chandler = new Eml210SAXHandler(dbconn, action, docid, rev, |
2779 |
user, groups, pub, serverCode); |
|
2823 |
user, groups, pub, serverCode, createDate, updateDate);
|
|
2780 | 2824 |
chandler.setIsRevisionDoc(isRevision); |
2781 | 2825 |
parser.setContentHandler((ContentHandler) chandler); |
2782 | 2826 |
parser.setErrorHandler((ErrorHandler) chandler); |
... | ... | |
2802 | 2846 |
//create a DBSAXHandler object which has the revision |
2803 | 2847 |
// specification |
2804 | 2848 |
chandler = new DBSAXHandler(dbconn, action, docid, rev, user, |
2805 |
groups, pub, serverCode); |
|
2849 |
groups, pub, serverCode, createDate, updateDate);
|
|
2806 | 2850 |
chandler.setIsRevisionDoc(isRevision); |
2807 | 2851 |
parser.setContentHandler((ContentHandler) chandler); |
2808 | 2852 |
parser.setErrorHandler((ErrorHandler) chandler); |
... | ... | |
2876 | 2920 |
|
2877 | 2921 |
long rootNodeId = doc.getRootNodeID(); |
2878 | 2922 |
|
2879 |
archiveDocRevison(dbconn, docid, user, rootNodeId); |
|
2923 |
archiveDocAndNodesRevison(dbconn, docid, user, rootNodeId);
|
|
2880 | 2924 |
|
2881 | 2925 |
}catch (Exception e) { |
2882 | 2926 |
MetaCatUtil.debugMessage( |
... | ... | |
2887 | 2931 |
|
2888 | 2932 |
} |
2889 | 2933 |
|
2890 |
|
|
2891 |
private static void archiveDocRevison(DBConnection dbconn, String docid, |
|
2934 |
/** |
|
2935 |
* This method will archive both xml_revision and xml_nodes_revision. |
|
2936 |
* @param dbconn |
|
2937 |
* @param docid |
|
2938 |
* @param user |
|
2939 |
* @param rootNodeId |
|
2940 |
* @throws Exception |
|
2941 |
*/ |
|
2942 |
private static void archiveDocAndNodesRevison(DBConnection dbconn, String docid, |
|
2892 | 2943 |
String user, long rootNodeId) throws Exception |
2893 | 2944 |
{ |
2894 | 2945 |
String sysdate = dbAdapter.getDateTimeFunction(); |
2895 | 2946 |
//DBConnection conn = null; |
2896 | 2947 |
//int serialNumber = -1; |
2897 | 2948 |
PreparedStatement pstmt = null; |
2898 |
try
|
|
2899 |
{
|
|
2949 |
try |
|
2950 |
{ |
|
2900 | 2951 |
// Move the nodes from xml_nodes to xml_nodes_revisions table... |
2901 | 2952 |
moveNodesToNodesRevision(dbconn, rootNodeId); |
2902 |
|
|
2903 |
// Move the document information to xml_revisions table...
|
|
2953 |
//archiveDocRevision(docid, user); |
|
2954 |
//Move the document information to xml_revisions table... |
|
2904 | 2955 |
pstmt = dbconn.prepareStatement("INSERT INTO xml_revisions " |
2905 | 2956 |
+ "(docid, rootnodeid, docname, doctype, " |
2906 | 2957 |
+ "user_owner, user_updated, date_created, date_updated, " |
2907 | 2958 |
+ "server_location, rev, public_access, catalog_id) " |
2908 | 2959 |
+ "SELECT ?, rootnodeid, docname, doctype, " |
2909 |
+ "user_owner, ?, " + sysdate + ", " + sysdate + ", "
|
|
2960 |
+ "user_owner, ?, date_created, date_updated, "
|
|
2910 | 2961 |
+ "server_location, rev, public_access, catalog_id " |
2911 | 2962 |
+ "FROM xml_documents " + "WHERE docid = ?"); |
2912 | 2963 |
|
... | ... | |
2921 | 2972 |
|
2922 | 2973 |
} catch (SQLException e) { |
2923 | 2974 |
MetaCatUtil.debugMessage( |
2924 |
"Error in DocumentImpl.archiveDocRevision : " |
|
2975 |
"Error in DocumentImpl.archiveDocAndNodesRevision : "
|
|
2925 | 2976 |
+ e.getMessage(), 30); |
2926 | 2977 |
throw e; |
2927 | 2978 |
} catch (Exception e) { |
2928 | 2979 |
MetaCatUtil.debugMessage( |
2929 |
"Error in DocumentImpl.archiveDocRevision : " |
|
2980 |
"Error in DocumentImpl.archiveDocAndNodesRevision : "
|
|
2930 | 2981 |
+ e.getMessage(), 30); |
2931 | 2982 |
throw e; |
2932 | 2983 |
} |
... | ... | |
2939 | 2990 |
+ ee.getMessage(), 50); |
2940 | 2991 |
} |
2941 | 2992 |
} |
2993 |
|
|
2942 | 2994 |
} |
2943 | 2995 |
|
2944 | 2996 |
private static void moveNodesToNodesRevision(DBConnection dbconn, |
... | ... | |
2962 | 3014 |
} |
2963 | 3015 |
|
2964 | 3016 |
/** Save a document entry in the xml_revisions table */ |
2965 |
private static void archiveDocRevision(String docid, String user) |
|
3017 |
private static void archiveDocRevision(String docid, String user) throws Exception
|
|
2966 | 3018 |
{ |
2967 | 3019 |
String sysdate = dbAdapter.getDateTimeFunction(); |
2968 | 3020 |
DBConnection conn = null; |
... | ... | |
2982 | 3034 |
+ "user_owner, user_updated, date_created, date_updated, " |
2983 | 3035 |
+ "server_location, rev, public_access, catalog_id) " |
2984 | 3036 |
+ "SELECT ?, rootnodeid, docname, doctype, " |
2985 |
+ "user_owner, ?, " + sysdate + ", " + sysdate + ", "
|
|
3037 |
+ "user_owner, ?, date_created, date_updated, "
|
|
2986 | 3038 |
+ "server_location, rev, public_access, catalog_id " |
2987 | 3039 |
+ "FROM xml_documents " + "WHERE docid = ?"); |
2988 | 3040 |
// Bind the values to the query and execute it |
3041 |
conn.increaseUsageCount(1); |
|
2989 | 3042 |
pstmt.setString(1, docid); |
2990 | 3043 |
pstmt.setString(2, user); |
2991 | 3044 |
pstmt.setString(3, docid); |
... | ... | |
2995 | 3048 |
MetaCatUtil.debugMessage( |
2996 | 3049 |
"Error in DocumentImpl.archiveDocRevision : " |
2997 | 3050 |
+ e.getMessage(), 30); |
3051 |
throw e; |
|
2998 | 3052 |
} finally { |
2999 | 3053 |
try { |
3000 | 3054 |
pstmt.close(); |
... | ... | |
3002 | 3056 |
MetaCatUtil.debugMessage( |
3003 | 3057 |
"Error in DocumnetImpl.archiveDocRevision: " |
3004 | 3058 |
+ ee.getMessage(), 50); |
3059 |
throw ee; |
|
3005 | 3060 |
} finally { |
3006 | 3061 |
//check in DBConnection |
3007 | 3062 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
... | ... | |
3448 | 3503 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
3449 | 3504 |
} |
3450 | 3505 |
} |
3506 |
/* |
|
3507 |
* This method will write a record to revision table base on given |
|
3508 |
* info. The create date and update will be current time. |
|
3509 |
* If rootNodeId < 0, this means it has not rootid |
|
3510 |
*/ |
|
3511 |
private static void writeDocumentToRevisionTable(DBConnection con, String docId, |
|
3512 |
String rev, String docType, String docName, String user, |
|
3513 |
String catalogid, int serverCode, long rootNodeId, String createDate, String updateDate) throws SQLException, Exception |
|
3514 |
{ |
|
3515 |
|
|
3516 |
try |
|
3517 |
{ |
|
3518 |
PreparedStatement pstmt = null; |
|
3519 |
String sql = null; |
|
3520 |
if (rootNodeId <= 0) |
|
3521 |
{ |
|
3522 |
// this is for data file, not rootnodeid need |
|
3523 |
sql = "INSERT INTO xml_revisions " |
|
3524 |
+ "(docid, docname, doctype, user_owner, " |
|
3525 |
+ "user_updated, date_created, date_updated, " |
|
3526 |
+ "public_access, catalog_id, server_location, rev) " |
|
3527 |
+ "VALUES (?, ?, ?, ?, ?, " + createDate + ", " |
|
3528 |
+ updateDate + ", ?, ?, ?, ?)"; |
|
3529 |
} |
|
3530 |
else |
|
3531 |
{ |
|
3532 |
sql = "INSERT INTO xml_revisions " |
|
3533 |
+ "(docid, docname, doctype, user_owner, " |
|
3534 |
+ "user_updated, date_created, date_updated, " |
|
3535 |
+ "public_access, catalog_id, server_location, rev, rootnodeid ) " |
|
3536 |
+ "VALUES (?, ?, ?, ?, ?, " + createDate + ", " |
|
3537 |
+ updateDate + ", ?, ?, ?, ?, ?)"; |
|
3538 |
} |
|
3539 |
pstmt = con.prepareStatement(sql); |
|
3540 |
// Increase dbconnection usage count |
|
3541 |
con.increaseUsageCount(1); |
|
3542 |
|
|
3543 |
// Bind the values to the query |
|
3544 |
pstmt.setString(1, docId); |
|
3545 |
pstmt.setString(2, docName); |
|
3546 |
pstmt.setString(3, docType); |
|
3547 |
pstmt.setString(4, user); |
|
3548 |
pstmt.setString(5, user); |
|
3549 |
pstmt.setInt(6, 0); |
|
3550 |
pstmt.setInt(7, (new Integer(catalogid)).intValue()); |
|
3551 |
pstmt.setInt(8, serverCode); |
|
3552 |
pstmt.setInt(9, Integer.parseInt(rev)); |
|
3553 |
|
|
3554 |
if (rootNodeId >0 ) |
|
3555 |
{ |
|
3556 |
pstmt.setLong(10, rootNodeId); |
|
3557 |
} |
|
3558 |
// Do the insertion |
|
3559 |
pstmt.execute(); |
|
3560 |
pstmt.close(); |
|
3561 |
|
|
3562 |
|
|
3563 |
} |
|
3564 |
catch (SQLException sqle) |
|
3565 |
{ |
|
3566 |
sqle.printStackTrace(); |
|
3567 |
throw sqle; |
|
3568 |
} |
|
3569 |
catch (Exception e) |
|
3570 |
{ |
|
3571 |
throw e; |
|
3572 |
} |
|
3573 |
} |
|
3574 |
|
|
3575 |
/** |
|
3576 |
* This method will generate record in xml_revision table for a data file |
|
3577 |
* The reason why we need this method is because data file would be parsed by |
|
3578 |
* xml parser. So the constructor would be called for data file and this |
|
3579 |
* method will replace the function |
|
3580 |
*/ |
|
3581 |
static private void registerDeletedDataFile(String docname, |
|
3582 |
String doctype, String accnum, String user, int serverCode, |
|
3583 |
String createDate, String updateDate) throws Exception |
|
3584 |
{ |
|
3585 |
DBConnection dbconn = null; |
|
3586 |
int serialNumber = -1; |
|
3587 |
//MetaCatUtil util = new MetaCatUtil(); |
|
3588 |
AccessionNumber ac; |
|
3589 |
PreparedStatement pstmt = null; |
|
3590 |
String action = null; |
|
3591 |
try |
|
3592 |
{ |
|
3593 |
//dbconn = util.openDBConnection(); |
|
3594 |
dbconn = DBConnectionPool.getDBConnection( |
|
3595 |
"DeletedDocumentImpl.registerDeletedDataFile"); |
|
3596 |
serialNumber = dbconn.getCheckOutSerialNumber(); |
|
3597 |
String docIdWithoutRev = MetaCatUtil |
|
3598 |
.getDocIdFromAccessionNumber(accnum); |
|
3599 |
String rev = MetaCatUtil.getRevisionStringFromString(accnum); |
|
3600 |
writeDocumentToRevisionTable(dbconn, docIdWithoutRev, |
|
3601 |
rev, doctype, docname, user, |
|
3602 |
null, serverCode, -1, createDate, updateDate); |
|
3603 |
dbconn.close(); |
|
3604 |
} |
|
3605 |
finally |
|
3606 |
{ |
|
3607 |
|
|
3608 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
3609 |
} |
|
3610 |
} |
|
3451 | 3611 |
} |
Also available in: Unified diff
Rewrite replication for revision document.