Project

General

Profile

« Previous | Next » 

Revision 1065

Added by Jing Tao over 22 years ago

Fixed some db connection bug.

View differences:

src/edu/ucsb/nceas/metacat/MetacatReplication.java
479 479
    String docid = ((String[])params.get("docid"))[0]; // sent the document
480 480
    if (docid==null)
481 481
    {
482
      util.debugMessage("Didn't specify docid for replication", 10);
482
      util.debugMessage("Didn't specify docid for replication", 20);
483 483
      return;
484 484
    }
485 485
    //docid was switch to two parts
......
501 501
      {
502 502
        dbaction = "update";
503 503
      }
504
      serverCode = MetacatReplication.getServerCode(server);
504
      //serverCode = MetacatReplication.getServerCode(server);
505 505
      MetacatReplication.replLog("force replication request from " + server); 
506 506
      
507 507
      // get the document info from server
......
521 521
      String docName = (String)docinfoHash.get("docname");
522 522
     
523 523
      String docType = (String)docinfoHash.get("doctype");
524
     
525 524
      
526
      conn = util.getConnection();
525
      String docHomeServer= (String)docinfoHash.get("home_server");
526
      MetaCatUtil.debugMessage("docHomeServer of data file: "+docHomeServer);
527 527
      
528
      
529
      
528 530
      //if action is delete, we don't delete the data file. Just archieve
529 531
      //the xml_documents
530 532
      if (dbaction.equals("delete"))
531 533
      {
534
        conn = util.getConnection();
532 535
        DocumentImpl.delete(conn,docid,user,null);
536
        util.returnConnection(conn);
533 537
      }
534 538
      //To data file insert or update is same
535 539
      else if (dbaction.equals("insert")||dbaction.equals("update"))
......
543 547
        //register data file into xml_documents table and wite data file
544 548
        //into file system
545 549
        DocumentImpl.writeDataFile(url.openStream(), datafilePath, docName,
546
                              docType, docid, user,serverCode);
550
                              docType, docid, user,docHomeServer);
547 551
     }
548 552
    
549
    util.returnConnection(conn);
553
  
550 554
    
551 555
    MetacatReplication.replLog("document " + docid + " added to DB with " +
552 556
                                 "action " + dbaction);
553 557
    } catch(Exception e) 
554 558
    {
555
      try
556
      {
557
        conn.close();
558
      }
559
      catch (SQLException sqlE)
560
      {
561
        util.debugMessage(sqlE.getMessage());
562
      }
563
      System.out.println("ERROR in MetacatReplication.handleForceReplicate" +
564
                         "Request(): " + e.getMessage());
559
      
560
      util.returnConnection(conn);
561
      util.debugMessage("ERROR in MetacatReplication.handleForceReplicate" +
562
                         "Request(): " + e.getMessage(), 30);
565 563
    }
566 564
  }
567 565
  /**

Also available in: Unified diff