private static final Log log = LogFactory.getLog(RSSAction.class.getName());
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
RSSFeed feed = getNewRSSFeed(request);
ResourceManagerLocal manager = LookupUtil.getResourceManager();
// Set title
MessageResources res = getResources(request);
feed.setTitle(res.getMessage("dash.home.ResourceHealth"));
// Get the resources health
WebUser user = getWebUser(request);
if (user != null) {
WebUserPreferences preferences = user.getWebPreferences();
FavoriteResourcePortletPreferences favoriteResourcePreferences = preferences
.getFavoriteResourcePortletPreferences();
PageList<ResourceHealthComposite> results = manager.findResourceHealth(user.getSubject(),
favoriteResourcePreferences.asArray(), PageControl.getUnlimitedInstance());
if ((results != null) && (results.size() > 0)) {
PageList<DisambiguationReport<ResourceHealthComposite>> list = DisambiguatedResourceListUtil.disambiguate(manager, results, ViewAction.RESOURCE_ID_EXTRACTOR);
for (DisambiguationReport<ResourceHealthComposite> summary : list) {
String link = feed.getBaseUrl() + FunctionTagLibrary.getDefaultResourceTabURL() + "?id="
+ summary.getOriginal().getId();
String availText = res.getMessage("dash.home.ResourceHealth.rss.item.availability", summary
.getOriginal().getAvailabilityType().toString());
String alertsText = res.getMessage("dash.home.ResourceHealth.rss.item.alerts", Long.valueOf(summary
.getOriginal().getAlerts()));
String typeText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceType", summary
.getOriginal().getTypeName());
String parentsText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceParents", getLineage(summary));
long now = System.currentTimeMillis();
StringBuffer desc = new StringBuffer();
desc.append("<table><tr><td align=\"left\">").append(typeText).append("</td></tr>");
desc.append("<tr><td align=\"left\">").append(parentsText).append("</td></tr>");
if (favoriteResourcePreferences.showAvailability) {
desc.append("<tr><td align=\"left\">").append(availText).append("</td></tr>");
}
if (favoriteResourcePreferences.showAlerts) {
desc.append("<tr><td align=\"left\">").append(alertsText).append("</td></tr>");
}
desc.append("</table>");
feed.addItem(summary.getOriginal().getName(), link, desc.toString(), now);
}
}
request.setAttribute("rssFeed", feed);