// set the IP Address as param
Map<String, Object> param = new HashMap<String, Object>();
if (StringUtil.isEmpty(IPAddress))
param.put("IPAddress", IPAddress);
UrlResponseObject response = UrlUtil.getPage(url, req, param);
if (response==null)
return null;
if (response.getResponseType()
.startsWith(Widget.TYPE_IMAGE)) {
_log.debug("Retrieving image [" + widget.getName()
+ "] from url [" + widget.getUrl() + "]...");
widget.setCacheType(response.getResponseType());
widget.setCache(response.getResponseBody());
widget.setLastCacheUpdate(new Date());
save(widget);
_log.debug("Saved image [" + widget.getName()
+ "] to cache...");
return widget;
} else {
_log.debug("Retrieving widget [" + widget.getName()
+ "] from url [" + widget.getUrl() + "]...");
widget.setCacheType(response.getResponseType());
// check for image inside the html
String html = new String(response.getResponseBody());
String hostname = UrlUtil.getHostname(url);
Matcher matcher = pattern.matcher(html);
while (matcher.find()) {
// add image link to cache
String imageUrl = matcher.group(1);