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.util.Configuration; |
31 |
| import org.apache.xindice.util.StringUtilities; |
32 |
| import org.apache.xindice.webadmin.util.CollectionConfigurationHelper; |
33 |
| import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer; |
34 |
| import org.apache.xindice.webadmin.viewer.HtmlViewerComponent; |
35 |
| import org.apache.commons.logging.Log; |
36 |
| import org.apache.commons.logging.LogFactory; |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| public class CreateCollectionViewer extends HtmlViewerComponent implements HtmlCollectionViewer { |
45 |
| private static final Log log = LogFactory.getLog(CreateCollectionViewer.class); |
46 |
| |
47 |
0
| public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
|
48 |
| throws ServletException, IOException { |
49 |
| |
50 |
0
| String path = col.getCanonicalName();
|
51 |
0
| String title = "Create Subcollection in " + path;
|
52 |
| |
53 |
0
| Writer output = startViewer(title, path, res);
|
54 |
| |
55 |
0
| String name = req.getParameter("name");
|
56 |
0
| String inlineMeta = req.getParameter("meta");
|
57 |
0
| String compressed = req.getParameter("compressed");
|
58 |
0
| String filer = req.getParameter("filer");
|
59 |
| |
60 |
0
| if (name == null || name.length() == 0) {
|
61 |
0
| printStartTable(title, output);
|
62 |
0
| printStartSingleTableBox(output);
|
63 |
0
| output.write(CREATE_FORM_START);
|
64 |
0
| output.write(Boolean.toString(CollectionConfigurationHelper.getDefaultInlineMetadata()));
|
65 |
0
| output.write(CREATE_FORM_META_DEFAULT);
|
66 |
0
| output.write(Boolean.toString(!CollectionConfigurationHelper.getDefaultInlineMetadata()));
|
67 |
0
| output.write(CREATE_FORM_META_END);
|
68 |
0
| output.write(Boolean.toString(CollectionConfigurationHelper.getDefaultCompressed()));
|
69 |
0
| output.write(CREATE_FORM_COMPRESSED_DEFAULT);
|
70 |
0
| output.write(Boolean.toString(!CollectionConfigurationHelper.getDefaultCompressed()));
|
71 |
0
| output.write(CREATE_FORM_COMPRESSED_END);
|
72 |
0
| output.write(CollectionConfigurationHelper.getDefaultFilerClass());
|
73 |
0
| output.write(CREATE_FORM_FILER);
|
74 |
0
| printEndSingleTableBox(output);
|
75 |
0
| printEndTable(output);
|
76 |
| } else { |
77 |
0
| try {
|
78 |
0
| Configuration config = CollectionConfigurationHelper.createConfiguration(name, compressed, inlineMeta, filer);
|
79 |
0
| col.createCollection(name, config);
|
80 |
| |
81 |
0
| printStartTable(title, output);
|
82 |
0
| printStartSingleTableBox(output);
|
83 |
0
| output.write("<b>Collection <a href=\"./");
|
84 |
0
| output.write(StringUtilities.escapePath(name));
|
85 |
0
| output.write("/?viewer=default\"><b>");
|
86 |
0
| output.write(name);
|
87 |
0
| output.write("</b></a> created!</b>");
|
88 |
0
| printEndSingleTableBox(output);
|
89 |
0
| printEndTable(output);
|
90 |
| } catch (Exception e) { |
91 |
0
| log.error(e);
|
92 |
0
| title = "Error while creating new Collection!";
|
93 |
0
| printStartTable(title, output);
|
94 |
0
| printStartSingleTableBox(output);
|
95 |
0
| output.write("<b>Could not create Collection ");
|
96 |
0
| output.write(name);
|
97 |
0
| output.write("!</b><br />");
|
98 |
0
| output.write(e.getMessage());
|
99 |
0
| printEndSingleTableBox(output);
|
100 |
0
| printEndTable(output);
|
101 |
| } |
102 |
| } |
103 |
| |
104 |
0
| finishViewer(output);
|
105 |
| } |
106 |
| |
107 |
0
| protected String getName() {
|
108 |
0
| return "create";
|
109 |
| } |
110 |
| |
111 |
| } |