Search in sources :

Example 1 with EntityTemplate

use of org.apache.http.entity.EntityTemplate in project jena by apache.

the class TestMultipleEmbedded method graphToHttpEntity.

/** Create an HttpEntity for the graph */
protected static HttpEntity graphToHttpEntity(final Graph graph) {
    final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS;
    ContentProducer producer = new ContentProducer() {

        @Override
        public void writeTo(OutputStream out) {
            RDFDataMgr.write(out, graph, syntax);
        }
    };
    EntityTemplate entity = new EntityTemplate(producer);
    ContentType ct = syntax.getLang().getContentType();
    entity.setContentType(ct.getContentType());
    return entity;
}
Also used : ContentType(org.apache.jena.atlas.web.ContentType) OutputStream(java.io.OutputStream) EntityTemplate(org.apache.http.entity.EntityTemplate) RDFFormat(org.apache.jena.riot.RDFFormat) ContentProducer(org.apache.http.entity.ContentProducer)

Example 2 with EntityTemplate

use of org.apache.http.entity.EntityTemplate in project jena by apache.

the class TestEmbeddedFuseki method graphToHttpEntity.

/** Create an HttpEntity for the graph */
protected static HttpEntity graphToHttpEntity(final Graph graph) {
    final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS;
    ContentProducer producer = new ContentProducer() {

        @Override
        public void writeTo(OutputStream out) {
            RDFDataMgr.write(out, graph, syntax);
        }
    };
    EntityTemplate entity = new EntityTemplate(producer);
    ContentType ct = syntax.getLang().getContentType();
    entity.setContentType(ct.getContentType());
    return entity;
}
Also used : ContentType(org.apache.jena.atlas.web.ContentType) OutputStream(java.io.OutputStream) EntityTemplate(org.apache.http.entity.EntityTemplate) RDFFormat(org.apache.jena.riot.RDFFormat) ContentProducer(org.apache.http.entity.ContentProducer)

Example 3 with EntityTemplate

use of org.apache.http.entity.EntityTemplate in project jena by apache.

the class DatasetGraphAccessorHTTP method graphToHttpEntity.

/** Create an HttpEntity for the graph */
protected HttpEntity graphToHttpEntity(final Graph graph) {
    final RDFFormat syntax = getOutboundSyntax();
    ContentProducer producer = new ContentProducer() {

        @Override
        public void writeTo(OutputStream out) {
            RDFDataMgr.write(out, graph, syntax);
        }
    };
    EntityTemplate entity = new EntityTemplate(producer);
    String ct = syntax.getLang().getContentType().getContentType();
    entity.setContentType(ct);
    return entity;
}
Also used : OutputStream(java.io.OutputStream) EntityTemplate(org.apache.http.entity.EntityTemplate) RDFFormat(org.apache.jena.riot.RDFFormat) ContentProducer(org.apache.http.entity.ContentProducer)

Example 4 with EntityTemplate

use of org.apache.http.entity.EntityTemplate in project jena by apache.

the class RDFConnectionRemote method datasetToHttpEntity.

/** Create an HttpEntity for the dataset */
protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) {
    EntityTemplate entity = new EntityTemplate((out) -> RDFDataMgr.write(out, dataset, syntax));
    String ct = syntax.getLang().getContentType().getContentType();
    entity.setContentType(ct);
    return entity;
}
Also used : EntityTemplate(org.apache.http.entity.EntityTemplate)

Example 5 with EntityTemplate

use of org.apache.http.entity.EntityTemplate in project jena by apache.

the class RDFConnectionRemote method graphToHttpEntity.

/** Create an HttpEntity for the graph */
protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) {
    EntityTemplate entity = new EntityTemplate((out) -> RDFDataMgr.write(out, graph, syntax));
    String ct = syntax.getLang().getContentType().getContentType();
    entity.setContentType(ct);
    return entity;
}
Also used : EntityTemplate(org.apache.http.entity.EntityTemplate)

Aggregations

EntityTemplate (org.apache.http.entity.EntityTemplate)6 OutputStream (java.io.OutputStream)3 ContentProducer (org.apache.http.entity.ContentProducer)3 RDFFormat (org.apache.jena.riot.RDFFormat)3 ContentType (org.apache.jena.atlas.web.ContentType)2