{
uiApplication.addMessage(new ApplicationMessage("UIDashboard.msg.notUrl", null));
return;
}
Gadget gadget;
UIGadget uiGadget;
//TODO check the way we create the unique ID, is it really unique?
try
{
String name = "gadget" + url.hashCode();
gadget = GadgetUtil.toGadget(name, url, false);
service.saveGadget(gadget);
uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);
uiGadget.setState(new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(gadget.getName()));
}
catch (Exception e)
{
try
{
URI uri = URI.create(url);
RSSParser parser = new RSSParser();
RSSDocument<DefaultRSSChannel, DefaultRSSItem> doc = parser.createDocument(uri, "UTF-8");
if (doc == null)
throw new Exception("Wrong url");
}
catch (Exception e1)
{
uiApplication.addMessage(new ApplicationMessage("UIDashboard.msg.notUrl", null));
return;
}
String aggregatorId = uiDashboard.getAggregatorId();
gadget = service.getGadget(aggregatorId);
//TODO make sure it's an rss feed
// TODO make sure that we did not add it already
uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);
uiGadget.setState(new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(gadget.getName()));
String params = "{'rssurl':'" + url + "'}";
// Julien : I commented those 2 lines
// we need to save the same way it is done in the UIGadget clas