package org.jerrymouse.chineseCalendar.controller;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.jerrymouse.chineseCalendar.view.FeedView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;
import com.sun.syndication.feed.synd.SyndFeed;

@SuppressWarnings("serial")
@Component("feedAction")
@ParentPackage("rss")
public class FeedAction extends ActionSupport {

	@Autowired
	FeedView feedController;

	String data;

	SyndFeed feed;

	@Override
	@Action(value = "/feed", results = { @Result(name = ActionSupport.SUCCESS, type = "rss", params = {
			"feedName", "feed", "feedType", "atom_1.0", "encoding", "UTF-8" }) })
	public String execute() throws Exception {
		feed = feedController.creatFeed(data);
		return super.execute();
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public SyndFeed getFeed() {
		return feed;
	}

	public void setFeed(SyndFeed feed) {
		this.feed = feed;
	}
}
