Project

General

Profile

Revision 6614

use DateTimeMarshaller for all replication date transfers

View differences:

src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
48 48

  
49 49
import org.apache.log4j.Logger;
50 50
import org.dataone.service.types.v1.SystemMetadata;
51
import org.dataone.service.util.DateTimeMarshaller;
51 52
import org.dataone.service.util.TypeMarshaller;
52 53
import org.xml.sax.ContentHandler;
53 54
import org.xml.sax.ErrorHandler;
......
399 400
      // dates
400 401
      String createdDateString = docinfoHash.get("date_created");
401 402
      String updatedDateString = docinfoHash.get("date_updated");
402
      Date createdDate = DatatypeConverter.parseDateTime(createdDateString).getTime();
403
      Date updatedDate = DatatypeConverter.parseDateTime(updatedDateString).getTime();
403
      Date createdDate = DateTimeMarshaller.deserializeDateToUTC(createdDateString);
404
      Date updatedDate = DateTimeMarshaller.deserializeDateToUTC(updatedDateString);
404 405
      
405 406
      //docid should include rev number too
406 407
      /*String accnum=docId+util.getProperty("document.accNumSeparator")+
......
564 565
      String docHomeServer = docinfoHash.get("home_server");
565 566
      String createdDateString = docinfoHash.get("date_created");
566 567
      String updatedDateString = docinfoHash.get("date_updated");
567
      Date createdDate = DatatypeConverter.parseDateTime(createdDateString).getTime();
568
      Date updatedDate = DatatypeConverter.parseDateTime(updatedDateString).getTime();
568
      Date createdDate = DateTimeMarshaller.deserializeDateToUTC(createdDateString);
569
      Date updatedDate = DateTimeMarshaller.deserializeDateToUTC(updatedDateString);
569 570
      //docid should include rev number too
570 571
      /*String accnum=docId+util.getProperty("document.accNumSeparator")+
571 572
                                              (String)docinfoHash.get("rev");*/
......
777 778
    	  
778 779
    	  // parse the ISO datetime
779 780
         String datestr = datexml.substring(11, datexml.indexOf('<', 11));
780
         Calendar updated = DatatypeConverter.parseDateTime(datestr);
781
         Date updated = DateTimeMarshaller.deserializeDateToUTC(datestr);
781 782
         
782 783
         StringBuffer sql = new StringBuffer();
783 784
         sql.append("update xml_replication set last_checked = ? ");
784 785
         sql.append(" where server like ? ");
785 786
         pstmt = dbConn.prepareStatement(sql.toString());
786
         pstmt.setTimestamp(1, new Timestamp(updated.getTimeInMillis()));
787
         pstmt.setTimestamp(1, new Timestamp(updated.getTime()));
787 788
         pstmt.setString(2, server);
788 789
         
789 790
         pstmt.executeUpdate();
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
48 48
import java.sql.ResultSet;
49 49
import java.sql.SQLException;
50 50
import java.sql.Timestamp;
51
import java.text.SimpleDateFormat;
52 51
import java.util.Calendar;
53 52
import java.util.Date;
54 53
import java.util.Hashtable;
......
58 57

  
59 58
import javax.servlet.http.HttpServletRequest;
60 59
import javax.servlet.http.HttpServletResponse;
61
import javax.xml.bind.DatatypeConverter;
62 60

  
63 61
import org.apache.http.HttpResponse;
64 62
import org.apache.http.conn.scheme.Scheme;
......
66 64
import org.apache.log4j.Logger;
67 65
import org.dataone.client.RestClient;
68 66
import org.dataone.client.auth.CertificateManager;
69
import org.dataone.service.types.v1.Session;
70 67
import org.dataone.service.types.v1.SystemMetadata;
68
import org.dataone.service.util.DateTimeMarshaller;
71 69
import org.dataone.service.util.TypeMarshaller;
72 70
import org.xml.sax.InputSource;
73 71
import org.xml.sax.SAXException;
......
610 608
			// dates
611 609
			String createdDateString = docinfoHash.get("date_created");
612 610
			String updatedDateString = docinfoHash.get("date_updated");
613
			Date createdDate = DatatypeConverter.parseDateTime(createdDateString).getTime();
614
			Date updatedDate = DatatypeConverter.parseDateTime(updatedDateString).getTime();
611
			Date createdDate = DateTimeMarshaller.deserializeDateToUTC(createdDateString);
612
			Date updatedDate = DateTimeMarshaller.deserializeDateToUTC(updatedDateString);
615 613
		      
616 614
			logReplication.info("ReplicationService.handleForceReplicateRequest - homeServer: " + homeServer);
617 615
			// Get Document type
......
824 822
			String createdDateString = docinfoHash.get("date_created");
825 823
			String updatedDateString = docinfoHash.get("date_updated");
826 824
			
827
			Date createdDate = DatatypeConverter.parseDateTime(createdDateString).getTime();
828
			Date updatedDate = DatatypeConverter.parseDateTime(updatedDateString).getTime();
825
			Date createdDate = DateTimeMarshaller.deserializeDateToUTC(createdDateString);
826
			Date updatedDate = DateTimeMarshaller.deserializeDateToUTC(updatedDateString);
829 827
			
830 828
			logReplication.info("ReplicationService.handleForceReplicateDataFileRequest - docHomeServer of datafile: " + docHomeServer);
831 829

  
......
1000 998
			sb.append("</user_owner><user_updated>").append(doc.getUserupdated());
1001 999
			sb.append("</user_updated>");
1002 1000
			sb.append("<date_created>");
1003
			sb.append(DatatypeConverter.printDateTime(created));
1001
			sb.append(DateTimeMarshaller.serializeDateToUTC(doc.getCreateDate()));
1004 1002
			sb.append("</date_created>");
1005 1003
			sb.append("<date_updated>");
1006
			sb.append(DatatypeConverter.printDateTime(updated));
1004
			sb.append(DateTimeMarshaller.serializeDateToUTC(doc.getUpdateDate()));
1007 1005
			sb.append("</date_updated>");
1008 1006
			sb.append("<home_server>");
1009 1007
			sb.append(doc.getDocHomeServer());
......
1761 1759
	protected static void handleGetTimeRequest(
1762 1760
			Hashtable<String, String[]> params, HttpServletResponse response) {
1763 1761
		
1764
		// use standard ISO format -- the receiving end wants this too
1765
		String dateString = DatatypeConverter.printDateTime(Calendar.getInstance());
1762
		// use standard format -- the receiving end wants this too
1763
		String dateString = DateTimeMarshaller.serializeDateToUTC(Calendar.getInstance().getTime());
1766 1764
		
1767 1765
		// get a writer for sending back to response
1768 1766
		response.setContentType("text/xml");
src/edu/ucsb/nceas/metacat/replication/ReplicationServlet.java
26 26

  
27 27
package edu.ucsb.nceas.metacat.replication;
28 28

  
29
import java.io.ByteArrayInputStream;
30 29
import java.io.FileInputStream;
31
import java.io.FileNotFoundException;
32 30
import java.io.IOException;
33 31
import java.io.InputStream;
34 32
import java.io.OutputStream;
......
49 47
import javax.servlet.http.HttpServletResponse;
50 48
import javax.servlet.http.HttpSession;
51 49

  
52
import org.apache.commons.io.IOUtils;
53 50
import org.apache.log4j.Logger;
54 51
import org.dataone.client.auth.CertificateManager;
55 52

  

Also available in: Unified diff