Revision 1217
Added by Jing Tao almost 22 years ago
DocumentImpl.java | ||
---|---|---|
72 | 72 |
static final int READ = 4; |
73 | 73 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
74 | 74 |
|
75 |
private Connection conn = null;
|
|
75 |
private DBConnection connection = null;
|
|
76 | 76 |
private String docid = null; |
77 | 77 |
private String updatedVersion=null; |
78 | 78 |
private String docname = null; |
... | ... | |
102 | 102 |
* @param docid the identifier of the document to be created |
103 | 103 |
* @param readNodes flag indicating whether the xmlnodes should be read |
104 | 104 |
*/ |
105 |
public DocumentImpl(Connection conn, String docid, boolean readNodes)
|
|
105 |
public DocumentImpl(String docid, boolean readNodes) |
|
106 | 106 |
throws McdbException |
107 | 107 |
{ |
108 | 108 |
try { |
109 |
this.conn = conn; |
|
109 |
//this.conn = conn;
|
|
110 | 110 |
this.docid = docid; |
111 | 111 |
|
112 | 112 |
// Look up the document information |
113 | 113 |
getDocumentInfo(docid); |
114 |
|
|
114 |
|
|
115 | 115 |
if (readNodes) { |
116 | 116 |
// Download all of the document nodes using a single SQL query |
117 | 117 |
// The sort order of the records is determined by the NodeComparator |
118 | 118 |
// class, and needs to represent a depth-first traversal for the |
119 | 119 |
// toXml() method to work properly |
120 | 120 |
nodeRecordList = getNodeRecordList(rootnodeid); |
121 |
|
|
121 | 122 |
} |
122 | 123 |
|
123 | 124 |
} catch (McdbException ex) { |
... | ... | |
135 | 136 |
* @param conn the database connection from which to read the document |
136 | 137 |
* @param docid the identifier of the document to be created |
137 | 138 |
*/ |
138 |
public DocumentImpl(Connection conn, String docid) throws McdbException
|
|
139 |
public DocumentImpl(String docid) throws McdbException |
|
139 | 140 |
{ |
140 |
this(conn, docid, true);
|
|
141 |
this(docid, true); |
|
141 | 142 |
} |
142 | 143 |
|
143 | 144 |
/** |
... | ... | |
164 | 165 |
* resides. |
165 | 166 |
* |
166 | 167 |
*/ |
167 |
public DocumentImpl(Connection conn, long rootnodeid, String docname, |
|
168 |
/*public DocumentImpl(Connection conn, long rootnodeid, String docname,
|
|
168 | 169 |
String doctype, String docid, String action, String user, |
169 | 170 |
String pub, String catalogid, int serverCode) |
170 | 171 |
throws SQLException, Exception |
... | ... | |
175 | 176 |
this.doctype = doctype; |
176 | 177 |
this.docid = docid; |
177 | 178 |
writeDocumentToDB(action, user, pub, catalogid, serverCode); |
178 |
} |
|
179 |
}*/
|
|
179 | 180 |
|
180 | 181 |
/** |
181 | 182 |
* Construct a new document instance, writing the contents to the database. |
... | ... | |
206 | 207 |
* resides. |
207 | 208 |
* |
208 | 209 |
*/ |
209 |
public DocumentImpl(Connection conn, long rootNodeId, String docName, |
|
210 |
public DocumentImpl(DBConnection conn, long rootNodeId, String docName,
|
|
210 | 211 |
String docType, String docId, String newRevision, |
211 | 212 |
String action, String user, |
212 | 213 |
String pub, String catalogId, int serverCode) |
213 | 214 |
throws SQLException, Exception |
214 | 215 |
{ |
215 |
this.conn = conn; |
|
216 |
this.connection = conn;
|
|
216 | 217 |
this.rootnodeid = rootNodeId; |
217 | 218 |
this.docname = docName; |
218 | 219 |
this.doctype = docType; |
... | ... | |
228 | 229 |
String docname, String doctype, String accnum, String user) |
229 | 230 |
throws SQLException, AccessionNumberException, Exception |
230 | 231 |
{ |
231 |
Connection dbConn = null; |
|
232 |
MetaCatUtil ut = new MetaCatUtil(); |
|
232 |
|
|
233 | 233 |
try |
234 | 234 |
{ |
235 |
dbConn = ut.openDBConnection(); |
|
236 |
// get server location for this doc |
|
237 |
int serverLocation=getServerLocationNumber(dbConn,accnum); |
|
238 |
dbConn.close(); |
|
235 |
// get server location for this doc |
|
236 |
int serverLocation=getServerLocationNumber(accnum); |
|
239 | 237 |
registerDocument(docname, doctype,accnum, user, serverLocation); |
240 | 238 |
} |
241 | 239 |
catch (Exception e) |
242 | 240 |
{ |
243 | 241 |
throw e; |
244 | 242 |
} |
245 |
finally |
|
246 |
{ |
|
247 |
try |
|
248 |
{ |
|
249 |
dbConn.close(); |
|
250 |
} |
|
251 |
catch (Exception ee) |
|
252 |
{} |
|
253 |
} |
|
243 |
|
|
254 | 244 |
|
255 | 245 |
} |
256 | 246 |
/** |
... | ... | |
280 | 270 |
String user, int serverCode) |
281 | 271 |
throws SQLException, AccessionNumberException, Exception |
282 | 272 |
{ |
283 |
Connection dbconn = null; |
|
284 |
MetaCatUtil util = new MetaCatUtil(); |
|
273 |
DBConnection dbconn = null; |
|
274 |
int serialNumber = -1; |
|
275 |
PreparedStatement pstmt = null; |
|
276 |
//MetaCatUtil util = new MetaCatUtil(); |
|
285 | 277 |
AccessionNumber ac; |
286 | 278 |
try { |
287 |
dbconn = util.openDBConnection(); |
|
279 |
//dbconn = util.openDBConnection(); |
|
280 |
//check out DBConnection |
|
281 |
dbconn=DBConnectionPool. |
|
282 |
getDBConnection("DocumentImpl.registerDocument"); |
|
283 |
serialNumber=dbconn.getCheckOutSerialNumber(); |
|
288 | 284 |
String docIdWithoutRev=MetaCatUtil.getDocIdFromString(accnum); |
289 | 285 |
int userSpecifyRev=MetaCatUtil.getVersionFromString(accnum); |
290 |
int revInDataBase=getLatestRevisionNumber(dbconn, docIdWithoutRev);
|
|
286 |
int revInDataBase=getLatestRevisionNumber(docIdWithoutRev); |
|
291 | 287 |
//revIndataBase=-1, there is no record in xml_documents table |
292 | 288 |
//the data file is a new one, inert it into table |
293 | 289 |
//user specified rev should be great than 0 |
294 | 290 |
if (revInDataBase==-1 && userSpecifyRev>0 ) |
295 | 291 |
{ |
296 |
ac = new AccessionNumber(dbconn, accnum, "insert");
|
|
292 |
ac = new AccessionNumber(accnum, "insert"); |
|
297 | 293 |
} |
298 | 294 |
//rev is greater the last revsion number and revInDataBase isn't -1 |
299 | 295 |
// it is a updated data file |
... | ... | |
301 | 297 |
{ |
302 | 298 |
|
303 | 299 |
//archive the old entry |
304 |
archiveDocRevision(dbconn, docIdWithoutRev, user);
|
|
300 |
archiveDocRevision(docIdWithoutRev, user); |
|
305 | 301 |
//delete the old entry in xml_documents |
306 |
deleteXMLDocuments(dbconn, docIdWithoutRev);
|
|
307 |
ac = new AccessionNumber(dbconn, accnum, "update");
|
|
302 |
deleteXMLDocuments(docIdWithoutRev); |
|
303 |
ac = new AccessionNumber(accnum, "update"); |
|
308 | 304 |
} |
309 | 305 |
//other situation |
310 | 306 |
else |
... | ... | |
336 | 332 |
sql.append(sqlDateString).append(","); |
337 | 333 |
sql.append(sqlDateString).append(","); |
338 | 334 |
sql.append("'0')"); |
339 |
PreparedStatement pstmt = dbconn.prepareStatement(sql.toString());
|
|
335 |
pstmt = dbconn.prepareStatement(sql.toString()); |
|
340 | 336 |
pstmt.execute(); |
341 | 337 |
pstmt.close(); |
342 |
dbconn.close(); |
|
338 |
//dbconn.close();
|
|
343 | 339 |
} |
344 | 340 |
finally |
345 | 341 |
{ |
346 | 342 |
try |
347 | 343 |
{ |
348 |
dbconn.close();
|
|
344 |
pstmt.close();
|
|
349 | 345 |
} |
350 |
catch (SQLException sqlE)
|
|
346 |
finally
|
|
351 | 347 |
{ |
352 |
util.debugMessage("Error in DocumentImpl.registerDocument:" + |
|
353 |
sqlE.getMessage(), 30); |
|
348 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
354 | 349 |
} |
355 | 350 |
} |
356 | 351 |
} |
... | ... | |
385 | 380 |
String user, int serverCode) |
386 | 381 |
throws SQLException, AccessionNumberException, Exception |
387 | 382 |
{ |
388 |
Connection dbconn = null; |
|
389 |
MetaCatUtil util = new MetaCatUtil(); |
|
383 |
DBConnection dbconn = null; |
|
384 |
int serialNumber = -1; |
|
385 |
//MetaCatUtil util = new MetaCatUtil(); |
|
390 | 386 |
AccessionNumber ac; |
387 |
PreparedStatement pstmt = null; |
|
391 | 388 |
try { |
392 |
dbconn = util.openDBConnection(); |
|
389 |
//dbconn = util.openDBConnection(); |
|
390 |
dbconn=DBConnectionPool. |
|
391 |
getDBConnection("DocumentImpl.registerDocumentInReplication"); |
|
392 |
serialNumber=dbconn.getCheckOutSerialNumber(); |
|
393 | 393 |
String docIdWithoutRev=MetaCatUtil.getDocIdFromString(accnum); |
394 | 394 |
int userSpecifyRev=MetaCatUtil.getVersionFromString(accnum); |
395 |
int revInDataBase=getLatestRevisionNumber(dbconn, docIdWithoutRev);
|
|
395 |
int revInDataBase=getLatestRevisionNumber(docIdWithoutRev); |
|
396 | 396 |
//revIndataBase=-1, there is no record in xml_documents table |
397 | 397 |
//the data file is a new one, inert it into table |
398 | 398 |
//user specified rev should be great than 0 |
399 | 399 |
if (revInDataBase==-1 && userSpecifyRev>0 ) |
400 | 400 |
{ |
401 | 401 |
|
402 |
ac = new AccessionNumber(dbconn, accnum, "insert");
|
|
402 |
ac = new AccessionNumber(accnum, "insert"); |
|
403 | 403 |
} |
404 | 404 |
//rev is greater the last revsion number and revInDataBase isn't -1 |
405 | 405 |
// it is a updated data file |
... | ... | |
407 | 407 |
{ |
408 | 408 |
|
409 | 409 |
//archive the old entry |
410 |
archiveDocRevision(dbconn, docIdWithoutRev, user);
|
|
410 |
archiveDocRevision(docIdWithoutRev, user); |
|
411 | 411 |
//delete the old entry in xml_documents |
412 |
deleteXMLDocuments(dbconn, docIdWithoutRev);
|
|
413 |
ac = new AccessionNumber(dbconn, accnum, "update");
|
|
412 |
deleteXMLDocuments(docIdWithoutRev); |
|
413 |
ac = new AccessionNumber(accnum, "update"); |
|
414 | 414 |
} |
415 | 415 |
//other situation |
416 | 416 |
else |
... | ... | |
442 | 442 |
sql.append(sqlDateString).append(","); |
443 | 443 |
sql.append(sqlDateString).append(","); |
444 | 444 |
sql.append("'0')"); |
445 |
PreparedStatement pstmt = dbconn.prepareStatement(sql.toString());
|
|
445 |
pstmt = dbconn.prepareStatement(sql.toString()); |
|
446 | 446 |
pstmt.execute(); |
447 | 447 |
pstmt.close(); |
448 |
dbconn.close(); |
|
448 |
//dbconn.close();
|
|
449 | 449 |
} |
450 | 450 |
finally |
451 | 451 |
{ |
452 |
try |
|
453 |
{ |
|
454 |
dbconn.close(); |
|
455 |
} |
|
456 |
catch (SQLException sqlE) |
|
457 |
{ |
|
458 |
util.debugMessage("Error in DocumentImpl.registerDocument:" + |
|
459 |
sqlE.getMessage()); |
|
460 |
} |
|
452 |
pstmt.close(); |
|
453 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
461 | 454 |
} |
462 | 455 |
} |
463 | 456 |
|
... | ... | |
539 | 532 |
public static boolean getDataFileLockGrant(String accnum) |
540 | 533 |
throws Exception |
541 | 534 |
{ |
542 |
Connection dbConn = null; |
|
543 |
MetaCatUtil ut= new MetaCatUtil(); |
|
535 |
|
|
544 | 536 |
try |
545 | 537 |
{ |
546 |
dbConn = ut.openDBConnection(); |
|
547 |
int serverLocation=getServerLocationNumber(dbConn,accnum);
|
|
548 |
dbConn.close(); |
|
538 |
|
|
539 |
int serverLocation=getServerLocationNumber(accnum); |
|
540 |
|
|
549 | 541 |
return getDataFileLockGrant(accnum,serverLocation); |
550 | 542 |
} |
551 | 543 |
catch (Exception e) |
552 | 544 |
{ |
553 |
try |
|
554 |
{ |
|
555 |
dbConn.close(); |
|
556 |
} |
|
557 |
catch (Exception ee) |
|
558 |
{} |
|
545 |
|
|
559 | 546 |
throw e; |
560 | 547 |
} |
561 | 548 |
} |
... | ... | |
574 | 561 |
throws Exception |
575 | 562 |
{ |
576 | 563 |
boolean flag=true; |
577 |
MetaCatUtil util = new MetaCatUtil(); |
|
578 |
String docid = util.getDocIdFromString(accnum);
|
|
579 |
int rev = util.getVersionFromString(accnum);
|
|
564 |
//MetaCatUtil util = new MetaCatUtil();
|
|
565 |
String docid = MetaCatUtil.getDocIdFromString(accnum);
|
|
566 |
int rev = MetaCatUtil.getVersionFromString(accnum);
|
|
580 | 567 |
|
581 | 568 |
if (serverCode == 1) |
582 | 569 |
{ |
... | ... | |
594 | 581 |
|
595 | 582 |
String server = MetacatReplication.getServer(serverCode); |
596 | 583 |
MetacatReplication.replLog("attempting to lock " + accnum); |
597 |
URL u = new URL("https://" + server + "?server=" |
|
598 |
+util.getLocalReplicationServerName()+"&action=getlock&updaterev="
|
|
584 |
URL u = new URL("https://" + server + "?server=" +
|
|
585 |
MetaCatUtil.getLocalReplicationServerName()+"&action=getlock&updaterev="
|
|
599 | 586 |
+rev + "&docid=" + docid); |
600 | 587 |
//System.out.println("sending message: " + u.toString()); |
601 | 588 |
String serverResStr = MetacatReplication.getURLContent(u); |
... | ... | |
940 | 927 |
private boolean isRevisionOnly(DocumentIdentifier docid) throws Exception |
941 | 928 |
{ |
942 | 929 |
//System.out.println("inRevisionOnly"); |
943 |
PreparedStatement pstmt; |
|
930 |
DBConnection dbconn = null; |
|
931 |
int serialNumber = -1; |
|
932 |
PreparedStatement pstmt =null; |
|
944 | 933 |
String rev = docid.getRev(); |
945 | 934 |
String newid = docid.getIdentifier(); |
946 |
pstmt = conn.prepareStatement("select rev from xml_documents " + |
|
935 |
try |
|
936 |
{ |
|
937 |
dbconn=DBConnectionPool. |
|
938 |
getDBConnection("DocumentImpl.isRevisionOnly"); |
|
939 |
serialNumber=dbconn.getCheckOutSerialNumber(); |
|
940 |
pstmt = dbconn.prepareStatement("select rev from xml_documents " + |
|
947 | 941 |
"where docid like '" + newid + "'"); |
948 |
pstmt.execute(); |
|
949 |
ResultSet rs = pstmt.getResultSet(); |
|
950 |
boolean tablehasrows = rs.next(); |
|
951 |
if(rev.equals("newest") || rev.equals("all")) |
|
952 |
{ |
|
953 |
return false; |
|
954 |
} |
|
955 |
|
|
956 |
if(tablehasrows) |
|
957 |
{ |
|
958 |
int r = rs.getInt(1); |
|
959 |
pstmt.close(); |
|
960 |
if(new Integer(rev).intValue() == r) |
|
961 |
{ //the current revision in in xml_documents |
|
962 |
//System.out.println("returning false"); |
|
942 |
pstmt.execute(); |
|
943 |
ResultSet rs = pstmt.getResultSet(); |
|
944 |
boolean tablehasrows = rs.next(); |
|
945 |
if(rev.equals("newest") || rev.equals("all")) |
|
946 |
{ |
|
963 | 947 |
return false; |
964 | 948 |
} |
965 |
else if(new Integer(rev).intValue() < r) |
|
966 |
{ //the current revision is in xml_revisions. |
|
967 |
//System.out.println("returning true"); |
|
968 |
return true; |
|
969 |
} |
|
970 |
else if(new Integer(rev).intValue() > r) |
|
971 |
{ //error, rev cannot be greater than r |
|
972 |
throw new Exception("requested revision cannot be greater than " + |
|
949 |
|
|
950 |
if(tablehasrows) |
|
951 |
{ |
|
952 |
int r = rs.getInt(1); |
|
953 |
pstmt.close(); |
|
954 |
if(new Integer(rev).intValue() == r) |
|
955 |
{ //the current revision in in xml_documents |
|
956 |
//System.out.println("returning false"); |
|
957 |
return false; |
|
958 |
} |
|
959 |
else if(new Integer(rev).intValue() < r) |
|
960 |
{ //the current revision is in xml_revisions. |
|
961 |
//System.out.println("returning true"); |
|
962 |
return true; |
|
963 |
} |
|
964 |
else if(new Integer(rev).intValue() > r) |
|
965 |
{ //error, rev cannot be greater than r |
|
966 |
throw new Exception("requested revision cannot be greater than " + |
|
973 | 967 |
"the latest revision number."); |
968 |
} |
|
974 | 969 |
} |
975 |
} |
|
976 |
throw new Exception("the requested docid '" + docid.toString() + |
|
970 |
throw new Exception("the requested docid '" + docid.toString() + |
|
977 | 971 |
"' does not exist"); |
972 |
}//try |
|
973 |
finally |
|
974 |
{ |
|
975 |
pstmt.close(); |
|
976 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
977 |
}//finally |
|
978 | 978 |
} |
979 | 979 |
|
980 | 980 |
private void getDocumentInfo(String docid) throws McdbException, |
... | ... | |
990 | 990 |
*/ |
991 | 991 |
private void getDocumentInfo(DocumentIdentifier docid) throws McdbException |
992 | 992 |
{ |
993 |
PreparedStatement pstmt; |
|
993 |
DBConnection dbconn = null; |
|
994 |
int serialNumber = -1; |
|
995 |
PreparedStatement pstmt = null; |
|
994 | 996 |
String table = "xml_documents"; |
995 | 997 |
|
996 | 998 |
try |
... | ... | |
1013 | 1015 |
|
1014 | 1016 |
} |
1015 | 1017 |
|
1016 |
try { |
|
1018 |
try |
|
1019 |
{ |
|
1020 |
dbconn=DBConnectionPool.getDBConnection("DocumentImpl.getDocumentInfo"); |
|
1021 |
serialNumber=dbconn.getCheckOutSerialNumber(); |
|
1017 | 1022 |
StringBuffer sql = new StringBuffer(); |
1018 | 1023 |
// DOCTITLE attr cleared from the db |
1019 | 1024 |
// sql.append("SELECT docname, doctype, rootnodeid, doctitle, "); |
... | ... | |
1025 | 1030 |
sql.append("' and rev like '").append(docid.getRev()).append("'"); |
1026 | 1031 |
//System.out.println(sql.toString()); |
1027 | 1032 |
pstmt = |
1028 |
conn.prepareStatement(sql.toString()); |
|
1033 |
dbconn.prepareStatement(sql.toString());
|
|
1029 | 1034 |
// Bind the values to the query |
1030 | 1035 |
//pstmt.setString(1, docid.getIdentifier()); |
1031 | 1036 |
//pstmt.setString(2, docid.getRev()); |
... | ... | |
1051 | 1056 |
|
1052 | 1057 |
//get doc home server name |
1053 | 1058 |
|
1054 |
pstmt = conn.prepareStatement("select server " + |
|
1059 |
pstmt = dbconn.prepareStatement("select server " +
|
|
1055 | 1060 |
"from xml_replication where serverid = ?"); |
1056 |
|
|
1057 |
|
|
1061 |
//because connection use twise here, so we need to increase one |
|
1062 |
dbconn.increaseUsageCount(1); |
|
1058 | 1063 |
pstmt.setInt(1, serverlocation); |
1059 | 1064 |
pstmt.execute(); |
1060 | 1065 |
rs = pstmt.getResultSet(); |
... | ... | |
1078 | 1083 |
pstmt.close(); |
1079 | 1084 |
if (this.doctype != null) { |
1080 | 1085 |
pstmt = |
1081 |
conn.prepareStatement("SELECT system_id " + |
|
1086 |
dbconn.prepareStatement("SELECT system_id " +
|
|
1082 | 1087 |
"FROM xml_catalog " + |
1083 | 1088 |
"WHERE public_id = ?"); |
1089 |
//should increase usage count again |
|
1090 |
dbconn.increaseUsageCount(1); |
|
1084 | 1091 |
// Bind the values to the query |
1085 | 1092 |
pstmt.setString(1, doctype); |
1086 | 1093 |
|
... | ... | |
1099 | 1106 |
throw new McdbException("Error accessing database connection in " + |
1100 | 1107 |
"DocumentImpl.getDocumentInfo: ", e); |
1101 | 1108 |
} |
1109 |
finally |
|
1110 |
{ |
|
1111 |
try |
|
1112 |
{ |
|
1113 |
pstmt.close(); |
|
1114 |
} |
|
1115 |
catch (SQLException ee) |
|
1116 |
{ |
|
1117 |
MetaCatUtil.debugMessage("error in DocumentImple.getDocumentInfo: " |
|
1118 |
+ee.getMessage(), 30); |
|
1119 |
}//catch |
|
1120 |
finally |
|
1121 |
{ |
|
1122 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
1123 |
} |
|
1124 |
} |
|
1102 | 1125 |
|
1103 | 1126 |
if (this.docname == null) { |
1104 | 1127 |
throw new McdbDocNotFoundException("Document not found: " + docid); |
... | ... | |
1110 | 1133 |
* |
1111 | 1134 |
* @param rootnodeid the id of the root node of the node tree to look up |
1112 | 1135 |
*/ |
1113 |
private TreeSet getNodeRecordList(long rootnodeid) throws McdbException
|
|
1136 |
private TreeSet getNodeRecordList(long rootnodeid) throws McdbException |
|
1114 | 1137 |
{ |
1115 |
PreparedStatement pstmt; |
|
1138 |
PreparedStatement pstmt = null; |
|
1139 |
DBConnection dbconn = null; |
|
1140 |
int serialNumber = -1; |
|
1116 | 1141 |
TreeSet nodeRecordList = new TreeSet(new NodeComparator()); |
1117 | 1142 |
long nodeid = 0; |
1118 | 1143 |
long parentnodeid = 0; |
... | ... | |
1124 | 1149 |
String quotechar = dbAdapter.getStringDelimiter(); |
1125 | 1150 |
|
1126 | 1151 |
try { |
1152 |
dbconn=DBConnectionPool. |
|
1153 |
getDBConnection("DocumentImpl.getNodeRecordList"); |
|
1154 |
serialNumber=dbconn.getCheckOutSerialNumber(); |
|
1127 | 1155 |
pstmt = |
1128 |
conn.prepareStatement("SELECT nodeid,parentnodeid,nodeindex, " + |
|
1156 |
dbconn.prepareStatement("SELECT nodeid,parentnodeid,nodeindex, " +
|
|
1129 | 1157 |
"nodetype,nodename,nodeprefix,nodedata " + |
1130 | 1158 |
"FROM xml_nodes WHERE rootnodeid = ?"); |
1131 | 1159 |
|
... | ... | |
1158 | 1186 |
throw new McdbException("Error in DocumentImpl.getNodeRecordList " + |
1159 | 1187 |
e.getMessage()); |
1160 | 1188 |
} |
1189 |
finally |
|
1190 |
{ |
|
1191 |
try |
|
1192 |
{ |
|
1193 |
pstmt.close(); |
|
1194 |
} |
|
1195 |
catch (SQLException ee) |
|
1196 |
{ |
|
1197 |
MetaCatUtil.debugMessage("error in DocumentImpl.getNodeRecordList: " |
|
1198 |
+ee.getMessage(), 30); |
|
1199 |
} |
|
1200 |
finally |
|
1201 |
{ |
|
1202 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
1203 |
} |
|
1204 |
} |
|
1205 |
|
|
1161 | 1206 |
|
1162 | 1207 |
if (nodeRecordList != null) { |
1163 | 1208 |
return nodeRecordList; |
... | ... | |
1187 | 1232 |
if (action.equals("INSERT")) { |
1188 | 1233 |
//AccessionNumber ac = new AccessionNumber(); |
1189 | 1234 |
//this.docid = ac.generate(docid, "INSERT"); |
1190 |
System.out.println("before pstmt"); |
|
1191 |
pstmt = conn.prepareStatement( |
|
1235 |
|
|
1236 |
pstmt = connection.prepareStatement(
|
|
1192 | 1237 |
"INSERT INTO xml_documents " + |
1193 | 1238 |
"(docid, rootnodeid, docname, doctype, " + |
1194 | 1239 |
"user_owner, user_updated, date_created, date_updated, " + |
1195 | 1240 |
"public_access, catalog_id, server_location, rev) " + |
1196 | 1241 |
"VALUES (?, ?, ?, ?, ?, ?, " + sysdate + ", " + sysdate + |
1197 | 1242 |
", ?, ?, ?, ?)"); |
1243 |
// Increase dbconnection usage count |
|
1244 |
connection.increaseUsageCount(1); |
|
1245 |
|
|
1198 | 1246 |
//note that the server_location is set to 1. |
1199 | 1247 |
//this means that "localhost" in the xml_replication table must |
1200 | 1248 |
//always be the first entry!!!!! |
... | ... | |
1221 | 1269 |
} else if (action.equals("UPDATE")) { |
1222 | 1270 |
|
1223 | 1271 |
// Save the old document publicaccessentry in a backup table |
1224 |
DocumentImpl.archiveDocRevision( conn, docid, user );
|
|
1225 |
DocumentImpl thisdoc = new DocumentImpl(conn, docid);
|
|
1272 |
DocumentImpl.archiveDocRevision(connection, docid, user );
|
|
1273 |
DocumentImpl thisdoc = new DocumentImpl(docid); |
|
1226 | 1274 |
int thisrev = thisdoc.getRev(); |
1227 | 1275 |
|
1228 | 1276 |
//if the updated vesion is not greater than current one, |
... | ... | |
1240 | 1288 |
|
1241 | 1289 |
// Delete index for the old version of docid |
1242 | 1290 |
// The new index is inserting on the next calls to DBSAXNode |
1243 |
pstmt = conn.prepareStatement( |
|
1291 |
pstmt = connection.prepareStatement(
|
|
1244 | 1292 |
"DELETE FROM xml_index WHERE docid='" + this.docid + "'"); |
1293 |
// Increase dbconnection usage count |
|
1294 |
connection.increaseUsageCount(1); |
|
1295 |
|
|
1245 | 1296 |
pstmt.execute(); |
1246 | 1297 |
pstmt.close(); |
1247 | 1298 |
|
1248 | 1299 |
// Update the new document to reflect the new node tree |
1249 |
pstmt = conn.prepareStatement( |
|
1300 |
pstmt = connection.prepareStatement(
|
|
1250 | 1301 |
"UPDATE xml_documents " + |
1251 | 1302 |
"SET rootnodeid = ?, docname = ?, doctype = ?, " + |
1252 | 1303 |
"user_updated = ?, date_updated = " + sysdate + ", " + |
1253 | 1304 |
"server_location = ?, rev = ?, public_access = ?, catalog_id = ? " + |
1254 | 1305 |
"WHERE docid = ?"); |
1306 |
// Increase dbconnection usage count |
|
1307 |
connection.increaseUsageCount(1); |
|
1255 | 1308 |
// Bind the values to the query |
1256 | 1309 |
pstmt.setLong(1, rootnodeid); |
1257 | 1310 |
pstmt.setString(2, docname); |
... | ... | |
1276 | 1329 |
|
1277 | 1330 |
// Do the insertion |
1278 | 1331 |
pstmt.execute(); |
1279 |
System.out.println("after excecute"); |
|
1332 |
|
|
1280 | 1333 |
pstmt.close(); |
1281 | 1334 |
|
1282 | 1335 |
} catch (SQLException sqle) { |
... | ... | |
1298 | 1351 |
* @param user the user that owns the document |
1299 | 1352 |
* @param groups the groups to which user belongs |
1300 | 1353 |
*/ |
1301 |
public static String write(Connection conn,String filename, |
|
1354 |
public static String write(DBConnection conn,String filename,
|
|
1302 | 1355 |
String pub, String dtdfilename, |
1303 | 1356 |
String action, String docid, String user, |
1304 | 1357 |
String[] groups ) |
... | ... | |
1312 | 1365 |
pub, dtd, action, docid, user, groups, false); |
1313 | 1366 |
} |
1314 | 1367 |
|
1315 |
public static String write(Connection conn,Reader xml,String pub,Reader dtd, |
|
1368 |
public static String write(DBConnection conn,Reader xml,String pub,Reader dtd,
|
|
1316 | 1369 |
String action, String docid, String user, |
1317 | 1370 |
String[] groups, boolean validate) |
1318 | 1371 |
throws Exception { |
1319 | 1372 |
//this method will be called in handleUpdateOrInsert method |
1320 | 1373 |
//in MetacatServlet class |
1321 | 1374 |
// get server location for this doc |
1322 |
int serverLocation=getServerLocationNumber(conn,docid);
|
|
1375 |
int serverLocation=getServerLocationNumber(docid); |
|
1323 | 1376 |
//System.out.println("server location: "+serverLocation); |
1324 | 1377 |
return write(conn,xml,pub,dtd,action,docid,user,groups,serverLocation,false, |
1325 | 1378 |
validate); |
1326 | 1379 |
} |
1327 | 1380 |
|
1328 |
public static String write(Connection conn, Reader xml, String pub, |
|
1381 |
public static String write(DBConnection conn, Reader xml, String pub,
|
|
1329 | 1382 |
String action, String docid, String user, |
1330 | 1383 |
String[] groups ) |
1331 | 1384 |
throws Exception { |
1332 | 1385 |
if(action.equals("UPDATE")) |
1333 | 1386 |
{//if the document is being updated then use the servercode from the |
1334 | 1387 |
//originally inserted document. |
1335 |
DocumentImpl doc = new DocumentImpl(conn, docid);
|
|
1388 |
DocumentImpl doc = new DocumentImpl(docid); |
|
1336 | 1389 |
int servercode = doc.getServerlocation(); |
1337 | 1390 |
return write(conn, xml, pub, action, docid, user, groups, servercode); |
1338 | 1391 |
} |
... | ... | |
1342 | 1395 |
} |
1343 | 1396 |
} |
1344 | 1397 |
|
1345 |
public static String write( Connection conn, Reader xml,
|
|
1398 |
public static String write(DBConnection conn, Reader xml,
|
|
1346 | 1399 |
String action, String docid, String user, |
1347 | 1400 |
String[] groups, int serverCode ) |
1348 | 1401 |
throws Exception |
... | ... | |
1350 | 1403 |
return write(conn,xml,null,action,docid,user,groups,serverCode); |
1351 | 1404 |
} |
1352 | 1405 |
|
1353 |
public static String write( Connection conn, Reader xml, String pub,
|
|
1406 |
public static String write(DBConnection conn, Reader xml, String pub,
|
|
1354 | 1407 |
String action, String docid, String user, |
1355 | 1408 |
String[] groups, int serverCode) |
1356 | 1409 |
throws Exception |
... | ... | |
1359 | 1412 |
serverCode,false,false); |
1360 | 1413 |
} |
1361 | 1414 |
|
1362 |
public static String write( Connection conn, Reader xml, String pub,
|
|
1415 |
public static String write(DBConnection conn, Reader xml, String pub,
|
|
1363 | 1416 |
String action, String docid, String user, |
1364 | 1417 |
String[] groups, int serverCode, boolean override) |
1365 | 1418 |
throws Exception |
... | ... | |
1388 | 1441 |
* update will be locked and version checked. |
1389 | 1442 |
*/ |
1390 | 1443 |
|
1391 |
public static String write( Connection conn,Reader xml,String pub,Reader dtd,
|
|
1392 |
String action, String accnum, String user,
|
|
1393 |
String[] groups, int serverCode, boolean override,
|
|
1394 |
boolean validate)
|
|
1444 |
public static String write(DBConnection conn, Reader xml,String pub,
|
|
1445 |
Reader dtd, String action, String accnum, String user,
|
|
1446 |
String[] groups, int serverCode, boolean override, |
|
1447 |
boolean validate) |
|
1395 | 1448 |
throws Exception |
1396 | 1449 |
{ |
1397 | 1450 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
1398 |
MetaCatUtil util = new MetaCatUtil(); |
|
1399 |
AccessionNumber ac = new AccessionNumber(conn, accnum, action); |
|
1451 |
//MetaCatUtil util = new MetaCatUtil(); |
|
1452 |
MetaCatUtil.debugMessage("conn usage count before writting: " |
|
1453 |
+conn.getUsageCount(), 50); |
|
1454 |
AccessionNumber ac = new AccessionNumber(accnum, action); |
|
1400 | 1455 |
String docid = ac.getDocid(); |
1401 | 1456 |
String rev = ac.getRev(); |
1402 | 1457 |
MetaCatUtil.debugMessage("action: " + action + " servercode: " + |
... | ... | |
1412 | 1467 |
char istreamChar; |
1413 | 1468 |
|
1414 | 1469 |
// check for 'write' permission for 'user' to update this document |
1415 |
if ( !hasPermission(conn, user, groups, docid) ) {
|
|
1470 |
if ( !hasPermission(user, groups, docid) ) { |
|
1416 | 1471 |
throw new Exception("User " + user + |
1417 | 1472 |
" does not have permission to update XML Document #" + accnum); |
1418 | 1473 |
} |
... | ... | |
1421 | 1476 |
String updaterev = id.getRev(); |
1422 | 1477 |
String server = MetacatReplication.getServer(serverCode); |
1423 | 1478 |
MetacatReplication.replLog("attempting to lock " + accnum); |
1424 |
URL u = new URL("https://" + server + "?server=" |
|
1425 |
+util.getLocalReplicationServerName()+"&action=getlock&updaterev="
|
|
1479 |
URL u = new URL("https://" + server + "?server="+
|
|
1480 |
MetaCatUtil.getLocalReplicationServerName()+"&action=getlock&updaterev="
|
|
1426 | 1481 |
+updaterev + "&docid=" + docid); |
1427 | 1482 |
//System.out.println("sending message: " + u.toString()); |
1428 | 1483 |
String serverResStr = MetacatReplication.getURLContent(u); |
... | ... | |
1452 | 1507 |
|
1453 | 1508 |
//If Metacat is super hub, tell all servers in its server list to get |
1454 | 1509 |
//the new document, ture mean it is xml document |
1455 |
if ((util.getOption("hub")).equals("super"))
|
|
1510 |
if ((MetaCatUtil.getOption("hub")).equals("super"))
|
|
1456 | 1511 |
{ |
1457 | 1512 |
ForceReplicationHandler frh = new ForceReplicationHandler(accnum, |
1458 |
true, ReplicationHandler.buildServerList(conn));
|
|
1513 |
true, ReplicationHandler.buildServerList()); |
|
1459 | 1514 |
} |
1460 | 1515 |
else |
1461 | 1516 |
{ |
... | ... | |
1495 | 1550 |
if ( action.equals("UPDATE") ) { |
1496 | 1551 |
// check for 'write' permission for 'user' to update this document |
1497 | 1552 |
|
1498 |
if ( !hasPermission(conn, user, groups, docid) ) {
|
|
1553 |
if ( !hasPermission(user, groups, docid) ) { |
|
1499 | 1554 |
throw new Exception("User " + user + |
1500 | 1555 |
" does not have permission to update XML Document #" + accnum); |
1501 | 1556 |
} |
... | ... | |
1506 | 1561 |
|
1507 | 1562 |
XMLReader parser = initializeParser(conn, action, docid, rev, validate, |
1508 | 1563 |
user, groups, pub, serverCode, dtd); |
1564 |
|
|
1509 | 1565 |
conn.setAutoCommit(false); |
1510 | 1566 |
parser.parse(new InputSource(xml)); |
1511 | 1567 |
conn.commit(); |
... | ... | |
1525 | 1581 |
//start the thread to replicate this new document out to the other servers |
1526 | 1582 |
//true mean it is xml document |
1527 | 1583 |
ForceReplicationHandler frh = new ForceReplicationHandler |
1528 |
(accnum, action, true,ReplicationHandler.buildServerList(conn));
|
|
1584 |
(accnum, action, true,ReplicationHandler.buildServerList()); |
|
1529 | 1585 |
|
1530 | 1586 |
} |
1531 |
|
|
1587 |
MetaCatUtil.debugMessage("Conn Usage count after writting: " |
|
1588 |
+conn.getUsageCount(),50); |
|
1532 | 1589 |
return(accnum); |
1533 | 1590 |
} |
1534 | 1591 |
|
... | ... | |
1547 | 1604 |
* @param validate, if the xml document is valid or not |
1548 | 1605 |
*/ |
1549 | 1606 |
|
1550 |
public static String writeReplication( Connection conn,Reader xml,String pub,
|
|
1551 |
Reader dtd, String action, String accnum, String user,
|
|
1552 |
String[] groups,String homeServer, boolean validate)
|
|
1607 |
public static String writeReplication(DBConnection conn, Reader xml,
|
|
1608 |
String pub, Reader dtd, String action, String accnum, String user,
|
|
1609 |
String[] groups,String homeServer, boolean validate) |
|
1553 | 1610 |
throws Exception |
1554 | 1611 |
{ |
1555 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
|
1556 |
MetaCatUtil util = new MetaCatUtil(); |
|
1557 |
//AccessionNumber ac = new AccessionNumber(conn, accnum, action); |
|
1558 |
//String docid = ac.getDocid(); |
|
1559 |
// String rev = ac.getRev(); |
|
1560 |
String docid=util.getDocIdFromString(accnum); |
|
1561 |
String rev=(new Integer(util.getVersionFromString(accnum))).toString(); |
|
1612 |
|
|
1613 |
String docid=MetaCatUtil.getDocIdFromString(accnum); |
|
1614 |
String rev=(new Integer(MetaCatUtil.getVersionFromString(accnum))). |
|
1615 |
toString(); |
|
1562 | 1616 |
|
1563 | 1617 |
//check if xml_documents table has the document or not |
1564 | 1618 |
//if not, set action to insert |
1565 |
if (getLatestRevisionNumber(conn,docid)==-1)
|
|
1619 |
if (getLatestRevisionNumber(docid)==-1) |
|
1566 | 1620 |
{ |
1567 | 1621 |
action="INSERT"; |
1568 | 1622 |
} |
... | ... | |
1581 | 1635 |
MetaCatUtil.debugMessage("action: " + action + " servercode: " + |
1582 | 1636 |
serverCode, 10); |
1583 | 1637 |
|
1584 |
/*if((serverCode != 1 && action.equals("UPDATE")) ) |
|
1585 |
{ |
|
1586 |
int istreamInt; |
|
1587 |
char istreamChar; |
|
1588 |
DocumentIdentifier id = new DocumentIdentifier(accnum); |
|
1589 |
String updaterev = id.getRev(); |
|
1590 |
String server = MetacatReplication.getServer(serverCode); |
|
1591 |
MetacatReplication.replLog("attempting to lock " + accnum); |
|
1592 |
URL u = new URL("https://" + server + "?server=" |
|
1593 |
+util.getLocalReplicationServerName()+"&action=getlock&updaterev=" |
|
1594 |
+updaterev + "&docid=" + docid); |
|
1595 |
|
|
1596 |
String serverResStr = MetacatReplication.getURLContent(u); |
|
1597 |
String openingtag =serverResStr.substring(0, serverResStr.indexOf(">")+1); |
|
1598 |
if(openingtag.equals("<lockgranted>")) |
|
1599 |
{ |
|
1600 |
try |
|
1601 |
{ |
|
1602 |
|
|
1603 |
MetacatReplication.replLog("lock granted for " + accnum + " from " + |
|
1604 |
server); |
|
1605 |
XMLReader parser = initializeParser(conn, action, docid, updaterev, |
|
1606 |
validate, user, groups, pub, serverCode, dtd); |
|
1607 |
conn.setAutoCommit(false); |
|
1608 |
parser.parse(new InputSource(xml)); |
|
1609 |
conn.commit(); |
|
1610 |
conn.setAutoCommit(true); |
|
1611 |
} |
|
1612 |
catch (Exception e) |
|
1613 |
{ |
|
1614 |
conn.rollback(); |
|
1615 |
conn.setAutoCommit(true); |
|
1616 |
throw e; |
|
1617 |
} |
|
1618 |
return (accnum); |
|
1619 |
} |
|
1638 |
|
|
1620 | 1639 |
|
1621 |
else if(openingtag.equals("<filelocked>")) |
|
1622 |
{ |
|
1623 |
MetacatReplication.replLog("lock denied for " + accnum + " on " + |
|
1624 |
server + " reason: file already locked"); |
|
1625 |
throw new Exception("The file specified is already locked by another " + |
|
1626 |
"user. Please wait 30 seconds, checkout the " + |
|
1627 |
"newer document, merge your changes and try " + |
|
1628 |
"again."); |
|
1629 |
} |
|
1630 |
else if(openingtag.equals("<outdatedfile>")) |
|
1631 |
{ |
|
1632 |
MetacatReplication.replLog("lock denied for " + accnum + " on " + |
|
1633 |
server + " reason: local file outdated"); |
|
1634 |
throw new Exception("The file you are trying to update is an outdated" + |
|
1635 |
" version. Please checkout the newest document, " + |
|
1636 |
"merge your changes and try again."); |
|
1637 |
} |
|
1638 |
}*/ |
|
1639 |
|
|
1640 |
/*if ( action.equals("UPDATE") ) { |
|
1641 |
|
|
1642 |
if ( !hasPermission(conn, user, groups, docid) ) { |
|
1643 |
throw new Exception("User " + user + |
|
1644 |
" does not have permission to update XML Document #" + accnum); |
|
1645 |
} |
|
1646 |
}*/ |
|
1647 |
|
|
1648 | 1640 |
try |
1649 | 1641 |
{ |
1650 | 1642 |
|
... | ... | |
1672 | 1664 |
* |
1673 | 1665 |
* @param docid the ID of the document to be deleted from the database |
1674 | 1666 |
*/ |
1675 |
public static void delete( Connection conn, String accnum,
|
|
1667 |
public static void delete(String accnum, |
|
1676 | 1668 |
String user, String[] groups ) |
1677 | 1669 |
throws Exception |
1678 | 1670 |
{ |
... | ... | |
1685 | 1677 |
// Determine if the docid,rev are OK for DELETE |
1686 | 1678 |
//AccessionNumber ac = new AccessionNumber(conn); |
1687 | 1679 |
//docid = ac.generate(docid, rev, "DELETE"); |
1680 |
DBConnection conn = null; |
|
1681 |
int serialNumber = -1; |
|
1682 |
PreparedStatement pstmt =null; |
|
1683 |
try |
|
1684 |
{ |
|
1685 |
//check out DBConnection |
|
1686 |
conn=DBConnectionPool. |
|
1687 |
getDBConnection("DocumentImpl.delete"); |
|
1688 |
serialNumber=conn.getCheckOutSerialNumber(); |
|
1688 | 1689 |
|
1689 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
|
1690 |
AccessionNumber ac = new AccessionNumber(conn, accnum, "DELETE");
|
|
1691 |
String docid = ac.getDocid(); |
|
1692 |
String rev = ac.getRev(); |
|
1690 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT
|
|
1691 |
AccessionNumber ac = new AccessionNumber(accnum, "DELETE");
|
|
1692 |
String docid = ac.getDocid();
|
|
1693 |
String rev = ac.getRev();
|
|
1693 | 1694 |
|
1694 | 1695 |
|
1695 | 1696 |
// check for 'write' permission for 'user' to delete this document |
1696 |
if ( !hasPermission(conn, user, groups, docid) ) {
|
|
1697 |
throw new Exception("User " + user + |
|
1697 |
if ( !hasPermission(user, groups, docid) ) {
|
|
1698 |
throw new Exception("User " + user +
|
|
1698 | 1699 |
" does not have permission to delete XML Document #" + accnum); |
1699 |
} |
|
1700 |
}
|
|
1700 | 1701 |
|
1701 |
conn.setAutoCommit(false); |
|
1702 |
// Copy the record to the xml_revisions table |
|
1703 |
DocumentImpl.archiveDocRevision( conn, docid, user );
|
|
1702 |
conn.setAutoCommit(false);
|
|
1703 |
// Copy the record to the xml_revisions table
|
|
1704 |
DocumentImpl.archiveDocRevision(conn, docid, user );
|
|
1704 | 1705 |
|
1705 |
// Now delete it from the xml_documents table |
|
1706 |
|
|
1707 |
Statement stmt = conn.createStatement(); |
|
1708 |
stmt.execute("DELETE FROM xml_index WHERE docid = '" + docid + "'"); |
|
1709 |
//stmt.execute("DELETE FROM xml_access WHERE docid = '" + docid + "'"); |
|
1710 |
stmt.execute("DELETE FROM xml_access WHERE accessfileid = '" + docid + "'"); |
|
1711 |
stmt.execute("DELETE FROM xml_relation WHERE docid = '" + docid + "'"); |
|
1712 |
stmt.execute("DELETE FROM xml_documents WHERE docid = '" + docid + "'"); |
|
1713 |
stmt.close(); |
|
1714 |
conn.commit(); |
|
1715 |
conn.setAutoCommit(true); |
|
1706 |
// Now delete it from the xml_index table |
|
1707 |
pstmt = conn.prepareStatement("DELETE FROM xml_index WHERE docid = ?"); |
|
1708 |
pstmt.setString(1,docid); |
|
1709 |
pstmt.execute(); |
|
1710 |
pstmt.close(); |
|
1711 |
conn.increaseUsageCount(1); |
|
1712 |
|
|
1713 |
//stmt.execute("DELETE FROM xml_access WHERE docid = '" + docid + "'"); |
|
1714 |
// Now delete it from xml_access table |
|
1715 |
pstmt = conn. |
|
1716 |
prepareStatement("DELETE FROM xml_access WHERE accessfileid = ?"); |
|
1717 |
pstmt.setString(1, docid); |
|
1718 |
pstmt.execute(); |
|
1719 |
pstmt.close(); |
|
1720 |
conn.increaseUsageCount(1); |
|
1721 |
|
|
1722 |
// Delete it from relation table |
|
1723 |
pstmt = conn. |
|
1724 |
prepareStatement("DELETE FROM xml_relation WHERE docid = ?"); |
|
1725 |
//increase usage count |
|
1726 |
conn.increaseUsageCount(1); |
|
1727 |
pstmt.setString(1, docid); |
|
1728 |
pstmt.execute(); |
|
1729 |
pstmt.close(); |
|
1730 |
|
|
1731 |
// Delete it from xml_doucments table |
|
1732 |
pstmt =conn.prepareStatement("DELETE FROM xml_documents WHERE docid = ?"); |
|
1733 |
pstmt.setString(1, docid); |
|
1734 |
pstmt.execute(); |
|
1735 |
pstmt.close(); |
|
1736 |
//Usaga count increase 1 |
|
1737 |
conn.increaseUsageCount(1); |
|
1738 |
|
|
1739 |
conn.commit(); |
|
1740 |
conn.setAutoCommit(true); |
|
1741 |
}//try |
|
1742 |
finally |
|
1743 |
{ |
|
1744 |
|
|
1745 |
try |
|
1746 |
{ |
|
1747 |
// close preparedStatement |
|
1748 |
pstmt.close(); |
|
1749 |
}//try |
|
1750 |
finally |
|
1751 |
{ |
|
1752 |
//check in DBonnection |
|
1753 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
1754 |
}//finally |
|
1755 |
}//finally |
|
1716 | 1756 |
//IF this is a package document: |
1717 | 1757 |
//delete all of the relations that this document created. |
1718 | 1758 |
//if the deleted document is a package document its relations should |
... | ... | |
1724 | 1764 |
* Check for "WRITE" permission on @docid for @user and/or @groups |
1725 | 1765 |
* from DB connection |
1726 | 1766 |
*/ |
1727 |
private static boolean hasPermission ( Connection conn, String user,
|
|
1767 |
private static boolean hasPermission (String user, |
|
1728 | 1768 |
String[] groups, String docid ) |
1729 | 1769 |
throws SQLException, Exception |
1730 | 1770 |
{ |
1731 | 1771 |
// Check for WRITE permission on @docid for @user and/or @groups |
1732 |
AccessControlList aclobj = new AccessControlList(conn); |
|
1733 |
return aclobj.hasPermission("WRITE", user, groups, docid); |
|
1772 |
//AccessControlList aclobj = new AccessControlList(dbconn); |
|
1773 |
return AccessControlList.hasPermission("WRITE", user, groups, docid); |
|
1774 |
//return aclobj.hasPermission("WRITE", user, groups, docid); |
|
1734 | 1775 |
} |
1735 | 1776 |
|
1736 | 1777 |
/** |
... | ... | |
1740 | 1781 |
*@group, user's group |
1741 | 1782 |
* |
1742 | 1783 |
*/ |
1743 |
public boolean hasReadPermission ( Connection conn, String user,
|
|
1784 |
public static boolean hasReadPermission (String user,
|
|
1744 | 1785 |
String[] groups, String docId ) |
1745 | 1786 |
throws SQLException, Exception |
1746 | 1787 |
{ |
1747 | 1788 |
// Check for READ permission on @docid for @user and/or @groups |
1748 |
AccessControlList aclObj = new AccessControlList(conn); |
|
1749 |
return aclObj.hasPermission("READ", user, groups, docId); |
|
1789 |
//AccessControlList aclObj = new AccessControlList(conn); |
|
1790 |
//return aclObj.hasPermission("READ", user, groups, docId); |
|
1791 |
return AccessControlList.hasPermission("READ", user, groups, docId); |
|
1750 | 1792 |
} |
1751 | 1793 |
|
1752 | 1794 |
/** |
1753 | 1795 |
* Set up the parser handlers for writing the document to the database |
1754 | 1796 |
*/ |
1755 |
private static XMLReader initializeParser(Connection conn, String action,
|
|
1797 |
private static XMLReader initializeParser(DBConnection dbconn, String action,
|
|
1756 | 1798 |
String docid, String rev, boolean validate, |
1757 | 1799 |
String user, String[] groups, String pub, |
1758 | 1800 |
int serverCode, Reader dtd) |
1759 | 1801 |
throws Exception |
1760 | 1802 |
{ |
1761 | 1803 |
XMLReader parser = null; |
1804 |
//DBConnection conn = null; |
|
1805 |
//int serialNumber = -1; |
|
1762 | 1806 |
// |
1763 | 1807 |
// Set up the SAX document handlers for parsing |
1764 | 1808 |
// |
1765 | 1809 |
try { |
1810 |
//check out DBConnection |
|
1811 |
/*conn=DBConnectionPool. |
|
1812 |
getDBConnection("DocumentImpl.initializeParse"); |
|
1813 |
serialNumber=conn.getCheckOutSerialNumber();*/ |
|
1814 |
|
|
1766 | 1815 |
//create a DBSAXHandler object which has the revision specification |
1767 |
ContentHandler chandler = new DBSAXHandler(conn, action, docid, rev,
|
|
1768 |
user, groups, pub, serverCode);
|
|
1769 |
EntityResolver eresolver= new DBEntityResolver(conn, |
|
1816 |
ContentHandler chandler = new DBSAXHandler(dbconn, action,
|
|
1817 |
docid, rev, user, groups, pub, serverCode);
|
|
1818 |
EntityResolver eresolver= new DBEntityResolver(dbconn,
|
|
1770 | 1819 |
(DBSAXHandler)chandler, dtd); |
1771 |
DTDHandler dtdhandler = new DBDTDHandler(conn); |
|
1820 |
DTDHandler dtdhandler = new DBDTDHandler(dbconn);
|
|
1772 | 1821 |
|
1773 | 1822 |
// Get an instance of the parser |
1774 | 1823 |
String parserName = MetaCatUtil.getOption("saxparser"); |
... | ... | |
1795 | 1844 |
} catch (Exception e) { |
1796 | 1845 |
throw e; |
1797 | 1846 |
} |
1847 |
//finally |
|
1848 |
//{ |
|
1849 |
//DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
1850 |
//} |
|
1798 | 1851 |
|
1799 | 1852 |
return parser; |
1800 | 1853 |
} |
1801 | 1854 |
|
1855 |
/** |
|
1856 |
* Save a document entry in the xml_revisions table |
|
1857 |
* Connection use as a paramter is in order to rollback feature |
|
1858 |
*/ |
|
1859 |
private static void archiveDocRevision(DBConnection dbconn, String docid, |
|
1860 |
String user) |
|
1861 |
{ |
|
1862 |
String sysdate = dbAdapter.getDateTimeFunction(); |
|
1863 |
//DBConnection conn = null; |
|
1864 |
//int serialNumber = -1; |
|
1865 |
PreparedStatement pstmt = null; |
|
1866 |
|
|
1867 |
// create a record in xml_revisions table |
|
1868 |
// for that document as selected from xml_documents |
|
1869 |
|
|
1870 |
try |
|
1871 |
{ |
|
1872 |
//check out DBConnection |
|
1873 |
/*conn=DBConnectionPool. |
|
1874 |
getDBConnection("DocumentImpl.archiveDocRevision"); |
|
1875 |
serialNumber=conn.getCheckOutSerialNumber();*/ |
|
1876 |
pstmt = dbconn.prepareStatement( |
|
1877 |
"INSERT INTO xml_revisions " + |
|
1878 |
"(docid, rootnodeid, docname, doctype, " + |
|
1879 |
"user_owner, user_updated, date_created, date_updated, " + |
|
1880 |
"server_location, rev, public_access, catalog_id) " + |
|
1881 |
"SELECT ?, rootnodeid, docname, doctype, " + |
|
1882 |
"user_owner, ?, " + sysdate + ", " + sysdate + ", "+ |
|
1883 |
"server_location, rev, public_access, catalog_id " + |
|
1884 |
"FROM xml_documents " + |
|
1885 |
"WHERE docid = ?"); |
|
1886 |
// Increase dbconnection usage count |
|
1887 |
dbconn.increaseUsageCount(1); |
|
1888 |
// Bind the values to the query and execute it |
|
1889 |
pstmt.setString(1, docid); |
|
1890 |
pstmt.setString(2, user); |
|
1891 |
pstmt.setString(3, docid); |
|
1892 |
pstmt.execute(); |
|
1893 |
pstmt.close(); |
|
1894 |
}//try |
|
1895 |
catch (SQLException e) |
|
1896 |
{ |
|
1897 |
MetaCatUtil.debugMessage("Error in DocumentImpl.archiveDocRevision : "+ |
|
1898 |
e.getMessage(), 30); |
|
1899 |
}//catch |
|
1900 |
finally |
|
1901 |
{ |
|
1902 |
try |
|
1903 |
{ |
|
1904 |
pstmt.close(); |
|
1905 |
}//try |
|
1906 |
catch (SQLException ee) |
|
1907 |
{ |
|
1908 |
MetaCatUtil.debugMessage("Error in DocumnetImpl.archiveDocRevision: "+ |
|
1909 |
ee.getMessage(), 50); |
|
1910 |
}//catch |
|
1911 |
//finally |
|
1912 |
//{ |
|
1913 |
|
|
1914 |
//check in DBConnection |
|
1915 |
//DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
1916 |
//}//finally |
|
1917 |
}//finnally |
|
1918 |
|
|
1919 |
|
|
1920 |
}//achiveDocRevision |
|
1921 |
|
|
1802 | 1922 |
/** Save a document entry in the xml_revisions table */ |
1803 |
private static void archiveDocRevision(Connection conn, String docid, |
|
1804 |
String user) |
|
1923 |
private static void archiveDocRevision(String docid, String user) |
|
1805 | 1924 |
{ |
1806 | 1925 |
String sysdate = dbAdapter.getDateTimeFunction(); |
1926 |
DBConnection conn = null; |
|
1927 |
int serialNumber = -1; |
|
1928 |
PreparedStatement pstmt = null; |
|
1929 |
|
|
1807 | 1930 |
// create a record in xml_revisions table |
1808 | 1931 |
// for that document as selected from xml_documents |
1809 | 1932 |
|
1810 | 1933 |
try |
1811 | 1934 |
{ |
1812 |
PreparedStatement pstmt = conn.prepareStatement( |
|
1935 |
//check out DBConnection |
|
1936 |
conn=DBConnectionPool. |
|
1937 |
getDBConnection("DocumentImpl.archiveDocRevision"); |
|
1938 |
serialNumber=conn.getCheckOutSerialNumber(); |
|
1939 |
pstmt = conn.prepareStatement( |
|
1813 | 1940 |
"INSERT INTO xml_revisions " + |
1814 | 1941 |
"(docid, rootnodeid, docname, doctype, " + |
1815 | 1942 |
"user_owner, user_updated, date_created, date_updated, " + |
... | ... | |
1825 | 1952 |
pstmt.setString(3, docid); |
1826 | 1953 |
pstmt.execute(); |
1827 | 1954 |
pstmt.close(); |
1828 |
} |
|
1955 |
}//try
|
|
1829 | 1956 |
catch (SQLException e) |
1830 | 1957 |
{ |
1831 |
} |
|
1832 |
|
|
1958 |
MetaCatUtil.debugMessage("Error in DocumentImpl.archiveDocRevision : "+ |
|
1959 |
e.getMessage(), 30); |
|
1960 |
}//catch |
|
1961 |
finally |
|
1962 |
{ |
|
1963 |
try |
|
1964 |
{ |
|
1965 |
pstmt.close(); |
|
1966 |
}//try |
|
1967 |
catch (SQLException ee) |
|
1968 |
{ |
|
1969 |
MetaCatUtil.debugMessage("Error in DocumnetImpl.archiveDocRevision: "+ |
|
1970 |
ee.getMessage(), 50); |
|
1971 |
}//catch |
|
1972 |
finally |
|
1973 |
{ |
|
1974 |
//check in DBConnection |
|
1975 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
1976 |
}//finally |
|
1977 |
}//finnally |
|
1978 |
|
|
1833 | 1979 |
|
1834 |
} |
|
1980 |
}//achiveDocRevision
|
|
1835 | 1981 |
|
1836 | 1982 |
/** |
1837 | 1983 |
* delete a entry in xml_table for given docid |
1838 | 1984 |
* @param docId, the id of the document need to be delete |
1839 | 1985 |
*/ |
1840 |
private static void deleteXMLDocuments(Connection conn, String docId)
|
|
1986 |
private static void deleteXMLDocuments(String docId) |
|
1841 | 1987 |
throws SQLException |
1842 | 1988 |
{ |
1843 |
//delete a record |
|
1844 |
PreparedStatement pStmt = |
|
1989 |
DBConnection conn = null; |
|
1990 |
int serialNumber = -1; |
|
1991 |
PreparedStatement pStmt = null; |
|
1992 |
try |
|
1993 |
{ |
|
1994 |
//check out DBConnection |
|
1995 |
conn=DBConnectionPool. |
|
1996 |
getDBConnection("DocumentImpl.deleteXMLDocuments"); |
|
1997 |
serialNumber=conn.getCheckOutSerialNumber(); |
|
1998 |
//delete a record |
|
1999 |
pStmt = |
|
1845 | 2000 |
conn.prepareStatement("DELETE FROM xml_documents WHERE docid = '" |
1846 | 2001 |
+ docId + "'"); |
1847 | 2002 |
pStmt.execute(); |
1848 |
pStmt.close(); |
|
2003 |
}//try |
|
2004 |
finally |
|
2005 |
{ |
|
2006 |
try |
|
2007 |
{ |
|
2008 |
pStmt.close(); |
|
2009 |
}//try |
|
2010 |
catch (SQLException e) |
|
2011 |
{ |
|
2012 |
MetaCatUtil.debugMessage("error in DocumentImpl.deleteXMLDocuments: "+ |
|
2013 |
e.getMessage(), 50); |
|
2014 |
}//catch |
|
2015 |
finally |
|
2016 |
{ |
|
2017 |
//return back DBconnection |
|
2018 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
2019 |
}//finally |
|
2020 |
}//finally |
|
2021 |
|
|
1849 | 2022 |
|
1850 | 2023 |
}//deleteXMLDocuments |
1851 | 2024 |
|
... | ... | |
1855 | 2028 |
* The return value is integer because we want compare it to there new one |
1856 | 2029 |
* @param docid <sitecode>.<uniqueid> part of Accession Number |
1857 | 2030 |
*/ |
1858 |
private static int getLatestRevisionNumber(Connection conn, String docId)
|
|
2031 |
private static int getLatestRevisionNumber(String docId) |
|
1859 | 2032 |
throws SQLException |
1860 | 2033 |
{ |
1861 | 2034 |
int rev = 1; |
1862 |
PreparedStatement pStmt; |
|
2035 |
PreparedStatement pStmt = null; |
|
2036 |
DBConnection dbConn = null; |
|
2037 |
int serialNumber = -1; |
|
2038 |
|
|
2039 |
try |
|
2040 |
{ |
|
2041 |
//check out DBConnection |
|
2042 |
dbConn=DBConnectionPool. |
|
2043 |
getDBConnection("DocumentImpl.getLatestRevisionNumber"); |
|
2044 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
|
1863 | 2045 |
|
1864 |
pStmt = conn.prepareStatement
|
|
2046 |
pStmt = dbConn.prepareStatement
|
|
1865 | 2047 |
("SELECT rev FROM xml_documents WHERE docid='" + docId + "'"); |
1866 |
pStmt.execute(); |
|
2048 |
pStmt.execute();
|
|
1867 | 2049 |
|
1868 |
ResultSet rs = pStmt.getResultSet(); |
|
1869 |
boolean hasRow = rs.next(); |
|
1870 |
if (hasRow) |
|
2050 |
ResultSet rs = pStmt.getResultSet(); |
|
2051 |
boolean hasRow = rs.next(); |
|
2052 |
if (hasRow) |
|
2053 |
{ |
|
2054 |
rev = rs.getInt(1); |
|
2055 |
pStmt.close(); |
|
2056 |
} |
|
2057 |
else |
|
2058 |
{ |
|
2059 |
rev=-1; |
|
2060 |
pStmt.close(); |
|
2061 |
} |
|
2062 |
}//try |
|
2063 |
finally |
|
1871 | 2064 |
{ |
1872 |
rev = rs.getInt(1); |
|
1873 |
pStmt.close(); |
|
1874 |
} |
|
1875 |
else |
|
1876 |
{ |
|
1877 |
rev=-1; |
|
1878 |
pStmt.close(); |
|
1879 |
} |
|
2065 |
try |
|
2066 |
{ |
|
2067 |
pStmt.close(); |
|
2068 |
} |
|
2069 |
catch (Exception ee) |
|
2070 |
{ |
|
2071 |
MetaCatUtil.debugMessage("Error in DocumentImpl."+ |
|
2072 |
"getLatestRevisionNumber: "+ee.getMessage(), 50); |
|
2073 |
} |
|
2074 |
finally |
|
2075 |
{ |
|
2076 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
|
2077 |
} |
|
2078 |
}//finally |
|
1880 | 2079 |
|
1881 | 2080 |
return rev; |
1882 | 2081 |
}//getLatestRevisionNumber |
... | ... | |
1886 | 2085 |
* |
1887 | 2086 |
* @param accum <sitecode>.<uniqueid>.<rev> |
1888 | 2087 |
*/ |
1889 |
private static int getServerLocationNumber(Connection conn, String accNum)
|
|
2088 |
private static int getServerLocationNumber(String accNum) |
|
1890 | 2089 |
throws SQLException |
1891 | 2090 |
{ |
1892 | 2091 |
//get rid of revNum part |
1893 | 2092 |
String docId=MetaCatUtil.getDocIdFromString(accNum); |
1894 |
PreparedStatement pStmt; |
|
1895 |
int serverLocation; |
|
2093 |
PreparedStatement pStmt = null; |
|
2094 |
int serverLocation = 1; |
|
2095 |
DBConnection conn = null; |
|
2096 |
int serialNumber = -1; |
|
2097 |
|
|
2098 |
try |
|
2099 |
{ |
|
2100 |
//check out DBConnection |
|
2101 |
conn=DBConnectionPool. |
|
2102 |
getDBConnection("DocumentImpl.getServerLocationNumber"); |
|
2103 |
serialNumber=conn.getCheckOutSerialNumber(); |
|
1896 | 2104 |
|
1897 |
pStmt = conn.prepareStatement |
|
2105 |
pStmt = conn.prepareStatement
|
|
1898 | 2106 |
("SELECT server_location FROM xml_documents WHERE docid='" + docId + "'"); |
1899 |
pStmt.execute(); |
|
2107 |
pStmt.execute();
|
|
1900 | 2108 |
|
1901 |
ResultSet rs = pStmt.getResultSet(); |
|
1902 |
boolean hasRow = rs.next(); |
|
1903 |
//if there is entry in xml_documents, get the serverlocation |
|
1904 |
if (hasRow) |
|
2109 |
ResultSet rs = pStmt.getResultSet(); |
|
2110 |
boolean hasRow = rs.next(); |
|
2111 |
//if there is entry in xml_documents, get the serverlocation |
|
2112 |
if (hasRow) |
|
2113 |
{ |
|
2114 |
serverLocation = rs.getInt(1); |
|
2115 |
pStmt.close(); |
|
2116 |
} |
|
2117 |
else |
|
2118 |
{ |
|
2119 |
//if htere is no entry in xml_documents, we consider it is new document |
|
2120 |
//the server location is local host and value is 1 |
|
2121 |
serverLocation=1; |
|
2122 |
pStmt.close(); |
|
2123 |
} |
|
2124 |
}//try |
|
2125 |
finally |
|
1905 | 2126 |
{ |
1906 |
serverLocation = rs.getInt(1); |
|
1907 |
pStmt.close(); |
|
1908 |
} |
|
1909 |
else |
|
1910 |
{ |
|
1911 |
// if htere is no entry in xml_documents, we consider it is new document |
|
1912 |
// the server location is local host and value is 1 |
|
1913 |
serverLocation=1; |
|
1914 |
pStmt.close(); |
|
1915 |
} |
|
2127 |
try |
|
2128 |
{ |
|
2129 |
pStmt.close(); |
|
2130 |
}//try |
|
2131 |
catch (Exception ee) |
|
2132 |
{ |
|
2133 |
MetaCatUtil.debugMessage("Error in DocumentImpl.getServerLocationNu(): " |
|
2134 |
+ee.getMessage(), 50); |
|
2135 |
}//catch |
|
2136 |
finally |
|
2137 |
{ |
|
2138 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
2139 |
}//finally |
|
2140 |
}//finally |
|
1916 | 2141 |
|
1917 | 2142 |
return serverLocation; |
1918 | 2143 |
} |
... | ... | |
1926 | 2151 |
{ |
1927 | 2152 |
PreparedStatement pStmt=null; |
1928 | 2153 |
int serverLocation=-2; |
1929 |
Connection dbConn = null; |
|
1930 |
MetaCatUtil util = new MetaCatUtil(); |
|
2154 |
DBConnection dbConn = null; |
|
2155 |
int serialNumber = -1; |
|
2156 |
//MetaCatUtil util = new MetaCatUtil(); |
|
1931 | 2157 |
|
1932 | 2158 |
|
1933 | 2159 |
//we should consider about local host too |
1934 |
if (serverName.equals(util.getLocalReplicationServerName()))
|
|
2160 |
if (serverName.equals(MetaCatUtil.getLocalReplicationServerName()))
|
|
1935 | 2161 |
{ |
1936 | 2162 |
serverLocation=1; |
1937 | 2163 |
return serverLocation; |
... | ... | |
1941 | 2167 |
try |
1942 | 2168 |
{ |
1943 | 2169 |
//check xml_replication table |
1944 |
dbConn=util.openDBConnection(); |
|
2170 |
//dbConn=util.openDBConnection(); |
|
2171 |
//check out DBConnection |
|
2172 |
dbConn=DBConnectionPool.getDBConnection("DocumentImpl.getServerCode"); |
|
2173 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
|
1945 | 2174 |
pStmt = dbConn.prepareStatement |
1946 | 2175 |
("SELECT serverid FROM xml_replication WHERE server='" + serverName +"'"); |
1947 | 2176 |
pStmt.execute(); |
... | ... | |
1963 | 2192 |
} |
1964 | 2193 |
catch (Exception e) |
1965 | 2194 |
{ |
1966 |
util.debugMessage("Error in DocumentImpl.getServerCode(): "
|
|
2195 |
MetaCatUtil.debugMessage("Error in DocumentImpl.getServerCode(): "
|
|
1967 | 2196 |
+e.getMessage(), 30); |
1968 | 2197 |
} |
1969 | 2198 |
finally |
1970 | 2199 |
{ |
1971 | 2200 |
try |
1972 | 2201 |
{ |
1973 |
dbConn.close();
|
|
2202 |
pStmt.close();
|
|
1974 | 2203 |
} |
1975 | 2204 |
catch (Exception ee) |
1976 |
{} |
|
2205 |
{ |
|
2206 |
MetaCatUtil.debugMessage("Error in DocumentImpl.getServerCode(): " |
|
2207 |
+ee.getMessage(), 50); |
|
2208 |
} |
|
2209 |
finally |
|
2210 |
{ |
|
2211 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
|
2212 |
} |
|
1977 | 2213 |
} |
1978 | 2214 |
|
1979 | 2215 |
|
... | ... | |
1987 | 2223 |
private static void insertServerIntoReplicationTable(String server) |
1988 | 2224 |
{ |
1989 | 2225 |
PreparedStatement pStmt=null; |
1990 |
Connection dbConn = null; |
|
2226 |
DBConnection dbConn = null; |
|
2227 |
int serialNumber = -1; |
|
1991 | 2228 |
int replicate = 1; |
1992 |
MetaCatUtil util = new MetaCatUtil(); |
|
2229 |
//MetaCatUtil util = new MetaCatUtil();
|
|
1993 | 2230 |
try |
1994 | 2231 |
{ |
1995 |
dbConn=util.openDBConnection(); |
|
2232 |
//dbConn=util.openDBConnection(); |
|
2233 |
//check out DBConnection |
|
2234 |
dbConn=DBConnectionPool. |
|
2235 |
getDBConnection("DocumentImpl.insertServIntoReplicationTable"); |
|
2236 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
|
1996 | 2237 |
pStmt = dbConn.prepareStatement("INSERT INTO xml_replication " + |
1997 | 2238 |
"(server, last_checked, replicate) " + |
1998 | 2239 |
"VALUES ('" + server + "', to_date(" + |
... | ... | |
2001 | 2242 |
pStmt.execute(); |
2002 | 2243 |
pStmt.close(); |
2003 | 2244 |
dbConn.commit(); |
2004 |
} |
|
2245 |
}//try
|
|
2005 | 2246 |
catch (Exception e) |
2006 | 2247 |
{ |
2007 |
util.debugMessage("Error in DocumentImpl.getServerCode(): "
|
|
2248 |
MetaCatUtil.debugMessage("Error in DocumentImpl.insertServerIntoRepli(): "
|
|
2008 | 2249 |
+e.getMessage(), 30); |
2009 |
} |
|
2250 |
}//catch
|
|
2010 | 2251 |
finally |
2011 | 2252 |
{ |
2253 |
|
|
2012 | 2254 |
try |
2013 | 2255 |
{ |
2014 | 2256 |
pStmt.close(); |
2015 |
dbConn.close(); |
|
2257 |
}//try |
|
2258 |
catch (Exception ee) |
|
2259 |
{ |
|
2260 |
MetaCatUtil.debugMessage("Error in DocumentImpl.insetServerIntoRepl(): " |
|
2261 |
+ee.getMessage(), 50); |
|
2262 |
}//catch |
|
2263 |
finally |
|
2264 |
{ |
|
2265 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
|
2016 | 2266 |
} |
2017 |
catch (Exception ee) |
|
2018 |
{} |
|
2019 |
} |
|
2267 |
|
|
2268 |
}//finally |
|
2020 | 2269 |
|
2021 | 2270 |
} |
2022 | 2271 |
|
Also available in: Unified diff
Merge DBConnection branch to head.