/** * Construct a DirectoryScanner given information about the data server to be cataloged. * * @param service - the service for the datasets found in the directory scanned. * @param serviceTitle - a title for the service (used as the title of the top-level dataset). * @param serviceBaseUrlDir - the local directory to which the service's base URL references. * @param prefixPath - path name to append to the urlPath of resulting datasets, can be null. * @param createCatalogRefs - if true, generate a catalogRef for each directory, otherwise, * recurse into directories. * @throws IllegalArgumentException if invalid service type is given or root directory is not a * directory. */ public DirectoryScanner( InvService service, String serviceTitle, File serviceBaseUrlDir, String prefixPath, boolean createCatalogRefs) { this.service = service; this.serviceTitle = serviceTitle; this.serviceBaseUrlDir = serviceBaseUrlDir; try { collectionCrDs = CrawlableDatasetFactory.createCrawlableDataset( serviceBaseUrlDir.getAbsolutePath(), null, null); } catch (IOException e) { // @todo Should throw an IOException! throw new IllegalArgumentException("IOException while creating dataset: " + e.getMessage()); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Did not find class: " + e.getMessage()); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( "Required constructor not found in class: " + e.getMessage()); } catch (IllegalAccessException e) { throw new IllegalArgumentException( "Did not have necessary access to class: " + e.getMessage()); } catch (InvocationTargetException e) { throw new IllegalArgumentException( "Could not invoke required method in class: " + e.getMessage()); } catch (InstantiationException e) { throw new IllegalArgumentException("Could not instatiate class: " + e.getMessage()); } if (!collectionCrDs.isCollection()) throw new IllegalArgumentException( "Base URL directory is not a directory <" + serviceBaseUrlDir.getAbsolutePath() + ">."); this.prefixPath = prefixPath; this.createCatalogRefs = createCatalogRefs; // log.debug( "DirectoryScanner(): service="+service.getName()+"; // serviceTitle="+serviceTitle+"; serviceBaseUrlDir="+serviceBaseUrlDir+"; // createCatalogRefs="+createCatalogRefs); // this.serviceTitle = serviceTitle; // this.serviceBaseUrlDir = serviceBaseUrlDir; // if ( this.serviceBaseUrlDir.getPath().indexOf( "*") == -1) // { // if ( ! this.serviceBaseUrlDir.isDirectory()) throw new IllegalArgumentException( "Base // URL directory is not a directory <" + serviceBaseUrlDir.getAbsolutePath() + ">."); // } // this.service = new ResultService( service, serviceBaseUrlDir.getAbsolutePath()); // // this.prefixPath = prefixPath; // this.createCatalogRefs = createCatalogRefs; }
public InvCatalog getDirCatalog( File directory, String filterPattern, boolean sortInIncreasingOrder, String addIdBase, boolean addDatasetSize, String dsNameMatchPattern, String startTimeSubstitutionPattern, String duration) { CrawlableDataset catalogCrDs; try { catalogCrDs = CrawlableDatasetFactory.createCrawlableDataset(directory.getAbsolutePath(), null, null); } catch (IOException e) { // @todo Should throw an IOException! throw new IllegalArgumentException("IOException while creating dataset: " + e.getMessage()); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Did not find class: " + e.getMessage()); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( "Required constructor not found in class: " + e.getMessage()); } catch (IllegalAccessException e) { throw new IllegalArgumentException( "Did not have necessary access to class: " + e.getMessage()); } catch (InvocationTargetException e) { throw new IllegalArgumentException( "Could not invoke required method in class: " + e.getMessage()); } catch (InstantiationException e) { throw new IllegalArgumentException("Could not instatiate class: " + e.getMessage()); } if (!catalogCrDs.isCollection()) throw new IllegalArgumentException( "catalog directory is not a directory <" + serviceBaseUrlDir.getAbsolutePath() + ">."); return getDirCatalog( catalogCrDs, filterPattern, sortInIncreasingOrder, addIdBase, addDatasetSize, dsNameMatchPattern, startTimeSubstitutionPattern, duration); }