/** * 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; }
@Test public void testParseCatalog() throws Exception { URL file = TestData.url(this, "commonSchemas_new.oasis.xml"); ResolvingXMLReader reader = new ResolvingXMLReader(); Catalog catalog = reader.getCatalog(); catalog.getCatalogManager().setVerbosity(9); catalog.parseCatalog(file); final URL baseUri = new URL("http://schemas.opengis.net/gml/"); // the system override defined in the catalog final URL override = new URL("file:///schemas/gml/trunk/gml/"); final String extraPath = "3.1.1/basicTypes.xsd"; final String uri = new URL(baseUri, extraPath).toExternalForm(); final String expected = new URL(override, extraPath).toExternalForm(); String resolved = catalog.resolveSystem(uri); assertNotNull(resolved); final String actual = new URL(resolved).toExternalForm(); assertEquals(expected, actual); } }
/** * Set the configuration. Load the system catalog and apply any * parameters that may have been set using the public setter methods. */ public void init() throws Exception { // Over-ride debug level that is set by CatalogManager.properties if ( this.verbosity != null ) { if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("Setting Catalog resolver verbosity level to " + this.verbosity); } this.catalogManager.setVerbosity(this.verbosity.intValue()); } // Load the built-in catalog if ( this.catalog == null ) { this.getLogger().warn("No default catalog defined."); } else { this.parseCatalog(this.catalog); } // Load a single additional local catalog if ( this.localCatalog != null ) { this.parseCatalog( this.localCatalog ); } }
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
catalogManager.setVerbosity(999);
manager.setRelativeCatalogs(false); manager.setUseStaticCatalog(false); manager.setVerbosity(0); _catalogResolver = new XmlValidatorCatalogResolver(manager); _catalogResolver.namespaceAware = _isNamespaceAware;
manager.setRelativeCatalogs(false); manager.setUseStaticCatalog(false); manager.setVerbosity(0); _catalogResolver = new XmlValidatorCatalogResolver(manager); _catalogResolver.namespaceAware = _isNamespaceAware;
@Test public void testParseCatalog() throws Exception{ URL file = TestData.url(this, "commonSchemas_new.oasis.xml"); ResolvingXMLReader reader = new ResolvingXMLReader(); Catalog catalog = reader.getCatalog(); catalog.getCatalogManager().setVerbosity(9); catalog.parseCatalog(file); final URL baseUri = new URL("http://schemas.opengis.net/gml/"); //the system override defined in the catalog final URL override = new URL("file:///schemas/gml/trunk/gml/"); final String extraPath = "3.1.1/basicTypes.xsd"; final String uri = new URL(baseUri, extraPath).toExternalForm(); final String expected = new URL(override, extraPath).toExternalForm(); String resolved = catalog.resolveSystem(uri); assertNotNull(resolved); final String actual = new URL(resolved).toExternalForm(); assertEquals(expected, actual); } }
CatalogManager.getStaticManager().setVerbosity(2);
CatalogManager.getStaticManager().setVerbosity(2);
/** * 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); }