/** * 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; }
@Before public void setUp() throws Exception { catalog = new Catalog(); catalog.setupReaders(); }
default_override = catalogManager.getPreferPublic(); catalogManager.debug.message(DEBUG_NORMAL, "Parse catalog: " + fileName); catalogManager.debug.message(DEBUG_NORMAL, "Unable to access " + base + ex.getMessage()); break; reader.readCatalog(this, inStream); parsed = true; catalogManager.debug.message(DEBUG_NORMAL, "Parse failed for " + fileName + ce.getMessage()); if (ce.getExceptionType() == CatalogException.PARSE_FAILED)
@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); } }
String resolvedLocation = null; try { resolvedLocation = catalog.resolveURI(location); } catch (Exception e) { throw new RuntimeException(e);
catalog.setCatalogManager(this); catalog.setupReaders(); catalog.loadSystemCatalogs();
@Override public Void run() throws Exception { ((Catalog)catalog).parseCatalog(catalogURL); return null; } });
public String resolveSystem(String sys) throws MalformedURLException, IOException { if (catalog == null) { return null; } return ((Catalog)catalog).resolveSystem(sys); }
/** * How are missing properties handled? * * <p>If ignore is true, missing or unreadable property files will * not be reported. Otherwise, a message will be sent to System.err. * </p> * * @deprecated No longer static; use get/set methods. */ public void ignoreMissingProperties(boolean ignore) { setIgnoreMissingProperties(ignore); }
public String resolvePublic(String uri, String parent) throws MalformedURLException, IOException { if (resolver == null) { return null; } return ((Catalog)catalog).resolvePublic(uri, parent); }
Vector<String> catalogs = catalogManager.getCatalogFiles(); if (catalogs != null) catalogManager.debug.message(DEBUG_ALL, "Unable to get input stream for " + name + ". " + ce.getMessage()); catalogManager.debug.message(DEBUG_ALL, "Exception caught parsing input stream for " + fileName + ". " + ex.getMessage());
/** * Find out how many arguments an entry is required to have. * * @param name The name of the catalog entry type. * @return The number of arguments that entry type is required to have. * @throws InvalidCatalogEntryTypeException if no entry has the * specified name. */ public static int getEntryArgCount(String name) throws CatalogException { return getEntryArgCount(getEntryType(name)); }
/** * Perform character normalization on a URI reference. * * @param uriref The URI reference * @return The normalized URI reference. */ @Override protected String normalizeURI(final String uriref) { final ConfigurationInterpolator ci = ((CatalogManager) catalogManager).getInterpolator(); final String resolved = ci != null ? String.valueOf(ci.interpolate(uriref)) : uriref; return super.normalizeURI(resolved); } }
/** * Get the version string for xml-commons-resolver. * Version String formatted like: * <CODE>"XmlResolver v.r"</CODE>. * * @return String denoting our current version */ public static String getVersion() { return getProduct()+" "+getVersionNum(); }
/** * Get the current Catalog class name. */ public String getCatalogClassName() { if (catalogClassName == null) { catalogClassName = queryCatalogClassName(); } return catalogClassName; }
/** * Get the current XML Catalog PI setting. * * @deprecated No longer static; use get/set methods. */ public boolean allowOasisXMLCatalogPI() { return getAllowOasisXMLCatalogPI(); }
public String resolveURI(String uri) throws MalformedURLException, IOException { if (catalog == null) { return null; } return ((Catalog)catalog).resolveURI(uri); } public String resolvePublic(String uri, String parent) throws MalformedURLException, IOException {
public String resolveSystem(String sys) throws MalformedURLException, IOException { if (catalog == null) { return null; } return ((Catalog)catalog).resolveSystem(sys); }
public String resolveURI(String uri) throws MalformedURLException, IOException { if (catalog == null) { return null; } return ((Catalog)catalog).resolveURI(uri); } public String resolvePublic(String uri, String parent) throws MalformedURLException, IOException {
public String resolveURI(String uri) throws MalformedURLException, IOException { if (catalog == null) { return null; } return ((Catalog)catalog).resolveURI(uri); } public String resolvePublic(String uri, String parent) throws MalformedURLException, IOException {