Search in sources :

Example 1 with OntologyHandleException

use of org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyHandleException 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)

Example 2 with OntologyHandleException

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

the class ClerezzaOntologyProvider method removeOntology.

@Override
public boolean removeOntology(OWLOntologyID publicKey) throws OntologyHandleException {
    if (descriptor.getDependents(publicKey).isEmpty() && descriptor.getHandles(publicKey).isEmpty()) {
        IRI graphName = keymap.getMapping(publicKey);
        // TODO propagate everything to the descriptor
        // release dependencies
        descriptor.clearDependencies(publicKey);
        // remove metadata
        keymap.registerOntologyDeletion(publicKey);
        // Now the actual deletion
        store.deleteGraph(graphName);
        return true;
    } else
        throw new OntologyHandleException("There are ontologies or collectors depending on " + publicKey + "Those handles must be released first.");
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) OntologyHandleException(org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyHandleException)

Aggregations

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