1 package net.sf.flock.webapp;
2
3 import java.net.URL;
4
5 import net.sf.flock.FlockResourceException;
6 import net.sf.flock.MetaData;
7 import net.sf.flock.SubscriptionI;
8 import net.sf.tapestry.IRequestCycle;
9 import net.sf.tapestry.html.BasePage;
10 import net.sf.tapestry.valid.IValidationDelegate;
11 import org.apache.log4j.LogManager;
12 import org.apache.log4j.Logger;
13
14 public class SubscriptionsPage extends BasePage {
15
16 private final static Logger LOGGER = LogManager.getLogger(SubscriptionsPage.class);
17
18 private URL feedUrl;
19 private String path;
20
21 /***
22 * @see net.sf.tapestry.IPage#detach()
23 */
24 public void detach() {
25 this.feedUrl = null;
26 this.path = null;
27
28 super.detach();
29 }
30
31 public URL getFeedUrl() {
32 return this.feedUrl;
33 }
34
35 public void setFeedUrl(URL feedUrl) {
36 this.feedUrl = feedUrl;
37 this.fireObservedChange("feedUrl", feedUrl);
38 }
39
40
41 public String getPath() {
42 return path;
43 }
44
45 public void setPath(String path) {
46 this.path = path;
47 this.fireObservedChange("path", path);
48 }
49
50 public void formSubmit(IRequestCycle requestCycle) {
51 IValidationDelegate delegate = (IValidationDelegate) getBeans().getBean("delegate");
52
53 if (!delegate.getHasErrors()) {
54 LOGGER.info("Subscribing to " + this.getFeedUrl() + " path: " + this.getPath());
55
56 try {
57 MetaData md = new MetaData();
58 md.set("path", this.getPath());
59
60 SubscriptionI[] subscriptions =
61 FlockContext.getSubscriptionManager().subscribe( this.getFeedUrl(), md );
62
63 LOGGER.info("Added "+subscriptions.length+" feeds");
64
65 } catch (FlockResourceException e) {
66 LOGGER.warn("Unable to add feed", e);
67 delegate.setFormComponent(null);
68 delegate.record(e.getMessage(), null, null);
69 return;
70 }
71
72 HomePage browsePage = (HomePage)requestCycle.getPage("Home");
73 browsePage.setSelectedPath( this.getPath() );
74 requestCycle.setPage(browsePage);
75 }
76 }
77
78 public void refreshAll(IRequestCycle cycle) {
79 FlockContext.getSubscriptionManager().refreshAll();
80 }
81 }
This page was automatically generated by Maven