Project

General

Profile

« Previous | Next » 

Revision 2641

Added by Jing Tao over 18 years ago

Change the code to make sure DocumentImpl class's constructor should have rev attached.

View differences:

ReplicationHandler.java
269 269

  
270 270
  /* Handle replicate single xml document*/
271 271
  private void handleSingleXMLDocument(String remoteserver, String actions,
272
                                       String docId, String tableName)
272
                                       String accNumber, String tableName)
273 273
               throws Exception
274 274
  {
275 275
    DBConnection dbConn = null;
......
282 282
      serialNumber=dbConn.getCheckOutSerialNumber();
283 283
      //if the document needs to be updated or inserted, this is executed
284 284
      String readDocURLString = "https://" + remoteserver + "?server="+
285
              util.getLocalReplicationServerName()+"&action=read&docid="+docId;
285
              util.getLocalReplicationServerName()+"&action=read&docid="+accNumber;
286 286
      readDocURLString = MetaCatUtil.replaceWhiteSpaceForURL(readDocURLString);
287 287
      URL u = new URL(readDocURLString);
288 288

  
......
301 301
      XMLReader docinfoParser = initParser(dih);
302 302
      String docInfoURLStr = "https://" + remoteserver +
303 303
                       "?server="+util.getLocalReplicationServerName()+
304
                       "&action=getdocumentinfo&docid="+docId;
304
                       "&action=getdocumentinfo&docid="+accNumber;
305 305
      docInfoURLStr = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLStr);
306 306
      URL docinfoUrl = new URL(docInfoURLStr);
307 307
      MetaCatUtil.debugMessage("Sending message: " +
......
315 315
      String createdDate = (String)docinfoHash.get("date_created");
316 316
      String updatedDate = (String)docinfoHash.get("date_updated");
317 317
      //docid should include rev number too
318
      String accnum=docId+util.getOption("accNumSeparator")+
319
                                              (String)docinfoHash.get("rev");
320
      MetaCatUtil.debugMessage("docid in repl: "+accnum, 45);
318
      /*String accnum=docId+util.getOption("accNumSeparator")+
319
                                              (String)docinfoHash.get("rev");*/
320
      MetaCatUtil.debugMessage("docid in repl: "+accNumber, 45);
321 321
      String docType = (String)docinfoHash.get("doctype");
322 322
      MetaCatUtil.debugMessage("doctype in repl: "+docType, 45);
323 323

  
......
342 342
                              (String)docinfoHash.get("public_access"),
343 343
                              null,  /* the dtd text */
344 344
                              actions,
345
                              accnum,
345
                              accNumber,
346 346
                              (String)docinfoHash.get("user_owner"),
347 347
                              null, /* null for groups[] */
348 348
                              docHomeServer,
349 349
                              remoteserver, tableName, true,// true is for time replication 
350 350
                              createdDate,
351 351
                              updatedDate);
352
      MetaCatUtil.debugMessage("Successfully replicated doc " + accnum, 35);
353
      MetacatReplication.replLog("wrote doc " + accnum + " from " +
352
      MetaCatUtil.debugMessage("Successfully replicated doc " + accNumber, 35);
353
      MetacatReplication.replLog("wrote doc " + accNumber + " from " +
354 354
                                         remoteserver);
355 355

  
356 356
    }//try
357 357
    catch(Exception e)
358 358
    {
359
      MetacatReplication.replErrorLog("Failed to write doc " + docId +
359
      MetacatReplication.replErrorLog("Failed to write doc " + accNumber +
360 360
                                      " into db because " +e.getMessage());
361
      MetaCatUtil.debugMessage("Failed to write doc " + docId +
361
      MetaCatUtil.debugMessage("Failed to write doc " + accNumber +
362 362
                                      " into db because " +e.getMessage(), 30);
363 363
      throw e;
364 364
    }
......
373 373

  
374 374
  /* Handle replicate single xml document*/
375 375
  private void handleSingleDataFile(String remoteserver, String actions,
376
                                    String docId, String tableName)
376
                                    String accNumber, String tableName)
377 377
               throws Exception
378 378
  {
379
    MetaCatUtil.debugMessage("Try to replicate data file: "+docId, 40);
379
    MetaCatUtil.debugMessage("Try to replicate data file: "+accNumber, 40);
380 380
    DBConnection dbConn = null;
381 381
    int serialNumber = -1;
382 382
    try
......
390 390
      XMLReader docinfoParser = initParser(dih);
391 391
      String docInfoURLString = "https://" + remoteserver +
392 392
                  "?server="+util.getLocalReplicationServerName()+
393
                  "&action=getdocumentinfo&docid="+docId;
393
                  "&action=getdocumentinfo&docid="+accNumber;
394 394
      docInfoURLString = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLString);
395 395
      URL docinfoUrl = new URL(docInfoURLString);
396 396

  
......
409 409
      String createdDate = (String)docinfoHash.get("date_created");
410 410
      String updatedDate = (String)docinfoHash.get("date_updated");
411 411
      //docid should include rev number too
412
      String accnum=docId+util.getOption("accNumSeparator")+
413
                                              (String)docinfoHash.get("rev");
412
      /*String accnum=docId+util.getOption("accNumSeparator")+
413
                                              (String)docinfoHash.get("rev");*/
414 414

  
415 415

  
416 416
      String datafilePath = util.getOption("datafilepath");
417 417
      // Get data file content
418 418
      String readDataURLString = "https://" + remoteserver + "?server="+
419 419
                                        util.getLocalReplicationServerName()+
420
                                            "&action=readdata&docid="+accnum;
420
                                            "&action=readdata&docid="+accNumber;
421 421
      readDataURLString = MetaCatUtil.replaceWhiteSpaceForURL(readDataURLString);
422 422
      URL u = new URL(readDataURLString);
423 423
      InputStream input = u.openStream();
......
428 428
        DocumentImpl.writeDataFileInReplication(input,
429 429
                                                datafilePath,
430 430
                                                docName,docType,
431
                                                accnum, user,
431
                                                accNumber, user,
432 432
                                                docHomeServer,
433 433
                                                remoteserver,
434 434
                                                tableName,
......
436 436
                                                createdDate,
437 437
                                                updatedDate);
438 438
                                         
439
        MetaCatUtil.debugMessage("Successfully to write datafile " + docId, 30);
440
        MetacatReplication.replLog("wrote datafile " + accnum + " from " +
439
        MetaCatUtil.debugMessage("Successfully to write datafile " + accNumber, 30);
440
        MetacatReplication.replLog("wrote datafile " + accNumber + " from " +
441 441
                                    remoteserver);
442 442
      }//if
443 443
      else
444 444
      {
445
         MetaCatUtil.debugMessage("Couldn't open the data file: " + accnum, 30);
446
         throw new Exception("Couldn't open the data file: " + accnum);
445
         MetaCatUtil.debugMessage("Couldn't open the data file: " + accNumber, 30);
446
         throw new Exception("Couldn't open the data file: " + accNumber);
447 447
      }//else
448 448

  
449 449
    }//try
450 450
    catch(Exception e)
451 451
    {
452
      MetacatReplication.replErrorLog("Failed to try wrote datafile " + docId +
452
      MetacatReplication.replErrorLog("Failed to try wrote datafile " + accNumber +
453 453
                                      " because " +e.getMessage());
454
      MetaCatUtil.debugMessage("Failed to try wrote datafile " + docId +
454
      MetaCatUtil.debugMessage("Failed to try wrote datafile " + accNumber +
455 455
                                      " because " +e.getMessage(), 30);
456 456
      throw e;
457 457
    }
......
991 991
       boolean flag = false;
992 992
       try
993 993
       {
994
         localrev = DocumentImpl.getLatestRevisionNumber(docid);
994
         localrev = DBUtil.getLatestRevisionInDocumentTable(docid);
995 995
       }
996 996
       catch (SQLException e)
997 997
       {
......
1027 1027
           flag = true;
1028 1028
         }
1029 1029
       }
1030

  
1030
       
1031
       String accNumber = docid + MetaCatUtil.getOption("accNumSeparator") + rev;
1031 1032
       // this is non-data file
1032 1033
       if(flag && !dataFile)
1033 1034
       {
1034 1035
         try
1035 1036
         {
1036
           handleSingleXMLDocument(remoteServer, action, docid, DocumentImpl.DOCUMENTTABLE);
1037
           handleSingleXMLDocument(remoteServer, action, accNumber, DocumentImpl.DOCUMENTTABLE);
1037 1038
         }
1038 1039
         catch(Exception e)
1039 1040
         {
......
1047 1048
       {
1048 1049
         try
1049 1050
         {
1050
           handleSingleDataFile(remoteServer, action, docid, DocumentImpl.DOCUMENTTABLE);
1051
           handleSingleDataFile(remoteServer, action, accNumber, DocumentImpl.DOCUMENTTABLE);
1051 1052
         }
1052 1053
         catch(Exception e)
1053 1054
         {
......
1065 1066
                                        throws Exception
1066 1067
   {
1067 1068
       // compare the update rev and local rev to see what need happen
1069
       System.out.println("In handle repliation revsion table");
1070
       System.out.println("the docid is "+ docid);
1071
       System.out.println("The rev is "+rev);
1068 1072
       Vector localrev = null;
1069 1073
       String action = "INSERT";
1070 1074
       boolean flag = false;
......
1088 1092
       {
1089 1093
           flag = true;    
1090 1094
       }
1091

  
1095
     
1096
       String accNumber = docid + MetaCatUtil.getOption("accNumSeparator") + rev;
1092 1097
       // this is non-data file
1093 1098
       if(flag && !dataFile)
1094 1099
       {
1095 1100
         try
1096 1101
         {
1097
           handleSingleXMLDocument(remoteServer, action, docid, DocumentImpl.REVISIONTABLE);
1102
           
1103
           handleSingleXMLDocument(remoteServer, action, accNumber, DocumentImpl.REVISIONTABLE);
1098 1104
         }
1099 1105
         catch(Exception e)
1100 1106
         {
......
1108 1114
       {
1109 1115
         try
1110 1116
         {
1111
           handleSingleDataFile(remoteServer, action, docid, DocumentImpl.REVISIONTABLE);
1117
           handleSingleDataFile(remoteServer, action, accNumber, DocumentImpl.REVISIONTABLE);
1112 1118
         }
1113 1119
         catch(Exception e)
1114 1120
         {

Also available in: Unified diff