Project

General

Profile

« Previous | Next » 

Revision 8738

Added by Jing Tao about 10 years ago

Index the document after document is written to the db.

View differences:

src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
43 43
import java.util.TimerTask;
44 44
import java.util.Vector;
45 45

  
46

  
47 46
import org.apache.log4j.Logger;
48 47
import org.dataone.service.types.v1.SystemMetadata;
49 48
import org.dataone.service.util.DateTimeMarshaller;
......
388 387
      // strip out the system metadata portion
389 388
      String systemMetadataXML = ReplicationUtil.getSystemMetadataContent(docInfoStr);
390 389
   	  docInfoStr = ReplicationUtil.getContentWithoutSystemMetadata(docInfoStr);
391
      
390
   	  SystemMetadata sysMeta = null;
392 391
   	  // process system metadata if we have it
393 392
      if (systemMetadataXML != null) {
394
    	  SystemMetadata sysMeta = 
393
    	  sysMeta = 
395 394
    		  TypeMarshaller.unmarshalTypeFromStream(
396 395
    				  SystemMetadata.class, 
397 396
    				  new ByteArrayInputStream(systemMetadataXML.getBytes("UTF-8")));
......
402 401
      	  // save the system metadata
403 402
    	  logReplication.debug("Saving SystemMetadata to shared map: " + sysMeta.getIdentifier().getValue());
404 403
      	  HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
405
      	  // submit for indexing
406
          MetacatSolrIndex.getInstance().submit(sysMeta.getIdentifier(), sysMeta, null, true);
404
      	  
407 405
      }
408 406
   	  
409 407
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
......
458 456
                              createdDate,
459 457
                              updatedDate);
460 458
      
459
      if(sysMeta != null) {
460
			// submit for indexing. When the doc writing process fails, the index process will fail as well. But this failure
461
			// will not interrupt the process.
462
			try {
463
				MetacatSolrIndex.getInstance().submit(sysMeta.getIdentifier(), sysMeta, null, true);
464
			} catch (Exception ee) {
465
				logReplication.warn("ReplicationService.handleForceReplicateRequest - couldn't index the doc since "+ee.getMessage());
466
			}
467
          
468
		}
469
      
461 470
      //set the user information
462 471
      String user = (String) docinfoHash.get("user_owner");
463 472
      String updated = (String) docinfoHash.get("user_updated");

Also available in: Unified diff