legacy/src/main/java/thredds/catalog/crawl/CatalogCrawler.java
public void crawlDirectDatasets(InvDataset ds, CancelTask task, PrintWriter out, Object context, boolean release) {
    boolean isCatRef = (ds instanceof InvCatalogRef);
    if (filter != null && filter.skipAll(ds)) {
      if (isCatRef && release) ((InvCatalogRef) ds).release();
      return;
    }

    if (isCatRef) {
      InvCatalogRef catref = (InvCatalogRef) ds;
      if (out != null)
        out.println(" **CATREF " + catref.getURI() + " (" + ds.getName() + ") ");
      countCatrefs++;
      
      if (!listen.getCatalogRef( catref, context)) {
        if (release) catref.release();
        return;
      }
    }

    // get datasets with data access ("leaves")
    List<InvDataset> dlist = ds.getDatasets();
    List<InvDataset> leaves = new ArrayList<InvDataset>();
    for (InvDataset dds : dlist) {
      if (dds.hasAccess())
        leaves.add(dds);
    }

    if (leaves.size() > 0) {
      if (type == Type.first_direct) {
        InvDataset dds = leaves.get(0);
        listen.getDataset(dds, context);

      } else if (type == Type.random_direct) {
        listen.getDataset(chooseRandom(leaves), context);

      } else if (type == Type.random_direct_middle) {
        listen.getDataset(chooseRandomNotFirstOrLast(leaves), context);

      } else { // do all of them
        for (InvDataset dds : leaves) {
          listen.getDataset(dds, context);
          if ((task != null) && task.isCancel()) break;
        }
      }
    }

    // recurse
      for (InvDataset dds : dlist) {
        if (dds.hasNestedDatasets())
          crawlDirectDatasets(dds, task, out, context, release);
        if ((task != null) && task.isCancel())
          break;
      }

    /* if (out != null) {
     int took = (int) (System.currentTimeMillis() - start);
     out.println(" ** " + ds.getName() + " took " + took + " msecs\n");
   } */

    if (ds instanceof InvCatalogRef && release) {
      InvCatalogRef catref = (InvCatalogRef) ds;
      catref.release();
    }

  }
public void crawlDirectDatasets(InvDataset ds, CancelTask task, PrintWriter out, Object context, boolean release) {
    boolean isCatRef = (ds instanceof InvCatalogRef);
    if (filter != null && filter.skipAll(ds)) {
      if (isCatRef && release) ((InvCatalogRef) ds).release();
      return;
    }

    if (isCatRef) {
      InvCatalogRef catref = (InvCatalogRef) ds;
      if (out != null)
        out.println(" **CATREF " + catref.getURI() + " (" + ds.getName() + ") ");
      countCatrefs++;
      
      if (!listen.getCatalogRef( catref, context)) {
        if (release) catref.release();
        return;
      }
    }

    // get datasets with data access ("leaves")
    List<InvDataset> dlist = ds.getDatasets();
    List<InvDataset> leaves = new ArrayList<InvDataset>();
    for (InvDataset dds : dlist) {
      if (dds.hasAccess())
        leaves.add(dds);
    }

    if (leaves.size() > 0) {
      if (type == Type.first_direct) {
        InvDataset dds = leaves.get(0);
        listen.getDataset(dds, context);

      } else if (type == Type.random_direct) {
        listen.getDataset(chooseRandom(leaves), context);

      } else if (type == Type.random_direct_middle) {
        listen.getDataset(chooseRandomNotFirstOrLast(leaves), context);

      } else { // do all of them
        for (InvDataset dds : leaves) {
          listen.getDataset(dds, context);
          if ((task != null) && task.isCancel()) break;
        }
      }
    }

    // recurse
      for (InvDataset dds : dlist) {
        if (dds.hasNestedDatasets())
          crawlDirectDatasets(dds, task, out, context, release);
        if ((task != null) && task.isCancel())
          break;
      }

    /* if (out != null) {
     int took = (int) (System.currentTimeMillis() - start);
     out.println(" ** " + ds.getName() + " took " + took + " msecs\n");
   } */

    if (ds instanceof InvCatalogRef && release) {
      InvCatalogRef catref = (InvCatalogRef) ds;
      catref.release();
    }

  }
public void crawlDirectDatasets ( InvDataset ds , CancelTask task , PrintWriter out , Object context , boolean release ) { boolean isCatRef = ( ds instanceof InvCatalogRef ) ; if ( filter != null && filter . skipAll ( ds ) ) { if ( isCatRef && release ) ( ( InvCatalogRef ) ds ) . release ( ) ; return ; } if ( isCatRef ) { InvCatalogRef catref = ( InvCatalogRef ) ds ; if ( out != null ) out . println ( " **CATREF " + catref . getURI ( ) + " (" + ds . getName ( ) + ") " ) ; countCatrefs ++ ; if ( ! listen . getCatalogRef ( catref , context ) ) { if ( release ) catref . release ( ) ; return ; } } // get datasets with data access ("leaves") List < InvDataset > dlist = ds . getDatasets ( ) ; List < InvDataset > leaves = new ArrayList < InvDataset > ( ) ; for ( InvDataset dds : dlist ) { if ( dds . hasAccess ( ) ) leaves . add ( dds ) ; } if ( leaves . size ( ) > 0 ) { if ( type == Type . first_direct ) { InvDataset dds = leaves . get ( 0 ) ; listen . getDataset ( dds , context ) ; } else if ( type == Type . random_direct ) { listen . getDataset ( chooseRandom ( leaves ) , context ) ; } else if ( type == Type . random_direct_middle ) { listen . getDataset ( chooseRandomNotFirstOrLast ( leaves ) , context ) ; } else { // do all of them for ( InvDataset dds : leaves ) { listen . getDataset ( dds , context ) ; if ( ( task != null ) && task . isCancel ( ) ) break ; } } } // recurse for ( InvDataset dds : dlist ) { if ( dds . hasNestedDatasets ( ) ) crawlDirectDatasets ( dds , task , out , context , release ) ; if ( ( task != null ) && task . isCancel ( ) ) break ; } /* if (out != null) {
     int took = (int) (System.currentTimeMillis() - start);
     out.println(" ** " + ds.getName() + " took " + took + " msecs\n");
   } */ if ( ds instanceof InvCatalogRef && release ) { InvCatalogRef catref = ( InvCatalogRef ) ds ; catref . release ( ) ; } }
Crawl this dataset recursively. Only send back direct datasets

@param ds   the dataset
@param task user can cancel the task (may be null)
@param out  send status messages to here (may be null)
@param context caller can pass this object in (used for thread safety)
Crawl this dataset recursively . Only send back direct datasets