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; }
/** * Copy with default buffer size. * * @see #copy(java.io.OutputStream, java.io.InputStream) * @see #DEFAULT_BUFFER_SIZE */ public static void copy(OutputStream dest, InputStream source) throws IOException { copy(dest, source, DEFAULT_BUFFER_SIZE); }
ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { StreamUtils.write(bos, (Serializable) details.detailsExt); } catch (Exception ex) { __log.error("Error serializing job detail: " + job.detail);
ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { StreamUtils.write(bos, (Serializable) details.detailsExt); } catch (Exception ex) { __log.error("Error serializing job detail: " + job.getDetails());
/** * 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; }
/** * Read the contents of the given URL into a byte array. * * @param input * the URL to read * @return an array of bytes. * @throws IOException * in case of I/O error */ public static byte[] read(URL input) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE); copy(byteStream, input); return byteStream.toByteArray(); }
/** * 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; }
/** * Read the contents of the given InputStream into a byte array. * * @param input * the InputStream to read * @return an array of bytes. * @throws IOException * in case of I/O error */ public static byte[] read(InputStream source) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE); copy(byteStream, source); return byteStream.toByteArray(); }
Process process; try { InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL()))); isrc.setSystemId(bpelFile.getAbsolutePath());
/** * Copy from {@link URL} stream. * * @see #copy(java.io.OutputStream, java.io.InputStream, int) * @param dest * destination {@link OutputStream} * @param source * source {@link URL} */ public static void copy(OutputStream dest, URL source) throws IOException { InputStream urlStream = source.openStream(); copy(dest, urlStream); urlStream.close(); }
data = StreamUtils.read(is); } finally { is.close();
/** * Expand a Jar input stream. */ public static void extractJar(File dest, InputStream is) throws IOException { JarInputStream jis = new JarInputStream(is); JarEntry je; while ((je = jis.getNextJarEntry()) != null) { File outputFile = new File(dest, je.getName()); if (je.isDirectory()) { outputFile.mkdirs(); } else { outputFile.getParentFile().mkdirs(); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outputFile)); copy(bos, jis); bos.flush(); bos.close(); } jis.closeEntry(); } }
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); } }
public static String doSend(URL u, InputStream is, String proxyServer, int proxyPort, String username, String password, String soapAction) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(8192); StreamUtils.copy(bos, is); String now = Long.toString(System.currentTimeMillis()); int c = 1;