public void run() throws SaxonApiException { super.run(); if (runtime.getSafeMode()) { throw XProcException.dynamicError(21); } boolean recursive = getOption(_recursive, false); boolean fail_on_error = getOption(_fail_on_error, true); RuntimeValue href = getOption(_href); String base = href.getBaseURI().toASCIIString(); URI uri = href.getBaseURI().resolve(href.getString()); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); performDelete(href, base, recursive, fail_on_error); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); }
public void load(URI id, String media, final InputStream src, long len) throws IOException { RuntimeValue target = getOption(_target); URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() { public void store(OutputStream dst) throws IOException { byte[] buffer = new byte[bufsize]; int read = src.read(buffer, 0, bufsize); while (read >= 0) { dst.write(buffer, 0, read); read = src.read(buffer, 0, bufsize); } } }); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } });
private void performDelete(RuntimeValue href, String base, boolean recursive, boolean fail_on_error) { DataStore store = runtime.getDataStore(); if (recursive) { try { for (String entry : getAllEntries(href.getString(), base)) { store.deleteEntry(entry, entry); } } catch (FileNotFoundException e) { if (fail_on_error) { throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e); } } catch (IOException e) { if (fail_on_error) { throw new XProcException(step.getNode(), e); } } } try { store.deleteEntry(href.getString(), base); } catch (FileNotFoundException e) { if (fail_on_error) { throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e); } } catch (IOException e) { if (fail_on_error) { throw new XProcException(step.getNode(), e); } } }
public void run() throws SaxonApiException { super.run(); if (runtime.getSafeMode()) { throw XProcException.dynamicError(21); } RuntimeValue href = getOption(_href); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); try { DataStore store = runtime.getDataStore(); URI uri = store.createList(href.getString(), href.getBaseURI().toASCIIString()); tree.addText(uri.toASCIIString()); } catch (FileNotFoundException e) { throw new XProcException(step.getNode(), "Cannot mkdir: file exists: " + href.getString()); } catch (IOException e) { throw new XProcException(step.getNode(), "Mkdir failed for: " + href.getString()); } tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } }
RuntimeValue href = getOption(_href);
public void run() throws SaxonApiException { super.run(); if (runtime.getSafeMode()) { throw XProcException.dynamicError(21); } boolean recursive = getOption(_recursive, false); boolean fail_on_error = getOption(_fail_on_error, true); RuntimeValue href = getOption(_href); String base = href.getBaseURI().toASCIIString(); URI uri = href.getBaseURI().resolve(href.getString()); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); performDelete(href, base, recursive, fail_on_error); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); }
public void load(URI id, String media, final InputStream src, long len) throws IOException { RuntimeValue target = getOption(_target); URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() { public void store(OutputStream dst) throws IOException { byte[] buffer = new byte[bufsize]; int read = src.read(buffer, 0, bufsize); while (read >= 0) { dst.write(buffer, 0, read); read = src.read(buffer, 0, bufsize); } } }); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } });
private void performDelete(RuntimeValue href, String base, boolean recursive, boolean fail_on_error) { DataStore store = runtime.getDataStore(); if (recursive) { try { for (String entry : getAllEntries(href.getString(), base)) { store.deleteEntry(entry, entry); } } catch (FileNotFoundException e) { if (fail_on_error) { throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e); } } catch (IOException e) { if (fail_on_error) { throw new XProcException(step.getNode(), e); } } } try { store.deleteEntry(href.getString(), base); } catch (FileNotFoundException e) { if (fail_on_error) { throw new XProcException(step.getNode(), "Cannot delete: file does not exist", e); } } catch (IOException e) { if (fail_on_error) { throw new XProcException(step.getNode(), e); } } }
public void run() throws SaxonApiException { super.run(); if (runtime.getSafeMode()) { throw XProcException.dynamicError(21); } RuntimeValue href = getOption(_href); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); try { DataStore store = runtime.getDataStore(); URI uri = store.createList(href.getString(), href.getBaseURI().toASCIIString()); tree.addText(uri.toASCIIString()); } catch (FileNotFoundException e) { throw new XProcException(step.getNode(), "Cannot mkdir: file exists: " + href.getString()); } catch (IOException e) { throw new XProcException(step.getNode(), "Mkdir failed for: " + href.getString()); } tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } }
RuntimeValue href = getOption(_href);
RuntimeValue href = getOption(_href);
public void load(URI id, String media, final InputStream src, long len) throws IOException { RuntimeValue target = getOption(_target); URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() { public void store(OutputStream dst) throws IOException { byte[] buffer = new byte[bufsize]; int read = src.read(buffer, 0, bufsize); while (read >= 0) { dst.write(buffer, 0, read); read = src.read(buffer, 0, bufsize); } } }); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } });
RuntimeValue href = getOption(_href);
public void load(URI id, String media, final InputStream src, long len) throws IOException { RuntimeValue target = getOption(_target); URI uri = store.writeEntry(target.getString(), target.getBaseURI().toASCIIString(), media, new DataWriter() { public void store(OutputStream dst) throws IOException { byte[] buffer = new byte[bufsize]; int read = src.read(buffer, 0, bufsize); while (read >= 0) { dst.write(buffer, 0, read); read = src.read(buffer, 0, bufsize); } } }); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(step.getNode().getBaseURI()); tree.addStartElement(XProcConstants.c_result); tree.startContent(); tree.addText(uri.toASCIIString()); tree.addEndElement(); tree.endDocument(); result.write(tree.getResult()); } });