private Map<String,InputStream> getExternalBindingFiles() throws IOException { if (externalBindings == null) return null; Map<String,InputStream> files = new HashMap<String,InputStream>(); StringTokenizer st = new StringTokenizer(externalBindings, ","); while (st.hasMoreTokens()) { String name = st.nextToken(); Resolver resolver = new Resolver(baseURI, name); if (resolver.getInputStream() == null) throw new IllegalStateException("Could not find binding file " + name); files.put(resolver.getURI().toString(), resolver.getInputStream()); } return files; }
public Resolver(String baseUriStr, String uriStr) throws IOException { if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } if (is == null) { String msg = "Could not find resource '" + uriStr; if (baseUriStr != null) msg += "' relative to '" + baseUriStr + "'"; throw new IOException(msg); } }
public InputSource getImportInputSource(String arg0, String name) { Resolver resolver; InputSource result = null; // Set the last imported value. lastimport = name; try { resolver = new Resolver(baseURI, name); InputStream is = resolver.getInputStream(); if (is != null) result = new InputSource(resolver.getInputStream()); } catch (IOException e) { LOG.warn("Source: " + name + " failed to find input source with exception: ", e); } return result; }
private void tryClasspath(String uriStr) throws IOException { if (uriStr.startsWith("classpath:")) { uriStr = uriStr.substring(10); } URL url = ClassLoaderUtils.getResource(uriStr, getClass()); if (url == null) { tryRemote(uriStr); } else { try { String decodedURL = url.toString(); uri = new URI(URLEncoder.encode(decodedURL, "UTF-8")); } catch (URISyntaxException e) { // this occurs when you have spaces instead of '%20'... } is = url.openStream(); this.url = url; } }
public void write(OutputStream out) throws IOException { InputStream is; if (wsdlUrl != null) is = wsdlUrl.openStream(); else is = new Resolver(baseString, wsdlString).getInputStream(); copy(is, out, 8096 ); }
Resolver resolver = new Resolver(baseURI, wsdl); if (resolver.getInputStream() == null) String wsdlUri = resolver.getURI().toString(); if (baseURI == null) InputSource source = new InputSource(resolver.getInputStream()); source.setSystemId(wsdlUri); WSDLServiceBuilder builder = new WSDLServiceBuilder(baseURI, source);
private Schema setupValidationSchema(Collection<String> schemaLocations) throws IOException, SAXException { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource[] schemaSources = new StreamSource[schemaLocations.size()]; Schema schema; try { int i = 0; for (Iterator itr = schemaLocations.iterator(); itr.hasNext();) { String schemaLocation = (String) itr.next(); schemaSources[i] = new StreamSource(new Resolver(schemaLocation).getInputStream()); i++; } schema = factory.newSchema(schemaSources); } /** make sure to close all ressources * */ finally { for (int i = 0; i < schemaSources.length; i++) { if (schemaSources[i] != null) { InputStream inputStream = schemaSources[i].getInputStream(); if (inputStream != null) { inputStream.close(); } } } } return schema; }