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 |
| public class ListCollectionDocuments extends Command { |
35 |
| |
36 |
0
| public boolean execute(XMLTools.Config table) throws Exception {
|
37 |
| |
38 |
0
| if (table.getString(XMLTools.COLLECTION) == null) {
|
39 |
0
| System.out.println("ERROR : Collection and switch required");
|
40 |
0
| return false;
|
41 |
| } |
42 |
| |
43 |
0
| Collection col = null;
|
44 |
0
| try {
|
45 |
| |
46 |
0
| String colstring = normalizeCollectionURI(table.getString(XMLTools.COLLECTION),
|
47 |
| table.getBoolean(XMLTools.LOCAL)); |
48 |
| |
49 |
0
| col = DatabaseManager.getCollection(colstring);
|
50 |
0
| if (col == null) {
|
51 |
0
| System.out.println("ERROR : Collection not found!");
|
52 |
0
| return false;
|
53 |
| } |
54 |
| |
55 |
0
| String[] documentarray = col.listResources();
|
56 |
0
| System.out.println();
|
57 |
| |
58 |
0
| for (int i = 0; i < documentarray.length; i++) {
|
59 |
0
| System.out.println("\t" + documentarray[i]);
|
60 |
| } |
61 |
| |
62 |
0
| System.out.println("\nTotal documents: " + documentarray.length);
|
63 |
| } finally { |
64 |
| |
65 |
0
| if (col != null) {
|
66 |
0
| col.close();
|
67 |
| } |
68 |
| } |
69 |
| |
70 |
0
| return true;
|
71 |
| } |
72 |
| |
73 |
0
| public void usage() {
|
74 |
0
| System.out.println("Format: xindice ld -c <context> [-l [-d <path>]] [-v]");
|
75 |
0
| System.out.println();
|
76 |
0
| System.out.println("List all documents in a specific collection. Document names are");
|
77 |
0
| System.out.println("returned in no specific order");
|
78 |
0
| System.out.println();
|
79 |
| } |
80 |
| } |