Package org.apache.roller.planet.pojos

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


       
        // make sure we are using a persistent object
        Subscription testSub = mgr.getSubscriptionById(sub.getId());
       
        // store
        SubscriptionEntry testEntry = new SubscriptionEntry();
        testEntry.setPermalink(title);
        testEntry.setTitle(title);
        testEntry.setPubTime(new java.sql.Timestamp(System.currentTimeMillis()));
        testEntry.setSubscription(testSub);
        testSub.getEntries().add(testEntry);
        mgr.saveEntry(testEntry);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        SubscriptionEntry entry = mgr.getEntryById(testEntry.getId());
       
        if(entry == null)
            throw new PlanetException("error inserting new entry");
       
        return entry;
View Full Code Here


     */
    public static void teardownEntry(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        SubscriptionEntry entry = mgr.getEntryById(id);
       
        // remove
        mgr.deleteEntry(entry);
        entry.getSubscription().getEntries().remove(entry);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

           
            // 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) {
View Full Code Here

        }
       
        // add entries
        List<SyndEntry> feedEntries = feed.getEntries();
        for( SyndEntry feedEntry : feedEntries ) {
            SubscriptionEntry newEntry = buildEntry(feedEntry);
           
            // some kludge to handle feeds with no entry dates
            if (newEntry.getPubTime() == null) {
                log.debug("No published date, assigning fake date for "+feedURL);
                newEntry.setPubTime(new Timestamp(cal.getTimeInMillis()));
                cal.add(Calendar.DATE, -1);
            }
           
            if(newEntry != null) {
                newSub.addEntry(newEntry);
View Full Code Here

        // if we don't have a permalink then we can't continue
        if(romeEntry.getLink() == null) {
            return null;
        }
       
        SubscriptionEntry newEntry = new SubscriptionEntry();
       
        newEntry.setTitle(romeEntry.getTitle());
        newEntry.setPermalink(romeEntry.getLink());
       
        // Play some games to get the author
        DCModule entrydc = (DCModule)romeEntry.getModule(DCModule.URI);
        if (romeEntry.getAuthor() != null) {
            newEntry.setAuthor(romeEntry.getAuthor());
        } else {
            newEntry.setAuthor(entrydc.getCreator()); // use <dc:creator>
        }
       
        // Play some games to get the updated date
        if (romeEntry.getUpdatedDate() != null) {
            newEntry.setUpdateTime(new Timestamp(romeEntry.getUpdatedDate().getTime()));
        }
        // TODO: should we set a default update time here?
       
        // And more games getting publish date
        if (romeEntry.getPublishedDate() != null) {
            newEntry.setPubTime(new Timestamp(romeEntry.getPublishedDate().getTime())); // use <pubDate>
        } else if (entrydc != null && entrydc.getDate() != null) {
            newEntry.setPubTime(new Timestamp(entrydc.getDate().getTime())); // use <dc:date>
        } else {
            newEntry.setPubTime(newEntry.getUpdateTime());
        }
       
        // get content and unescape if it is 'text/plain'
        if (romeEntry.getContents().size() > 0) {
            SyndContent content= (SyndContent)romeEntry.getContents().get(0);
            if (content != null && content.getType().equals("text/plain")) {
                newEntry.setText(StringEscapeUtils.unescapeHtml(content.getValue()));
            } else if (content != null) {
                newEntry.setText(content.getValue());
            }
        }
       
        // no content, try summary
        if (newEntry.getText() == null || newEntry.getText().trim().length() == 0) {
            if (romeEntry.getDescription() != null) {
                newEntry.setText(romeEntry.getDescription().getValue());
            }
        }
       
        // copy categories
        if (romeEntry.getCategories().size() > 0) {
            List list = new ArrayList();
            Iterator cats = romeEntry.getCategories().iterator();
            while (cats.hasNext()) {
                SyndCategory cat = (SyndCategory)cats.next();
                list.add(cat.getName());
            }
            newEntry.setCategoriesString(list);
        }
       
        return newEntry;
    }
View Full Code Here

       
        // make sure we are using a persistent object
        Subscription testSub = mgr.getSubscriptionById(sub.getId());
       
        // store
        SubscriptionEntry testEntry = new SubscriptionEntry();
        testEntry.setPermalink(title);
        testEntry.setTitle(title);
        testEntry.setPubTime(new java.sql.Timestamp(System.currentTimeMillis()));
        testEntry.setSubscription(testSub);
        testSub.getEntries().add(testEntry);
        mgr.saveEntry(testEntry);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        SubscriptionEntry entry = mgr.getEntryById(testEntry.getId());
       
        if(entry == null)
            throw new PlanetException("error inserting new entry");
       
        return entry;
View Full Code Here

     */
    public static void teardownEntry(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        SubscriptionEntry entry = mgr.getEntryById(id);
       
        // remove
        mgr.deleteEntry(entry);
        entry.getSubscription().getEntries().remove(entry);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

    public void testEntryCRUD() throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Subscription sub = mgr.getSubscriptionById(testSub.getId());
       
        SubscriptionEntry testEntry = new SubscriptionEntry();
        testEntry.setPermalink("entryBasics");
        testEntry.setTitle("entryBasics");
        testEntry.setPubTime(new java.sql.Timestamp(System.currentTimeMillis()));
        testEntry.setSubscription(sub);
       
        // add
        mgr.saveEntry(testEntry);
        TestUtils.endSession(true);
       
        // verify
        SubscriptionEntry entry = null;
        entry = mgr.getEntryById(testEntry.getId());
        assertNotNull(entry);
        assertEquals("entryBasics", entry.getPermalink());
       
        // modify
        entry.setTitle("foo");
        mgr.saveEntry(entry);
        TestUtils.endSession(true);
       
        // verify
        entry = null;
        entry = mgr.getEntryById(testEntry.getId());
        assertNotNull(entry);
        assertEquals("foo", entry.getTitle());
       
        // remove
        mgr.deleteEntry(entry);
        TestUtils.endSession(true);
       
View Full Code Here

    public void testEntryLookups() throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // by id
        SubscriptionEntry entry = mgr.getEntryById(testEntry1.getId());
        assertNotNull(entry);
        assertEquals("entryFuncTestEntry1", entry.getPermalink());
       
        // by subscription
        Subscription sub = mgr.getSubscriptionById(testSub2.getId());
        assertEquals(2, sub.getEntries().size());
       
View Full Code Here

        }
       
        // add entries
        List<SyndEntry> feedEntries = feed.getEntries();
        for( SyndEntry feedEntry : feedEntries ) {
            SubscriptionEntry newEntry = buildEntry(feedEntry);
           
            // some kludge to handle feeds with no entry dates
            if (newEntry.getPubTime() == null) {
                log.debug("No published date, assigning fake date for "+feedURL);
                newEntry.setPubTime(new Timestamp(cal.getTimeInMillis()));
                cal.add(Calendar.DATE, -1);
            }
           
            if(newEntry != null) {
                newSub.addEntry(newEntry);
View Full Code Here

TOP

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

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.