public InvCatalogImpl makeCatalogForDirectory ( String orgPath , URI catURI ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "baseURI=" + catURI ) ; log . debug ( "orgPath=" + orgPath ) ; log . debug ( "rootPath=" + rootPath ) ; log . debug ( "scanLocation=" + scanLocation ) ; } // Get the dataset path. String dsDirPath = translatePathToLocation ( orgPath ) ; if ( dsDirPath == null ) { String tmpMsg = "makeCatalogForDirectory(): Requesting path <" + orgPath + "> must start with \"" + rootPath + "\"." ; log . error ( tmpMsg ) ; return null ; } // Setup and create catalog builder. CatalogBuilder catBuilder = buildCatalogBuilder ( ) ; if ( catBuilder == null ) return null ; // A very round about way to remove the filename (e.g., "catalog.xml"). // Note: Gets around "path separator at end of path" issues that are CrDs implementation dependant. // Note: Does not check that CrDs is allowed by filters. String dsPath = dsDirPath . substring ( scanLocationCrDs . getPath ( ) . length ( ) ) ; if ( dsPath . startsWith ( "/" ) ) dsPath = dsPath . substring ( 1 ) ; CrawlableDataset reqCrDs = scanLocationCrDs . getDescendant ( dsPath ) ; CrawlableDataset parent = reqCrDs . getParentDataset ( ) ; if ( parent == null ) { log . error ( "makeCatalogForDirectory(): I/O error getting parent crDs level <" + dsDirPath + ">: " ) ; return null ; } dsDirPath = parent . getPath ( ) ; // Get the CrawlableDataset for the desired catalog level (checks that allowed by filters). CrawlableDataset catalogCrDs ; try { catalogCrDs = catBuilder . requestCrawlableDataset ( dsDirPath ) ; } catch ( IOException e ) { log . error ( "makeCatalogForDirectory(): I/O error getting catalog level <" + dsDirPath + ">: " + e . getMessage ( ) , e ) ; return null ; } if ( catalogCrDs == null ) { log . warn ( "makeCatalogForDirectory(): requested catalog level <" + dsDirPath + "> not allowed (filtered out)." ) ; return null ; } if ( ! catalogCrDs . isCollection ( ) ) { log . warn ( "makeCatalogForDirectory(): requested catalog level <" + dsDirPath + "> is not a collection." ) ; return null ; } // Generate the desired catalog using the builder. InvCatalogImpl catalog ; try { catalog = catBuilder . generateCatalog ( catalogCrDs ) ; } catch ( IOException e ) { log . error ( "makeCatalogForDirectory(): catalog generation failed <" + catalogCrDs . getPath ( ) + ">: " + e . getMessage ( ) ) ; return null ; } // Set the catalog base URI. if ( catalog != null ) catalog . setBaseURI ( catURI ) ; // InvDatasetImpl top = (InvDatasetImpl) catalog.getDataset(); // // if we name it carefully, can get catalogRef to useProxy == true (disappear top dataset) // if ( service.isRelativeBase()) { // pos = dataDir.lastIndexOf("/"); // String lastDir = (pos > 0) ? dataDir.substring(pos+1) : dataDir; // String topName = lastDir.length() > 0 ? lastDir : getName(); // top.setName( topName); // } return catalog ; }
Try to build a catalog for the given path by scanning the location associated with this InvDatasetScan . The given path must start with the path of this InvDatasetScan .