Revision 1021
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
310 | 310 |
util.returnConnection(dbconn); |
311 | 311 |
} |
312 | 312 |
} |
313 |
/** |
|
314 |
* unRegister a an XML file (data file) from the database (actually, |
|
315 |
* just make it a revision in the xml_revisions table and delete it |
|
316 |
* from xml_documents table). |
|
317 |
* |
|
318 |
* @param docid the ID of the document to be deleted from the database |
|
319 |
*/ |
|
320 |
public static void unRegisterDocument( Connection conn, String accnum, |
|
321 |
String user, String[] groups ) |
|
322 |
throws Exception |
|
323 |
{ |
|
324 |
|
|
313 | 325 |
|
326 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
|
327 |
AccessionNumber ac = new AccessionNumber(conn, accnum, "DELETE"); |
|
328 |
String docid = ac.getDocid(); |
|
329 |
String rev = ac.getRev(); |
|
330 |
|
|
331 |
|
|
332 |
// check for 'write' permission for 'user' to delete this document |
|
333 |
if ( !hasPermission(conn, user, groups, docid) ) { |
|
334 |
throw new Exception("User " + user + |
|
335 |
" does not have permission to delete XML Document #" + accnum); |
|
336 |
} |
|
337 |
|
|
338 |
conn.setAutoCommit(false); |
|
339 |
// Copy the record to the xml_revisions table |
|
340 |
DocumentImpl.archiveDocRevision( conn, docid, user ); |
|
341 |
|
|
342 |
// Now delete it from the xml_documents table |
|
343 |
|
|
344 |
Statement stmt = conn.createStatement(); |
|
345 |
//stmt.execute("DELETE FROM xml_access WHERE docid = '" + docid + "'"); |
|
346 |
stmt.execute("DELETE FROM xml_documents WHERE docid = '" + docid + "'"); |
|
347 |
stmt.close(); |
|
348 |
conn.commit(); |
|
349 |
conn.setAutoCommit(true); |
|
350 |
|
|
351 |
|
|
352 |
} |
|
314 | 353 |
/** |
315 | 354 |
* get the document name |
316 | 355 |
*/ |
... | ... | |
1076 | 1115 |
|
1077 | 1116 |
//after inserting the document locally, tell the document's home server |
1078 | 1117 |
//to come get a copy from here. |
1079 |
ForceReplicationHandler frh = new ForceReplicationHandler(accnum); |
|
1118 |
//ture mean it is xml document |
|
1119 |
ForceReplicationHandler frh = new ForceReplicationHandler(accnum, true); |
|
1080 | 1120 |
|
1081 | 1121 |
return (accnum); |
1082 | 1122 |
} |
... | ... | |
1136 | 1176 |
{ |
1137 | 1177 |
|
1138 | 1178 |
//start the thread to replicate this new document out to the other servers |
1139 |
ForceReplicationHandler frh = new ForceReplicationHandler(accnum, action); |
|
1179 |
//true mean it is xml document |
|
1180 |
ForceReplicationHandler frh = new ForceReplicationHandler |
|
1181 |
(accnum, action, true); |
|
1140 | 1182 |
|
1141 | 1183 |
} |
1142 | 1184 |
|
Also available in: Unified diff
Add a new method named unRegisterDocument. This method will delete the record in xml_document table which is for a data file