Search in sources :

Example 1 with OrphanOntologyKeyException

use of org.apache.stanbol.ontologymanager.servicesapi.ontology.OrphanOntologyKeyException in project stanbol by apache.

the class RootResource method deleteOntology.

@DELETE
@Path("/{ontologyId:.+}")
public Response deleteOntology(@PathParam("ontologyId") String ontologyId, @Context HttpHeaders headers) {
    OWLOntologyID key = OntologyUtils.decode(ontologyId);
    ResponseBuilder rb;
    try {
        if (!ontologyProvider.hasOntology(key)) {
            rb = Response.status(NOT_FOUND);
        } else {
            try {
                // TODO check aliases!
                ontologyProvider.removeOntology(key);
                rb = Response.ok();
            } catch (OntologyHandleException e) {
                rb = Response.status(CONFLICT);
            }
        }
    } catch (OrphanOntologyKeyException e) {
        log.warn("Orphan ontology key {}. No associated graph found in store.", e.getOntologyKey());
        rb = Response.status(NOT_FOUND);
    }
    // addCORSOrigin(servletContext, rb, headers);
    return rb.build();
}
Also used : OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OntologyHandleException(org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyHandleException) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) OrphanOntologyKeyException(org.apache.stanbol.ontologymanager.servicesapi.ontology.OrphanOntologyKeyException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 OntologyHandleException (org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyHandleException)1 OrphanOntologyKeyException (org.apache.stanbol.ontologymanager.servicesapi.ontology.OrphanOntologyKeyException)1 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)1