@Override
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
BindException errors)
{
HTTPRepository repo = (HTTPRepository)request.getSession().getAttribute(SessionKeys.REPOSITORY_KEY);
ExtractionSettings settings = (ExtractionSettings)command;
RDFFormat format = settings.getResultFormat();
RepositoryConnection conn = null;
try {
response.setContentType(format.getDefaultMIMEType());
String filename = "extract";
if (format.getDefaultFileExtension() != null) {
filename += "." + format.getDefaultFileExtension();
}
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
RDFWriter writer = Rio.createWriter(format, response.getOutputStream());
conn = repo.getConnection();
conn.exportStatements(settings.getSubject(), settings.getPredicate(), settings.getObject(),
settings.isIncludeInferred(), writer, settings.getContexts());
}
catch (RepositoryException e) {
e.printStackTrace();