1 package hudson.model; 2 3 import hudson.FeedAdapter; 4 import org.kohsuke.stapler.StaplerRequest; 5 import org.kohsuke.stapler.StaplerResponse; 6 7 import javax.servlet.ServletException ; 8 import javax.servlet.http.HttpServletResponse ; 9 import java.io.IOException ; 10 import java.io.PrintWriter ; 11 import java.util.Collection ; 12 13 18 final class RSS { 19 20 23 public static void doTrackback( Object it, StaplerRequest req, StaplerResponse rsp ) throws IOException , ServletException { 24 req.setCharacterEncoding("UTF-8"); 25 26 String title = req.getParameter("title"); 27 String url = req.getParameter("url"); 28 String excerpt = req.getParameter("excerpt"); 29 String blog_name = req.getParameter("blog_name"); 30 31 rsp.setStatus(HttpServletResponse.SC_OK); 32 rsp.setContentType("application/xml; charset=UTF-8"); 33 PrintWriter pw = rsp.getWriter(); 34 pw.println("<response>"); 35 pw.println("<error>"+(url!=null?0:1)+"</error>"); 36 if(url==null) { 37 pw.println("<message>url must be specified</message>"); 38 } 39 pw.println("</response>"); 40 pw.close(); 41 } 42 43 55 public static <E> void forwardToRss(String title, String url, Collection <? extends E> entries, FeedAdapter<E> adapter, StaplerRequest req, HttpServletResponse rsp) throws IOException , ServletException { 56 req.setAttribute("adapter",adapter); 57 req.setAttribute("title",title); 58 req.setAttribute("url",url); 59 req.setAttribute("entries",entries); 60 61 String flavor = req.getParameter("flavor"); 62 if(flavor==null) flavor="atom"; 63 64 req.getView(Hudson.getInstance(),"/hudson/"+flavor+".jelly").forward(req,rsp); 65 } 66 } 67 | Popular Tags |