WSDLRegistry(CompilerContext cc) { // bogus schema to force schema creation _schemas.put(URI.create("http://fivesight.com/bogus/namespace"), ("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + " targetNamespace=\"http://fivesight.com/bogus/namespace\">" + "<xsd:simpleType name=\"__bogusType__\">" + "<xsd:restriction base=\"xsd:normalizedString\"/>" + "</xsd:simpleType>" + "</xsd:schema>").getBytes()); try { _schemas.put(URI.create(Namespaces.WSDL_11), StreamUtils.read(getClass().getResource("/wsdl.xsd"))); _schemas.put(URI.create("http://www.w3.org/2001/xml.xsd"), StreamUtils.read(getClass().getResource("/xml.xsd"))); } catch (IOException e) { throw new RuntimeException("Couldn't load default schemas.", e); } _ctx = cc; }
/** * Given a URI this function will attempt to retrieve the resource declared at that URI location * as a string. (Hopefully everything's character encodings are all ok...) This URI can be * defined as being relative to the executing process instance's physical file location. * * @param docUri - the URI to resolve * @return String - the resource contents, or null if none found. */ private String getResourceAsString(URI docUri) { URI resolvedURI= _baseResourceURI.resolve(docUri); InputStream is = null; try { File f = new File(resolvedURI); if (!f.exists()) return null; is = new FileInputStream(f); return new String(StreamUtils.read(is)); } catch (IOException e) { __log.info("Couldn't load XSL resource " + docUri); } finally { try { if (is != null) is.close(); } catch (Exception ex) { // No worries. } } return null; }
/** * Given a URI this function will attempt to retrieve the resource declared at that URI location * as a string. (Hopefully everything's character encodings are all ok...) This URI can be * defined as being relative to the executing process instance's physical file location. * * @param docUri - the URI to resolve * @return String - the resource contents, or null if none found. */ private String getResourceAsString(URI docUri) { URI resolvedURI= _baseResourceURI.resolve(docUri); InputStream is = null; try { File f = new File(resolvedURI); if (!f.exists()) return null; is = new FileInputStream(f); return new String(StreamUtils.read(is)); } catch (IOException e) { __log.info("Couldn't load XSL resource " + docUri); } finally { try { if (is != null) is.close(); } catch (Exception ex) { // No worries. } } return null; }
Process process; try { InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL()))); isrc.setSystemId(bpelFile.getAbsolutePath());
data = StreamUtils.read(is); } finally { is.close();
public void addXsdImport(URI from, URI location, SourceLocation sloc) { URI resFrom = _resourceFinder.resolve(from, location); if (__log.isDebugEnabled()) __log.debug("Adding XSD import from " + resFrom + " location " + location); XMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(_resourceFinder, location, new HashMap<URI,byte[]>(), true); try { InputStream xsdStream = _resourceFinder.openResource(resFrom); byte[] data; try { data = StreamUtils.read(xsdStream); } finally { xsdStream.close(); } Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, resolver); _wsdlRegistry.addSchemas(schemas); } catch (XsdException e) { CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString())); recoveredFromError(sloc, ce); } catch (MalformedURLException e) { CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString())); recoveredFromError(sloc, ce); } catch (IOException e) { CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString())); recoveredFromError(sloc, ce); } }