HttpServletResponse res) throws Exception {
String name = req.getParameter("name");
Map<String, Object> model = new HashMap<String, Object>();
if (!StringUtil.isEmpty(name)) {
String widgetUrl = req.getRequestURL().toString();
Widget widget = widgetService
.requestWidget(widgetUrl, name, req);
if (widget != null) {
if (widget.getCacheType().startsWith(
Widget.TYPE_IMAGE)) {
// return as image
res.setContentType(widget.getCacheType());
OutputStream outputStream = res.getOutputStream();
outputStream.write(widget.getCache());
outputStream.flush();
return null;
}
model.put("body", new String(widget.getCache()));
model.put("cacheDate", widget.getLastCacheUpdate());
} else {
model.put("body", "Unable to load widget. Name [" + name
+ "] not found");
model.put("cacheDate", new Date());
}