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
* if it is not an RDF document.
* This code is not reached when there already is some data about the resource.
*/
RepositoryConnection metaDataConn = null;
try {
metaDataConn = metaDataRepository.getConnection();
/* Manual support for one level of redirects */
String resourceRedirect = cacheController.getCachedHeaderDataValue(metaDataConn, focalResource, "location");
Resource resourceURI = (resourceRedirect == null ? focalResource : new URIImpl(resourceRedirect));
/* Get target content type */
String contentType = cacheController.getCachedHeaderDataValue(metaDataConn, resourceURI, "content-type");
if (contentType != null && !ContentTypes.isRDF(contentType)) {
redirectLocation = focalResource.toString();