Project

General

Profile

« Previous | Next » 

Revision 6099

-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

View differences:

ReplicationService.java
562 562
			// Get home server of this docid
563 563
			String homeServer = (String) docinfoHash.get("home_server");
564 564
			String guid = (String) docinfoHash.get("guid");
565
			logReplication.info("XXXXXXXXXXXXXXXX GUID found in dociinfoHash: " + guid);
565
			logReplication.debug("GUID found in docinfoHash: " + guid);
566 566
			
567
			logReplication.info("Processing guid " + guid + 
567
			logReplication.debug("Processing guid " + guid + 
568 568
			  " information from handleForceReplicationRequest: " + 
569 569
			  docinfoHash.toString());
570
      IdentifierManager idman = IdentifierManager.getInstance();
571
      if(guid != null)
572
      { //if the guid was passed in, put it in the identifiers table
573
        logReplication.info("YYYYYYYYYYYYYY Creating guid/docid mapping for docid " + 
574
          docinfoHash.get("docid") + " and guid: " + guid);
575
        
576
        docName = (String) docinfoHash.get("docname");
577
        logReplication.info("ZZZZZZZZZZZZ docName: " + docName);
578
        if(docName.trim().equals("systemMetadata"))
579
        {
580
        	if (dbaction.equalsIgnoreCase("UPDATE")) {
581
        		logReplication.info("update mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
582
	            idman.updateSystemMetadataMapping(guid, docinfoHash.get("docid"));
583
	            logReplication.info("handleForceReplicateRequest: updating SM with additional info");
584
        	} else { // insert
585
	            logReplication.info("creating mapping for systemMetadata: guid: " + guid + " localId: " + docinfoHash.get("docid"));
586
	            idman.createSystemMetadataMapping(guid, docinfoHash.get("docid"));
587
        	}
588
        	logReplication.info("handleForceReplicateRequest: updating SM with additional info");
589
        	Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded")));
590
	        Date dateModified = new Date(new Long(docinfoHash.get("date_modified")));
591
            SystemMetadata sysMeta = IdentifierManager.getInstance().asSystemMetadata(
592
                    dateUploaded, 
593
                    docinfoHash.get("rights_holder"),
594
                    docinfoHash.get("checksum"), 
595
                    docinfoHash.get("checksum_algorithm"), 
596
                    docinfoHash.get("origin_member_node"),
597
                    docinfoHash.get("authoritive_member_node"), 
598
                    dateModified,
599
                    docinfoHash.get("submitter"),
600
                    docinfoHash.get("guid"),
601
                    docinfoHash.get("object_format"),
602
                    new Long(docinfoHash.get("size")).longValue());
603
            IdentifierManager.getInstance().insertAdditionalSystemMetadataFields(sysMeta);
604
        }
605
        else
606
        {
607
        	if (dbaction.equalsIgnoreCase("UPDATE")) {
608
        		logReplication.info("updating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
609
	            idman.updateMapping(guid, docinfoHash.get("docid"));
610
        	} else { // insert
611
	            logReplication.info("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
612
	            idman.createMapping(guid, docinfoHash.get("docid"));
613
        	}
614
        }
615
      }
616
      else
617
      {
618
        logReplication.debug("No guid information was included with the replicated document");
619
      }
570
			
571
			//if the guid was passed in, we have system metadata with the doc
572
			if (guid != null) {
573
				// map the guid to local identifiers
574
	        	if (dbaction.equalsIgnoreCase("UPDATE")) {
575
	        		logReplication.info("updating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
576
	        		IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid"));
577
	        	} else { // insert
578
		            logReplication.info("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
579
		            IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid"));
580
	        	}
581
	        	// process system metadata
582
	        	logReplication.info("handleForceReplicateRequest: updating system metadata");
583
	        	Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded")));
584
		        Date dateModified = new Date(new Long(docinfoHash.get("date_modified")));
585
	            SystemMetadata sysMeta = IdentifierManager.getInstance().asSystemMetadata(
586
	                    dateUploaded, 
587
	                    docinfoHash.get("rights_holder"),
588
	                    docinfoHash.get("checksum"), 
589
	                    docinfoHash.get("checksum_algorithm"), 
590
	                    docinfoHash.get("origin_member_node"),
591
	                    docinfoHash.get("authoritive_member_node"), 
592
	                    dateModified,
593
	                    docinfoHash.get("submitter"),
594
	                    docinfoHash.get("guid"),
595
	                    docinfoHash.get("object_format"),
596
	                    new Long(docinfoHash.get("size")).longValue());
597
	        	if (dbaction.equalsIgnoreCase("INSERT")) {
598
		            logReplication.info("Adding systemMetadata for guid: " + guid);
599
		            IdentifierManager.getInstance().createSystemMetadata(sysMeta);
600
	        	}
601
	            IdentifierManager.getInstance().updateSystemMetadata(sysMeta);
602
			}
620 603
      
604
        	// replicate doc contents
621 605
			String createdDate = (String) docinfoHash.get("date_created");
622 606
			String updatedDate = (String) docinfoHash.get("date_updated");
623 607
			logReplication.info("ReplicationService.handleForceReplicateRequest - homeServer: " + homeServer);
......
815 799
				dbaction = "update";
816 800
			}
817 801

  
818
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - force replication request from " + server);
819 802
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - Force replication request from: " + server);
820 803
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - Force replication docid: " + docid);
821 804
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - Force replication action: " + dbaction);
......
843 826
			String updatedDate = (String) docinfoHash.get("date_updated");
844 827
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - docHomeServer of datafile: " + docHomeServer);
845 828

  
846
			//if action is delete, we don't delete the data file. Just archieve
847
			//the xml_documents
848
			/*if (dbaction.equals("delete"))
849
			{
850
			  //conn = util.getConnection();
851
			  DocumentImpl.delete(docid,user,null);
852
			  //util.returnConnection(conn);
853
			}*/
854
			//To data file insert or update is same
855 829
			if (dbaction.equals("insert") || dbaction.equals("update")) {
856 830
				//Get data file and store it into local file system.
857 831
				// sending back readdata request to server
......
893 867
		        		}
894 868
		            }
895 869
		        }
870
		        
871
				String guid = (String) docinfoHash.get("guid");
872
				//if the guid was passed in, we have system metadata with the doc
873
				if (guid != null) {
874
					// map the guid to local identifiers
875
		        	if (dbaction.equalsIgnoreCase("UPDATE")) {
876
		        		logReplication.info("updating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
877
		        		IdentifierManager.getInstance().updateMapping(guid, docinfoHash.get("docid"));
878
		        	} else { // insert
879
			            logReplication.info("creating mapping: guid: " + guid + " localId: " + docinfoHash.get("docid"));
880
			            IdentifierManager.getInstance().createMapping(guid, docinfoHash.get("docid"));
881
		        	}
882
		        	// process system metadata
883
		        	logReplication.info("handleForceReplicateRequest: updating system metadata");
884
		        	Date dateUploaded = new Date(new Long(docinfoHash.get("date_uploaded")));
885
			        Date dateModified = new Date(new Long(docinfoHash.get("date_modified")));
886
		            SystemMetadata sysMeta = IdentifierManager.getInstance().asSystemMetadata(
887
		                    dateUploaded, 
888
		                    docinfoHash.get("rights_holder"),
889
		                    docinfoHash.get("checksum"), 
890
		                    docinfoHash.get("checksum_algorithm"), 
891
		                    docinfoHash.get("origin_member_node"),
892
		                    docinfoHash.get("authoritive_member_node"), 
893
		                    dateModified,
894
		                    docinfoHash.get("submitter"),
895
		                    docinfoHash.get("guid"),
896
		                    docinfoHash.get("object_format"),
897
		                    new Long(docinfoHash.get("size")).longValue());
898
		        	if (dbaction.equalsIgnoreCase("INSERT")) {
899
			            logReplication.info("Adding systemMetadata for guid: " + guid);
900
			            IdentifierManager.getInstance().createSystemMetadata(sysMeta);
901
		        	}
902
		            IdentifierManager.getInstance().updateSystemMetadata(sysMeta);
903
				}
896 904

  
897 905
				if (writeException != null) {
898 906
					throw writeException;
899 907
				}
900 908

  
901
				//false means non-timed replication
902 909
				logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - datafile " + docid + " added to DB with "
903 910
						+ "action " + dbaction);
904 911
				EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER,
......
990 997
			{
991 998
			  String guid = idman.getGUID(doc.getDocID(), doc.getRev());
992 999
			  sb.append("<guid>").append(guid).append("</guid>");
993
			  String smLocalId = idman.getSystemMetadataLocalId(guid);
994
			  Hashtable<String, String> sysmetaInfo = idman.getSystemMetadataInfo(smLocalId);
995
			  if(smLocalId != null && !smLocalId.trim().equals(""))
996
			  {
997
			      sb.append("<systemmetadatalocalid>").append(smLocalId).append("</systemmetadatalocalid>");
998
			  }
1000
			  Hashtable<String, String> sysmetaInfo = idman.getSystemMetadataInfo(guid);
999 1001
			  
1000 1002
			  Enumeration<String> sysmetaKeys = sysmetaInfo.keys();
1001 1003
			  while(sysmetaKeys.hasMoreElements())

Also available in: Unified diff