use of org.apache.stanbol.ontologymanager.servicesapi.scope.Scope in project stanbol by apache.
the class RootResource method performShowOntology.
/**
* Helper method to make sure a ResponseBuilder is created on every conditions, so that it is then
* possible to enable CORS on it afterwards.
*
* @param ontologyId
* @return
*/
protected ResponseBuilder performShowOntology(String ontologyId) {
if (ontologyId == null || ontologyId.isEmpty()) {
return Response.status(BAD_REQUEST);
}
OWLOntologyID key = OntologyUtils.decode(ontologyId);
if (ontologyProvider.listOrphans().contains(key)) {
return Response.status(NO_CONTENT);
}
OWLOntology o = getOWLOntology(ontologyId, false, uriInfo.getRequestUri());
if (o == null) {
return Response.status(NOT_FOUND);
}
// Assemble dependency list
Map<OWLOntologyID, OntologyProvider.Status> deps = new HashMap<OWLOntologyID, OntologyProvider.Status>();
for (OWLOntologyID dep : getDescriptor().getDependencies(key)) {
deps.put(dep, ontologyProvider.getStatus(dep));
}
Set<OntologyCollector> handles = new HashSet<OntologyCollector>();
if (onManager != null) {
for (Scope scope : onManager.getRegisteredScopes()) {
if (scope.getCoreSpace().hasOntology(key)) {
handles.add(scope.getCoreSpace());
}
if (scope.getCustomSpace().hasOntology(key)) {
handles.add(scope.getCustomSpace());
}
}
}
if (sessionManager != null) {
for (String sesId : sessionManager.getRegisteredSessionIDs()) {
if (sessionManager.getSession(sesId).hasOntology(key)) {
handles.add(sessionManager.getSession(sesId));
}
}
}
return Response.ok(new Viewable("ontology", new OntologyStats(uriInfo, key, o, ontologyProvider.listAliases(key), deps, handles)));
}
use of org.apache.stanbol.ontologymanager.servicesapi.scope.Scope in project stanbol by apache.
the class ScopeManagerResource method getScopeModel.
/**
* Default GET method for obtaining the set of (both active and, optionally, inactive) ontology scopes
* currently registered with this instance of KReS.
*
* @param inactive
* if true, both active and inactive scopes will be included. Default is false.
* @param headers
* the HTTP headers, supplied by the REST call.
* @param servletContext
* the servlet context, supplied by the REST call.
* @return a string representation of the requested scope set, in a format acceptable by the client.
*/
@GET
@Produces(value = { RDF_XML, OWL_XML, TURTLE, X_TURTLE, FUNCTIONAL_OWL, MANCHESTER_OWL, RDF_JSON, N3, N_TRIPLE, TEXT_PLAIN })
public Response getScopeModel(@DefaultValue("false") @QueryParam("with-inactive") boolean inactive, @Context HttpHeaders headers, @Context ServletContext servletContext) {
Set<Scope> scopes = inactive ? onm.getRegisteredScopes() : onm.getActiveScopes();
OWLOntology ontology = ScopeSetRenderer.getScopes(scopes);
ResponseBuilder rb = Response.ok(ontology);
MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null);
if (mediaType != null)
rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
Aggregations