1 package org.nextime.ion.backoffice.action.resource; 2 3 4 import java.io.File ; 5 import java.io.IOException ; 6 import java.util.Vector ; 7 8 import javax.servlet.ServletException ; 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 import org.apache.struts.action.ActionForm; 12 import org.apache.struts.action.ActionForward; 13 import org.apache.struts.action.ActionMapping; 14 import org.nextime.ion.backoffice.action.BaseAction; 15 import org.nextime.ion.backoffice.bean.ResourceXmlBean; 16 import org.nextime.ion.backoffice.bean.Resources; 17 import org.nextime.ion.common.ResourceServlet; 18 19 20 21 public class ListResourceAction extends BaseAction { 22 23 public ActionForward perform(ActionMapping mapping, 24 ActionForm form, 25 HttpServletRequest request, 26 HttpServletResponse response) 27 throws IOException , ServletException { 28 29 checkUser(request); 31 32 String id = request.getParameter("id"); 34 String path = null; 35 try { 36 ResourceXmlBean bean = Resources.getResourceXmlBean(servlet,id); 37 path = bean.getDirectory(); 38 } catch( Exception e ) { 39 throw new ServletException (e); 40 } 41 42 String realPath = servlet.getServletContext().getRealPath("/"); 43 File resources = new File (realPath,ResourceServlet.relativePath); 44 File tresources = new File (resources,path); 45 46 File [] files = tresources.listFiles(); 47 Vector mfiles = new Vector (); 48 for( int i=0; i<files.length; i++ ) { 49 mfiles.add(new org.nextime.ion.backoffice.bean.File(files[i])); 50 } 51 52 request.setAttribute("files",mfiles); 53 54 return (mapping.findForward("view")); 56 57 } 58 59 } 60 | Popular Tags |