Search in sources :

Example 1 with RegistryOntologyNotLoadedException

use of org.apache.stanbol.ontologymanager.registry.api.RegistryOntologyNotLoadedException in project stanbol by apache.

the class LibraryImpl method getOntologies.

@Override
public <O> Set<O> getOntologies(Class<O> returnType) throws RegistryContentException {
    /*
         * Note that this implementation is not synchronized. Listeners may indefinitely be notified before or
         * after the rest of this method is executed. If listeners call loadOntologies(), they could still get
         * a RegistryContentException, which however they can catch by calling loadOntologies() and
         * getOntologies() in sequence.
         */
    fireContentRequested(this);
    // If no listener has saved the day by loading the ontologies by now, an exception will be thrown.
    if (!loaded)
        throw new LibraryContentNotLoadedException(this);
    Set<O> ontologies = new HashSet<O>();
    for (RegistryItem child : getChildren()) {
        if (child instanceof RegistryOntology) {
            O o = getCache().getStoredOntology(child.getIRI(), returnType);
            // thrown when loading it), but just in case.
            if (o != null)
                ontologies.add(o);
            else
                throw new RegistryOntologyNotLoadedException((RegistryOntology) child);
        }
    }
    return ontologies;
}
Also used : RegistryOntology(org.apache.stanbol.ontologymanager.registry.api.model.RegistryOntology) RegistryOntologyNotLoadedException(org.apache.stanbol.ontologymanager.registry.api.RegistryOntologyNotLoadedException) LibraryContentNotLoadedException(org.apache.stanbol.ontologymanager.registry.api.LibraryContentNotLoadedException) RegistryItem(org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 LibraryContentNotLoadedException (org.apache.stanbol.ontologymanager.registry.api.LibraryContentNotLoadedException)1 RegistryOntologyNotLoadedException (org.apache.stanbol.ontologymanager.registry.api.RegistryOntologyNotLoadedException)1 RegistryItem (org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem)1 RegistryOntology (org.apache.stanbol.ontologymanager.registry.api.model.RegistryOntology)1