static public OutputStreamHandle OutputStreamSenderToHandle(OutputStreamSender value) { return (value == null) ? null : new OutputStreamHandle(value); } static public Stream<OutputStreamHandle> OutputStreamSenderToHandle(Stream<? extends OutputStreamSender> values) {
/** * Initializes the handle with an outputstream sender providing * the callback that writes content to the database via an output stream. * @param sender the processor that sends content to the database */ public OutputStreamHandle(OutputStreamSender sender) { this(); set(sender); }
/** * Specifies the format of the content and returns the handle * as a fluent convenience. * @param format the format of the content * @return this handle */ public OutputStreamHandle withFormat(Format format) { setFormat(format); return this; } /**
@Override public void writeConfiguration() throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException { if (logger.isInfoEnabled()) logger.info("Writing server configuration"); OutputStreamHandle handle = new OutputStreamHandle(this); handle.setResendable(true); services.putValue(null, "config/properties", null, "application/xml", handle); } @Override
/** * Specifies whether the content can be resent to the output stream and * returns the handle as a fluent convenience. * @param resendable true if the content can be sent again * @return this handle */ public OutputStreamHandle withResendable(boolean resendable) { setResendable(resendable); return this; }
/** * Specifies the mime type of the content and returns the handle * as a fluent convenience. * @param mimetype the mime type of the content * @return this handle */ public OutputStreamHandle withMimetype(String mimetype) { setMimetype(mimetype); return this; }
@Override public void writeConfiguration() throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException { if (logger.isInfoEnabled()) logger.info("Writing server configuration"); OutputStreamHandle handle = new OutputStreamHandle(this); handle.setResendable(true); services.putValue(null, "config/properties", null, "application/xml", handle); } @Override
/** * Specifies whether the content can be resent to the output stream and * returns the handle as a fluent convenience. * @param resendable true if the content can be sent again * @return this handle */ public OutputStreamHandle withResendable(boolean resendable) { setResendable(resendable); return this; }
/** * Specifies the mime type of the content and returns the handle * as a fluent convenience. * @param mimetype the mime type of the content * @return this handle */ public OutputStreamHandle withMimetype(String mimetype) { setMimetype(mimetype); return this; }
public void writeGraph(String uri, Graph graph) { WriterGraphRIOT writer = RDFDataMgr.createGraphWriter(Lang.NTRIPLES); OutputStreamRIOTSender sender = new OutputStreamRIOTSender(writer); sender.setGraph(graph); OutputStreamHandle handle = new OutputStreamHandle(sender); this.graphManager.write(uri, handle, currentTransaction); } /**
/** * Assigns an output stream sender providing the callback that writes * content to the database and returns the handle as a fluent convenience. * @param sender the output stream sender * @return this handle */ public OutputStreamHandle with(OutputStreamSender sender) { set(sender); return this; }
/** * Specifies the format of the content and returns the handle * as a fluent convenience. * @param format the format of the content * @return this handle */ public OutputStreamHandle withFormat(Format format) { setFormat(format); return this; } /**
public void mergeGraph(String uri, Graph graph) { WriterGraphRIOT writer = RDFDataMgr.createGraphWriter(Lang.NTRIPLES); OutputStreamRIOTSender sender = new OutputStreamRIOTSender(writer); sender.setGraph(graph); OutputStreamHandle handle = new OutputStreamHandle(sender); this.graphManager.merge(uri, handle, currentTransaction); }
/** * Assigns an output stream sender providing the callback that writes * content to the database and returns the handle as a fluent convenience. * @param sender the output stream sender * @return this handle */ public OutputStreamHandle with(OutputStreamSender sender) { set(sender); return this; }
public void writeDocumentUsingOutputStreamHandle(DatabaseClient client, final String filename, String uri, String type) { final int MAX_BUF = 1024; // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); String docId = uri + filename; // create an anonymous class with a callback method OutputStreamSender sender = new OutputStreamSender() { // the callback receives the output stream public void write(OutputStream out) throws IOException { // acquire the content InputStream docStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // copy content to the output stream byte[] buf = new byte[MAX_BUF]; int byteCount = 0; while ((byteCount = docStream.read(buf)) != -1) { out.write(buf, 0, byteCount); } docStream.close(); } }; // create the handle OutputStreamHandle contentHandle = new OutputStreamHandle(sender); // write the doc docMgr.write(docId, contentHandle); System.out.println("Write " + docId + " to the database"); }
/** * Initializes the handle with an outputstream sender providing * the callback that writes content to the database via an output stream. * @param sender the processor that sends content to the database */ public OutputStreamHandle(OutputStreamSender sender) { this(); set(sender); }
public void updateDocumentUsingOutputStreamHandle(DatabaseClient client, final String filename, String uri, String type) throws FileNotFoundException { final int MAX_BUF = 1024; // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); String docId = uri; // create an anonymous class with a callback method OutputStreamSender sender = new OutputStreamSender() { // the callback receives the output stream public void write(OutputStream out) throws IOException { // acquire the content InputStream docStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // copy content to the output stream byte[] buf = new byte[MAX_BUF]; int byteCount = 0; while ((byteCount = docStream.read(buf)) != -1) { out.write(buf, 0, byteCount); } docStream.close(); } }; // create handle OutputStreamHandle contentHandle = new OutputStreamHandle(sender); // set uri // write doc docMgr.write(docId, contentHandle); System.out.println("Update " + docId + " to database"); }
OutputStreamHandle contentHandle = new OutputStreamHandle(sender);