/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package news;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import database.DBConn;
import filter.FaceFilter;
import filter.HTMLFilter;
import filter.UbbCode;

/** 
 * MyEclipse Struts
 * Creation date: 05-25-2008
 * 
 * XDoclet definition:
 * @struts.action path="/addNews" name="addNews" input="/addNews.jsp" scope="request" validate="true"
 * @struts.action-forward name="ok" path="/addNews.jsp"
 */
public class addNewsAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AddNewsForm addNews = (AddNewsForm) form;// TODO Auto-generated method stub
		DBConn db = new DBConn();
		News news = new News();
		FaceFilter ff = new FaceFilter();
		HTMLFilter html = new HTMLFilter();
		UbbCode uc = new UbbCode();
		html.setSource(addNews.getContent());
		html.run();
		uc.setSource(html.getResult());
		uc.run();
		ff.setSource(uc.getResult());
		ff.run();
		news.setTitle(addNews.getTitle());
		news.setUsers(addNews.getUsers());
		news.setContent(ff.getResult());
		news.setClasses(addNews.getClasses());
		db.addNews(news);
		return mapping.findForward("ok");
	}
}