1 package org.nextime.ion.backoffice.action.content; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 import org.apache.struts.action.ActionForm; 9 import org.apache.struts.action.ActionForward; 10 import org.apache.struts.action.ActionMapping; 11 import org.nextime.ion.backoffice.action.BaseAction; 12 import org.nextime.ion.commons.PublicationSorter; 13 import org.nextime.ion.backoffice.exception.BackofficeSecurityException; 14 import org.nextime.ion.backoffice.security.SecurityManagerImpl; 15 16 import org.nextime.ion.framework.business.Publication; 17 import org.nextime.ion.framework.business.User; 18 import org.nextime.ion.framework.business.Section; 19 import org.nextime.ion.framework.mapping.Mapping; 20 21 public class DeletePublicationAction extends BaseAction { 22 23 public ActionForward perform( 24 ActionMapping mapping, 25 ActionForm form, 26 HttpServletRequest request, 27 HttpServletResponse response) 28 throws IOException , ServletException { 29 30 checkUser(request); 32 33 String selectedId = request.getParameter("id"); 35 36 try { 38 Mapping.begin(); 39 if (!new SecurityManagerImpl().canDeletePublication(Publication.getInstance(selectedId), User.getInstance(request.getSession().getAttribute("userLogin")+""))) { 40 throw new Exception (); 41 } 42 } catch (Exception e) { 43 throw new BackofficeSecurityException(); 44 } finally { 45 Mapping.rollback(); 46 } 47 48 try { 49 Mapping.begin(); 50 51 Publication publication = Publication.getInstance(selectedId); 52 Section section = Section.getInstance(request.getParameter("sectionId")); 53 PublicationSorter.removePublication(publication,section); 54 publication.remove(); 55 56 Mapping.commit(); 57 } catch (Exception e) { 58 Mapping.rollback(); 59 throw new ServletException (e); 60 } 61 62 return (mapping.findForward("ok")); 64 65 } 66 67 } 68 | Popular Tags |