/** * Build a private {@link Catalog}, that is, not the static instance that {@link CatalogManager} * returns by default. * * <p>Care must be taken to use only private {@link Catalog} instances if there will ever be * more than one OASIS Catalog used in a single class loader (i.e. a single maven test run), * otherwise {@link Catalog} contents will be an amalgam of the entries of both OASIS Catalog * files, with likely unintended or incorrect results. See GEOT-2497. * * @param catalogLocation URL of OASIS Catalog * @return a private Catalog */ static Catalog buildPrivateCatalog(URL catalogLocation) { CatalogManager catalogManager = new CatalogManager(); catalogManager.setUseStaticCatalog(false); catalogManager.setVerbosity(0); catalogManager.setIgnoreMissingProperties(true); Catalog catalog = catalogManager.getCatalog(); try { catalog.parseCatalog(catalogLocation); } catch (IOException e) { throw new RuntimeException( "Error trying to load OASIS catalog from URL " + catalogLocation.toString(), e); } return catalog; }
/** * Loads mappings from configuration file */ private void init() { if (log.isDebugEnabled()) { log.debug("init catalog file " + this.catalogFileURI); } manager.setUseStaticCatalog(false); manager.setCatalogFiles(this.catalogFileURI.toString()); manager.setIgnoreMissingProperties(true); catalog = manager.getCatalog(); }
/** * Get CatalogResolver. * @return CatalogResolver */ public static synchronized CatalogResolver getCatalogResolver() { if (catalogResolver == null) { final CatalogManager manager = new CatalogManager(); manager.setIgnoreMissingProperties(true); manager.setUseStaticCatalog(false); // We'll use a private catalog. manager.setPreferPublic(true); final File catalogFilePath = new File(ditaDir, Configuration.pluginResourceDirs.get("org.dita.base") + File.separator + FILE_NAME_CATALOG); manager.setCatalogFiles(catalogFilePath.toURI().toASCIIString()); //manager.setVerbosity(10); catalogResolver = new CatalogResolver(manager); } return catalogResolver; } }
private static EntityResolver getResolver() { try { CatalogManager catalogManager = new CatalogManager(); if (DEBUG_LEVEL != null) { catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL)); } catalogManager.setUseStaticCatalog(false); catalogManager.setIgnoreMissingProperties(true); return new CatalogResolver(catalogManager) { public String getResolvedEntity(String publicId, String systemId) { String s = super.getResolvedEntity(publicId, systemId); if (s != null && s.startsWith("classpath:")) { try { URIResolver r = new URIResolver(s); if (r.isResolved()) { r.getInputStream().close(); return r.getURL().toExternalForm(); } } catch (IOException e) { //ignore } } return s; } }; } catch (Throwable t) { //ignore } return null; }
private static EntityResolver getResolver() { try { CatalogManager catalogManager = new CatalogManager(); if (DEBUG_LEVEL != null) { catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL)); } catalogManager.setUseStaticCatalog(false); catalogManager.setIgnoreMissingProperties(true); return new CatalogResolver(catalogManager) { public String getResolvedEntity(String publicId, String systemId) { String s = super.getResolvedEntity(publicId, systemId); if (s != null && s.startsWith("classpath:")) { try { URIResolver r = new URIResolver(s); if (r.isResolved()) { r.getInputStream().close(); return r.getURL().toExternalForm(); } } catch (IOException e) { //ignore } } return s; } }; } catch (Throwable t) { //ignore } return null; }
catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL)); catalogManager.setUseStaticCatalog(false); catalogManager.setIgnoreMissingProperties(true); CatalogResolver catalogResolver = new CatalogResolver(catalogManager) {
catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL)); catalogManager.setUseStaticCatalog(false); catalogManager.setIgnoreMissingProperties(true); CatalogResolver catalogResolver = new CatalogResolver(catalogManager) {
cm.setIgnoreMissingProperties(true); cm.setUseStaticCatalog(false); if (preferPublic != null) { cm.setPreferPublic(preferPublic.booleanValue());
private void initResolver() throws IOException { CatalogManager catalogManager = new CatalogManager(); catalogManager.setUseStaticCatalog(true); catalogManager.setIgnoreMissingProperties(true); catalogManager.setVerbosity(1); catalogManager.setPreferPublic(true); CatalogResolver catalogResolver = new CatalogResolver(catalogManager); Catalog catalog = catalogResolver.getCatalog(); if (catalogFiles != null && catalogFiles.length > 0) { for (File catalogFile : catalogFiles) { LOGGER.trace("Using catalog file {}", catalogFile); catalog.parseCatalog(catalogFile.getPath()); } } else if (catalogResourceName != null) { LOGGER.trace("Using catalog from resource: {}", catalogResourceName); Enumeration<URL> catalogs = Thread.currentThread().getContextClassLoader().getResources(catalogResourceName); while (catalogs.hasMoreElements()) { URL catalogResourceUrl = catalogs.nextElement(); LOGGER.trace("Parsing catalog from URL: {}", catalogResourceUrl); catalog.parseCatalog(catalogResourceUrl); } } else { throw new IllegalStateException("Catalog is not defined"); } builtinSchemaResolver = catalogResolver; } //endregion
private Catalog loadCatalog() { URL catalogURI = null; try { catalogURI = getCatalog(JAXWSUtils.DEFAULT_CATALOG_WEB); if (catalogURI == null) { catalogURI = getCatalog(JAXWSUtils.DEFAULT_CATALOG_EJB); } } catch (IOException e) { LOG.warn("Failed to open OASIS catalog", e); } CatalogManager catalogManager = new CatalogManager(); catalogManager.setUseStaticCatalog(false); catalogManager.setIgnoreMissingProperties(true); CatalogResolver catalogResolver = new CatalogResolver(catalogManager); Catalog catalog = catalogResolver.getCatalog(); if (catalogURI != null) { LOG.debug("Found OASIS catalog {} ", catalogURI); try { catalog.parseCatalog(catalogURI); } catch (Exception e) { LOG.warn("Failed to read OASIS catalog", e); } } return catalog; }
manager.setPreferPublic(true); manager.setRelativeCatalogs(false); manager.setUseStaticCatalog(false); manager.setVerbosity(0); _catalogResolver = new XmlValidatorCatalogResolver(manager);
manager.setPreferPublic(true); manager.setRelativeCatalogs(false); manager.setUseStaticCatalog(false); manager.setVerbosity(0); _catalogResolver = new XmlValidatorCatalogResolver(manager);
/** * Initialization. Create a CatalogManager and set all * the properties upfront. This prevents JVM wide system properties * or a property file somewhere in the environment from affecting * the behaviour of this catalog resolver. */ private void init (String [] catalogs, boolean preferPublic) { fCatalogsList = (catalogs != null) ? (String[]) catalogs.clone() : null; fPreferPublic = preferPublic; fResolverCatalogManager = new CatalogManager(); fResolverCatalogManager.setAllowOasisXMLCatalogPI(false); fResolverCatalogManager.setCatalogClassName("org.apache.xml.resolver.Catalog"); fResolverCatalogManager.setCatalogFiles(""); fResolverCatalogManager.setIgnoreMissingProperties(true); fResolverCatalogManager.setPreferPublic(fPreferPublic); fResolverCatalogManager.setRelativeCatalogs(false); fResolverCatalogManager.setUseStaticCatalog(false); fResolverCatalogManager.setVerbosity(0); }
if (catalog.exists()) { CatalogManager catman = new CatalogManager(); catman.setUseStaticCatalog(false); catman.setCatalogFiles(catalog.getPath()); testResolver = new CatalogResolver(catman);