private void correctAllEntriesInTheList(File newRoot) {
   for (RetrieveEntry rent : currentRetrievalList) {
     String oldPath = rent.getLocalBaseFile().toString();
     String newPath =
         new String(
             new StringBuffer(oldPath)
                 .replace(0, currentSaveRootFile.toString().length(), newRoot.toString()));
     File newLocalBaseFile = new File(newPath);
     rent.setLocalBaseFile(newLocalBaseFile);
   }
   for (RetrieveEntry rent : retrievedList) {
     String oldPath = rent.getSaveFile().toString();
     String newPath =
         new String(
             new StringBuffer(oldPath)
                 .replace(0, currentSaveRootFile.toString().length(), newRoot.toString()));
     File newLocalBaseFile = new File(newPath);
     rent.setSaveFile(newLocalBaseFile);
   }
 }
  private void pullRecursively() {
    synchronized (RetrieverEngineImpl.class) {
      while (!currentRetrievalList.isEmpty() && !STOP_PULL) {
        // System.out.println(currentRetrievalList);
        RetrieveEntry rent = currentRetrievalList.getFirst();
        // System.out.println("###"+rent.toString());
        currentRetrievalList.removeFirst();
        RetrieverTask rt = new RetrieverTask(rent, this);

        if (firstTime) {
          firstAddressParentStr =
              rent.getCurrentAddress().substring(0, rent.getCurrentAddress().lastIndexOf("/"));
          firstTime = false;
        }

        updateDownloadingInfo(rent);

        HashMap<String, File> storedFileMap = null;
        try {
          storedFileMap = rt.goGetIt();
        } catch (URISyntaxException ex) {
          // This might an error in the file. Ignore
          // ex.printStackTrace();
          handleException(rent, ex);
          continue;
        } catch (IOException ex) {
          // This might have been thrown to indicate a cyclic reference.
          // ex.printStackTrace();
          handleException(rent, ex);
          continue;
        }

        if (!rent.isRecursive()) continue;

        if (storedFileMap == null) {
          continue;
        }
        String effectiveSrcAddr = storedFileMap.keySet().iterator().next();
        File storedFile = storedFileMap.get(effectiveSrcAddr);

        rent.setSaveFile(storedFile);
        rent.setEffectiveAddress(effectiveSrcAddr);

        updateDownloadedInfo(rent);

        createCatalogIfRequired(rent);

        DocumentTypeParser dtp = DocumentParserFactory.getParser(rent.getDocType());
        List<String> thisFileRefs = null;
        try {
          thisFileRefs = dtp.getAllLocationOfReferencedEntities(storedFile);
          // System.out.println("Parsed:"+storedFile+" Got:"+thisFileRefs);
        } catch (Exception ex) {
          // was not able to parse the doc. Currently ignore this.
          // ex.printStackTrace();
          continue;
        }
        for (String ref : thisFileRefs) {
          currentRetrievalList.addLast(
              new RetrieveEntry(
                  effectiveSrcAddr, ref, storedFile, null, rent.getDocType(), rent.isRecursive()));
        }
        printList();
      }
      closeOPOuts();
    }
  }