1 25 package org.snipsnap.net; 26 27 import org.snipsnap.app.Application; 28 import org.snipsnap.config.Configuration; 29 import org.snipsnap.container.Components; 30 import org.snipsnap.snip.Snip; 31 import org.snipsnap.snip.SnipSpace; 32 import org.snipsnap.versioning.VersionManager; 33 34 import javax.servlet.RequestDispatcher ; 35 import javax.servlet.ServletException ; 36 import javax.servlet.http.HttpServlet ; 37 import javax.servlet.http.HttpServletRequest ; 38 import javax.servlet.http.HttpServletResponse ; 39 import java.io.IOException ; 40 import java.util.List ; 41 42 48 49 public class HistoryServlet extends HttpServlet { 50 51 public void doGet(HttpServletRequest request, HttpServletResponse response) 52 throws IOException , ServletException { 53 54 final String name = request.getParameter("name"); 55 if (null == name) { 56 Configuration config = Application.get().getConfiguration(); 57 response.sendRedirect(config.getUrl("/space/"+config.getStartSnip())); 58 return; 59 } 60 61 SnipSpace space = (SnipSpace)Components.getComponent(SnipSpace.class); 62 Snip snip = space.load(name); 63 64 VersionManager versionManager = (VersionManager) Components.getComponent(VersionManager.class); 65 List history = versionManager.getHistory(snip); 66 67 request.setAttribute("snip", snip); 68 request.setAttribute("history", history); 69 request.setAttribute("URI", request.getRequestURL().toString()); 70 71 RequestDispatcher dispatcher = request.getRequestDispatcher("/exec/history.jsp"); 72 dispatcher.forward(request, response); 73 } 74 } | Popular Tags |