Project

General

Profile

« Previous | Next » 

Revision 1600

Added by Jing Tao over 21 years ago

Add code to get rid of white space in url.

View differences:

src/edu/ucsb/nceas/metacat/ReplicationHandler.java
370 370
                  getDBConnection("ReplicationHandler.handleSingleXMLDocument");
371 371
      serialNumber=dbConn.getCheckOutSerialNumber();
372 372
      //if the document needs to be updated or inserted, this is executed
373
      URL u = new URL("https://" + remoteserver + "?server="+
374
              util.getLocalReplicationServerName()+"&action=read&docid="+docId);
373
      String readDocURLString = "https://" + remoteserver + "?server="+
374
              util.getLocalReplicationServerName()+"&action=read&docid="+docId;
375
      readDocURLString = MetaCatUtil.replaceWhiteSpaceForURL(readDocURLString);
376
      URL u = new URL(readDocURLString);
375 377
      
376 378
      // Get docid content
377 379
      String newxmldoc = MetacatReplication.getURLContent(u);
......
386 388
      // Try get the docid info from remote server
387 389
      DocInfoHandler dih = new DocInfoHandler();
388 390
      XMLReader docinfoParser = initParser(dih);
389
      URL docinfoUrl = new URL("https://" + remoteserver + 
391
      String docInfoURLStr = "https://" + remoteserver + 
390 392
                       "?server="+util.getLocalReplicationServerName()+
391
                       "&action=getdocumentinfo&docid="+docId);
393
                       "&action=getdocumentinfo&docid="+docId;
394
      docInfoURLStr = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLStr);
395
      URL docinfoUrl = new URL(docInfoURLStr);
392 396
      MetaCatUtil.debugMessage("Sending message: " + 
393 397
                                                  docinfoUrl.toString(), 45);
394 398
      String docInfoStr = MetacatReplication.getURLContent(docinfoUrl);
......
462 466
      // Try get docid info from remote server
463 467
      DocInfoHandler dih = new DocInfoHandler();
464 468
      XMLReader docinfoParser = initParser(dih);
465
      URL docinfoUrl = new URL("https://" + remoteserver + 
469
      String docInfoURLString = "https://" + remoteserver + 
466 470
                  "?server="+util.getLocalReplicationServerName()+
467
                  "&action=getdocumentinfo&docid="+docId);
468
            
471
                  "&action=getdocumentinfo&docid="+docId;
472
      docInfoURLString = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLString);
473
      URL docinfoUrl = new URL(docInfoURLString);
474
         
469 475
      String docInfoStr = MetacatReplication.getURLContent(docinfoUrl);
470 476
      docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
471 477
      Hashtable docinfoHash = dih.getDocInfo();
......
482 488
      //docid should include rev number too
483 489
      String accnum=docId+util.getOption("accNumSeparator")+
484 490
                                              (String)docinfoHash.get("rev");
491
      
492
      
485 493
      String datafilePath = util.getOption("datafilepath");
486 494
      // Get data file content
487
      URL u = new URL("https://" + remoteserver + "?server="+
495
      String readDataURLString = "https://" + remoteserver + "?server="+
488 496
                                        util.getLocalReplicationServerName()+
489
                                            "&action=readdata&docid="+accnum);
490
          
497
                                            "&action=readdata&docid="+accnum;
498
      readDataURLString = MetaCatUtil.replaceWhiteSpaceForURL(readDataURLString);
499
      URL u = new URL(readDataURLString);
500
      InputStream input = u.openStream();  
491 501
      //register data file into xml_documents table and wite data file
492 502
      //into file system
493
      if (u.openStream() != null)
503
      if ( input != null)
494 504
      {
495
         DocumentImpl.writeDataFileInReplication(u.openStream(), 
505
        DocumentImpl.writeDataFileInReplication(input, 
496 506
                                                        datafilePath, 
497 507
                                                        docName,docType, 
498 508
                                                        accnum, user,
......
504 514
      }//if
505 515
      else
506 516
      {
517
         MetaCatUtil.debugMessage("Couldn't open the data file: " + accnum, 30);
507 518
         throw new Exception("Couldn't open the data file: " + accnum);
508 519
      }//else
509 520
 

Also available in: Unified diff