Project

General

Profile

« Previous | Next » 

Revision 6968

process systemMetadata from the docInfo string before writing to the database so that we guarantee guid-docid mapping exists before attempting to look it up.

View differences:

src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
391 391
      String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr);
392 392
   	  docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr);
393 393
      
394
   	  // process system metadata if we have it
395
      if (systemMetadataXML != null) {
396
    	  SystemMetadata sysMeta = 
397
    		  TypeMarshaller.unmarshalTypeFromStream(
398
    				  SystemMetadata.class, 
399
    				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
400
    	  // need the guid-to-docid mapping
401
    	  if (!IdentifierManager.getInstance().identifierExists(sysMeta.getIdentifier().getValue())) {
402
	      	  IdentifierManager.getInstance().createMapping(sysMeta.getIdentifier().getValue(), accNumber);
403
    	  }
404
      	  // save the system metadata
405
      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
406
      }
407
   	  
394 408
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
395 409
      Hashtable<String, String> docinfoHash = dih.getDocInfo();
396 410
      // Get home server of the docid
......
459 473
          }
460 474
      }
461 475
      
462
      // process system metadata
463
      if (systemMetadataXML != null) {
464
    	  SystemMetadata sysMeta = 
465
    		  TypeMarshaller.unmarshalTypeFromStream(
466
    				  SystemMetadata.class, 
467
    				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
468
    	  // need the guid-to-docid mapping
469
      	  IdentifierManager.getInstance().createMapping(sysMeta.getIdentifier().getValue(), accNumber);
470
      	  // save the system metadata
471
      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
472
      }
473 476
      
474 477
      logReplication.info("ReplicationHandler.handleSingleXMLDocument - Successfully replicated doc " + accNumber);
475 478
      if (tableName.equals(DocumentImpl.DOCUMENTTABLE))
......
555 558
      String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr);
556 559
   	  docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr);  
557 560
   	  
561
   	  // process system metadata
562
      if (systemMetadataXML != null) {
563
    	  SystemMetadata sysMeta = 
564
    		TypeMarshaller.unmarshalTypeFromStream(
565
    				  SystemMetadata.class, 
566
    				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
567
    	  // need the guid-to-docid mapping
568
    	  if (!IdentifierManager.getInstance().identifierExists(sysMeta.getIdentifier().getValue())) {
569
	      	  IdentifierManager.getInstance().createMapping(sysMeta.getIdentifier().getValue(), accNumber);
570
    	  }
571
    	  // save the system metadata
572
    	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
573

  
574
      }
575
   	  
558 576
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
559 577
      Hashtable<String, String> docinfoHash = dih.getDocInfo();
560 578
      
......
613 631
            }
614 632
        }
615 633
        
616
        // process system metadata
617
        if (systemMetadataXML != null) {
618
      	  SystemMetadata sysMeta = 
619
      		TypeMarshaller.unmarshalTypeFromStream(
620
      				  SystemMetadata.class, 
621
      				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
622
      	  // need the guid-to-docid mapping
623
      	  IdentifierManager.getInstance().createMapping(sysMeta.getIdentifier().getValue(), accNumber);
624
      	  // save the system metadata
625
      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
626

  
627
        }
628
        
629 634
        logReplication.info("ReplicationHandler.handleSingleDataFile - Successfully to write datafile " + accNumber);
630 635
        /*MetacatReplication.replLog("wrote datafile " + accNumber + " from " +
631 636
                                    remote server);*/

Also available in: Unified diff