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 org.apache.struts.action.Action; |
---|
8 | import org.apache.struts.action.ActionError; |
---|
9 | import org.apache.struts.action.ActionErrors; |
---|
10 | import org.apache.struts.action.ActionForm; |
---|
11 | import org.apache.struts.action.ActionForward; |
---|
12 | import org.apache.struts.action.ActionMapping; |
---|
13 | |
---|
14 | import com.medias.xml.hierarchie.Hierarchie; |
---|
15 | |
---|
16 | |
---|
17 | /** |
---|
18 | * @author combaz |
---|
19 | * |
---|
20 | * Created on 22 févr. 2005 |
---|
21 | */ |
---|
22 | public class PrepareFileListAccessAction extends Action { |
---|
23 | |
---|
24 | public ActionForward execute (ActionMapping mapping, |
---|
25 | ActionForm form, |
---|
26 | HttpServletRequest request, |
---|
27 | HttpServletResponse response) |
---|
28 | throws ServletException { |
---|
29 | |
---|
30 | String target = "failure"; |
---|
31 | ActionErrors errors = new ActionErrors (); |
---|
32 | |
---|
33 | Hierarchie tree = (Hierarchie) request.getSession ().getServletContext ().getAttribute ("APP_ACCESSTREE"); |
---|
34 | // String path = (String) request.getParameter("setPath"); |
---|
35 | String path = tree.getDataRoot () + '/' + ((String) request.getParameter ("setPath")); |
---|
36 | System.out.println (" ************" + path); |
---|
37 | |
---|
38 | try{ |
---|
39 | tree.createFileView(path); |
---|
40 | request.getSession().setAttribute("jeu", path.substring(path.lastIndexOf ("/") + 1)); |
---|
41 | target = "success"; |
---|
42 | } |
---|
43 | catch(Exception e) { |
---|
44 | System.out.println ("exception_prepareFileListAction"); |
---|
45 | errors.add (ActionErrors.GLOBAL_MESSAGE, new ActionError ("errors.upload.prepareFileList.failed")); |
---|
46 | e.printStackTrace (); |
---|
47 | } |
---|
48 | |
---|
49 | if(!errors.isEmpty ()){ |
---|
50 | saveErrors (request, errors); |
---|
51 | } |
---|
52 | |
---|
53 | return (mapping.findForward (target)); |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | } |
---|