PrintWriter writer = new PrintWriter(new OutputStreamWriter(response.getOutputStream() , "UTF-8"));
String errorString = null;
Selection selected = null;
List<org.apache.commons.httpclient.URI> retrievedURLs = null;
Resource focalResource = null;
Configuration conf = null;
String redirectLocation = null;
try {
/* Reload the Fresnel configuration using the provided language */
String langPref = (request.getParameter("lang") != null ? request.getParameter("lang") : "en");
loadFresnelConfig(langPref);
conf = new Configuration(confRepository, ontoRepository);
/* Create the focal resource */
if (request.getParameter("uri") != null) {
String uriString = request.getParameter("uri");
if (uriString.startsWith("_:")) /* blank node */
focalResource = valueFactory.createBNode(uriString.substring(2));
else
focalResource = valueFactory.createURI(uriString);
/* Collect data about the focal resource */
if (request.getParameter("skipload") == null) {
retrievedURLs = semwebClient.discoverResource(focalResource, true /* wait */);
} /* skip */
/* Initiate manual owl:sameAs inference */
if (request.getParameter("skipInference") == null) {
sameAsInferencer.addInferredForResource(focalResource);
}
if (conf.hasWarnings())
writer.println(conf.getWarningsString());
Purpose purpose = null;
/* Look up the requested lens purpose */
if (request.getParameter("purpose") != null && (!request.getParameter("purpose").equals("defaultPurpose")))
purpose = new Purpose(new URIImpl(Constants.nsFresnelExt + request.getParameter("purpose")));
else
purpose = new Purpose(new URIImpl("http://www.w3.org/2004/09/fresnel#defaultLens")); /* this must be provided, or a random lens is chosen */
try {
/* Perform Fresnel selection using the requested display purpose and language */
selected = conf.select(dataRepository, focalResource, purpose, langPref);
/* Perform Fresnel formatting */
selected = conf.format(dataRepository, selected);
}
catch (NoResultsException e) {
/*
* If no results are found, redirect the user to the resource