Revision 582
Added by berkley about 24 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
792 | 792 |
{//the lock was granted go ahead with the insert |
793 | 793 |
try |
794 | 794 |
{ |
795 |
System.out.println("in try"); |
|
796 | 795 |
XMLReader parser = initializeParser(conn,action,newdocid,user, |
797 | 796 |
serverCode); |
798 | 797 |
conn.setAutoCommit(false); |
... | ... | |
803 | 802 |
if ( action.equals("UPDATE") ) |
804 | 803 |
{ |
805 | 804 |
Statement stmt = conn.createStatement(); |
806 |
stmt.execute("DELETE FROM xml_access WHERE docid='"+newdocid +"'");
|
|
805 |
stmt.execute("DELETE FROM xml_access WHERE docid='"+newdocid+"'"); |
|
807 | 806 |
stmt.close(); |
808 | 807 |
} |
809 |
AccessControlList aclobj = new AccessControlList(conn, newdocid,acl);
|
|
808 |
AccessControlList aclobj = new AccessControlList(conn,newdocid,acl); |
|
810 | 809 |
conn.commit(); |
811 | 810 |
} |
812 | 811 |
conn.setAutoCommit(true); |
... | ... | |
820 | 819 |
|
821 | 820 |
//after inserting the document locally, tell the document's home server |
822 | 821 |
//to come get a copy from here. |
822 |
ForceReplicationHandler frh = new ForceReplicationHandler(docid); |
|
823 |
/* |
|
823 | 824 |
URL comeAndGetIt = new URL("http://" + server + |
824 | 825 |
"?action=forcereplicate&server=" + |
825 | 826 |
util.getOption("server") + |
... | ... | |
827 | 828 |
"&docid=" + docid); |
828 | 829 |
System.out.println("sending message: " + comeAndGetIt.toString()); |
829 | 830 |
String message = MetacatReplication.getURLContent(comeAndGetIt); |
830 |
|
|
831 |
*/ |
|
831 | 832 |
if ( (docid != null) && !(newdocid.equals(docid)) ) |
832 | 833 |
{ |
833 | 834 |
return new String("New document ID generated:" + newdocid); |
... | ... | |
894 | 895 |
|
895 | 896 |
//force replicate out the new document to each server in our server list. |
896 | 897 |
if(serverCode == 1) |
897 |
{ |
|
898 |
Enumeration keys = (ReplicationHandler.buildServerList(conn)).keys(); |
|
899 |
while(keys.hasMoreElements()) |
|
900 |
{ |
|
901 |
String server = (String)(keys.nextElement()); |
|
902 |
URL comeAndGetIt = new URL("http://" + server + |
|
903 |
"?action=forcereplicate&server=" + |
|
904 |
util.getOption("server") + |
|
905 |
util.getOption("replicationpath") + |
|
906 |
"&docid=" + newdocid + "&dbaction=" + |
|
907 |
action); |
|
908 |
System.out.println("sending message: " + comeAndGetIt.toString()); |
|
909 |
String message = MetacatReplication.getURLContent(comeAndGetIt); |
|
910 |
} |
|
898 |
{ //start the thread to replicate this new document out to the other servers |
|
899 |
ForceReplicationHandler frh = new ForceReplicationHandler(newdocid, |
|
900 |
action); |
|
911 | 901 |
} |
912 | 902 |
|
913 | 903 |
if ( (docid != null) && !(newdocid.equals(docid)) ) |
src/edu/ucsb/nceas/metacat/ReplicationHandler.java | ||
---|---|---|
246 | 246 |
|
247 | 247 |
/** |
248 | 248 |
* Method that returns true if docid has already been "deleted" from metacat. |
249 |
* This method really implements a truth table for deleted documents |
|
250 |
* The table is (a document in one of the tables is represented by the X): |
|
251 |
* xml_docs xml_revs deleted? |
|
252 |
* ------------------------------------ |
|
253 |
* X X FALSE |
|
254 |
* X _ FALSE |
|
255 |
* _ X TRUE |
|
256 |
* _ _ TRUE |
|
249 | 257 |
*/ |
250 | 258 |
private static boolean alreadyDeleted(String docid, Connection conn) |
251 | 259 |
{ |
252 | 260 |
try |
253 | 261 |
{ |
262 |
boolean xml_docs = false; |
|
263 |
boolean xml_revs = false; |
|
264 |
|
|
254 | 265 |
StringBuffer sb = new StringBuffer(); |
255 |
sb.append("select docid from xml_revisions where docid not in "); |
|
256 |
sb.append("(select docid from xml_documents) and docid like '"); |
|
266 |
sb.append("select docid from xml_revisions where docid like '"); |
|
257 | 267 |
sb.append(docid).append("'"); |
258 | 268 |
PreparedStatement pstmt = conn.prepareStatement(sb.toString()); |
259 | 269 |
pstmt.execute(); |
... | ... | |
261 | 271 |
boolean tablehasrows = rs.next(); |
262 | 272 |
if(tablehasrows) |
263 | 273 |
{ |
274 |
xml_revs = true; |
|
275 |
} |
|
276 |
|
|
277 |
sb = new StringBuffer(); |
|
278 |
sb.append("select docid from xml_documents where docid like '"); |
|
279 |
sb.append(docid).append("'"); |
|
280 |
pstmt = conn.prepareStatement(sb.toString()); |
|
281 |
pstmt.execute(); |
|
282 |
rs = pstmt.getResultSet(); |
|
283 |
tablehasrows = rs.next(); |
|
284 |
if(tablehasrows) |
|
285 |
{ |
|
286 |
xml_docs = true; |
|
287 |
} |
|
288 |
|
|
289 |
if(xml_docs && xml_revs) |
|
290 |
{ |
|
291 |
return false; |
|
292 |
} |
|
293 |
else if(xml_docs && !xml_revs) |
|
294 |
{ |
|
295 |
return false; |
|
296 |
} |
|
297 |
else if(!xml_docs && xml_revs) |
|
298 |
{ |
|
264 | 299 |
return true; |
265 | 300 |
} |
266 |
return false; |
|
301 |
else if(!xml_docs && !xml_revs) |
|
302 |
{ |
|
303 |
return true; |
|
304 |
} |
|
267 | 305 |
} |
268 | 306 |
catch(Exception e) |
269 | 307 |
{ |
src/edu/ucsb/nceas/metacat/AccessionNumber.java | ||
---|---|---|
262 | 262 |
} |
263 | 263 |
|
264 | 264 |
/** check for existence of Accesssion Number xml_acc_numbers table */ |
265 |
private boolean accNumberUsed ( String accNumber )
|
|
265 |
public boolean accNumberUsed ( String accNumber )
|
|
266 | 266 |
throws SQLException { |
267 | 267 |
|
268 | 268 |
boolean hasAccNumber = false; |
... | ... | |
359 | 359 |
|
360 | 360 |
/** |
361 | 361 |
* '$Log$ |
362 |
* 'Revision 1.15 2000/11/30 22:41:32 bojilova |
|
363 |
* 'change the generation of Accession# in the form of <sidecode>.<createdate> |
|
364 |
* ' |
|
362 | 365 |
* 'Revision 1.14 2000/09/28 18:05:46 bojilova |
363 | 366 |
* 'Changed to prevent the insertion if the provided Accession# is in use as Dan suggested. |
364 | 367 |
* ' |
Also available in: Unified diff
made replication on insert or update us. Also made a method in AccessionNumber public so that you can tell if an accession number has already been used.e place be