Package thredds.catalog

Examples of thredds.catalog.InvCatalogFactory


    crawlCatalogs( new File( new File( catWriteDir, startPath), "catalog.xml") );
  }

  private void crawlCatalogs( File topCatalogFile)
  {
    InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory( false);
    InvCatalogImpl topCatalog = fac.readXML( topCatalogFile.toURI() );

    //topCatalog.g
    // TODO actually test something
  }
View Full Code Here


    super( name );
  }

  protected void setUp()
  {
    this.factory = new InvCatalogFactory( "default", true );
    tmpDataRootDir = new File( TestAll.temporaryLocalDataDir );
    tmpDataDir = TestFileDirUtils.createTempDirectory( "TestCatalogGen", tmpDataRootDir );
  }
View Full Code Here

      assertTrue( tmpMsg, false );
    }
    InputStream expectedCatalogInputStream = expectedCatalogURIName.getClass().getResourceAsStream( expectedCatalogResourceName );

    // Read in expected result catalog.
    InvCatalogFactory factory = new InvCatalogFactory( "default", true );
    InvCatalogImpl expectedCatalog = factory.readXML( expectedCatalogInputStream, expectedCatalogURI);

    // Close the CatalogGenConf and the expected catalog InputStreams.
    try
    {
      expectedCatalogInputStream.close();
    }
    catch ( IOException e )
    {
      String tmpMsg = "IOException thrown closing InputStream: " + e.getMessage();
      log.debug( "compareCatalogToCatalogResource(): " + tmpMsg, e );
      assertTrue( tmpMsg, false );
    }

    if ( display )
    {
      // Print expected and resulting catalogs to std out.
      String expectedCatalogAsString;
      String catalogAsString;
      try
      {
        expectedCatalogAsString = factory.writeXML( (InvCatalogImpl) expectedCatalog );
        catalogAsString = factory.writeXML( (InvCatalogImpl) expandedCatalog );
      }
      catch ( IOException e )
      {
        System.out.println( "IOException trying to write catalog to sout: " + e.getMessage() );
        return;
View Full Code Here

    assertTrue( "Can't read file [" + expectedCatalogDocFile.getPath() + "].", expectedCatalogDocFile.canRead());

    InputStream expectedCatalogInputStream = new FileInputStream( expectedCatalogDocFile);

    // Read in expected result catalog.
    InvCatalogFactory factory = new InvCatalogFactory( "default", true );
    InvCatalogImpl expectedCatalog = factory.readXML( expectedCatalogInputStream, expectedCatalogDocFile.toURI());

    expectedCatalogInputStream.close();

    if ( display )
    {
      // Print expected and resulting catalogs to std out.
      String expectedCatalogAsString;
      String catalogAsString;
      try
      {
        expectedCatalogAsString = factory.writeXML( (InvCatalogImpl) expectedCatalog );
        catalogAsString = factory.writeXML( (InvCatalogImpl) expandedCatalog );
      }
      catch ( IOException e )
      {
        System.out.println( "IOException trying to write catalog to sout: " + e.getMessage() );
        return;
View Full Code Here

      fail( "Problem parsing XML document: " + e.getMessage());
      return;
    }
    Element inFilterElem = inDoc.getRootElement();

    InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory( false);
    InvCatalogFactory10 factory = (InvCatalogFactory10) fac.getCatalogConverter( thredds.catalog.XMLEntityResolver.CATALOG_NAMESPACE_10 );
    CrawlableDatasetFilter inFilter = factory.readDatasetScanFilter( inFilterElem);
    Element outFilterElem = factory.writeDatasetScanFilter( inFilter );

    // Write the resulting element to string.
    ByteArrayOutputStream inBaos = new ByteArrayOutputStream();
View Full Code Here

    {
      fail( "URISyntaxException: " + e.getMessage() );
      return;
    }

    InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory( false );
    InvCatalogImpl cat = fac.readXML( catAsString.toString(), catURI );

    InvDatasetImpl ds = (InvDatasetImpl) cat.getDatasets().get( 0 );
    double d = ds.getDataSize();

    fac.writeXML(cat, System.out);
    assertTrue( "Size of data <" + d + "> not as expected <" + sizeBytes + ">.", Misc.closeEnough(d, sizeBytes));
  }
View Full Code Here

   * @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");
View Full Code Here

      logger.error("Usage: Need a URI to proceed!");
      System.exit(1);
    }

    URI catalogURI = new URI(args[0]);
    InvCatalogFactory factory = new InvCatalogFactory("default", true);
    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML( catalogURI);
    StringBuilder buff = new StringBuilder();
    if (!catalog.check( buff)) {
         logger.error("Invalid catalog <'{}'> \n {}",
             catalogURI, buff.toString());
    } else {
View Full Code Here

      System.exit(1);
    }

    List<String> catalogList = readCatalogFile(args[0]);
   
    InvCatalogFactory factory = new InvCatalogFactory("default", true);
    URI cataURI = null;
    try {
      String uriString = args[1];
      cataURI = new URI(uriString);
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML(cataURI);
    final StringBuilder buff = new StringBuilder();
    if (catalog.check(buff)) {

      for (String cata : catalogList) {
        // create
        InvCatalogRef ref = new InvCatalogRef(null,
            cata.substring(0, cata.lastIndexOf('.')), "1/"+ cata);
                catalog.removeDataset(ref);
                if ((args.length < 3) || (!args[2].equals("remove"))) {
                    catalog.addDataset(ref);
                }
      }
      catalog.finish();

    } else {
      throw new Exception(buff.toString());
    }


    // write out catalog to String
    try {

      OutputStream fout = new FileOutputStream(new File(cataURI.getPath()));

      factory.writeXML(catalog, fout, true);

      System.out.println("Final xref catalog output:" + cataURI.getPath());
     
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of thredds.catalog.InvCatalogFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.