private static InvCatalogImpl doOne(InvCatalogFactory fac, String urlString, boolean show) { System.out.println("***read " + urlString); if (show) System.out.println(" original catalog=\n" + IO.readURLcontents(urlString)); try { InvCatalogImpl cat = fac.readXML(new URI(urlString)); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); System.out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // if (show) System.out.println(" parsed catalog=\n" + fac.writeXML(cat)); //System.out.println(" -----\n"+cat.dump()); return cat; } catch (Exception e) { e.printStackTrace(); return null; } }
private static InvCatalogImpl doOne(InvCatalogFactory fac, String urlString, boolean show) { System.out.println("***read " + urlString); if (show) System.out.println(" original catalog=\n" + IO.readURLcontents(urlString)); try { InvCatalogImpl cat = fac.readXML(new URI(urlString)); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); System.out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // if (show) System.out.println(" parsed catalog=\n" + fac.writeXML(cat)); //System.out.println(" -----\n"+cat.dump()); return cat; } catch (Exception e) { e.printStackTrace(); return null; } }
private static InvCatalogImpl doOne(InvCatalogFactory fac, String urlString, boolean show) { System.out.println("***read " + urlString); if (show) System.out.println(" original catalog=\n" + IO.readURLcontents(urlString)); try { InvCatalogImpl cat = fac.readXML(new URI(urlString)); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); System.out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // if (show) System.out.println(" parsed catalog=\n" + fac.writeXML(cat)); //System.out.println(" -----\n"+cat.dump()); return cat; } catch (Exception e) { e.printStackTrace(); return null; } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); ADNWriter w = new ADNWriter(); StringBuffer sbuff = new StringBuffer(); w.writeDatasetEntries( cat, "C:/temp/adn3", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); DCWriter w = new DCWriter( cat); w.writeItems( "C:/temp/dif"); } catch (Exception e) { e.printStackTrace(); } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); ADNWriter w = new ADNWriter(); StringBuilder sbuff = new StringBuilder(); w.writeDatasetEntries( cat, "C:/temp/adn3", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); ADNWriter w = new ADNWriter(); StringBuilder sbuff = new StringBuilder(); w.writeDatasetEntries( cat, "C:/temp/adn3", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = (InvCatalogImpl) fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); DCWriter w = new DCWriter( cat); w.writeItems( "C:/temp/dif"); } catch (Exception e) { e.printStackTrace(); } }
private static void doCatalog( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); System.out.println(" catalog=\n" + fac.writeXML(cat)); DIFWriter w = new DIFWriter(); StringBuilder sbuff = new StringBuilder(); w.writeDatasetEntries( cat, "C:/temp/dif2", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private static void doCatalog( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); System.out.println(" catalog=\n" + fac.writeXML(cat)); DIFWriter w = new DIFWriter(); StringBuilder sbuff = new StringBuilder(); w.writeDatasetEntries( cat, "C:/temp/dif2", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private static void doOne( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); // System.out.println(" catalog=\n" + fac.writeXML(cat)); DCWriter w = new DCWriter( cat); w.writeItems( "C:/temp/dif"); } catch (Exception e) { e.printStackTrace(); } }
@Override public boolean scan(boolean sendEvent) throws IOException { mfiles = new ArrayList<>(100); InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); InvCatalogImpl cat = catFactory.readXML(catalogUrl); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); if (!isValid) { logger.warn("Catalog invalid= "+catalogUrl+" validation output= "+ buff); return false; } CatalogCrawler crawler = new CatalogCrawler(CatalogCrawler.USE_ALL_DIRECT, false, this); long start = System.currentTimeMillis(); try { crawler.crawl(cat, null, null, null); } finally { long took = (System.currentTimeMillis() - start); if (debug) System.out.format("***Done " + catalogUrl + " took = " + took + " msecs%n"); } lastScanned = System.currentTimeMillis(); return true; }
@Override protected void reallyScan(java.util.Map<String, MFile> map) throws IOException { InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); InvCatalogImpl cat = catFactory.readXML(catalogUrl); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); if (!isValid) { logger.warn("Catalog invalid= "+catalogUrl+" validation output= "+ buff); return; } CatalogCrawler crawler = new CatalogCrawler(CatalogCrawler.USE_ALL_DIRECT, false, this); long start = System.currentTimeMillis(); try { crawler.crawl(cat, null, null, map); } finally { long took = (System.currentTimeMillis() - start); if (debug) System.out.format("***Done " + catalogUrl + " took = " + took + " msecs\n"); } }
private static void doCatalog( InvCatalogFactory fac, String url) { System.out.println("***read "+url); try { InvCatalogImpl cat = fac.readXML(url); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check( buff, false); System.out.println("catalog <" + cat.getName()+ "> "+ (isValid ? "is" : "is not") + " valid"); System.out.println(" validation output=\n" + buff); System.out.println(" catalog=\n" + fac.writeXML(cat)); DIFWriter w = new DIFWriter(); StringBuffer sbuff = new StringBuffer(); w.writeDatasetEntries( cat, "C:/temp/dif2", sbuff); System.out.println(" messages=\n"+sbuff); } catch (Exception e) { e.printStackTrace(); } }
private InvDatasetImpl openResolver(String urlString, ucar.nc2.util.CancelTask task, Result result) { InvCatalogFactory catFactory = new InvCatalogFactory("", false); InvCatalogImpl catalog = catFactory.readXML(urlString); if (catalog == null) { result.errLog.format("Couldnt open Resolver %s %n ", urlString); return null; } StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", urlString, buff.toString()); result.fatalError = true; return null; } InvDataset top = catalog.getDataset(); if (top.hasAccess()) return (InvDatasetImpl) top; else { java.util.List datasets = top.getDatasets(); return (InvDatasetImpl) datasets.get(0); } }
private InvDatasetImpl openResolver(String urlString, ucar.nc2.util.CancelTask task, Result result) { InvCatalogFactory catFactory = new InvCatalogFactory("", false); InvCatalogImpl catalog = catFactory.readXML(urlString); if (catalog == null) { result.errLog.format("Couldnt open Resolver %s %n ", urlString); return null; } StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", urlString, buff.toString()); result.fatalError = true; return null; } InvDataset top = catalog.getDataset(); if (top.hasAccess()) return (InvDatasetImpl) top; else { java.util.List datasets = top.getDatasets(); return (InvDatasetImpl) datasets.get(0); } }
/** * Open a catalog and crawl (depth first) all the datasets in it. * Close catalogs and release their resources as you. * * @param catUrl url of catalog to open * @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) * @return number of catalog references opened and crawled */ public int crawl(String catUrl, CancelTask task, PrintStream out, Object context) { InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); InvCatalogImpl cat = catFactory.readXML(catUrl); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); if (out != null) { out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); out.println(" validation output=\n" + buff); } if (isValid) return crawl(cat, task, out, context); return 0; }
private InvDatasetImpl openResolver(String urlString, ucar.nc2.util.CancelTask task, Result result) { InvCatalogFactory catFactory = new InvCatalogFactory("", false); InvCatalogImpl catalog = catFactory.readXML(urlString); if (catalog == null) { result.errLog.format("Couldnt open Resolver %s %n ", urlString); return null; } StringBuilder buff = new StringBuilder(); if (!catalog.check(buff)) { result.errLog.format("Invalid catalog from Resolver <%s>%n%s%n", urlString, buff.toString()); result.fatalError = true; return null; } InvDataset top = catalog.getDataset(); if (top.hasAccess()) return (InvDatasetImpl) top; else { java.util.List datasets = top.getDatasets(); return (InvDatasetImpl) datasets.get(0); } }
/** * Open a catalog and crawl (depth first) all the datasets in it. * Close catalogs and release their resources as you. * * @param catUrl url of catalog to open * @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) * @return number of catalog references opened and crawled */ public int crawl(String catUrl, CancelTask task, PrintStream out, Object context) { InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); InvCatalogImpl cat = catFactory.readXML(catUrl); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); if (out != null) { out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); out.println(" validation output=\n" + buff); } if (isValid) return crawl(cat, task, out, context); return 0; }
/** * Open a catalog and crawl (depth first) all the datasets in it. * Close catalogs and release their resources as you. * * @param catUrl url of catalog to open * @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) * @return number of catalog references opened and crawled */ public int crawl(String catUrl, CancelTask task, PrintWriter out, Object context) { InvCatalogFactory catFactory = InvCatalogFactory.getDefaultFactory(true); InvCatalogImpl cat = catFactory.readXML(catUrl); StringBuilder buff = new StringBuilder(); boolean isValid = cat.check(buff, false); if (out != null) { out.println("catalog <" + cat.getName() + "> " + (isValid ? "is" : "is not") + " valid"); out.println(" validation output=\n" + buff); } if (isValid) return crawl(cat, task, out, context); return 0; }