public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; }
/** * Check internal data structures. * * @param out : print errors here * @return true if no fatal consistency errors. */ public boolean check(StringBuilder out) { return check(out, false); }
public static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, String datasetId ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); if ( datasetId == null ) throw new IllegalArgumentException( "Dataset ID may not be null." ); InvDataset ds = catalog.findDatasetByID( datasetId ); if ( ds == null ) throw new IllegalArgumentException( "The dataset ID [" + datasetId + "] does not match the ID of a dataset in the catalog." ); return subsetCatalogOnDataset( catalog, ds ); }
public void writeItems( String fileDir) { File dir = new File(fileDir); if (!dir.exists()) { boolean ret = dir.mkdirs(); assert ret; } for (InvDataset dataset : cat.getDatasets()) { doDataset(dataset, fileDir); } }
catalog = catFactory.readXML(catalogLocation); StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", catalogLocation, buff.toString()); result.fatalError = true; invDataset = catalog.findDatasetByID(datasetId); if (invDataset == null) { result.fatalError = true;
List mdataList = findCatGenConfigMdata( this.catalog.getDatasets()); for ( int i = 0; i < mdataList.size(); i++) InvDataset genTopDs = (InvDataset) generatedCat.getDatasets().get( 0); for( Iterator it = generatedCat.getServices().iterator(); it.hasNext(); )
/** * Get URL to this dataset. Dataset must have an ID. * Form is catalogURL#DatasetID * * @return URL to this dataset. */ public String getCatalogUrl() { return getParentCatalog().getUriString() + "#" + getID(); }
private void addTopLevelMetadata( InvCatalog catalog, boolean isRegularCatalog ) { if ( this.topLevelMetadataContainer == null ) return; if ( ! catalogLevel.getPath().equals( currentLevel.getPath() ) ) return; // Transfer all metadata from given metadata container to the top // InvDataset. This propagates any public metadata from the given // metadata container to all generated catalogs. InvDatasetImpl topInvDs = (InvDatasetImpl) catalog.getDataset(); topInvDs.transferMetadata( this.topLevelMetadataContainer, true ); // LOOK experimental datasetScan may have its own access elements for ( Iterator it = this.topLevelMetadataContainer.getAccess().iterator(); it.hasNext(); ) { InvAccess invAccess = (InvAccess) it.next(); topInvDs.addAccess( invAccess ); InvService s = invAccess.getService(); ( (InvCatalogImpl) catalog ).addService( s ); } // If this is a collection level scan, set some special attributes // that transferMetadata() doesn't transfer. boolean isCollectionLevel = catalogLevel.getPath().equals( collectionLevel.getPath() ); if ( isCollectionLevel && isRegularCatalog ) { topInvDs.setHarvest( this.topLevelMetadataContainer.isHarvest() ); topInvDs.setCollectionType( this.topLevelMetadataContainer.getCollectionType() ); } // Finish catalog. ( (InvCatalogImpl) catalog ).finish(); }
private static List<InvService> copyServicesIntoCopiedCatalog( InvCatalog catalog, InvCatalogImpl resultCatalog ) { List<InvService> services = catalog.getServices(); for ( InvService service : services ) { resultCatalog.addService( DeepCopyUtils.copyService( service ) ); } List<InvService> copiedServices = resultCatalog.getServices(); return copiedServices; }
/** * Find named property. * * @param name match this name * @return string value of property or null if not exist. */ public String findProperty(String name) { InvProperty result = null; for (InvProperty p : getProperties()) { if (p.getName().equals(name)) result = p; } return (result == null) ? null : result.getValue(); }
/** * Find the named service declared in this dataset or one of its parents. * * @param name match this name * @return first service that matches the given name, or null if none found. */ public InvService findService(String name) { if (name == null) return null; // search local (but expanded) services for (InvService p : services) { if (p.getName().equals(name)) return p; } // not found, look in parent if (parent != null) return parent.findService(name); return (catalog == null) ? null : catalog.findService(name); }
/** * Constructs the CatalogGen for the given config document InputStream. * * @param configDocInputStream - the InputStream from which to read the config document. * @param configDocURL - the URL for the config document. */ public CatalogGen( InputStream configDocInputStream, URL configDocURL ) { // Create a InvCatalogFactory with CATALOG_GEN_CONFIG MetadataType registered. log.debug( "CatalogGen(InputStream): create catalog and CatalogGenConfig converter." ); this.catFactory = new InvCatalogFactory( "default", true ); this.catFactory.registerMetadataConverter( MetadataType.CATALOG_GEN_CONFIG.toString(), new CatGenConfigMetadataFactory() ); // Read the given XML config file. log.debug( "CatalogGen(InputStream): reading the config doc <" + configDocURL.toString() + ">." ); this.catalog = this.catFactory.readXML( configDocInputStream, URI.create( configDocURL.toExternalForm()) ); log.debug( "CatalogGen(InputStream): CatalogGenConfig doc <" + this.catalog.getName() + "> read."); }
public void writeItems( String fileDir) { File dir = new File(fileDir); if (!dir.exists()) dir.mkdirs(); List datasets = cat.getDatasets(); for (int i=0; i<datasets.size(); i++) { InvDataset elem = (InvDataset) datasets.get(i); doDataset( elem, fileDir); } }
catalog = catFactory.readXML(catalogLocation); StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", catalogLocation, buff.toString()); result.fatalError = true; invDataset = catalog.findDatasetByID(datasetId); if (invDataset == null) { result.fatalError = true;
List mdataList = findCatGenConfigMdata( this.catalog.getDatasets()); for ( int i = 0; i < mdataList.size(); i++) InvDataset genTopDs = (InvDataset) generatedCat.getDatasets().get( 0); for( Iterator it = generatedCat.getServices().iterator(); it.hasNext(); )
/** * Get URL to this dataset. Dataset must have an ID. * Form is catalogURL#DatasetID * * @return URL to this dataset. */ public String getCatalogUrl() { return getParentCatalog().getUriString() + "#" + getID(); }
private void addTopLevelMetadata( InvCatalog catalog, boolean isRegularCatalog ) { if ( this.topLevelMetadataContainer == null ) return; if ( ! catalogLevel.getPath().equals( currentLevel.getPath() ) ) return; // Transfer all metadata from given metadata container to the top // InvDataset. This propagates any public metadata from the given // metadata container to all generated catalogs. InvDatasetImpl topInvDs = (InvDatasetImpl) catalog.getDataset(); topInvDs.transferMetadata( this.topLevelMetadataContainer, true ); // LOOK experimental datasetScan may have its own access elements for ( Iterator it = this.topLevelMetadataContainer.getAccess().iterator(); it.hasNext(); ) { InvAccess invAccess = (InvAccess) it.next(); topInvDs.addAccess( invAccess ); InvService s = invAccess.getService(); ( (InvCatalogImpl) catalog ).addService( s ); } // If this is a collection level scan, set some special attributes // that transferMetadata() doesn't transfer. boolean isCollectionLevel = catalogLevel.getPath().equals( collectionLevel.getPath() ); if ( isCollectionLevel && isRegularCatalog ) { topInvDs.setHarvest( this.topLevelMetadataContainer.isHarvest() ); topInvDs.setCollectionType( this.topLevelMetadataContainer.getCollectionType() ); } // Finish catalog. ( (InvCatalogImpl) catalog ).finish(); }
private static List<InvService> copyServicesIntoCopiedCatalog( InvCatalog catalog, InvCatalogImpl resultCatalog ) { List<InvService> services = catalog.getServices(); for ( InvService service : services ) { resultCatalog.addService( DeepCopyUtils.copyService( service ) ); } return resultCatalog.getServices(); }
/** * Find named property. * * @param name match this name * @return string value of property or null if not exist. */ public String findProperty(String name) { InvProperty result = null; for (InvProperty p : getProperties()) { if (p.getName().equals(name)) result = p; } return (result == null) ? null : result.getValue(); }
/** * Find the named service declared in this dataset or one of its parents. * * @param name match this name * @return first service that matches the given name, or null if none found. */ public InvService findService(String name) { if (name == null) return null; // search local (but expanded) services for (InvService p : services) { if (p.getName().equals(name)) return p; } // not found, look in parent if (parent != null) return parent.findService(name); return (catalog == null) ? null : catalog.findService(name); }