use of org.eclipse.rdf4j.http.protocol.transaction.TransactionWriter in project rdf4j by eclipse.
the class RDF4JProtocolSession method sendTransaction.
/**
* Sends a transaction list as serialized XML to the server.
*
* @deprecated since 2.8.0
* @param txn
* @throws IOException
* @throws RepositoryException
* @throws UnauthorizedException
*/
@Deprecated
public void sendTransaction(final Iterable<? extends TransactionOperation> txn) throws IOException, RepositoryException, UnauthorizedException {
checkRepositoryURL();
HttpPost method = new HttpPost(Protocol.getStatementsLocation(getQueryURL()));
try {
// Create a RequestEntity for the transaction data
method.setEntity(new AbstractHttpEntity() {
public long getContentLength() {
// don't know
return -1;
}
public Header getContentType() {
return new BasicHeader("Content-Type", Protocol.TXN_MIME_TYPE);
}
public boolean isRepeatable() {
return true;
}
public boolean isStreaming() {
return true;
}
public InputStream getContent() throws IOException, IllegalStateException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
writeTo(buf);
return new ByteArrayInputStream(buf.toByteArray());
}
public void writeTo(OutputStream out) throws IOException {
TransactionWriter txnWriter = new TransactionWriter();
txnWriter.serialize(txn, out);
}
});
try {
executeNoContent(method);
} catch (RepositoryException e) {
throw e;
} catch (RDF4JException e) {
throw new RepositoryException(e);
}
} finally {
method.reset();
}
}
Aggregations