use of org.apache.stanbol.ontologymanager.web.util.OntologyPrettyPrintResource in project stanbol by apache.
the class ScopeResource method managedOntologyShow.
@GET
@Path("/{ontologyId:.+}")
@Produces(TEXT_HTML)
public Response managedOntologyShow(@PathParam("scopeid") String scopeid, @PathParam("ontologyId") String ontologyId, @Context HttpHeaders headers) {
ResponseBuilder rb;
scope = onm.getScope(scopeid);
if (scope == null)
rb = Response.status(NOT_FOUND);
else if (ontologyId == null || ontologyId.isEmpty())
rb = Response.status(BAD_REQUEST);
else if (!ontologyProvider.hasOntology(OntologyUtils.decode(ontologyId)))
rb = Response.status(NOT_FOUND);
else {
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
OWLOntology o = scope.getCustomSpace().getOntology(OntologyUtils.decode(ontologyId), OWLOntology.class, false, prefix);
if (o == null)
o = scope.getCoreSpace().getOntology(OntologyUtils.decode(ontologyId), OWLOntology.class, false, prefix);
if (o == null)
rb = Response.status(NOT_FOUND);
else
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
o.getOWLOntologyManager().saveOntology(o, new ManchesterOWLSyntaxOntologyFormat(), out);
rb = Response.ok(new Viewable("ontology", new OntologyPrettyPrintResource(uriInfo, out, scope)));
} catch (OWLOntologyStorageException e) {
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
}
}
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.ontologymanager.web.util.OntologyPrettyPrintResource in project stanbol by apache.
the class SessionResource method managedOntologyShow.
@GET
@Path("/{ontologyId:.+}")
@Produces(TEXT_HTML)
public Response managedOntologyShow(@PathParam("ontologyId") String ontologyId, @Context HttpHeaders headers) {
ResponseBuilder rb;
if (session == null)
rb = Response.status(NOT_FOUND);
else if (ontologyId == null || ontologyId.isEmpty())
rb = Response.status(BAD_REQUEST);
else if (!ontologyProvider.hasOntology(OntologyUtils.decode(ontologyId)))
rb = Response.status(NOT_FOUND);
else {
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
OWLOntology o = session.getOntology(OntologyUtils.decode(ontologyId), OWLOntology.class, false, prefix);
if (o == null)
rb = Response.status(NOT_FOUND);
else
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
o.getOWLOntologyManager().saveOntology(o, new ManchesterOWLSyntaxOntologyFormat(), out);
rb = Response.ok(new Viewable("ontology", new OntologyPrettyPrintResource(uriInfo, out, session)));
} catch (OWLOntologyStorageException e) {
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
}
}
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
Aggregations