Package org.jboss.util.xml.catalog

Examples of org.jboss.util.xml.catalog.CatalogException


    factory.setNamespaceAware(false);
    factory.setValidating(false);
    try {
      builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Document doc = null;

    try {
      doc = builder.parse(is);
    } catch (SAXException se) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    }

    Element root = doc.getDocumentElement();

    String namespaceURI = Namespaces.getNamespaceURI(root);
    String localName    = Namespaces.getLocalName(root);

    String domParserClass = getCatalogParser(namespaceURI,
               localName);

    if (domParserClass == null) {
      if (namespaceURI == null) {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + localName);
      } else {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + "{" + namespaceURI + "}"
              + localName);
      }
      return;
    }

    DOMCatalogParser domParser = null;

    try {
      domParser = (DOMCatalogParser) Class.forName(domParserClass).newInstance();
    } catch (ClassNotFoundException cnfe) {
      catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ClassCastException cce ) {
      catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Node node = root.getFirstChild();
    while (node != null) {
      domParser.parseCatalogEntry(catalog, node);
View Full Code Here


    throws IOException, CatalogException {

    // Create an instance of the parser
    if (parserFactory == null && parserClass == null) {
      debug.message(1, "Cannot read SAX catalog without a parser");
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    debug = catalog.getCatalogManager().debug;
    EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();

    this.catalog = catalog;

    try {
      if (parserFactory != null) {
  SAXParser parser = parserFactory.newSAXParser();
  SAXParserHandler spHandler = new SAXParserHandler();
  spHandler.setContentHandler(this);
  if (bResolver != null) {
    spHandler.setEntityResolver(bResolver);
  }
  parser.parse(new InputSource(is), spHandler);
      } else {
  Parser parser = (Parser) Class.forName(parserClass).newInstance();
  parser.setDocumentHandler(this);
  if (bResolver != null) {
    parser.setEntityResolver(bResolver);
  }
  parser.parse(new InputSource(is));
      }
    } catch (ClassNotFoundException cnfe) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    } catch (SAXException se) {
      Exception e = se.getException();
      // FIXME: there must be a better way
      UnknownHostException uhe = new UnknownHostException();
      FileNotFoundException fnfe = new FileNotFoundException();
      if (e != null) {
  if (e.getClass() == uhe.getClass()) {
    throw new CatalogException(CatalogException.PARSE_FAILED,
             e.toString());
  } else if (e.getClass() == fnfe.getClass()) {
    throw new CatalogException(CatalogException.PARSE_FAILED,
             e.toString());
  }
      }
      throw new CatalogException(se);
    }
  }
View Full Code Here

    factory.setNamespaceAware(false);
    factory.setValidating(false);
    try {
      builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Document doc = null;

    try {
      doc = builder.parse(is);
    } catch (SAXException se) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    }

    Element root = doc.getDocumentElement();

    String namespaceURI = Namespaces.getNamespaceURI(root);
    String localName    = Namespaces.getLocalName(root);

    String domParserClass = getCatalogParser(namespaceURI,
               localName);

    if (domParserClass == null) {
      if (namespaceURI == null) {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + localName);
      } else {
  catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
              + "{" + namespaceURI + "}"
              + localName);
      }
      return;
    }

    DOMCatalogParser domParser = null;

    try {
      domParser = (DOMCatalogParser) Class.forName(domParserClass).newInstance();
    } catch (ClassNotFoundException cnfe) {
      catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ClassCastException cce ) {
      catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    Node node = root.getFirstChild();
    while (node != null) {
      domParser.parseCatalogEntry(catalog, node);
View Full Code Here

    throws IOException, CatalogException {

    // Create an instance of the parser
    if (parserFactory == null && parserClass == null) {
      debug.message(1, "Cannot read SAX catalog without a parser");
      throw new CatalogException(CatalogException.UNPARSEABLE);
    }

    debug = catalog.getCatalogManager().debug;
    EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();

    this.catalog = catalog;

    try {
      if (parserFactory != null) {
  SAXParser parser = parserFactory.newSAXParser();
  SAXParserHandler spHandler = new SAXParserHandler();
  spHandler.setContentHandler(this);
  if (bResolver != null) {
    spHandler.setEntityResolver(bResolver);
  }
  parser.parse(new InputSource(is), spHandler);
      } else {
  Parser parser = (Parser) Class.forName(parserClass).newInstance();
  parser.setDocumentHandler(this);
  if (bResolver != null) {
    parser.setEntityResolver(bResolver);
  }
  parser.parse(new InputSource(is));
      }
    } catch (ClassNotFoundException cnfe) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (IllegalAccessException iae) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (InstantiationException ie) {
      throw new CatalogException(CatalogException.UNPARSEABLE);
    } catch (ParserConfigurationException pce) {
      throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
    } catch (SAXException se) {
      Exception e = se.getException();
      // FIXME: there must be a better way
      UnknownHostException uhe = new UnknownHostException();
      FileNotFoundException fnfe = new FileNotFoundException();
      if (e != null) {
  if (e.getClass() == uhe.getClass()) {
    throw new CatalogException(CatalogException.PARSE_FAILED,
             e.toString());
  } else if (e.getClass() == fnfe.getClass()) {
    throw new CatalogException(CatalogException.PARSE_FAILED,
             e.toString());
  }
      }
      throw new CatalogException(se);
    }
  }
View Full Code Here

/* 197 */     factory.setNamespaceAware(false);
/* 198 */     factory.setValidating(false);
/*     */     try {
/* 200 */       builder = factory.newDocumentBuilder();
/*     */     } catch (ParserConfigurationException pce) {
/* 202 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 205 */     Document doc = null;
/*     */     try
/*     */     {
/* 208 */       doc = builder.parse(is);
/*     */     } catch (SAXException se) {
/* 210 */       throw new CatalogException(5);
/*     */     }
/*     */
/* 213 */     Element root = doc.getDocumentElement();
/*     */
/* 215 */     String namespaceURI = Namespaces.getNamespaceURI(root);
/* 216 */     String localName = Namespaces.getLocalName(root);
/*     */
/* 218 */     String domParserClass = getCatalogParser(namespaceURI, localName);
/*     */
/* 221 */     if (domParserClass == null) {
/* 222 */       if (namespaceURI == null) {
/* 223 */         catalog.getCatalogManager().debug.message(1, "No Catalog parser for " + localName);
/*     */       }
/*     */       else {
/* 226 */         catalog.getCatalogManager().debug.message(1, "No Catalog parser for {" + namespaceURI + "}" + localName);
/*     */       }
/*     */
/* 230 */       return;
/*     */     }
/*     */
/* 233 */     DOMCatalogParser domParser = null;
/*     */     try
/*     */     {
/* 236 */       domParser = (DOMCatalogParser)Class.forName(domParserClass).newInstance();
/*     */     } catch (ClassNotFoundException cnfe) {
/* 238 */       catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
/* 239 */       throw new CatalogException(6);
/*     */     } catch (InstantiationException ie) {
/* 241 */       catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
/* 242 */       throw new CatalogException(6);
/*     */     } catch (IllegalAccessException iae) {
/* 244 */       catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
/* 245 */       throw new CatalogException(6);
/*     */     } catch (ClassCastException cce) {
/* 247 */       catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
/* 248 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 251 */     Node node = root.getFirstChild();
/* 252 */     while (node != null) {
/* 253 */       domParser.parseCatalogEntry(catalog, node);
View Full Code Here

/*     */   public void readCatalog(Catalog catalog, InputStream is)
/*     */     throws IOException, CatalogException
/*     */   {
/* 263 */     if ((this.parserFactory == null) && (this.parserClass == null)) {
/* 264 */       this.debug.message(1, "Cannot read SAX catalog without a parser");
/* 265 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 268 */     this.debug = catalog.getCatalogManager().debug;
/* 269 */     EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();
/*     */
/* 271 */     this.catalog = catalog;
/*     */     try
/*     */     {
/* 274 */       if (this.parserFactory != null) {
/* 275 */         SAXParser parser = this.parserFactory.newSAXParser();
/* 276 */         SAXParserHandler spHandler = new SAXParserHandler();
/* 277 */         spHandler.setContentHandler(this);
/* 278 */         if (bResolver != null) {
/* 279 */           spHandler.setEntityResolver(bResolver);
/*     */         }
/* 281 */         parser.parse(new InputSource(is), spHandler);
/*     */       } else {
/* 283 */         Parser parser = (Parser)Class.forName(this.parserClass).newInstance();
/* 284 */         parser.setDocumentHandler(this);
/* 285 */         if (bResolver != null) {
/* 286 */           parser.setEntityResolver(bResolver);
/*     */         }
/* 288 */         parser.parse(new InputSource(is));
/*     */       }
/*     */     } catch (ClassNotFoundException cnfe) {
/* 291 */       throw new CatalogException(6);
/*     */     } catch (IllegalAccessException iae) {
/* 293 */       throw new CatalogException(6);
/*     */     } catch (InstantiationException ie) {
/* 295 */       throw new CatalogException(6);
/*     */     } catch (ParserConfigurationException pce) {
/* 297 */       throw new CatalogException(5);
/*     */     } catch (SAXException se) {
/* 299 */       Exception e = se.getException();
/*     */
/* 301 */       UnknownHostException uhe = new UnknownHostException();
/* 302 */       FileNotFoundException fnfe = new FileNotFoundException();
/* 303 */       if (e != null) {
/* 304 */         if (e.getClass() == uhe.getClass()) {
/* 305 */           throw new CatalogException(7, e.toString());
/*     */         }
/* 307 */         if (e.getClass() == fnfe.getClass()) {
/* 308 */           throw new CatalogException(7, e.toString());
/*     */         }
/*     */       }
/*     */
/* 312 */       throw new CatalogException(se);
/*     */     }
/*     */   }
View Full Code Here

TOP

Related Classes of org.jboss.util.xml.catalog.CatalogException

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.