Revision 6099
Added by ben leinfelder almost 13 years ago
ReplicationHandler.java | ||
---|---|---|
248 | 248 |
//v is the list of updated documents |
249 | 249 |
Vector<Vector<String>> updateList = new Vector<Vector<String>>(message.getUpdatesVect()); |
250 | 250 |
logReplication.info("ReplicationHandler.update - The document list size is "+updateList.size()+ " from "+message.getServerName()); |
251 |
//System.out.println("v: " + v.toString()); |
|
252 | 251 |
//d is the list of deleted documents |
253 | 252 |
Vector<Vector<String>> deleteList = new Vector<Vector<String>>(message.getDeletesVect()); |
254 |
//System.out.println("d: " + d.toString()); |
|
255 | 253 |
logReplication.info("ReplicationHandler.update - Update vector size: "+ updateList.size()+" from "+message.getServerName()); |
256 | 254 |
logReplication.info("ReplicationHandler.update - Delete vector size: "+ deleteList.size()+" from "+message.getServerName()); |
257 | 255 |
logReplication.info("ReplicationHandler.update - The delete document list size is "+deleteList.size()+" from "+message.getServerName()); |
... | ... | |
421 | 419 |
} |
422 | 420 |
|
423 | 421 |
//process guid |
424 |
logReplication.debug("Processing guid information from docinfoHash: " + docinfoHash.toString()); |
|
425 | 422 |
String guid = docinfoHash.get("guid"); |
426 |
String docName = docinfoHash.get("docname"); |
|
427 |
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%guid passed from docinfo hash: " + guid); |
|
428 |
IdentifierManager idman = IdentifierManager.getInstance(); |
|
429 |
|
|
430 |
System.out.println("docname: " + docName); |
|
431 |
|
|
432 |
if(guid != null && !idman.identifierExists(guid)) |
|
433 |
{ //if the guid was passed in, put it in the identifiers table |
|
434 |
logReplication.debug("Creating guid/docid mapping for docid " + |
|
435 |
docinfoHash.get("docid") + " and guid: " + guid); |
|
436 |
|
|
437 |
|
|
438 |
System.out.println("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid")); |
|
439 |
idman.createMapping(guid, docinfoHash.get("docid")); |
|
440 |
} |
|
441 |
else |
|
442 |
{ |
|
443 |
logReplication.debug("No guid information was included with the replicated document"); |
|
444 |
} |
|
445 |
|
|
446 |
//handle systemMetadata |
|
447 |
if(docName.trim().equals("systemMetadata")) |
|
448 |
{ |
|
449 |
if (actions.equalsIgnoreCase("UPDATE")) { |
|
450 |
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!update mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid")); |
|
451 |
idman.updateSystemMetadataMapping(guid, docinfoHash.get("docid")); |
|
452 |
} else { |
|
453 |
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid")); |
|
454 |
idman.createSystemMetadataMapping(guid, docinfoHash.get("docid")); |
|
455 |
} |
|
456 |
|
|
457 |
Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded"))); |
|
423 |
logMetacat.debug("Guid passed from docinfo hash: " + guid); |
|
424 |
if (guid != null) { |
|
425 |
// if the guid was passed in, put it in the identifiers table |
|
426 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
427 |
logReplication.debug("Creating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
428 |
IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid")); |
|
429 |
} else { |
|
430 |
logReplication.debug("Updating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
431 |
IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid")); |
|
432 |
} |
|
433 |
// process system metadata |
|
434 |
Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded"))); |
|
458 | 435 |
Date dateModified = new Date(new Long(docinfoHash.get("date_modified"))); |
459 | 436 |
SystemMetadata sysMeta = IdentifierManager.getInstance().asSystemMetadata( |
460 | 437 |
dateUploaded, |
... | ... | |
468 | 445 |
docinfoHash.get("guid"), |
469 | 446 |
docinfoHash.get("object_format"), |
470 | 447 |
new Long(docinfoHash.get("size")).longValue()); |
471 |
IdentifierManager.getInstance().insertAdditionalSystemMetadataFields(sysMeta); |
|
472 |
|
|
473 |
System.out.println("4"); |
|
474 |
} |
|
475 |
|
|
476 |
if(guid != null) |
|
477 |
{ |
|
478 |
if(!docName.trim().equals("systemMetadata")) |
|
479 |
{ |
|
480 |
logReplication.info("replicate D1GUID:" + guid + ":D1SCIMETADATA:" + |
|
481 |
accNumber + ":"); |
|
448 |
if (actions.equalsIgnoreCase("INSERT")) { |
|
449 |
logMetacat.debug("Creating systemMetadata for guid: " + guid); |
|
450 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
482 | 451 |
} |
483 |
else |
|
484 |
{ |
|
485 |
logReplication.info("replicate D1GUID:" + guid + ":D1SYSMETADATA:" + |
|
486 |
accNumber + ":"); |
|
487 |
} |
|
452 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
488 | 453 |
} |
489 | 454 |
|
490 | 455 |
logReplication.info("ReplicationHandler.handleSingleXMLDocument - Successfully replicated doc " + accNumber); |
... | ... | |
623 | 588 |
} |
624 | 589 |
} |
625 | 590 |
|
591 |
//process guid |
|
592 |
String guid = docinfoHash.get("guid"); |
|
593 |
logMetacat.debug("Guid passed from docinfo hash: " + guid); |
|
594 |
if (guid != null) { |
|
595 |
// if the guid was passed in, put it in the identifiers table |
|
596 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
597 |
logReplication.debug("Creating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
598 |
IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid")); |
|
599 |
} else { |
|
600 |
logReplication.debug("Updating guid/docid mapping for docid " + docinfoHash.get("docid") + " and guid: " + guid); |
|
601 |
IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid")); |
|
602 |
} |
|
603 |
// process system metadata |
|
604 |
Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded"))); |
|
605 |
Date dateModified = new Date(new Long(docinfoHash.get("date_modified"))); |
|
606 |
SystemMetadata sysMeta = IdentifierManager.getInstance().asSystemMetadata( |
|
607 |
dateUploaded, |
|
608 |
docinfoHash.get("rights_holder"), |
|
609 |
docinfoHash.get("checksum"), |
|
610 |
docinfoHash.get("checksum_algorithm"), |
|
611 |
docinfoHash.get("origin_member_node"), |
|
612 |
docinfoHash.get("authoritive_member_node"), |
|
613 |
dateModified, |
|
614 |
docinfoHash.get("submitter"), |
|
615 |
docinfoHash.get("guid"), |
|
616 |
docinfoHash.get("object_format"), |
|
617 |
new Long(docinfoHash.get("size")).longValue()); |
|
618 |
if (actions.equalsIgnoreCase("INSERT")) { |
|
619 |
logMetacat.debug("Creating systemMetadata for guid: " + guid); |
|
620 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
621 |
} |
|
622 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
623 |
} |
|
624 |
|
|
626 | 625 |
logReplication.info("ReplicationHandler.handleSingleDataFile - Successfully to write datafile " + accNumber); |
627 | 626 |
/*MetacatReplication.replLog("wrote datafile " + accNumber + " from " + |
628 | 627 |
remote server);*/ |
... | ... | |
706 | 705 |
//because delete method docid should have rev number |
707 | 706 |
//so we just add one for it. This rev number is no sence. |
708 | 707 |
String accnum=docId+PropertyService.getProperty("document.accNumSeparator")+"1"; |
709 |
//System.out.println("accnum: "+accnum); |
|
710 | 708 |
DocumentImpl.delete(accnum, null, null, notifyServer); |
711 | 709 |
logReplication.info("ReplicationHandler.handleDeleteSingleDocument - Successfully deleted doc " + docId); |
712 | 710 |
logReplication.info("ReplicationHandler.handleDeleteSingleDocument - Doc " + docId + " deleted"); |
... | ... | |
892 | 890 |
Vector<String> v = new Vector<String>(localCatalog.elementAt(i)); |
893 | 891 |
logReplication.info("ReplicationHandler.updateCatalog - v1: " + v.toString()); |
894 | 892 |
publicId.add(new String((String)v.elementAt(3))); |
895 |
//System.out.println("adding " + (String)v.elementAt(3)); |
|
896 | 893 |
} |
897 | 894 |
}//try |
898 | 895 |
catch (Exception e) |
... | ... | |
914 | 911 |
getDBConnection("ReplicationHandler.updateCatalog"); |
915 | 912 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
916 | 913 |
Vector<String> v = remoteCatalog.elementAt(i); |
917 |
//System.out.println("v2: " + v.toString());
|
|
918 |
//System.out.println("i: " + i);
|
|
919 |
//System.out.println("remoteCatalog.size(): " + remoteCatalog.size());
|
|
920 |
//System.out.println("publicID: " + publicId.toString());
|
|
914 |
//logMetacat.debug("v2: " + v.toString());
|
|
915 |
//logMetacat.debug("i: " + i);
|
|
916 |
//logMetacat.debug("remoteCatalog.size(): " + remoteCatalog.size());
|
|
917 |
//logMetacat.debug("publicID: " + publicId.toString());
|
|
921 | 918 |
logReplication.info |
922 | 919 |
("ReplicationHandler.updateCatalog - v.elementAt(3): " + (String)v.elementAt(3)); |
923 | 920 |
if(!publicId.contains(v.elementAt(3))) |
924 | 921 |
{ //so we don't have this public id in our local table so we need to |
925 | 922 |
//add it. |
926 |
//System.out.println("in if");
|
|
923 |
//logMetacat.debug("in if");
|
|
927 | 924 |
StringBuffer sql = new StringBuffer(); |
928 | 925 |
sql.append("insert into xml_catalog (entry_type, source_doctype, "); |
929 | 926 |
sql.append("target_doctype, public_id, system_id) values (?,?,?,"); |
930 | 927 |
sql.append("?,?)"); |
931 |
//System.out.println("sql: " + sql.toString());
|
|
928 |
//logMetacat.debug("sql: " + sql.toString());
|
|
932 | 929 |
pstmt = dbConn.prepareStatement(sql.toString()); |
933 | 930 |
pstmt.setString(1, (String)v.elementAt(0)); |
934 | 931 |
pstmt.setString(2, (String)v.elementAt(1)); |
... | ... | |
1203 | 1200 |
logReplication.error("ReplicationHandler.handleDocList - Could not retrieve data file flag property. " |
1204 | 1201 |
+ "Leaving as false: " + pnfe.getMessage()); |
1205 | 1202 |
} |
1206 |
// System.out.println("w: " + w.toString());
|
|
1203 |
// logMetacat.debug("w: " + w.toString());
|
|
1207 | 1204 |
// Get docid |
1208 | 1205 |
String docid = (String) w.elementAt(0); |
1209 | 1206 |
logReplication.info("docid: " + docid); |
Also available in: Unified diff
-remove system metadata guid -> local id mapping (there is no document for system metadata now)
-include system metadata elements when replicating data objects (TODO: transfer all system metadata structures with the docinfo request).
TODO: remove docid+rev from the systemMetadata table definition