if ( log.isDebugEnabled() ) {
log.debug(this.getClass().getName()+ ": dispatching with outFormat=" +ontReq.outFormat);
}
ServletOutputStream os = ontReq.response.getOutputStream();
///////////////////////////////////////////////////////////////////
// OWL
if ( ontReq.outFormat.equalsIgnoreCase("owl")
|| ontReq.outFormat.equalsIgnoreCase("rdf")
) {
if ( log.isDebugEnabled() ) {
log.debug(this.getClass().getName()+ ": Serializing to RDF/XML-ABBREV");
}
ServletUtil.setContentTypeRdfXml(ontReq.response);
// is = OntServlet.serializeModel(model, "RDF/XML-ABBREV");
OntServlet.serializeModelToOutputStream(model, "RDF/XML-ABBREV", os);
}
///////////////////////////////////////////////////////////////////
// N3
else if ( ontReq.outFormat.equalsIgnoreCase("n3") ) {
ServletUtil.setContentTypeTextPlain(ontReq.response);
OntServlet.serializeModelToOutputStream(model, "N3", os);
}
///////////////////////////////////////////////////////////////////
// NT
else if ( ontReq.outFormat.equalsIgnoreCase("nt") ) {
ServletUtil.setContentTypeTextPlain(ontReq.response);
OntServlet.serializeModelToOutputStream(model, "N-TRIPLE", os);
}
///////////////////////////////////////////////////////////////////
// TTL
else if ( ontReq.outFormat.equalsIgnoreCase("ttl") ) {
ServletUtil.setContentTypeTextPlain(ontReq.response);
OntServlet.serializeModelToOutputStream(model, "TURTLE", os);
}
///////////////////////////////////////////////////////////////////
// HTML
else if ( ontReq.outFormat.equalsIgnoreCase("html") ) {
// Redirect to the appropriate service.
String ontologyUri;
if ( ontReq.ontology != null ) {
ontologyUri = ontReq.ontology.getUri();
}
else if ( ontReq.mmiUri != null ) {
// Note: drop any extension here (the Orr service will do the appropriate request
// back to this Ont service):
ontologyUri = ontReq.mmiUri.getOntologyUriWithExtension("");
}
else {
ontologyUri = ontReq.fullRequestedUri;
}
String portalServiceUrl = OntConfig.Prop.PORTAL_SERVICE_URL.getValue();
String url = portalServiceUrl+ "/#" +ontologyUri;
if ( log.isDebugEnabled() ) {
log.debug("REDIRECTING TO: " +url);
}
String redir = ontReq.response.encodeRedirectURL(url);
ontReq.response.sendRedirect(redir);
return;
}
///////////////////////////////////////////////////////////////////
// BAD REQUEST
else {
ontReq.response.sendError(HttpServletResponse.SC_BAD_REQUEST,
"ModelResponse: outFormat " +ontReq.outFormat+ " not recognized"
);
return;
}
os.close();
}