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;
}
Aggregations