01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders.files;
04:
05: import fitnesse.*;
06: import fitnesse.responders.SecureResponder;
07: import fitnesse.authentication.*;
08: import fitnesse.util.FileUtil;
09: import fitnesse.http.Response;
10: import fitnesse.http.Request;
11: import fitnesse.http.SimpleResponse;
12:
13: import java.io.File;
14:
15: public class DeleteFileResponder implements SecureResponder {
16: public String resource;
17:
18: public Response makeResponse(FitNesseContext context,
19: Request request) throws Exception {
20: Response response = new SimpleResponse();
21: resource = request.getResource();
22: String filename = (String) request.getInput("filename");
23: String pathname = context.rootPagePath + "/" + resource
24: + filename;
25: File file = new File(pathname);
26:
27: if (file.isDirectory())
28: FileUtil.deleteFileSystemDirectory(file);
29: else
30: file.delete();
31:
32: response.redirect("/" + resource);
33: return response;
34: }
35:
36: public SecureOperation getSecureOperation() {
37: return new AlwaysSecureOperation();
38: }
39: }
|