response.setCharacterEncoding("UTF-8");
response.setContentType(format.isOwl() ? "text/html" : "text/plain");
// creates ontology context
Context ontContext = Context.extract(this.getServletContext());
OntologyProcessor ontProcessor = new OntologyProcessor(ontContext,
request.getLocale());
// checks if ontology context is ready
if (!ontContext.isReady()) {
log.info("Ontology context not ready.");
response.setStatus(response.SC_SERVICE_UNAVAILABLE);
return;
}
// checks if query criteria are correct
if (queryCriteria.getTerm().length() == 0) {
log.info("No search term entered.");
response.setStatus(response.SC_BAD_REQUEST);
return;
}
// performs ontology search
log.info(
"Performing ontology search. query criteria: " + queryCriteria + "; selection: " + selection + "; format: " + format);
Date start = new Date();
Terms terms = ontProcessor.search(queryCriteria, selection);
Date end = new Date();
log.info("Ontology search has been completed in " + (end.getTime() - start.
getTime()) + " milliseconds.");
OntologyWriter ontWriter = new OntologyWriter(out, ontContext, queryCriteria.getTerm(), format);