legacy/src/main/java/thredds/catalog/InvCatalogFactory.java
public InvCatalogImpl readXML(org.jdom2.Document jdomDoc, URI uri) {

    // decide on converter based on namespace
    Element root = jdomDoc.getRootElement();
    if (!root.getName().equalsIgnoreCase("catalog")) {
      throw new IllegalArgumentException("not a catalog");
    }
    String namespace = root.getNamespaceURI();
    InvCatalogConvertIF fac = converters.get(namespace);
    if (fac == null) {
      fac = defaultConverter; // LOOK
      if (debugVersion)
        System.out.println("use default converter " + fac.getClass().getName() + "; no namespace " + namespace);
    } else if (debugVersion)
      System.out.println("use converter " + fac.getClass().getName() + " based on namespace " + namespace);


    InvCatalogImpl cat = fac.parseXML(this, jdomDoc, uri);
    cat.setCreateFrom(uri.toString());
    // cat.setCatalogFactory(this);
    //cat.setCatalogConverter(fac);
    cat.finish();

    /* if (showCatalogXML) {
      System.out.println("*** catalog/showCatalogXML");
      try {
        writeXML(cat, System.out);
      }
      catch (IOException ex) {
        log.warn("Error writing catalog for debugging", ex);
      }
    }  */

    if (fatalMessages.length() > 0)
      cat.appendErrorMessage(fatalMessages.toString(), true); // makes it invalid
    if (errMessages.length() > 0)
      cat.appendErrorMessage(errMessages.toString(), false); // doesnt make it invalid
    if (warnMessages.length() > 0)
      cat.appendErrorMessage(warnMessages.toString(), false); // doesnt make it invalid
    return cat;
  }
public InvCatalogImpl readXML(org.jdom2.Document jdomDoc, URI uri) {

    // decide on converter based on namespace
    Element root = jdomDoc.getRootElement();
    if (!root.getName().equalsIgnoreCase("catalog")) {
      throw new IllegalArgumentException("not a catalog");
    }
    String namespace = root.getNamespaceURI();
    InvCatalogConvertIF fac = converters.get(namespace);
    if (fac == null) {
      fac = defaultConverter; // LOOK
      if (debugVersion)
        System.out.println("use default converter " + fac.getClass().getName() + "; no namespace " + namespace);
    } else if (debugVersion)
      System.out.println("use converter " + fac.getClass().getName() + " based on namespace " + namespace);


    InvCatalogImpl cat = fac.parseXML(this, jdomDoc, uri);
    cat.setCreateFrom(uri.toString());
    // cat.setCatalogFactory(this);
    //cat.setCatalogConverter(fac);
    cat.finish();

    /* if (showCatalogXML) {
      System.out.println("*** catalog/showCatalogXML");
      try {
        writeXML(cat, System.out);
      }
      catch (IOException ex) {
        log.warn("Error writing catalog for debugging", ex);
      }
    }  */

    if (fatalMessages.length() > 0)
      cat.appendErrorMessage(fatalMessages.toString(), true); // makes it invalid
    if (errMessages.length() > 0)
      cat.appendErrorMessage(errMessages.toString(), false); // doesnt make it invalid
    if (warnMessages.length() > 0)
      cat.appendErrorMessage(warnMessages.toString(), false); // doesnt make it invalid
    return cat;
  }
public InvCatalogImpl readXML ( org . jdom2 . Document jdomDoc , URI uri ) { // decide on converter based on namespace Element root = jdomDoc . getRootElement ( ) ; if ( ! root . getName ( ) . equalsIgnoreCase ( "catalog" ) ) { throw new IllegalArgumentException ( "not a catalog" ) ; } String namespace = root . getNamespaceURI ( ) ; InvCatalogConvertIF fac = converters . get ( namespace ) ; if ( fac == null ) { fac = defaultConverter ; // LOOK if ( debugVersion ) System . out . println ( "use default converter " + fac . getClass ( ) . getName ( ) + "; no namespace " + namespace ) ; } else if ( debugVersion ) System . out . println ( "use converter " + fac . getClass ( ) . getName ( ) + " based on namespace " + namespace ) ; InvCatalogImpl cat = fac . parseXML ( this , jdomDoc , uri ) ; cat . setCreateFrom ( uri . toString ( ) ) ; // cat.setCatalogFactory(this); //cat.setCatalogConverter(fac); cat . finish ( ) ; /* if (showCatalogXML) {
      System.out.println("*** catalog/showCatalogXML");
      try {
        writeXML(cat, System.out);
      }
      catch (IOException ex) {
        log.warn("Error writing catalog for debugging", ex);
      }
    }  */ if ( fatalMessages . length ( ) > 0 ) cat . appendErrorMessage ( fatalMessages . toString ( ) , true ) ; // makes it invalid if ( errMessages . length ( ) > 0 ) cat . appendErrorMessage ( errMessages . toString ( ) , false ) ; // doesnt make it invalid if ( warnMessages . length ( ) > 0 ) cat . appendErrorMessage ( warnMessages . toString ( ) , false ) ; // doesnt make it invalid return cat ; }
Create an InvCatalog from a JDOM document.
Failures and exceptions are handled
by causing validate() to fail. Therefore, be sure to call validate() before trying
to use the InvCatalog object.

@param jdomDoc a parsed JDOM Document
@param uri : the URI of the document, used for resolving reletive references.
@return an InvCatalogImpl object
Create an InvCatalog from a JDOM document . Failures and exceptions are handled by causing validate () to fail . Therefore be sure to call validate () before trying to use the InvCatalog object .