Revision 6448
Added by ben leinfelder over 12 years ago
ReplicationService.java | ||
---|---|---|
47 | 47 |
import java.sql.SQLException; |
48 | 48 |
import java.text.SimpleDateFormat; |
49 | 49 |
import java.util.Date; |
50 |
import java.util.Enumeration; |
|
51 | 50 |
import java.util.Hashtable; |
52 | 51 |
import java.util.List; |
53 | 52 |
import java.util.Timer; |
... | ... | |
85 | 84 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
86 | 85 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
87 | 86 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
88 |
import edu.ucsb.nceas.metacat.util.ReplicationUtil; |
|
89 | 87 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
90 | 88 |
import edu.ucsb.nceas.utilities.FileUtil; |
91 | 89 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
... | ... | |
570 | 568 |
|
571 | 569 |
|
572 | 570 |
String docInfoStr = ReplicationService.getURLContent(docinfourl); |
573 |
// strip out the system metadata portion |
|
574 |
String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr); |
|
575 |
docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr); |
|
576 |
|
|
571 |
|
|
577 | 572 |
//dih is the parser for the docinfo xml format |
578 | 573 |
DocInfoHandler dih = new DocInfoHandler(); |
579 | 574 |
XMLReader docinfoParser = ReplicationHandler.initParser(dih); |
... | ... | |
583 | 578 |
|
584 | 579 |
// Get home server of this docid |
585 | 580 |
String homeServer = (String) docinfoHash.get("home_server"); |
586 |
|
|
587 |
// process system metadata |
|
588 |
if (systemMetadataXML != null) { |
|
589 |
SystemMetadata sysMeta = |
|
590 |
TypeMarshaller.unmarshalTypeFromStream( |
|
591 |
SystemMetadata.class, |
|
592 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
|
593 |
HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta); |
|
594 |
} |
|
595 | 581 |
|
596 | 582 |
// replicate doc contents |
597 | 583 |
String createdDate = (String) docinfoHash.get("date_created"); |
... | ... | |
788 | 774 |
|
789 | 775 |
String docInfoStr = ReplicationService.getURLContent(docinfourl); |
790 | 776 |
|
791 |
// strip out the system metadata portion |
|
792 |
String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr); |
|
793 |
docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr); |
|
794 |
|
|
795 | 777 |
//dih is the parser for the docinfo xml format |
796 | 778 |
DocInfoHandler dih = new DocInfoHandler(); |
797 | 779 |
XMLReader docinfoParser = ReplicationHandler.initParser(dih); |
... | ... | |
850 | 832 |
} |
851 | 833 |
} |
852 | 834 |
} |
853 |
|
|
854 |
// process system metadata |
|
855 |
if (systemMetadataXML != null) { |
|
856 |
SystemMetadata sysMeta = |
|
857 |
TypeMarshaller.unmarshalTypeFromStream( |
|
858 |
SystemMetadata.class, |
|
859 |
new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8"))); |
|
860 |
HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta); |
|
861 |
} |
|
862 | 835 |
|
863 | 836 |
if (writeException != null) { |
864 | 837 |
throw writeException; |
... | ... | |
949 | 922 |
DocumentImpl doc = new DocumentImpl(docid); |
950 | 923 |
sb.append("<documentinfo><docid>").append(docid); |
951 | 924 |
sb.append("</docid>"); |
952 |
|
|
953 |
try { |
|
954 |
// serialize the System Metadata as XML for docinfo |
|
955 |
String guid = IdentifierManager.getInstance().getGUID(doc.getDocID(), doc.getRev()); |
|
956 |
SystemMetadata systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid); |
|
957 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
958 |
TypeMarshaller.marshalTypeToOutputStream(systemMetadata, baos); |
|
959 |
String systemMetadataXML = baos.toString("UTF-8"); |
|
960 |
sb.append("<systemMetadata>"); |
|
961 |
sb.append(systemMetadataXML); |
|
962 |
sb.append("</systemMetadata>"); |
|
963 |
} catch(McdbDocNotFoundException e) { |
|
964 |
logMetacat.warn("No SystemMetadata found for: " + docid); |
|
965 |
} |
|
966 | 925 |
sb.append("<docname>").append(doc.getDocname()); |
967 | 926 |
sb.append("</docname><doctype>").append(doc.getDoctype()); |
968 | 927 |
sb.append("</doctype>"); |
Also available in: Unified diff
do not send <systemMetadata> with the <docInfo> replication information - this is handled by the Hazelcast shared map