throws Exception {
log.debug("Enter Rss Channel Action");
// Try to retrieve tile context
ComponentContext context = ComponentContext.getContext(request);
if (context == null) {
throw new ServletException("This action must be called by a Tile, not directly");
}
ActionMessages errors = new ActionMessages();
// -- Retrieve parameters --
// Urls can come from a list, or from a single attribute.
List channels = (List) context.getAttribute(CHANNEL_URLS_KEY);
if (channels == null) {
Object url = context.getAttribute(CHANNEL_URL_KEY);
channels = new ArrayList(1);
channels.add(url);
}
log.debug("urls count" + channels.size());
// -- Loop through channels --
ArrayList channelBeans = new ArrayList(channels.size());
try {
for (int i = 0; i < channels.size(); i++) {
RSSDigester digester = new RSSDigester();
String url = (String) channels.get(i);
// Add application path if needed
if (url.startsWith("/")) {
url = toFullUrl(request, url);
}
log.debug("Channel url=" + url);
Channel obj = (Channel) digester.parse(url);
log.debug("Channel:" + obj);
channelBeans.add(obj);
}
} catch (Throwable t) {
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("rss.access.error"));
servlet.log(t.toString());
}
// -- Handle Errors ---
if (!errors.isEmpty()) {
this.saveErrors(request, errors);
if (mapping.getInput() != null) {
return new ActionForward(mapping.getInput());
}
// If no input page, use error forwarding
log.debug("Exit Rss Channel Action : error");
return mapping.findForward("error");
}
// -- Save Bean, and Continue ---
log.debug("Exit Rss Channel Action");
// Use Tile context to pass channels
context.putAttribute(CHANNELS_KEY, channelBeans);
return mapping.findForward("continue");
}