/** * Resolve schema from <code>schemaLocationsNape</code> or <code>namespaceUri</code> for given * <code>namespaceUri</code>. * * @param schemaLocationMap {@link Map} of namespaceUri to URLs. * @param namespaceUri Namespace URI for schema. * @return {@link InputSource} for schema if found. * @throws IOException if unable to open {@link InputSource}. * @since GemFire 8.1 */ private static InputSource resolveSchema(final Map<String, String> schemaLocationMap, String namespaceUri) throws IOException { final EntityResolver2 entityResolver = new CacheXmlParser(); InputSource inputSource = null; // Try loading schema from locations until we find one. final String location = schemaLocationMap.get(namespaceUri); try { inputSource = entityResolver.resolveEntity(null, location); } catch (final SAXException e) { // ignore } if (null == inputSource) { // Try getting it from the namespace, will throw if does not exist. inputSource = new InputSource(new URL(namespaceUri).openStream()); } return inputSource; }
@Override public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { return entityResolver.getExternalSubset(name, baseURI); }
@Override public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { return entityResolver.getExternalSubset(name, baseURI); }
/** * Resolve entity using discovered {@link EntityResolver2}s. * * @return {@link InputSource} for resolved entity if found, otherwise null. * @since GemFire 8.1 */ private InputSource resolveEntityByEntityResolvers(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { final ServiceLoader<EntityResolver2> entityResolvers = ServiceLoader.load(EntityResolver2.class, ClassPathLoader.getLatest().asClassLoader()); for (final EntityResolver2 entityResolver : entityResolvers) { final InputSource inputSource = entityResolver.resolveEntity(name, publicId, baseURI, systemId); if (null != inputSource) { return inputSource; } } return null; }
@Override public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { return entityResolver.getExternalSubset(name, baseURI); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { if (entityResolver != null) { return entityResolver.resolveEntity(publicId, systemId); } else { return super.resolveEntity(publicId, systemId); } }
InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { if (resolver2 == null || !useResolver2 || !extPE) { return null; } return resolver2.getExternalSubset(name, baseURI); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { if (entityResolver != null) { return entityResolver.resolveEntity(publicId, systemId); } else { return super.resolveEntity(publicId, systemId); } }
@Nullable public InputSource getExternalSubset (final String sName, @Nullable final String sBaseURI) throws SAXException, IOException { _updatePosition ("getExternalSubset"); final EntityResolver2 aER2 = m_aEntityResolver2; if (aER2 != null) return aER2.getExternalSubset (sName, sBaseURI); return null; }
@Override public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { if (entityResolver != null) { return entityResolver.resolveEntity(name, publicId, baseURI, systemId); } return super.resolveEntity(name, publicId, baseURI, systemId); }
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI); return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
@Override public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { if (entityResolver != null) { return entityResolver.resolveEntity(name, publicId, baseURI, systemId); } return super.resolveEntity(name, publicId, baseURI, systemId); }
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI); return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
@Override public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { // TODO URLs returned by the Jar abstraction may be of the form jar:jar: // which is not a URL that can be resolved by the JRE. This should // use the JarFactory to construct and return a valid InputSource. return entityResolver.resolveEntity(name, publicId, baseURI, systemId); }
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI); return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
@Override public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { // TODO URLs returned by the Jar abstraction may be of the form jar:jar: // which is not a URL that can be resolved by the JRE. This should // use the JarFactory to construct and return a valid InputSource. return entityResolver.resolveEntity(name, publicId, baseURI, systemId); }
@Override public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { // TODO URLs returned by the Jar abstraction may be of the form jar:jar: // which is not a URL that can be resolved by the JRE. This should // use the JarFactory to construct and return a valid InputSource. return entityResolver.resolveEntity(name, publicId, baseURI, systemId); }
for (final String location : locations) { try { inputSource = entityResolver.resolveEntity(null, location); if (null != inputSource) { break;
@Nullable public InputSource resolveEntity (@Nullable final String sName, @Nullable final String sPublicId, @Nullable final String sBaseURI, @Nonnull final String sSystemId) throws SAXException, IOException { _updatePosition ("resolveEntity2"); final EntityResolver2 aER2 = m_aEntityResolver2; if (aER2 != null) return aER2.resolveEntity (sName, sPublicId, sBaseURI, sSystemId); final EntityResolver aER = m_aEntityResolver; if (aER != null) return aER.resolveEntity (sPublicId, sSystemId); if (LOGGER.isInfoEnabled ()) LOGGER.info ("Need to resolve entity with name '" + sName + "', public ID '" + sPublicId + "' base URI '" + sBaseURI + "' and system ID '" + sSystemId + "'"); return null; }
/** * Resolve entity using discovered {@link EntityResolver2}s. * @param publicId * @param systemId * @return {@link InputSource} for resolved entity if found, otherwise null. * @throws IOException * @throws SAXException * @since 8.1 */ private InputSource resolveEntityByEntityResolvers(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { final ServiceLoader<EntityResolver2> entityResolvers = ServiceLoader.load(EntityResolver2.class, ClassPathLoader.getLatest().asClassLoader()); for (final EntityResolver2 entityResolver : entityResolvers) { final InputSource inputSource = entityResolver.resolveEntity(name, publicId, baseURI, systemId); if (null != inputSource) { return inputSource; } } return null; }