if (session == null) return Response.status(NOT_FOUND).build(); IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/"); OWLOntology o = session.getOntology(OntologyUtils.decode(ontologyId), OWLOntology.class, merge, prefix); ResponseBuilder rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND);
OWLOntologyID id = OntologyUtils.decode(ontologyId); if (merge) { ImmutableGraph g = session.getOntology(id, ImmutableGraph.class, merge, prefix); rb = (g != null) ? Response.ok(g) : Response.status(NOT_FOUND); } else { OWLOntology o = session.getOntology(id, OWLOntology.class, merge, prefix); rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND);
/** * Gets the ontology with the given identifier in its version managed by the session. * * @param sessionId * the session identifier. * @param ontologyId * the ontology identifier. * @param uriInfo * @param headers * @return the requested managed ontology, or {@link Status#NOT_FOUND} if either the sessionn does not * exist, or the if the ontology either does not exist or is not managed. */ @GET @Path(value = "/{ontologyId:.+}") @Produces(value = {APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON}) public Response managedOntologyGetGraph(@PathParam("id") String sessionId, @PathParam("ontologyId") String ontologyId, @DefaultValue("false") @QueryParam("merge") boolean merge, // @Context UriInfo uriInfo, @Context HttpHeaders headers) { session = sesMgr.getSession(sessionId); if (session == null) return Response.status(NOT_FOUND).build(); IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/"); ImmutableGraph o = session.getOntology(OntologyUtils.decode(ontologyId), ImmutableGraph.class, merge, prefix); ResponseBuilder rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND); // addCORSOrigin(servletContext, rb, headers); return rb.build(); }
@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(); }