|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| package org.apache.xindice.tools.command; |
|
21 |
| |
|
22 |
| import org.apache.xindice.tools.XMLTools; |
|
23 |
| |
|
24 |
| import org.xmldb.api.DatabaseManager; |
|
25 |
| import org.xmldb.api.base.Collection; |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| public class ListCollections extends Command { |
|
36 |
| |
|
37 |
0
| public boolean execute(XMLTools.Config table) throws Exception {
|
|
38 |
| |
|
39 |
0
| if (table.getString(XMLTools.COLLECTION) == null) {
|
|
40 |
0
| System.out.println("ERROR : Collection context required");
|
|
41 |
0
| return false;
|
|
42 |
| } |
|
43 |
| |
|
44 |
0
| Collection col = null;
|
|
45 |
0
| try {
|
|
46 |
| |
|
47 |
0
| String colstring = normalizeCollectionURI(table.getString(XMLTools.COLLECTION),
|
|
48 |
| table.getBoolean(XMLTools.LOCAL)); |
|
49 |
| |
|
50 |
| |
|
51 |
0
| col = DatabaseManager.getCollection(colstring);
|
|
52 |
0
| if (col == null) {
|
|
53 |
0
| System.out.println("ERROR : Collection not found!");
|
|
54 |
0
| return false;
|
|
55 |
| } |
|
56 |
| |
|
57 |
0
| String[] colarray = col.listChildCollections();
|
|
58 |
0
| System.out.println();
|
|
59 |
| |
|
60 |
0
| for (int i = 0; i < colarray.length; i++) {
|
|
61 |
0
| System.out.println("\t" + colarray[i]);
|
|
62 |
| } |
|
63 |
| |
|
64 |
0
| System.out.println("\nTotal collections: " + colarray.length);
|
|
65 |
| } finally { |
|
66 |
| |
|
67 |
0
| if (col != null) {
|
|
68 |
0
| col.close();
|
|
69 |
| } |
|
70 |
| } |
|
71 |
0
| return true;
|
|
72 |
| } |
|
73 |
| |
|
74 |
0
| public void usage() {
|
|
75 |
0
| System.out.println("Format: xindice lc -c <context> [-l [-d <path>]] [-v]");
|
|
76 |
0
| System.out.println();
|
|
77 |
0
| System.out.println("Lists child collections in a specific collection");
|
|
78 |
0
| System.out.println();
|
|
79 |
| } |
|
80 |
| } |
|
81 |
| |
|
82 |
| |