logger.error("ERROR: cannot sync websites with Planet Roller - "
+"absolute URL not specified in Roller Config");
} else {
PlanetManager planet = roller.getPlanetManager();
UserManager userManager = roller.getUserManager();
PlanetGroupData group = planet.getGroup("all");
if (group == null) {
group = new PlanetGroupData();
group.setHandle("all");
group.setTitle("all");
planet.saveGroup(group);
roller.flush();
}
try {
String baseFeedURL = baseURL + "/rss/";
String baseSiteURL = baseURL + "/page/";
// get list of all enabled and active weblogs
Iterator websites =
roller.getUserManager().getWebsites(null, Boolean.TRUE, Boolean.TRUE).iterator();
while (websites.hasNext()) {
WebsiteData website = (WebsiteData)websites.next();
StringBuffer sitesb = new StringBuffer();
sitesb.append(baseSiteURL);
sitesb.append(website.getHandle());
String siteUrl = sitesb.toString();
StringBuffer feedsb = new StringBuffer();
feedsb.append(baseFeedURL);
feedsb.append(website.getHandle());
String feedUrl = feedsb.toString();
liveUserFeeds.add(feedUrl);
PlanetSubscriptionData sub =
planet.getSubscription(feedUrl);
if (sub == null) {
logger.info("ADDING feed: "+feedUrl);
sub = new PlanetSubscriptionData();
sub.setTitle(website.getName());
sub.setFeedUrl(feedUrl);
sub.setSiteUrl(siteUrl);
sub.setAuthor(website.getHandle());
planet.saveSubscription(sub);
group.addSubscription(sub);
} else {
sub.setTitle(website.getName());
sub.setAuthor(website.getHandle());
planet.saveSubscription(sub);
}
}
planet.saveGroup(group);
roller.flush();
roller.release();
// TODO: new planet manager method deleteSubs(list)
group = group = planet.getGroup("all");
Iterator subs = group.getSubscriptions().iterator();
while (subs.hasNext()) {
PlanetSubscriptionData sub =
(PlanetSubscriptionData)subs.next();
if (!liveUserFeeds.contains(sub.getFeedUrl())) {
logger.info("DELETING feed: "+sub.getFeedUrl());