Revision 1057
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
410 | 410 |
//if the url contains a dbaction then the default action is overridden |
411 | 411 |
if(params.containsKey("dbaction")) { |
412 | 412 |
dbaction = ((String[])params.get("dbaction"))[0]; |
413 |
serverCode = MetacatReplication.getServerCode(server); |
|
414 |
override = true; //we are now overriding the default action |
|
413 |
//serverCode = MetacatReplication.getServerCode(server);
|
|
414 |
//override = true; //we are now overriding the default action
|
|
415 | 415 |
} |
416 | 416 |
MetacatReplication.replLog("force replication request from " + server); |
417 | 417 |
|
418 | 418 |
// sending back read request to server |
419 |
|
|
419 | 420 |
URL u = new URL("https://" + server + "?server=" |
420 | 421 |
+util.getLocalReplicationServerName() |
421 | 422 |
+"&action=read&docid=" + docid); |
422 | 423 |
String xmldoc = MetacatReplication.getURLContent(u); |
423 |
|
|
424 |
|
|
424 | 425 |
// get the document info from server |
425 | 426 |
URL docinfourl = new URL("https://" + server + |
426 | 427 |
"?server="+util.getLocalReplicationServerName() |
427 | 428 |
+"&action=getdocumentinfo&docid=" + docid); |
429 |
|
|
428 | 430 |
String docInfoStr = MetacatReplication.getURLContent(docinfourl); |
429 |
|
|
431 |
|
|
430 | 432 |
//dih is the parser for the docinfo xml format |
431 | 433 |
DocInfoHandler dih = new DocInfoHandler(); |
432 | 434 |
XMLReader docinfoParser = ReplicationHandler.initParser(dih); |
433 | 435 |
docinfoParser.parse(new InputSource(new StringReader(docInfoStr))); |
434 | 436 |
Hashtable docinfoHash = dih.getDocInfo(); |
435 | 437 |
String user = (String)docinfoHash.get("user_owner"); |
436 |
|
|
438 |
|
|
439 |
String homeServer=(String)docinfoHash.get("home_server"); |
|
440 |
|
|
437 | 441 |
// write the document here |
438 | 442 |
Connection conn = util.openDBConnection(); |
439 |
DocumentImpl.write(conn, new StringReader(xmldoc), null, dbaction, docid, |
|
440 |
user, null, serverCode, override); |
|
443 |
DocumentImpl.writeReplication(conn, new StringReader(xmldoc), null, null, |
|
444 |
dbaction, docid, user, null, homeServer, false); |
|
445 |
|
|
446 |
|
|
441 | 447 |
conn.close(); |
442 | 448 |
|
443 | 449 |
MetacatReplication.replLog("document " + docid + " added to DB with " + |
... | ... | |
445 | 451 |
} catch(Exception e) { |
446 | 452 |
System.out.println("ERROR in MetacatReplication.handleForceReplicate" + |
447 | 453 |
"Request(): " + e.getMessage()); |
454 |
e.printStackTrace(); |
|
448 | 455 |
} |
449 | 456 |
} |
450 | 457 |
|
... | ... | |
470 | 477 |
String docid = ((String[])params.get("docid"))[0]; // sent the document |
471 | 478 |
if (docid==null) |
472 | 479 |
{ |
473 |
util.debugMessage("Didn't specify docid for replication"); |
|
480 |
util.debugMessage("Didn't specify docid for replication", 10);
|
|
474 | 481 |
return; |
475 | 482 |
} |
476 | 483 |
//docid was switch to two parts |
... | ... | |
616 | 623 |
* Sends all of the xml_documents information encoded in xml to a requestor |
617 | 624 |
* the format is: |
618 | 625 |
* <!ELEMENT documentinfo (docid, docname, doctype, doctitle, user_owner, |
619 |
* user_updated, public_access, rev)
|
|
626 |
* user_updated, home_server, public_access, rev)/>
|
|
620 | 627 |
* all of the subelements of document info are #PCDATA |
621 | 628 |
*/ |
622 | 629 |
private void handleGetDocumentInfoRequest(PrintWriter out, Hashtable params, |
... | ... | |
634 | 641 |
sb.append("</docid><docname>").append(doc.getDocname()); |
635 | 642 |
sb.append("</docname><doctype>").append(doc.getDoctype()); |
636 | 643 |
sb.append("</doctype>"); |
637 |
// DOCTITLE attr cleared from the db |
|
638 |
// sb.append("</doctype><doctitle>").append(doc.getDocTitle()); |
|
639 | 644 |
sb.append("<user_owner>").append(doc.getUserowner()); |
640 | 645 |
sb.append("</user_owner><user_updated>").append(doc.getUserupdated()); |
641 |
sb.append("</user_updated><public_access>").append(doc.getPublicaccess()); |
|
646 |
sb.append("</user_updated>"); |
|
647 |
sb.append("<home_server>"); |
|
648 |
sb.append(doc.getHomeServer(docid)); |
|
649 |
sb.append("</home_server>"); |
|
650 |
sb.append("<public_access>").append(doc.getPublicaccess()); |
|
642 | 651 |
sb.append("</public_access><rev>").append(doc.getRev()); |
643 | 652 |
sb.append("</rev></documentinfo>"); |
644 | 653 |
response.setContentType("text/xml"); |
Also available in: Unified diff
Revise the method getDocumentInfo. Home server of documnet is added in it.