Project

General

Profile

« Previous | Next » 

Revision 574

Added by berkley over 23 years ago

replication on insert functionality is now working.

View differences:

ReplicationHandler.java
173 173
            URL docinfoUrl = new URL("http://" + docServer + 
174 174
                                     "?action=getdocumentinfo&docid=" +
175 175
                                     docid);
176
            InputStreamReader isr = new InputStreamReader(
177
                                        docinfoUrl.openStream());
178
            StringBuffer docInfoBuffer = new StringBuffer();
179
            while((istreamInt = isr.read()) != -1)
180
            {
181
              istreamChar = (char)istreamInt;
182
              docInfoBuffer.append(istreamChar);
183
            }
184
            
185
            docinfoParser.parse(new InputSource(new StringReader(
186
                                                docInfoBuffer.toString())));
176
            String docInfoStr = MetacatReplication.getURLContent(docinfoUrl);
177
            docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
187 178
            Hashtable docinfoHash = dih.getDocInfo();
188 179
            String newDocid = DocumentImpl.write(conn, 
189 180
                               new StringReader(srvrResponseStr),
......
211 202
        server = (String)(keys.nextElement()); 
212 203
        URL dateurl = new URL("http://" + server + "?action=gettime");
213 204
        String datexml = MetacatReplication.getURLContent(dateurl);
214
        System.out.println("datexml: " + datexml);
215 205
        String datestr = datexml.substring(11, datexml.indexOf('<', 11));
216
        System.out.println("datestr: " + datestr);
217 206
        StringBuffer sql = new StringBuffer();
218 207
        sql.append("update xml_replication set last_checked = to_date('");
219 208
        sql.append(datestr).append("', 'YY-MM-DD HH24:MI:SS') where ");
......
272 261
  }
273 262
  
274 263
  /**
275
   * Method to initialize the message parser
276
   */
277
  private static XMLReader initParser(DefaultHandler dh)
278
          throws Exception
279
  {
280
    XMLReader parser = null;
281

  
282
    try {
283
      ContentHandler chandler = dh;
284

  
285
      // Get an instance of the parser
286
      MetaCatUtil util = new MetaCatUtil();
287
      String parserName = util.getOption("saxparser");
288
      parser = XMLReaderFactory.createXMLReader(parserName);
289

  
290
      // Turn off validation
291
      parser.setFeature("http://xml.org/sax/features/validation", false);
292
      
293
      parser.setContentHandler((ContentHandler)chandler);
294
      parser.setErrorHandler((ErrorHandler)chandler);
295

  
296
    } catch (Exception e) {
297
      throw e;
298
    }
299

  
300
    return parser;
301
  }
302
  
303
  /**
304 264
   * Method to query xml_replication and build a hashtable of each server
305 265
   * and it's last update time.
306 266
   * @param conn a connection to the database
......
334 294
    }
335 295
    return sl;
336 296
  }
297
  
298
  /**
299
   * Method to initialize the message parser
300
   */
301
  public static XMLReader initParser(DefaultHandler dh)
302
          throws Exception
303
  {
304
    XMLReader parser = null;
305

  
306
    try {
307
      ContentHandler chandler = dh;
308

  
309
      // Get an instance of the parser
310
      MetaCatUtil util = new MetaCatUtil();
311
      String parserName = util.getOption("saxparser");
312
      parser = XMLReaderFactory.createXMLReader(parserName);
313

  
314
      // Turn off validation
315
      parser.setFeature("http://xml.org/sax/features/validation", false);
316
      
317
      parser.setContentHandler((ContentHandler)chandler);
318
      parser.setErrorHandler((ErrorHandler)chandler);
319

  
320
    } catch (Exception e) {
321
      throw e;
322
    }
323

  
324
    return parser;
325
  }
337 326
}

Also available in: Unified diff