KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > action > resource > DeleteResourceAction


1 package org.nextime.ion.backoffice.action.resource;
2
3
4 import java.io.File JavaDoc;
5 import java.io.IOException JavaDoc;
6
7 import javax.servlet.ServletException JavaDoc;
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9 import javax.servlet.http.HttpServletResponse JavaDoc;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13 import org.nextime.ion.backoffice.action.BaseAction;
14 import org.nextime.ion.backoffice.bean.ResourceXmlBean;
15 import org.nextime.ion.backoffice.bean.Resources;
16 import org.nextime.ion.common.ResourceServlet;
17
18
19
20 public class DeleteResourceAction extends BaseAction {
21
22     public ActionForward perform(ActionMapping mapping,
23                                  ActionForm form,
24                                  HttpServletRequest JavaDoc request,
25                                  HttpServletResponse JavaDoc response)
26         throws IOException JavaDoc, ServletException JavaDoc {
27             
28         // check if user is correctly logged
29
checkUser(request);
30         
31         // retrieve resources selected
32
String JavaDoc id = request.getSession().getAttribute("selectedResources")+"";
33         String JavaDoc path = null;
34         try {
35             ResourceXmlBean bean = Resources.getResourceXmlBean(servlet,id);
36             path = bean.getDirectory();
37         } catch( Exception JavaDoc e ) {
38             throw new ServletException JavaDoc(e);
39         }
40         String JavaDoc realPath = servlet.getServletContext().getRealPath("/");
41         File JavaDoc resources = new File JavaDoc(realPath,ResourceServlet.relativePath);
42         File JavaDoc tresources = new File JavaDoc(resources,path);
43         
44         File JavaDoc as = new File JavaDoc(tresources, request.getParameter("id"));
45         as.delete();
46         
47         // Forward to the next page
48
return (mapping.findForward("ok"));
49
50     }
51
52 }
53
Popular Tags