1 | package com.medias.megapoli.struts.actions; |
---|
2 | |
---|
3 | import javax.servlet.ServletException; |
---|
4 | import javax.servlet.http.HttpServletRequest; |
---|
5 | import javax.servlet.http.HttpServletResponse; |
---|
6 | |
---|
7 | import com.medias.Context; |
---|
8 | import com.medias.xml.hierarchie.Hierarchie; |
---|
9 | import org.apache.struts.action.Action; |
---|
10 | import org.apache.struts.action.ActionError; |
---|
11 | import org.apache.struts.action.ActionErrors; |
---|
12 | import org.apache.struts.action.ActionForm; |
---|
13 | import org.apache.struts.action.ActionForward; |
---|
14 | import org.apache.struts.action.ActionMapping; |
---|
15 | import com.medias.xml.hierarchie.Hierarchie; |
---|
16 | import com.medias.megapoli.struts.forms.DeleteForm; |
---|
17 | import com.medias.Context; |
---|
18 | |
---|
19 | /** |
---|
20 | * @author combaz |
---|
21 | * |
---|
22 | * Created on 23 févr. 2005 |
---|
23 | */ |
---|
24 | public class DeleteFileAction extends Action { |
---|
25 | public ActionForward execute (ActionMapping mapping,ActionForm form, |
---|
26 | HttpServletRequest request, HttpServletResponse response) |
---|
27 | throws ServletException { |
---|
28 | String target = "failure"; |
---|
29 | ActionErrors errors = new ActionErrors(); |
---|
30 | |
---|
31 | if(this.isCancelled(request)) |
---|
32 | target = "cancel"; |
---|
33 | |
---|
34 | else if(form!=null) { |
---|
35 | DeleteForm df = (DeleteForm) form; |
---|
36 | String filePath = df.getPath(); |
---|
37 | Hierarchie tree = (Hierarchie) request.getSession().getServletContext().getAttribute("APP_UPLOADTREE"); |
---|
38 | try { |
---|
39 | tree.deleteFolder(filePath); |
---|
40 | target="success"; |
---|
41 | } |
---|
42 | catch(Exception e) { |
---|
43 | e.printStackTrace(); |
---|
44 | errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionError("errors.upload.deleteFile.failed", Context.getWebmaster( request ))); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | if(!errors.isEmpty()){ |
---|
49 | saveErrors(request, errors); |
---|
50 | } |
---|
51 | return mapping.findForward(target); |
---|
52 | } |
---|
53 | } |
---|