Project

General

Profile

« Previous | Next » 

Revision 1071

Added by Jing Tao almost 22 years ago

Revised update method.

View differences:

ReplicationHandler.java
89 89
      }
90 90
      catch(SQLException sqle)
91 91
      {
92
        try
92
        /*try
93 93
        {
94 94
          conn = util.openDBConnection();
95 95
        }
......
100 100
            conn = util.openDBConnection();
101 101
          }
102 102
          catch(SQLException sqleee)
103
          {
103
          {*/
104 104
            System.out.println("error getting db connection in " + 
105 105
                               "ReplicationHandler.run: " +
106
                               sqleee.getMessage());
107
          }
108
        }
106
                               sqle.getMessage());
107
          //}
108
        //}
109 109
      }
110 110
      serverList = buildServerList(conn);
111 111
      //if serverList is null, metacat don't need to replication
......
207 207
        //System.out.println("d: " + d.toString());
208 208
        //check the revs in u to see if there are any newer ones than
209 209
        //in the local DB.
210
        MetaCatUtil.debugMessage("Update vector size: "+ v.size(), 20);
211
        MetaCatUtil.debugMessage("Delete vector size: "+ d.size(),20);
210 212
        for(int j=0; j<v.size(); j++)
211 213
        {
212 214
          //initial dataFile is false
......
222 224
          }
223 225
          //System.out.println("w: " + w.toString());
224 226
          String docid = (String)w.elementAt(0);
225
          //System.out.println("docid: " + docid);
227
          MetaCatUtil.debugMessage("docid: " + docid, 40);
226 228
          int rev = Integer.parseInt((String)w.elementAt(1));
227
          //System.out.println("rev: " + rev);
229
          MetaCatUtil.debugMessage("rev: " + rev, 40);
228 230
          String docServer = (String)w.elementAt(2);
229
          //System.out.println("docServer: " + docServer);
231
          
230 232
    
231 233
          pstmt = conn.prepareStatement("select rev from xml_documents where "+
232 234
                                        "docid like '" + docid + "'");
......
260 262
              util.getLocalReplicationServerName()+"&action=read&docid="+docid);
261 263
            //System.out.println("Sending message: " + u.toString());
262 264
            String newxmldoc = MetacatReplication.getURLContent(u);
265
            MetaCatUtil.debugMessage("xml documnet:", 50);
266
            MetaCatUtil.debugMessage(newxmldoc, 50);
263 267
            DocInfoHandler dih = new DocInfoHandler();
264 268
            XMLReader docinfoParser = initParser(dih);
265 269
            URL docinfoUrl = new URL("https://" + docServer + 
......
378 382
          URL dateurl = new URL("https://" + server + "?server="+
379 383
          util.getLocalReplicationServerName()+"&action=gettime");
380 384
          String datexml = MetacatReplication.getURLContent(dateurl);
381
          String datestr = datexml.substring(11, datexml.indexOf('<', 11));
382
          StringBuffer sql = new StringBuffer();
383
          sql.append("update xml_replication set last_checked = to_date('");
384
          sql.append(datestr).append("', 'YY-MM-DD HH24:MI:SS') where ");
385
          sql.append("server like '").append(server).append("'");
386
          //System.out.println("sql: " + sql.toString());
387
          pstmt.close();
388
          pstmt = conn.prepareStatement(sql.toString());
389
          pstmt.executeUpdate();
390
          //conn.commit();
391
          System.out.println("last_checked updated to " + datestr + " on " +
385
          MetaCatUtil.debugMessage("datexml: "+datexml, 40);
386
          if (datexml!=null && !datexml.equals(""))
387
          {
388
            String datestr = datexml.substring(11, datexml.indexOf('<', 11));
389
            StringBuffer sql = new StringBuffer();
390
            sql.append("update xml_replication set last_checked = to_date('");
391
            sql.append(datestr).append("', 'YY-MM-DD HH24:MI:SS') where ");
392
            sql.append("server like '").append(server).append("'");
393
            //System.out.println("sql: " + sql.toString());
394
            pstmt.close();
395
            pstmt = conn.prepareStatement(sql.toString());
396
            pstmt.executeUpdate();
397
            //conn.commit();
398
            System.out.println("last_checked updated to " + datestr + " on " +
392 399
                            server);
400
          }
393 401
        }//wile
394 402
      }//for
395 403
    }//try

Also available in: Unified diff