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.user.User; 33 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.HttpServlet ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 import java.io.IOException ; 39 40 46 public class SnipRemoveServlet extends HttpServlet { 47 public void doGet(HttpServletRequest request, HttpServletResponse response) 48 throws ServletException , IOException { 49 Application app = Application.get(); 50 User user = app.getUser(); 51 Configuration config = app.getConfiguration(); 52 53 String name = request.getParameter("name"); 54 if (user != null && user.isAdmin()) { 56 SnipSpace space = (SnipSpace) Components.getComponent(SnipSpace.class); 57 Snip snip = space.load(name); 58 59 if (snip.getCommentedSnip() != null) { 61 snip.getCommentedSnip().getComments().getComments().remove(snip); 62 } 63 64 space.remove(snip); 65 response.sendRedirect(config.getUrl("/space/" + config.getStartSnip())); 66 return; 67 } 68 response.sendRedirect(config.getUrl("/space/" + name)); 69 } 70 } 71 | Popular Tags |