Package com.sun.syndication.feed.synd

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


        }      
       
        // 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"))
            {
                setContent(Utilities.unescapeHTML(content.getValue()));
            }
            else if (content != null)
            {
                setContent(content.getValue());
            }
        }
       
        // no content, then try <content:encoded>       
        if (getContent() == null || getContent().trim().length() == 0)
View Full Code Here


    private List getEntries() throws ParseException {

        List entries = new FastList();
        List<Annuncio> annunci = annunciService.getAnnunci(Constant.TYPE_FEED);
        SyndEntry entry;
        SyndContent description;
        for (Annuncio annuncio : annunci) {
            entry = new SyndEntryImpl();
            entry.setTitle(annuncio.getTitolo());
            // entry.setLink("http://www.jroller.com/page/desmax");
            entry.setPublishedDate(annuncio.getData());
            description = new SyndContentImpl();
            description.setType(Constant.FEED_TEXT);
            description.setValue(annuncio.getContenuto());
            entry.setDescription(description);
            entries.add(entry);
        }
        return entries;
    }
View Full Code Here

  /**
   *
   */
  private SyndEntry getFeedEntry(RecentChange change, boolean linkToVersion, String feedURL) {
    SyndContent description;
    SyndEntry entry = new SyndEntryImpl();
    entry.setTitle(change.getTopicName());
    entry.setAuthor(change.getAuthorName());
    entry.setPublishedDate(change.getChangeDate());
    description = new SyndContentImpl();
    description.setType("text/plain");
    StringBuffer descr = new StringBuffer();
    if (!StringUtils.isBlank(change.getChangeComment())) {
      descr.append(change.getChangeComment());
    }
    if (change.isDelete()) {
      descr.append(" (deleted)");
    } else {
      if (linkToVersion) {
        try {
        String url = feedURL + URLEncoder.encode("Special:History?topicVersionId=" + change.getTopicVersionId() + "&topic="
            + Utilities.encodeAndEscapeTopicName(change.getTopicName()), "UTF-8");
          entry.setLink(url);
        } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else {
        entry.setLink(feedURL + Utilities.encodeAndEscapeTopicName(change.getTopicName()));
      }
    }
    if (change.isUndelete()) {
      descr.append(" (undeleted)");
    }
    if (change.getMinor()) {
      descr.append(" (minor)");
    }
    description.setValue(descr.toString());
    entry.setDescription(description);
    // URI is used as GUID in RSS 2.0 and should therefore contain the
    // version id
    entry.setUri(feedURL + Utilities.encodeAndEscapeTopicName(change.getTopicName()) + "#" + change.getTopicVersionId());
    return entry;
View Full Code Here

        feed.setAuthor("anonymous");
        feed.setLink(uri);
       
        SyndEntry entry = new SyndEntryImpl();
        entry.setAuthor("anonymous");
        SyndContent content = new SyndContentImpl();
        content.setValue(value);
        entry.setDescription(content);
        feed.getEntries().add(entry);

        return feed;
    }
View Full Code Here

            feedEntry.setUri(key.toString());
            feedEntry.setTitle(item.getTitle());
   
            String value = item.getContents();
            if (value != null) {
                SyndContent content = new SyndContentImpl();
                content.setType("text/xml");
                content.setValue(value);
                List<SyndContent> contents = new ArrayList<SyndContent>();
                contents.add(content);
                feedEntry.setContents(contents);
            }
   
            String href = item.getLink();
            if (href == null) {
                href = key.toString();
            }
            SyndLink link = new SyndLinkImpl();
            link.setRel("edit");
            link.setHref(href);
            feedEntry.getLinks().add(link);
            link = new SyndLinkImpl();
            link.setRel("alternate");
            link.setHref(href);
            feedEntry.getLinks().add(link);
   
            Date date = item.getDate();
            if (date == null) {
                date = new Date();
            }
            feedEntry.setPublishedDate(date);
            return feedEntry;
           
        } else if (data != null) {
            SyndEntry feedEntry = new SyndEntryImpl();
            feedEntry.setUri(key.toString());
            feedEntry.setTitle("item");
   
            // Convert the item to XML
            String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
           
            SyndContent content = new SyndContentImpl();
            content.setType("text/xml");
            content.setValue(value);
            List<SyndContent> contents = new ArrayList<SyndContent>();
            contents.add(content);
            feedEntry.setContents(contents);
   
            SyndLink link = new SyndLinkImpl();
View Full Code Here

                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
               
                List<?> contents = feedEntry.getContents();
                if (!contents.isEmpty()) {
                    SyndContent content = (SyndContent)contents.get(0);
                    String value = content.getValue();
                    item.setContents(value);
                }
               
                for (Object l : feedEntry.getLinks()) {
                    SyndLink link = (SyndLink)l;
                    if (link.getRel() == null || "edit".equals(link.getRel())) {
                        String href = link.getHref();
                        if (href.startsWith("null/")) {
                            href = href.substring(5);
                        }
                        item.setLink(href);
                        break;
                    }
                }
               
                item.setDate(feedEntry.getPublishedDate());
               
                return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
               
            } else {
                String key = feedEntry.getUri();
               
                // Create the item from XML
                List<?> contents = feedEntry.getContents();
                if (contents.isEmpty()) {
                    return null;
                }
                SyndContent content = (SyndContent)contents.get(0);
                String value = content.getValue();
                Object data = mediator.mediate(value, itemXMLType, itemClassType, null);

                return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data);
            }
        } else {
View Full Code Here

    }

    protected void addMessageToFeed(SyndFeed feed, MessageExchange exchange, NormalizedMessage message) throws TransformerException, MessagingException {
        List entries = feed.getEntries();
        SyndEntry entry = createEntry(exchange, message);
        SyndContent description = createEntryContent(exchange, message);
        entry.setDescription(description);
       
        // TODO this line really should work but for some reason it doesn't
        // entries.add(0, entry);
       
View Full Code Here

        entry.setPublishedDate(new Date());
        return entry;
    }

    protected SyndContent createEntryContent(MessageExchange exchange, NormalizedMessage message) throws TransformerException, MessagingException {
        SyndContent description = new SyndContentImpl();
        description.setType(contentType);
        Source content = message.getContent();

        String value = ExpressionHelper.asString(getEntryValue(), exchange, message, null);
        if (value == null && content != null) {
            value = getSourceTransformer().toString(content);
            value = encodeContent(value);
        }
        if (value != null) {
            description.setValue(value);
        }
        return description;
    }
View Full Code Here

                } catch (IOException e) {
                    Debug.logError(e, module);
                }
                if (sub != null) {
                    String thisLink = entryLink + "?articleContentId=" + v.getString("contentId") + "&blogContentId=" + contentId;
                    SyndContent desc = new SyndContentImpl();
                    desc.setType("text/plain");
                    desc.setValue(sub);

                    SyndEntry entry = new SyndEntryImpl();
                    entry.setTitle(v.getString("contentName"));
                    entry.setPublishedDate(v.getTimestamp("createdDate"));
                    entry.setDescription(desc);
View Full Code Here

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

        List<SyndEntry> 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

TOP

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

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.