|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| package org.apache.xindice.webadmin.viewer.components; |
|
21 |
| |
|
22 |
| import java.io.IOException; |
|
23 |
| import java.io.Writer; |
|
24 |
| |
|
25 |
| import javax.servlet.ServletException; |
|
26 |
| import javax.servlet.http.HttpServletRequest; |
|
27 |
| import javax.servlet.http.HttpServletResponse; |
|
28 |
| |
|
29 |
| import org.apache.xindice.core.Collection; |
|
30 |
| import org.apache.xindice.core.DBException; |
|
31 |
| import org.apache.xindice.webadmin.viewer.HtmlViewerComponent; |
|
32 |
| import org.apache.xindice.webadmin.viewer.HtmlResourceViewer; |
|
33 |
| import org.apache.commons.logging.LogFactory; |
|
34 |
| import org.apache.commons.logging.Log; |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| public class DeleteResourceViewer extends HtmlViewerComponent implements HtmlResourceViewer { |
|
43 |
| private static final Log log = LogFactory.getLog(DeleteResourceViewer.class); |
|
44 |
| |
|
45 |
0
| public void execute(HttpServletRequest req, HttpServletResponse res, Collection col, String resourceName)
|
|
46 |
| throws ServletException, IOException { |
|
47 |
| |
|
48 |
0
| String path = col.getCanonicalName() + "/" + resourceName;
|
|
49 |
0
| String title = "Delete Document " + path;
|
|
50 |
| |
|
51 |
0
| String action = req.getParameter("action");
|
|
52 |
0
| String redirect = req.getParameter("redirect");
|
|
53 |
0
| if (redirect == null) {
|
|
54 |
0
| redirect = "";
|
|
55 |
| } |
|
56 |
| |
|
57 |
0
| if (!"yes".equals(action)) {
|
|
58 |
0
| Writer output = startViewer(title, path, res);
|
|
59 |
0
| printStartTable(title, output);
|
|
60 |
0
| printStartSingleTableBox(output);
|
|
61 |
0
| output.write("<a href=\"./?viewer=default\">up to parent collection</a>");
|
|
62 |
0
| printEndSingleTableBox(output);
|
|
63 |
0
| printStartSingleTableBox(output);
|
|
64 |
0
| output.write("Do you really want to delete ");
|
|
65 |
0
| output.write(resourceName);
|
|
66 |
0
| output.write("? <a href=\"javascript:history.back()\">no</a> ");
|
|
67 |
0
| output.write("<a href=\"?viewer=delete&action=yes&redirect=");
|
|
68 |
0
| output.write(redirect);
|
|
69 |
0
| output.write("\">yes</a>");
|
|
70 |
0
| printEndSingleTableBox(output);
|
|
71 |
0
| printEndTable(output);
|
|
72 |
0
| finishViewer(output);
|
|
73 |
| } else { |
|
74 |
0
| try {
|
|
75 |
| |
|
76 |
0
| col.remove(resourceName);
|
|
77 |
| |
|
78 |
| |
|
79 |
0
| if (redirect.length() > 0) {
|
|
80 |
0
| res.sendRedirect(redirect);
|
|
81 |
| } else { |
|
82 |
0
| Writer output = startViewer(title, path, res);
|
|
83 |
0
| printStartTable(title, output);
|
|
84 |
0
| printStartSingleTableBox(output);
|
|
85 |
0
| output.write("<a href=\"./?viewer=default\">up to parent collection</a>");
|
|
86 |
0
| printEndSingleTableBox(output);
|
|
87 |
0
| printStartSingleTableBox(output);
|
|
88 |
0
| output.write("<b>Document ");
|
|
89 |
0
| output.write(resourceName);
|
|
90 |
0
| output.write(" deleted! </b>");
|
|
91 |
0
| printEndSingleTableBox(output);
|
|
92 |
0
| printEndTable(output);
|
|
93 |
0
| finishViewer(output);
|
|
94 |
| } |
|
95 |
| } catch (DBException e) { |
|
96 |
0
| log.error(e);
|
|
97 |
0
| Writer output = startViewer(title, path, res);
|
|
98 |
0
| printStartTable(title, output);
|
|
99 |
0
| printStartSingleTableBox(output);
|
|
100 |
0
| output.write("<a href=\"./?viewer=default\">up to parent collection</a>");
|
|
101 |
0
| printEndSingleTableBox(output);
|
|
102 |
0
| printStartSingleTableBox(output);
|
|
103 |
0
| output.write("<b>Cannot delete ");
|
|
104 |
0
| output.write(resourceName);
|
|
105 |
0
| output.write(": ");
|
|
106 |
0
| output.write(e.getMessage());
|
|
107 |
0
| printEndSingleTableBox(output);
|
|
108 |
0
| printEndTable(output);
|
|
109 |
0
| finishViewer(output);
|
|
110 |
| } |
|
111 |
| } |
|
112 |
| |
|
113 |
| } |
|
114 |
| |
|
115 |
0
| protected String getName() {
|
|
116 |
0
| return "delete";
|
|
117 |
| } |
|
118 |
| |
|
119 |
| } |