use of javax.ws.rs.core.Response.ResponseBuilder in project stanbol by apache.
the class ReasoningServicesResource method getDocumentation.
@GET
@Produces(TEXT_HTML)
public Response getDocumentation(@Context HttpHeaders headers) {
ResponseBuilder rb = Response.ok(new Viewable("index", this));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
return rb.build();
}
use of javax.ws.rs.core.Response.ResponseBuilder in project stanbol by apache.
the class ResponseTaskBuilder method build.
/**
* Process the given object (result content output),
* returning an HTML representation or delegating the rendering to jersey writers.
*
* @param object
* @return
*/
private Response build(Object object) {
if (isHTML()) {
OutputStream out = stream(object);
this.result.setResult(out);
ResponseBuilder rb = Response.ok(new Viewable("result", result));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(context, rb, headers);
return rb.build();
/* return Response.ok(
new Viewable("result",
new ReasoningPrettyResultResource(
context, info, out)),
TEXT_HTML).build();*/
} else {
//return Response.ok(object).build();
ResponseBuilder rb = Response.ok(object);
// addCORSOrigin(context, rb, headers);
return rb.build();
}
}
use of javax.ws.rs.core.Response.ResponseBuilder in project stanbol by apache.
the class ScopeResource method getCoreSpaceOWL.
@GET
@Path("/core")
@Produces(value = { RDF_XML, TURTLE, X_TURTLE, MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN })
public Response getCoreSpaceOWL(@PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
scope = onm.getScope(scopeid);
OntologySpace space = scope.getCoreSpace();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
OWLOntology o = space.export(OWLOntology.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of javax.ws.rs.core.Response.ResponseBuilder in project stanbol by apache.
the class ScopeResource method manageOntology.
/**
* Tells the scope that it should manage the ontology obtained by parsing the supplied content.<br>
* <br>
* Note that the PUT method cannot be used, as it is not possible to predict what ID the ontology will
* have until it is parsed.
*
* @param content
* the ontology content
* @return {@link Status#OK} if the addition was successful, {@link Status#NOT_FOUND} if there is no such
* session at all, {@link Status#FORBIDDEN} if the session is locked or cannot modified for some
* other reason, {@link Status#INTERNAL_SERVER_ERROR} if some other error occurs.
*/
@POST
@Consumes(value = { RDF_XML, OWL_XML, N_TRIPLE, N3, TURTLE, X_TURTLE, FUNCTIONAL_OWL, MANCHESTER_OWL, RDF_JSON })
public Response manageOntology(InputStream content, @PathParam("scopeid") String scopeid, @Context HttpHeaders headers) {
long before = System.currentTimeMillis();
ResponseBuilder rb;
scope = onm.getScope(scopeid);
if (// Always check session first
scope == null)
// Always check session first
rb = Response.status(NOT_FOUND);
else
try {
MediaType mt = headers.getMediaType();
log.debug("POST content claimed to be of type {}.", mt);
OWLOntologyID key = scope.getCustomSpace().addOntology(/*
* For the time being, REST services operate in-memory (i.e. no TcProvider is supplied to the
* input source). This means that only the final processed graph is stored.
*
* TODO : we might find a reason to change that in the future.
*/
new GraphContentInputSource(content, mt.toString(), ontologyProvider.getStore()));
if (key == null || key.isAnonymous()) {
log.error("FAILED parse with media type {}.", mt);
throw new WebApplicationException(INTERNAL_SERVER_ERROR);
}
// FIXME ugly but will have to do for the time being
log.debug("SUCCESS parse with media type {}.", mt);
// key.split("::")[1];
String uri = OntologyUtils.encode(key);
// uri = uri.substring((ontologyProvider.getGraphPrefix() + "::").length());
URI created = null;
if (uri != null && !uri.isEmpty()) {
created = getCreatedResource(uri);
rb = Response.created(created);
} else
rb = Response.ok();
log.info("POST request for ontology addition completed in {} ms.", (System.currentTimeMillis() - before));
log.info("New resource URL is {}", created);
} catch (UnmodifiableOntologyCollectorException e) {
throw new WebApplicationException(e, FORBIDDEN);
}
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of javax.ws.rs.core.Response.ResponseBuilder in project stanbol by apache.
the class SessionManagerResource method getHtmlInfo.
@GET
@Produces(TEXT_HTML)
public Response getHtmlInfo(@Context HttpHeaders headers) {
ResponseBuilder rb = Response.ok(new Viewable("index", this));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
Aggregations