source: ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/actions/DeleteFileAction.java @ 151

Last change on this file since 151 was 151, checked in by vmipsl, 13 years ago

Import medias files and cleanup

File size: 1.6 KB
Line 
1package com.medias.megapoli.struts.actions;
2
3import javax.servlet.ServletException;
4import javax.servlet.http.HttpServletRequest;
5import javax.servlet.http.HttpServletResponse;
6
7import com.medias.Context;
8import com.medias.xml.hierarchie.Hierarchie;
9import org.apache.struts.action.Action;
10import org.apache.struts.action.ActionError;
11import org.apache.struts.action.ActionErrors;
12import org.apache.struts.action.ActionForm;
13import org.apache.struts.action.ActionForward;
14import org.apache.struts.action.ActionMapping;
15import com.medias.xml.hierarchie.Hierarchie;
16import com.medias.megapoli.struts.forms.DeleteForm;
17import com.medias.Context;
18
19/**
20 * @author combaz
21 *
22 * Created on 23 févr. 2005
23 */
24public 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}
Note: See TracBrowser for help on using the repository browser.