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.w3c.dom.Document; |
30 |
| |
31 |
| import org.apache.xindice.core.Collection; |
32 |
| import org.apache.xindice.core.DBException; |
33 |
| import org.apache.xindice.core.data.Entry; |
34 |
| import org.apache.xindice.webadmin.viewer.*; |
35 |
| import org.apache.xindice.webadmin.viewer.HtmlViewerComponent; |
36 |
| import org.apache.xindice.xml.Xml2HtmlWriter; |
37 |
| import org.apache.commons.logging.Log; |
38 |
| import org.apache.commons.logging.LogFactory; |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| public class ContentResourceViewer extends HtmlViewerComponent implements HtmlResourceViewer { |
47 |
| |
48 |
| private static final Log log = LogFactory.getLog(ContentResourceViewer.class); |
49 |
| |
50 |
0
| public void execute(HttpServletRequest req, HttpServletResponse res, Collection col, String name)
|
51 |
| throws ServletException, IOException { |
52 |
| |
53 |
0
| String path = col.getCanonicalName() + "/" + name;
|
54 |
0
| String title = "Document " + path;
|
55 |
| |
56 |
0
| Entry resource;
|
57 |
0
| try {
|
58 |
0
| resource = col.getEntry(name);
|
59 |
| } catch (DBException e) { |
60 |
0
| log.error(e);
|
61 |
0
| throw new ServletException(e);
|
62 |
| } |
63 |
| |
64 |
0
| Writer output = startViewer(title, path, res);
|
65 |
0
| printStartTable(title, output);
|
66 |
0
| printStartSingleTableBox(output);
|
67 |
0
| output.write("<a href=\"./?viewer=default\">up to parent collection</a>");
|
68 |
0
| printEndSingleTableBox(output);
|
69 |
0
| printStartSingleTableBox(output);
|
70 |
| |
71 |
0
| if (resource.getEntryType() == Entry.DOCUMENT) {
|
72 |
0
| Xml2HtmlWriter.write((Document) resource.getValue(), output);
|
73 |
| } else { |
74 |
0
| output.write("binary resource <a href=\"./");
|
75 |
0
| output.write(name);
|
76 |
0
| output.write("\">view content</a>");
|
77 |
| } |
78 |
0
| printEndSingleTableBox(output);
|
79 |
0
| printEndTable(output);
|
80 |
0
| finishViewer(output);
|
81 |
| } |
82 |
| |
83 |
0
| protected String getName() {
|
84 |
0
| return "content";
|
85 |
| } |
86 |
| } |