use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.
the class ScopeResource method getCoreSpaceGraph.
@GET
@Path("/core")
@Produces(value = { APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON })
public Response getCoreSpaceGraph(@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/");
ImmutableGraph o = space.export(ImmutableGraph.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.
the class ScopeResource method managedOntologyGetOWL.
/**
* 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("/{ontologyId:.+}")
@Produces(value = { RDF_XML, TURTLE, X_TURTLE, MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN })
public Response managedOntologyGetOWL(@PathParam("scopeid") String scopeid, @PathParam("ontologyId") String ontologyId, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
log.debug("Absolute URL Path {}", uriInfo.getRequestUri());
log.debug("Ontology ID {}", ontologyId);
ResponseBuilder rb;
scope = onm.getScope(scopeid);
if (scope == null)
rb = Response.status(NOT_FOUND);
else {
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
OWLOntology o = null;
OWLOntologyID id = OntologyUtils.decode(ontologyId);
OntologySpace spc = scope.getCustomSpace();
if (spc != null && spc.hasOntology(id)) {
o = spc.getOntology(id, OWLOntology.class, merge, prefix);
} else {
spc = scope.getCoreSpace();
if (spc != null && spc.hasOntology(id))
o = spc.getOntology(id, OWLOntology.class, merge, prefix);
}
if (o == null)
rb = Response.status(NOT_FOUND);
else
rb = Response.ok(o);
}
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.
the class ScopeResource method getCustomSpaceGraph.
@GET
@Path("/custom")
@Produces(value = { APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON })
public Response getCustomSpaceGraph(@PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
scope = onm.getScope(scopeid);
OntologySpace space = scope.getCustomSpace();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
ImmutableGraph o = space.export(ImmutableGraph.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.
the class ScopeResource method managedOntologyUnload.
/**
* Unloads an ontology from an ontology scope.
*
* @param scopeId
* @param ontologyid
* @param uriInfo
* @param headers
*/
@DELETE
@Path("/{ontologyId:.+}")
public Response managedOntologyUnload(@PathParam("scopeid") String scopeid, @PathParam("ontologyId") String ontologyId, @PathParam("scopeid") String scopeId, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
ResponseBuilder rb;
scope = onm.getScope(scopeid);
if (ontologyId != null && !ontologyId.trim().isEmpty()) {
OWLOntologyID id = OntologyUtils.decode(ontologyId);
OntologySpace cs = scope.getCustomSpace();
if (// ontology not managed
!cs.hasOntology(id))
// ontology not managed
rb = Response.notModified();
else
try {
onm.setScopeActive(scopeId, false);
cs.removeOntology(id);
rb = Response.ok();
} catch (IrremovableOntologyException e) {
throw new WebApplicationException(e, FORBIDDEN);
} catch (UnmodifiableOntologyCollectorException e) {
throw new WebApplicationException(e, FORBIDDEN);
} catch (OntologyCollectorModificationException e) {
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
} finally {
onm.setScopeActive(scopeId, true);
}
} else
// null/blank ontology ID
rb = Response.status(BAD_REQUEST);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
Aggregations