1 package eu.fbk.knowledgestore.server.http.jaxrs;
2
3 import eu.fbk.knowledgestore.OperationException;
4 import eu.fbk.knowledgestore.Outcome;
5 import eu.fbk.knowledgestore.data.Stream;
6 import eu.fbk.knowledgestore.internal.jaxrs.Protocol;
7 import org.codehaus.enunciate.jaxrs.TypeHint;
8 import org.openrdf.model.Statement;
9
10 import javax.ws.rs.Consumes;
11 import javax.ws.rs.POST;
12 import javax.ws.rs.Path;
13 import javax.ws.rs.Produces;
14 import javax.ws.rs.core.Response;
15
16
17
18
19
20 @Path("/" + Protocol.PATH_DELETE)
21 public class SparqlDelete extends Resource {
22
23 @POST
24 @Produces(Protocol.MIME_TYPES_ALL)
25 @Consumes(Protocol.MIME_TYPES_RDF)
26 @TypeHint(Stream.class)
27 public Response post(final Stream<Statement> statements) throws OperationException {
28
29 closeOnCompletion(statements);
30
31
32
33 init(true, null);
34
35 Outcome outcome = getSession().sparqldelete().statements(statements).exec();
36
37
38 final int httpStatus = outcome.getStatus().getHTTPStatus();
39 final Stream<Outcome> entity = Stream.create(outcome);
40
41
42 return newResponseBuilder(httpStatus, entity, Protocol.STREAM_OF_OUTCOMES).build();
43 }
44
45 }