Project

General

Profile

« Previous | Next » 

Revision 561

Added by berkley over 23 years ago

added functionality to allow the replication servlet to assertain and insert user and group info into the local database. started implementation of insert replication handler (it is commented out in this commit)

View differences:

ReplicationHandler.java
29 29
import org.xml.sax.SAXException;
30 30
import org.xml.sax.SAXParseException;
31 31
import org.xml.sax.helpers.XMLReaderFactory;
32
import org.xml.sax.helpers.DefaultHandler;
32 33

  
34

  
35

  
33 36
/**
34 37
 * This class handles deltaT replication checking.  Whenever this TimerTask
35 38
 * is fired it checks each server in xml_replication for updates and updates
......
186 189
            //work as a param to this method but it doesn'.  I don't know why
187 190
            //but putting a string reader there works but not an 
188 191
            //inputStreamReader.
192
            DocInfoHandler dih = new DocInfoHandler();
193
            XMLReader docinfoParser = initParser(dih);
194
            URL docinfoUrl = new URL("http://" + docServer + 
195
                                     "?action=getdocumentinfo&docid=" +
196
                                     docid);
197
            InputStreamReader isr = new InputStreamReader(
198
                                        docinfoUrl.openStream());
199
            StringBuffer docInfoBuffer = new StringBuffer();
200
            while((istreamInt = isr.read()) != 1)
201
            {
202
              istreamChar = (char)istreamInt;
203
              docInfoBuffer.append(istreamChar);
204
            }
205
            
206
            docinfoParser.parse(new InputSource(new StringReader(
207
                                                docInfoBuffer.toString())));
208
            Hashtable docinfoHash = dih.getDocInfo();
209
            
189 210
            String newDocid = DocumentImpl.write(conn, 
190
                                               new StringReader(serverResponse.toString())
191
                                               /*getDocIstream*/, 
192
                                               action, 
193
                                               docid, null, null, serverCode);
211
                               new StringReader(serverResponse.toString())
212
                               /*getDocIstream*/, 
213
                               action, 
214
                               docid, (String)docinfoHash.get("user_owner"), 
215
                               (String)docinfoHash.get("user_owner"), 
216
                               serverCode);
194 217
            System.out.println("newDocid: " + newDocid + " " + action + "ED");
195 218
          }
196 219
        }
......
201 224
          String docid = (String)w.elementAt(0);
202 225
          
203 226
          DocumentImpl.delete(conn, docid, null, null);
227
          System.out.println("Document " + docid + " deleted.");
204 228
        }
205 229
      }
206 230

  
......
267 291
  /**
268 292
   * Method to initialize the message parser
269 293
   */
270
  private static XMLReader initParser(ReplMessageHandler rmh)
294
  private static XMLReader initParser(DefaultHandler dh)
271 295
          throws Exception
272 296
  {
273 297
    XMLReader parser = null;
274 298

  
275 299
    try {
276
      ContentHandler chandler = rmh;
300
      ContentHandler chandler = dh;
277 301

  
278 302
      // Get an instance of the parser
279 303
      MetaCatUtil util = new MetaCatUtil();

Also available in: Unified diff