Package org.apache.roller.planet.pojos

Examples of org.apache.roller.planet.pojos.Subscription


               
                // add feed url to the "live" list
                liveUserFeeds.add(feedUrl);
               
                // if sub already exists then update it, otherwise add it
                Subscription sub = pmgr.getSubscription(feedUrl);
                if (sub == null) {
                    log.debug("ADDING feed: "+feedUrl);
                   
                    sub = new Subscription();
                    sub.setTitle(weblog.getName());
                    sub.setFeedURL(feedUrl);
                    sub.setSiteURL(
                        WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogURL(weblog, null, true));
                    sub.setAuthor(weblog.getName());
                    sub.setLastUpdated(new Date(0));
                    pmgr.saveSubscription(sub);
                   
                    sub.getGroups().add(group);
                    group.getSubscriptions().add(sub);

                    pmgr.saveGroup(group);

                } else {
                    log.debug("UPDATING feed: "+feedUrl);
                   
                    sub.setTitle(weblog.getName());
                    sub.setAuthor(weblog.getName());
                   
                    pmgr.saveSubscription(sub);
                }
               
                // save as we go
                PlanetFactory.getPlanet().flush();
            }
           
            // new subs added, existing subs updated, now delete old subs
            Set<Subscription> deleteSubs = new HashSet();
            Set<Subscription> subs = group.getSubscriptions();
            for( Subscription sub : subs ) {
               
                // only delete subs from the group if ...
                // 1. they are local
                // 2. they are no longer listed as a weblog
                if (sub.getFeedURL().startsWith("weblogger:") &&
                        !liveUserFeeds.contains(sub.getFeedURL())) {
                    deleteSubs.add(sub);
                }
            }
           
            // now go back through deleteSubs and do actual delete
View Full Code Here


            log.debug("Skipping unmodified LOCAL weblog");
            return null;
        }
       
        // build planet subscription from weblog
        Subscription newSub = new Subscription();
        newSub.setFeedURL(feedURL);
        newSub.setSiteURL(WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogURL(localWeblog, null, true));
        newSub.setTitle(localWeblog.getName());
        newSub.setAuthor(localWeblog.getName());
        newSub.setLastUpdated(localWeblog.getLastModified());
       
        // must have a last updated time
        if(newSub.getLastUpdated() == null) {
            newSub.setLastUpdated(new Date());
        }
       
        // lookup recent entries from weblog and add them to the subscription
        try {
            int entryCount = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");

            if (log.isDebugEnabled()) {
                log.debug("Seeking up to " + entryCount + " entries from " + localWeblog.getHandle());
            }
           
            // grab recent entries for this weblog
            WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
            List<WeblogEntry> entries = wmgr.getWeblogEntries(
                    localWeblog,                 // weblog
                    null,                        // user
                    null,                        // startDate
                    null,                        // endDate
                    null,                        // catName
                    null,                        // tags
                    WeblogEntry.PUBLISHED,       // status
                    null,                        // text
                    null,                        // sortby (null means pubTime)
                    null,                        // sortOrder
                    null,                        // locale
                    0,                           // offset
                    entryCount);                 // range
           
            log.debug("Found " + entries.size());

            // Populate subscription object with new entries
            PluginManager ppmgr = WebloggerFactory.getWeblogger().getPluginManager();
            Map pagePlugins = ppmgr.getWeblogEntryPlugins(localWeblog);
            for ( WeblogEntry rollerEntry : entries ) {
                SubscriptionEntry entry = new SubscriptionEntry();
                String content = "";
                if (!StringUtils.isEmpty(rollerEntry.getText())) {
                    content = rollerEntry.getText();
                } else {
                    content = rollerEntry.getSummary();
                }
                content = ppmgr.applyWeblogEntryPlugins(pagePlugins, rollerEntry, content);
               
                entry.setAuthor(rollerEntry.getCreator().getScreenName());
                entry.setTitle(rollerEntry.getTitle());
                entry.setPubTime(rollerEntry.getPubTime());
                entry.setText(content);
                entry.setPermalink(rollerEntry.getPermalink());
                entry.setCategoriesString(rollerEntry.getCategory().getPath());
               
                newSub.addEntry(entry);
            }
           
        } catch (WebloggerException ex) {
            throw new FetcherException("Error processing entries for local weblog - "+weblogHandle, ex);
        }
View Full Code Here

            try {
                PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
               
                List rawEntries = null;
                if (feedURL != null) {
                    Subscription sub = planetManager.getSubscription(feedURL);
                    if(sub != null) {
                        rawEntries = planetManager.getEntries(sub, offset, length+1);
                    }
                } else if (group != null) {
                    rawEntries = planetManager.getEntries(group, startDate, null, offset, length+1);
View Full Code Here

       
        if(!hasActionErrors()) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // check if this subscription already exists before adding it
            Subscription sub = pmgr.getSubscription(getSubUrl());
            if(sub == null) {
                log.debug("Adding New Subscription - "+getSubUrl());
               
                // sub doesn't exist yet, so we need to fetch it
                FeedFetcher fetcher = PlanetFactory.getPlanet().getFeedFetcher();
                sub = fetcher.fetchSubscription(getSubUrl());
               
                // save new sub
                pmgr.saveSubscription(sub);
            } else {
                log.debug("Adding Existing Subscription - "+getSubUrl());
               
                // Subscription already exists
                addMessage("planetSubscription.foundExisting", sub.getTitle());
            }
           
            // add the sub to the group
            group.getSubscriptions().add(sub);
            sub.getGroups().add(group);
            pmgr.saveGroup(group);
           
            // flush changes
            PlanetFactory.getPlanet().flush();
           
View Full Code Here

        if(getSubUrl() != null) try {
           
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // remove subscription
            Subscription sub = pmgr.getSubscription(getSubUrl());
            getGroup().getSubscriptions().remove(sub);
            sub.getGroups().remove(getGroup());
            pmgr.saveGroup(getGroup());
            PlanetFactory.getPlanet().flush();
           
            // clear field after success
            setSubUrl(null);
View Full Code Here

                PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
                Planet planet = planetManager.getPlanet("default");
               
                List entries = null;
                if (feedURL != null) {
                    Subscription sub = planetManager.getSubscription(feedURL);
                    entries = planetManager.getEntries(sub, offset, length+1);
                } else if (groupHandle != null) {
                    PlanetGroup group = planetManager.getGroup(planet, groupHandle);
                    entries = planetManager.getEntries(group, startDate, null, offset, length+1);
                } else {
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.pojos.Subscription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.