I need full-text feed, the complete list of contributor and corresponding operation like create/update and deleted entry information also. I found the RSS standard might not enough for hint my goal. I guess I have to develop ATOM feed based on activity stream application by myself.
Could anyone give me some suggestion about which articles, post and guidance I should go through to fulfill my requirement? or any example to follow?
Thanks a lot.
UPDATE
I found ATOM format feed will not help to include deleted entry since com.sun.syndication.feed.synd.SyndEntry doesn’t allow to be marked as deleted.
Then I figure out a final solution to meet my requirement and published in another thread How to differ-updated document from created one according to web feed
Many thanks for your help.
I am quite new to XWiki and I search the forum to try to figure out how a plugin works. But no lucky, there is just a few articles mention it and they don’t really helpful. I guess I should invoke the method getWebFeedOutput of the feed plugin. When I look at the API of getWebFeedOutput, I get totally lost. A bunch of questions raised in my mind, what is a query, what metadata map should I set and etc.
I try coding as following which is based on activity stream macro rss output script but it does NOT give me expected response.
{{velocity}}
$response.setContentType('application/atom+xml')
#set ($query = "where (doc.space='XWiki') order by doc.date desc")
$xwiki.feed.getWebFeedOutput($query, 20, 0, {}, 'atom_1.0'))
{{/velocity}}
Could you please give an example for using this plugin to get atom xml only?
I refered the RSS Feeds and change the output MIME to “application/atom+xml” and feed type to “atom_1.0”, but nothing is exported.
java.lang.ClassCastException: java.lang.String cannot be cast to com.sun.syndication.feed.synd.SyndPerson
at com.sun.syndication.feed.synd.impl.ConverterForAtom03.createAtomPersons(ConverterForAtom03.java:350)
at com.sun.syndication.feed.synd.impl.ConverterForAtom10.createAtomEntry(ConverterForAtom10.java:536)
at com.sun.syndication.feed.synd.impl.ConverterForAtom10.createAtomEntries(ConverterForAtom10.java:419)
at com.sun.syndication.feed.synd.impl.ConverterForAtom10.createRealFeed(ConverterForAtom10.java:400)
at com.sun.syndication.feed.synd.SyndFeedImpl.createWireFeed(SyndFeedImpl.java:229)
at com.sun.syndication.feed.synd.SyndFeedImpl.createWireFeed(SyndFeedImpl.java:211)
at com.sun.syndication.io.SyndFeedOutput.output(SyndFeedOutput.java:134)
at com.xpn.xwiki.plugin.feed.FeedPlugin.getFeedOutput(FeedPlugin.java:1098)
at com.xpn.xwiki.plugin.feed.FeedPluginApi.getFeedOutput(FeedPluginApi.java:834)
The Java code that creates the feed based on the query results sets the contributors of each feed entry as a list of Strings (contributor names) rather than a list of SyndPerson. This works for RSS but not for Atom unfortunately, as indicated by the Javadoc of getContributors
For Atom feeds, this returns the contributors as a list of SyndPerson objects
...
#set ($feed = $xwiki.feed.getWebFeed($queryObject.execute()))
#foreach ($entry in $feed.entries)
## Clear the list of contributors. Ideally we should convert the String to a SyndPerson object but we can't do this from Velocity.
#set ($discard = $entry.setContributors([]))
#end
...
After studying for couple days, I guess the reason activity stream gives me different RSS or ATOM information against its macro is the scripts in WebRSS.xml which totally uses different query to get information (Hope it is correct).
So maybe I can manually update (add/change) the feed entries list according to result of activity stream query.
I have read the activity stream source code and use following code to get activity stream information.
{{velocity}}
#set ($query = 'select act from ActivityEventImpl as act, ActivityEventImpl as act2')
#set ($query = "$query where act.eventId=act2.eventId and")`
#set ($query = "$query (act.hidden <> true or act.hidden is null) and")`
#set ($query = "$query (act.space=:space OR act.space LIKE :space_nested)")
#set ($query = "$query group by act.requestId having (act.priority)=max(act2.priority) order by act.url")
#set ($queryObject = $services.query.xwql($query).setLimit(20).setOffset(0))
#set ($queryObject = $queryObject.bindValue('space', 'XWiki'))
#set ($queryObject = $queryObject.bindValue('space_nested', 'XWiki.%'))
#set ($events = $queryObject.execute())
#foreach ($event in $events)
* $event.page | $event.url | $event.user | $event.stream | $event.date | $event.title | $event.body
#end
{{/velocity}}
I hope I can correct the create date/published date accroding to events and add deleted entries also.
Now I don’t know how to instantiate feed entries object and I found code block listed in snippet Create Object with Context Data EventListener doesn’t help.
It will be more convinience If I can call the activitystream service directly and utilize its method getFeed.
I tries follwoing codes but without lucky.