public void store(OutputStream content) throws IOException { final ZipOutputStream outZip = new ZipOutputStream(content); try { store.readEntry(zipFn, base, "application/zip", null, new DataStore.DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { ZipInputStream inZip = new ZipInputStream(content); try { update(inZip, outZip); } finally { inZip.close(); } } }); } catch (FileNotFoundException e) { update(null, outZip); } finally { outZip.close(); } } });
public void store(OutputStream content) throws IOException { final ZipOutputStream outZip = new ZipOutputStream(content); try { store.readEntry(zipFn, base, "application/zip", null, new DataStore.DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { ZipInputStream inZip = new ZipInputStream(content); try { update(inZip, outZip); } finally { inZip.close(); } } }); } catch (FileNotFoundException e) { update(null, outZip); } finally { outZip.close(); } } });
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { readHttpEntity(uri, accept, overrideContentType, handler); } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); String sch = uri.getScheme(); if ("http".equalsIgnoreCase(sch) || "https".equalsIgnoreCase(sch)) { readHttpEntity(uri, accept, overrideContentType, handler); } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
public void list(URI id, String media, long lastModified) throws IOException { final String accept = pattern == null ? ACCEPT_XML : "*/*"; final DataReader handler = new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { content.close(); String name = new File(id).getName(); if (pattern == null || pattern.matcher(name).matches()) { documents.add(parse(id.toASCIIString(), base)); } } }; String entry = id.toASCIIString(); if (media == null) { store.listEachEntry(entry, entry, accept, new DataInfo() { public void list(URI id, String media, long lastModified) throws IOException { String entry = id.toASCIIString(); store.readEntry(entry, entry, accept, null, handler); } }); } else { store.readEntry(entry, entry, accept, null, handler); } } });
public void list(URI id, String media, long lastModified) throws IOException { final String accept = pattern == null ? ACCEPT_XML : "*/*"; final DataReader handler = new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { content.close(); String name = new File(id).getName(); if (pattern == null || pattern.matcher(name).matches()) { documents.add(parse(id.toASCIIString(), base)); } } }; String entry = id.toASCIIString(); if (media == null) { store.listEachEntry(entry, entry, accept, new DataInfo() { public void list(URI id, String media, long lastModified) throws IOException { String entry = id.toASCIIString(); store.readEntry(entry, entry, accept, null, handler); } }); } else { store.readEntry(entry, entry, accept, null, handler); } } });
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); String type = getContentTypeFromName(file.getName()); if (overrideContentType != null) { type = overrideContentType; } InputStream in = new FileInputStream(file); try { handler.load(file.toURI(), type, in, file.length()); } finally { in.close(); } } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
public void readEntry(String href, String base, String accept, String overrideContentType, DataReader handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); String type = getContentTypeFromName(file.getName()); if (overrideContentType != null) { type = overrideContentType; } InputStream in = new FileInputStream(file); try { handler.load(file.toURI(), type, in, file.length()); } finally { in.close(); } } else { fallback.readEntry(href, base, accept, overrideContentType, handler); } }
private void readText(final String href, final XdmNode node, String base, final XPointer xpointer, final TreeWriter matcher) { logger.trace("XInclude read text: " + href + " (" + base + ")"); DataStore store = runtime.getDataStore(); try { store.readEntry(href, base, "text/plain, text/*, */*", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { String text = readText(node, xpointer, media, content, len); if (text == null) { logger.trace(MessageFormatter.nodeMessage(node, "XInclude text parse failed: " + href)); fallback(node, href); } else { logger.trace(MessageFormatter.nodeMessage(node, "XInclude text parse: " + href)); matcher.addText(text); } } }); } catch (Exception e) { logger.debug("XInclude read text failed"); mostRecentException = e; fallback(node, href); } }
private void readText(final String href, final XdmNode node, String base, final XPointer xpointer, final TreeWriter matcher) { logger.trace("XInclude read text: " + href + " (" + base + ")"); DataStore store = runtime.getDataStore(); try { store.readEntry(href, base, "text/plain, text/*, */*", null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { String text = readText(node, xpointer, media, content, len); if (text == null) { logger.trace(MessageFormatter.nodeMessage(node, "XInclude text parse failed: " + href)); fallback(node, href); } else { logger.trace(MessageFormatter.nodeMessage(node, "XInclude text parse: " + href)); matcher.addText(text); } } }); } catch (Exception e) { logger.debug("XInclude read text failed"); mostRecentException = e; fallback(node, href); } }
private void doFile(String href, String base) { try { DataStore store = runtime.getDataStore(); store.readEntry(href, base, "application/xml, text/xml, */*", overrideContentType, new DataReader() { public void load(URI id, String contentType, InputStream bodyStream, long len) throws IOException {
private void doFile(String href, String base) { try { DataStore store = runtime.getDataStore(); store.readEntry(href, base, "application/xml, text/xml, */*", overrideContentType, new DataReader() { public void load(URI id, String contentType, InputStream bodyStream, long len) throws IOException {
store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "text/*, */*", null, new DataStore.DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException { Reader rdr = new InputStreamReader(content);
store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "*/*", null, new DataReader() { public void load(URI id, String media, final InputStream src, long len) throws IOException {
store.readEntry(href.getString(), href.getBaseURI().toASCIIString(), "*/*", null, new DataReader() { public void load(URI id, String media, final InputStream src, long len) throws IOException {
final DataStore store = runtime.getDataStore(); String base = href.getBaseURI().toASCIIString(); store.readEntry(href.getString(), base, "*/*", null, new DataReader() { public void load(URI id, String media, final InputStream src, long len) throws IOException {
final DataStore store = runtime.getDataStore(); String base = href.getBaseURI().toASCIIString(); store.readEntry(href.getString(), base, "*/*", null, new DataReader() { public void load(URI id, String media, final InputStream src, long len) throws IOException {
String base = pURI.toASCIIString(); DataStore store = runtime.getDataStore(); store.readEntry(pFn, base, ACCEPT_TEXT, null, new DataReader() { public void load(URI id, String media, InputStream stream, long len) throws IOException {
DataStore store = runtime.getDataStore(); String base = zipURI.toASCIIString(); store.readEntry(zipFn, base, ACCEPT_ZIP, null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException {
DataStore store = runtime.getDataStore(); String base = zipURI.toASCIIString(); store.readEntry(zipFn, base, ACCEPT_ZIP, null, new DataReader() { public void load(URI id, String media, InputStream content, long len) throws IOException {