Package com.sun.syndication.feed.synd

Examples of com.sun.syndication.feed.synd.SyndFeed


    // Implementation methods
    // -------------------------------------------------------------------------

    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request) throws IOException, JMSException, ServletException {
        // now lets actually write out the content
        SyndFeed feed = getFeed(browser, request);
        SyndFeedOutput output = new SyndFeedOutput();
        try {
            output.output(feed, writer);
        } catch (FeedException e) {
            throw new ServletException(e);
View Full Code Here


        }
        return description;
    }

    protected SyndFeed createFeed(QueueBrowser browser, HttpServletRequest request) throws JMSException {
        SyndFeed feed = new SyndFeedImpl();
        feed.setFeedType(feedType);

        String title = browser.getQueue().toString();
        String selector = browser.getMessageSelector();
        if (selector != null) {
            title += " with selector: " + selector;
        }
        feed.setTitle(title);
        feed.setLink(request.getRequestURI());
        feed.setDescription(getDescription());
        return feed;
    }
View Full Code Here

    }

    public void parse(InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context) throws IOException,
            SAXException, TikaException {
        SyndFeed feed = null;
        // set the encoding?
        try {
            SyndFeedInput feedInput = new SyndFeedInput();
            InputSource input = new InputSource(stream);
            feed = feedInput.build(input);
        } catch (Exception e) {
            throw new TikaException(e.getMessage());
        }

        String feedLink = feed.getLink();
        String feedDesc = stripTags(feed.getDescriptionEx());
        String feedTitle = stripTags(feed.getTitleEx());

        metadata.set(Metadata.TITLE, feedTitle);
        metadata.set(Metadata.DESCRIPTION, feedDesc);
        // store the other fields in the metadata

        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        xhtml.startDocument();

        List entries = feed.getEntries();
        for (Iterator i = entries.iterator(); i.hasNext();) {
            SyndEntry entry = (SyndEntry) i.next();
            String link = entry.getLink();
            if (link == null)
                continue;
View Full Code Here

    private String description = "This feed is auto-generated by Apache ActiveMQ";
    private String entryContentType = "text/plain";

    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response,
            QueueBrowser browser, Message message) throws JMSException {
        SyndFeed feed = getFeed(browser, request);

        List entries = feed.getEntries();
        SyndEntry entry = createEntry(browser, message, request);
        SyndContent description = createEntryContent(browser, message, request);
        entry.setDescription(description);
        entries.add(entry);
    }
View Full Code Here

    // -------------------------------------------------------------------------

    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request)
            throws IOException, JMSException, ServletException {
        // now lets actually write out the content
        SyndFeed feed = getFeed(browser, request);
        SyndFeedOutput output = new SyndFeedOutput();
        try {
            output.output(feed, writer);
        }
        catch (FeedException e) {
View Full Code Here

        }
        return description;
    }

    protected SyndFeed createFeed(QueueBrowser browser, HttpServletRequest request) throws JMSException {
        SyndFeed feed = new SyndFeedImpl();
        feed.setFeedType(feedType);

        String title = browser.getQueue().toString();
        String selector = browser.getMessageSelector();
        if (selector != null) {
            title += " with selector: " + selector;
        }
        feed.setTitle(title);
        feed.setLink(request.getRequestURI());
        feed.setDescription(getDescription());
        return feed;
    }
View Full Code Here

            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        // set the encoding?
        try {
            SyndFeed feed = new SyndFeedInput().build(
                    new InputSource(new CloseShieldInputStream(stream)));

            String title = stripTags(feed.getTitleEx());
            String description = stripTags(feed.getDescriptionEx());

            metadata.set(TikaCoreProperties.TITLE, title);
            metadata.set(TikaCoreProperties.DESCRIPTION, description);
            // store the other fields in the metadata

            XHTMLContentHandler xhtml =
                new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();

            xhtml.element("h1", title);
            xhtml.element("p", description);

            xhtml.startElement("ul");
            for (Object e : feed.getEntries()) {
                SyndEntry entry = (SyndEntry) e;
                String link = entry.getLink();
                if (link != null) {
                    xhtml.startElement("li");
                    xhtml.startElement("a", "href", link);
View Full Code Here

        }

        try
        {
            Map<String, String> map = new HashMap<>();
            SyndFeed feed = null;

            if ( isAllowed( req, repoId, groupId, artifactId ) )
            {
                if ( repoId != null )
                {
                    // new artifacts in repo feed request
                    processor = wac.getBean( "rssFeedProcessor#new-artifacts", RssFeedProcessor.class );
                    map.put( RssFeedProcessor.KEY_REPO_ID, repoId );
                }
                else if ( ( groupId != null ) && ( artifactId != null ) )
                {
                    // TODO: this only works for guest - we could pass in the list of repos
                    // new versions of artifact feed request
                    processor = wac.getBean( "rssFeedProcessor#new-versions", RssFeedProcessor.class );
                    map.put( RssFeedProcessor.KEY_GROUP_ID, groupId );
                    map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );
                }
            }
            else
            {
                res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED );
                return;
            }

            RepositorySession repositorySession = repositorySessionFactory.createSession();
            try
            {
                feed = processor.process( map, repositorySession.getRepository() );
            }
            finally
            {
                repositorySession.close();
            }
            if ( feed == null )
            {
                res.sendError( HttpServletResponse.SC_NO_CONTENT, "No information available." );
                return;
            }

            res.setContentType( MIME_TYPE );

            if ( repoId != null )
            {
                feed.setLink( req.getRequestURL().toString() );
            }
            else if ( ( groupId != null ) && ( artifactId != null ) )
            {
                feed.setLink( req.getRequestURL().toString() );
            }

            SyndFeedOutput output = new SyndFeedOutput();
            output.output( feed, res.getWriter() );
        }
View Full Code Here

        entry = new RssFeedEntry( "Item 3" );
        entry.setDescription( "RSS 2.0 feed item 3." );
        entry.setPublishedDate( whenGathered );
        entries.add( entry );

        SyndFeed feed =
            generator.generateFeed( "Test Feed", "The test feed from Archiva.", entries );

        assertEquals( "Test Feed", feed.getTitle() );       
        assertEquals( "The test feed from Archiva.", feed.getDescription() );
        assertEquals( "en-us", feed.getLanguage() );
        assertEquals( entries.get( 2 ).getPublishedDate(), feed.getPublishedDate() );

        List<SyndEntry> syndEntries = feed.getEntries();
        assertEquals( 3, syndEntries.size() );
        assertEquals( "Item 1", syndEntries.get( 0 ).getTitle() );
        assertEquals( "Item 2", syndEntries.get( 1 ).getTitle() );
        assertEquals( "Item 3", syndEntries.get( 2 ).getTitle() );
    }
View Full Code Here

    @Test
    public void testNoDataEntries()
        throws Exception
    {
        List<RssFeedEntry> entries = new ArrayList<>();
        SyndFeed feed =
            generator.generateFeed( "Test Feed", "The test feed from Archiva.", entries );

        assertNull( feed );
    }
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.synd.SyndFeed

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.