ServiceAction action = typeToFetchActionIndex.get(streamType);
if (action == null)
{
throw new ExecutionException("Stream type not supported.");
}
Identifiable entity = (Identifiable) serviceActionController.execute(new ServiceActionContext(id, principal),
action);
// Get address
String address = (String) serviceActionController.execute(new ServiceActionContext(new EntityIdentifier(
streamType, id), principal), getTokenForStreamAction);
ModelAndView mv = new ModelAndView("vcardView");
mv.addObject("streamEntity", entity);
mv.addObject("email", address);
// This really should be part of the view, not the controller, but the Spring view classes (VelocityView and
// parents) don't provide a way to set content disposition, nor a way to set arbitrary headers.
response.setHeader("Content-Disposition", "attachment; filename=" + streamType.name().toLowerCase() + "-"
+ entity.getUniqueId() + ".vcf");
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
response.addHeader("Pragma", "no-cache");
return mv;
}