ladle 0.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ASL20-LICENSE +343 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE +20 -0
- data/NOTICE +52 -0
- data/README.md +121 -0
- data/lib/ladle.rb +13 -0
- data/lib/ladle/Ladle.iml +13 -0
- data/lib/ladle/apacheds/antlr-2.7.6.jar +0 -0
- data/lib/ladle/apacheds/apacheds-core-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-core-shared-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-kerberos-shared-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-protocol-changepw-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-protocol-kerberos-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-protocol-ldap-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-protocol-ntp-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-protocol-shared-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-server-jndi-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-server-main-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/apacheds-server-ssl-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/backport-util-concurrent-2.2.jar +0 -0
- data/lib/ladle/apacheds/commons-cli-1.0.jar +0 -0
- data/lib/ladle/apacheds/commons-collections-3.2.jar +0 -0
- data/lib/ladle/apacheds/commons-io-1.4.jar +0 -0
- data/lib/ladle/apacheds/commons-lang-2.1.jar +0 -0
- data/lib/ladle/apacheds/jcl-over-slf4j-1.5.6.jar +0 -0
- data/lib/ladle/apacheds/jdbm-1.0.jar +0 -0
- data/lib/ladle/apacheds/log4j-1.2.14.jar +0 -0
- data/lib/ladle/apacheds/mina-core-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/mina-filter-ssl-1.0.2.jar +0 -0
- data/lib/ladle/apacheds/shared-asn1-0.9.5.5.jar +0 -0
- data/lib/ladle/apacheds/shared-asn1-codec-0.9.5.5.jar +0 -0
- data/lib/ladle/apacheds/shared-ldap-0.9.5.5.jar +0 -0
- data/lib/ladle/apacheds/slf4j-api-1.5.6.jar +0 -0
- data/lib/ladle/apacheds/slf4j-log4j12-1.5.6.jar +0 -0
- data/lib/ladle/apacheds/spring-beans-1.2.8.jar +0 -0
- data/lib/ladle/apacheds/spring-context-1.2.8.jar +0 -0
- data/lib/ladle/apacheds/spring-core-1.2.8.jar +0 -0
- data/lib/ladle/apacheds/xercesImpl-2.0.2.jar +0 -0
- data/lib/ladle/default.ldif +292 -0
- data/lib/ladle/java/net/detailedbalance/ladle/LadleFatalException.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/LadleFatalException.java +14 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main$1.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main.java +141 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Server.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Server.java +170 -0
- data/lib/ladle/jruby_process.rb +61 -0
- data/lib/ladle/ruby_process.rb +46 -0
- data/lib/ladle/server.rb +334 -0
- data/lib/ladle/version.rb +5 -0
- data/spec/ladle/animals.ldif +28 -0
- data/spec/ladle/server_spec.rb +306 -0
- data/spec/ladle/version_spec.rb +11 -0
- data/spec/spec_helper.rb +32 -0
- metadata +172 -0
data/lib/ladle.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
##
|
2
|
+
# Ladle dishes out steaming helpings of lightweight directory access
|
3
|
+
# (LDAP) for use in testing with rspec, cucumber, or any other ruby
|
4
|
+
# test framework.
|
5
|
+
#
|
6
|
+
# This is the namespace for Ladle's implementation.
|
7
|
+
module Ladle
|
8
|
+
autoload :VERSION, "ladle/version"
|
9
|
+
autoload :Server, "ladle/server"
|
10
|
+
|
11
|
+
autoload :RubyProcess, "ladle/ruby_process"
|
12
|
+
autoload :JRubyProcess, "ladle/jruby_process"
|
13
|
+
end
|
data/lib/ladle/Ladle.iml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
|
+
<exclude-output />
|
5
|
+
<content url="file://$MODULE_DIR$">
|
6
|
+
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
|
7
|
+
</content>
|
8
|
+
<orderEntry type="inheritedJdk" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" name="apacheds" level="project" />
|
11
|
+
</component>
|
12
|
+
</module>
|
13
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,292 @@
|
|
1
|
+
version: 1
|
2
|
+
|
3
|
+
dn: ou=people,dc=example,dc=org
|
4
|
+
objectClass: top
|
5
|
+
objectClass: organizationalUnit
|
6
|
+
ou: people
|
7
|
+
|
8
|
+
dn: uid=aa729,ou=people,dc=example,dc=org
|
9
|
+
objectClass: top
|
10
|
+
objectClass: person
|
11
|
+
objectClass: organizationalPerson
|
12
|
+
objectClass: inetOrgPerson
|
13
|
+
cn: Alexandra Adams
|
14
|
+
sn: Adams
|
15
|
+
givenName: Alexandra
|
16
|
+
mail: alexandra@example.org
|
17
|
+
uid: aa729
|
18
|
+
|
19
|
+
dn: uid=bb459,ou=people,dc=example,dc=org
|
20
|
+
objectClass: top
|
21
|
+
objectClass: person
|
22
|
+
objectClass: organizationalPerson
|
23
|
+
objectClass: inetOrgPerson
|
24
|
+
cn: Belle Baldwin
|
25
|
+
sn: Baldwin
|
26
|
+
givenName: Belle
|
27
|
+
mail: belle@example.org
|
28
|
+
uid: bb459
|
29
|
+
|
30
|
+
dn: uid=cc414,ou=people,dc=example,dc=org
|
31
|
+
objectClass: top
|
32
|
+
objectClass: person
|
33
|
+
objectClass: organizationalPerson
|
34
|
+
objectClass: inetOrgPerson
|
35
|
+
cn: Claire Carpenter
|
36
|
+
sn: Carpenter
|
37
|
+
givenName: Claire
|
38
|
+
mail: claire@example.org
|
39
|
+
uid: cc414
|
40
|
+
|
41
|
+
dn: uid=dd945,ou=people,dc=example,dc=org
|
42
|
+
objectClass: top
|
43
|
+
objectClass: person
|
44
|
+
objectClass: organizationalPerson
|
45
|
+
objectClass: inetOrgPerson
|
46
|
+
cn: Dorothy Dawson
|
47
|
+
sn: Dawson
|
48
|
+
givenName: Dorothy
|
49
|
+
mail: dorothy@example.org
|
50
|
+
uid: dd945
|
51
|
+
|
52
|
+
dn: uid=ee855,ou=people,dc=example,dc=org
|
53
|
+
objectClass: top
|
54
|
+
objectClass: person
|
55
|
+
objectClass: organizationalPerson
|
56
|
+
objectClass: inetOrgPerson
|
57
|
+
cn: Elizabeth Emerson
|
58
|
+
sn: Emerson
|
59
|
+
givenName: Elizabeth
|
60
|
+
mail: elizabeth@example.org
|
61
|
+
uid: ee855
|
62
|
+
|
63
|
+
dn: uid=ff531,ou=people,dc=example,dc=org
|
64
|
+
objectClass: top
|
65
|
+
objectClass: person
|
66
|
+
objectClass: organizationalPerson
|
67
|
+
objectClass: inetOrgPerson
|
68
|
+
cn: Freya Fuller
|
69
|
+
sn: Fuller
|
70
|
+
givenName: Freya
|
71
|
+
mail: freya@example.org
|
72
|
+
uid: ff531
|
73
|
+
|
74
|
+
dn: uid=gg855,ou=people,dc=example,dc=org
|
75
|
+
objectClass: top
|
76
|
+
objectClass: person
|
77
|
+
objectClass: organizationalPerson
|
78
|
+
objectClass: inetOrgPerson
|
79
|
+
cn: Grace Gonzales
|
80
|
+
sn: Gonzales
|
81
|
+
givenName: Grace
|
82
|
+
mail: grace@example.org
|
83
|
+
uid: gg855
|
84
|
+
|
85
|
+
dn: uid=hh153,ou=people,dc=example,dc=org
|
86
|
+
objectClass: top
|
87
|
+
objectClass: person
|
88
|
+
objectClass: organizationalPerson
|
89
|
+
objectClass: inetOrgPerson
|
90
|
+
cn: Hilda Hatfield
|
91
|
+
sn: Hatfield
|
92
|
+
givenName: Hilda
|
93
|
+
mail: hilda@example.org
|
94
|
+
uid: hh153
|
95
|
+
|
96
|
+
dn: uid=ii711,ou=people,dc=example,dc=org
|
97
|
+
objectClass: top
|
98
|
+
objectClass: person
|
99
|
+
objectClass: organizationalPerson
|
100
|
+
objectClass: inetOrgPerson
|
101
|
+
cn: Iona Ingram
|
102
|
+
sn: Ingram
|
103
|
+
givenName: Iona
|
104
|
+
mail: iona@example.org
|
105
|
+
uid: ii711
|
106
|
+
|
107
|
+
dn: uid=jj243,ou=people,dc=example,dc=org
|
108
|
+
objectClass: top
|
109
|
+
objectClass: person
|
110
|
+
objectClass: organizationalPerson
|
111
|
+
objectClass: inetOrgPerson
|
112
|
+
cn: Josephine Jackson
|
113
|
+
sn: Jackson
|
114
|
+
givenName: Josephine
|
115
|
+
mail: josephine@example.org
|
116
|
+
uid: jj243
|
117
|
+
|
118
|
+
dn: uid=kk891,ou=people,dc=example,dc=org
|
119
|
+
objectClass: top
|
120
|
+
objectClass: person
|
121
|
+
objectClass: organizationalPerson
|
122
|
+
objectClass: inetOrgPerson
|
123
|
+
cn: Kelly Kline
|
124
|
+
sn: Kline
|
125
|
+
givenName: Kelly
|
126
|
+
mail: kelly@example.org
|
127
|
+
uid: kk891
|
128
|
+
|
129
|
+
dn: uid=ll819,ou=people,dc=example,dc=org
|
130
|
+
objectClass: top
|
131
|
+
objectClass: person
|
132
|
+
objectClass: organizationalPerson
|
133
|
+
objectClass: inetOrgPerson
|
134
|
+
cn: Leah Lawrence
|
135
|
+
sn: Lawrence
|
136
|
+
givenName: Leah
|
137
|
+
mail: leah@example.org
|
138
|
+
uid: ll819
|
139
|
+
|
140
|
+
dn: uid=mm405,ou=people,dc=example,dc=org
|
141
|
+
objectClass: top
|
142
|
+
objectClass: person
|
143
|
+
objectClass: organizationalPerson
|
144
|
+
objectClass: inetOrgPerson
|
145
|
+
cn: Mona Maddox
|
146
|
+
sn: Maddox
|
147
|
+
givenName: Mona
|
148
|
+
mail: mona@example.org
|
149
|
+
uid: mm405
|
150
|
+
|
151
|
+
dn: uid=nn297,ou=people,dc=example,dc=org
|
152
|
+
objectClass: top
|
153
|
+
objectClass: person
|
154
|
+
objectClass: organizationalPerson
|
155
|
+
objectClass: inetOrgPerson
|
156
|
+
cn: Noel Nash
|
157
|
+
sn: Nash
|
158
|
+
givenName: Noel
|
159
|
+
mail: noel@example.org
|
160
|
+
uid: nn297
|
161
|
+
|
162
|
+
dn: uid=oo981,ou=people,dc=example,dc=org
|
163
|
+
objectClass: top
|
164
|
+
objectClass: person
|
165
|
+
objectClass: organizationalPerson
|
166
|
+
objectClass: inetOrgPerson
|
167
|
+
cn: Ophelia Osborn
|
168
|
+
sn: Osborn
|
169
|
+
givenName: Ophelia
|
170
|
+
mail: ophelia@example.org
|
171
|
+
uid: oo981
|
172
|
+
|
173
|
+
dn: uid=pp468,ou=people,dc=example,dc=org
|
174
|
+
objectClass: top
|
175
|
+
objectClass: person
|
176
|
+
objectClass: organizationalPerson
|
177
|
+
objectClass: inetOrgPerson
|
178
|
+
cn: Penelope Patel
|
179
|
+
sn: Patel
|
180
|
+
givenName: Penelope
|
181
|
+
mail: penelope@example.org
|
182
|
+
uid: pp468
|
183
|
+
|
184
|
+
dn: uid=qq612,ou=people,dc=example,dc=org
|
185
|
+
objectClass: top
|
186
|
+
objectClass: person
|
187
|
+
objectClass: organizationalPerson
|
188
|
+
objectClass: inetOrgPerson
|
189
|
+
cn: Quin Queen
|
190
|
+
sn: Queen
|
191
|
+
givenName: Quin
|
192
|
+
mail: quin@example.org
|
193
|
+
uid: qq612
|
194
|
+
|
195
|
+
dn: uid=rr477,ou=people,dc=example,dc=org
|
196
|
+
objectClass: top
|
197
|
+
objectClass: person
|
198
|
+
objectClass: organizationalPerson
|
199
|
+
objectClass: inetOrgPerson
|
200
|
+
cn: Ruth Rowland
|
201
|
+
sn: Rowland
|
202
|
+
givenName: Ruth
|
203
|
+
mail: ruth@example.org
|
204
|
+
uid: rr477
|
205
|
+
|
206
|
+
dn: uid=ss198,ou=people,dc=example,dc=org
|
207
|
+
objectClass: top
|
208
|
+
objectClass: person
|
209
|
+
objectClass: organizationalPerson
|
210
|
+
objectClass: inetOrgPerson
|
211
|
+
cn: Serena Solomon
|
212
|
+
sn: Solomon
|
213
|
+
givenName: Serena
|
214
|
+
mail: serena@example.org
|
215
|
+
uid: ss198
|
216
|
+
|
217
|
+
dn: uid=tt882,ou=people,dc=example,dc=org
|
218
|
+
objectClass: top
|
219
|
+
objectClass: person
|
220
|
+
objectClass: organizationalPerson
|
221
|
+
objectClass: inetOrgPerson
|
222
|
+
cn: Talia Torres
|
223
|
+
sn: Torres
|
224
|
+
givenName: Talia
|
225
|
+
mail: talia@example.org
|
226
|
+
uid: tt882
|
227
|
+
|
228
|
+
dn: uid=uu972,ou=people,dc=example,dc=org
|
229
|
+
objectClass: top
|
230
|
+
objectClass: person
|
231
|
+
objectClass: organizationalPerson
|
232
|
+
objectClass: inetOrgPerson
|
233
|
+
cn: Ursula Underwood
|
234
|
+
sn: Underwood
|
235
|
+
givenName: Ursula
|
236
|
+
mail: ursula@example.org
|
237
|
+
uid: uu972
|
238
|
+
|
239
|
+
dn: uid=vv180,ou=people,dc=example,dc=org
|
240
|
+
objectClass: top
|
241
|
+
objectClass: person
|
242
|
+
objectClass: organizationalPerson
|
243
|
+
objectClass: inetOrgPerson
|
244
|
+
cn: Vera Vickers
|
245
|
+
sn: Vickers
|
246
|
+
givenName: Vera
|
247
|
+
mail: vera@example.org
|
248
|
+
uid: vv180
|
249
|
+
|
250
|
+
dn: uid=ww369,ou=people,dc=example,dc=org
|
251
|
+
objectClass: top
|
252
|
+
objectClass: person
|
253
|
+
objectClass: organizationalPerson
|
254
|
+
objectClass: inetOrgPerson
|
255
|
+
cn: Wendy Wise
|
256
|
+
sn: Wise
|
257
|
+
givenName: Wendy
|
258
|
+
mail: wendy@example.org
|
259
|
+
uid: ww369
|
260
|
+
|
261
|
+
dn: uid=xx396,ou=people,dc=example,dc=org
|
262
|
+
objectClass: top
|
263
|
+
objectClass: person
|
264
|
+
objectClass: organizationalPerson
|
265
|
+
objectClass: inetOrgPerson
|
266
|
+
cn: Xara Xiong
|
267
|
+
sn: Xiong
|
268
|
+
givenName: Xara
|
269
|
+
mail: xara@example.org
|
270
|
+
uid: xx396
|
271
|
+
|
272
|
+
dn: uid=yy423,ou=people,dc=example,dc=org
|
273
|
+
objectClass: top
|
274
|
+
objectClass: person
|
275
|
+
objectClass: organizationalPerson
|
276
|
+
objectClass: inetOrgPerson
|
277
|
+
cn: Yvette Yates
|
278
|
+
sn: Yates
|
279
|
+
givenName: Yvette
|
280
|
+
mail: yvette@example.org
|
281
|
+
uid: yy423
|
282
|
+
|
283
|
+
dn: uid=zz882,ou=people,dc=example,dc=org
|
284
|
+
objectClass: top
|
285
|
+
objectClass: person
|
286
|
+
objectClass: organizationalPerson
|
287
|
+
objectClass: inetOrgPerson
|
288
|
+
cn: Zana Zimmerman
|
289
|
+
sn: Zimmerman
|
290
|
+
givenName: Zana
|
291
|
+
mail: zana@example.org
|
292
|
+
uid: zz882
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
package net.detailedbalance.ladle;
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @author Rhett Sutphin
|
5
|
+
*/
|
6
|
+
public class LadleFatalException extends RuntimeException {
|
7
|
+
public LadleFatalException(String message) {
|
8
|
+
super(message);
|
9
|
+
}
|
10
|
+
|
11
|
+
public LadleFatalException(String msg, Throwable cause) {
|
12
|
+
super(msg, cause);
|
13
|
+
}
|
14
|
+
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,141 @@
|
|
1
|
+
package net.detailedbalance.ladle;
|
2
|
+
|
3
|
+
import org.apache.commons.cli.CommandLine;
|
4
|
+
import org.apache.commons.cli.CommandLineParser;
|
5
|
+
import org.apache.commons.cli.GnuParser;
|
6
|
+
import org.apache.commons.cli.OptionBuilder;
|
7
|
+
import org.apache.commons.cli.Options;
|
8
|
+
import org.apache.commons.cli.ParseException;
|
9
|
+
import org.apache.log4j.BasicConfigurator;
|
10
|
+
import org.apache.log4j.ConsoleAppender;
|
11
|
+
import org.apache.log4j.Level;
|
12
|
+
import org.apache.log4j.PatternLayout;
|
13
|
+
|
14
|
+
import java.io.BufferedReader;
|
15
|
+
import java.io.File;
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.io.InputStreamReader;
|
18
|
+
import java.io.PrintWriter;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The executable front-end to {@link Server}. Uses stdin/stdout as a control channel, with
|
22
|
+
* tracing info printed to stderr. The arguments expected and the control channel contents are
|
23
|
+
* tightly bound to the ruby controller code in <code>lib/ladle/server.rb</code>. There is no
|
24
|
+
* validation for form at this level -- it's all done in ruby.
|
25
|
+
*
|
26
|
+
* @author Rhett Sutphin
|
27
|
+
*/
|
28
|
+
public class Main {
|
29
|
+
public static void main(String[] args) {
|
30
|
+
configureLog4j();
|
31
|
+
|
32
|
+
CommandLine commandLine = parseArgs(args);
|
33
|
+
|
34
|
+
try {
|
35
|
+
if (commandLine.hasOption('F')) {
|
36
|
+
behaveBadly(commandLine.getOptionValue('F'));
|
37
|
+
}
|
38
|
+
|
39
|
+
final Server s = new Server(
|
40
|
+
new Integer(commandLine.getOptionValue("p")),
|
41
|
+
commandLine.getOptionValue("d"),
|
42
|
+
new File(commandLine.getOptionValue("l")),
|
43
|
+
new File(commandLine.getOptionValue("t")));
|
44
|
+
|
45
|
+
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
46
|
+
public void run() {
|
47
|
+
s.stop();
|
48
|
+
System.out.println("STOPPED");
|
49
|
+
}
|
50
|
+
}));
|
51
|
+
|
52
|
+
s.start();
|
53
|
+
System.out.println("STARTED");
|
54
|
+
} catch (LadleFatalException lfe) {
|
55
|
+
reportError(lfe);
|
56
|
+
System.exit(1);
|
57
|
+
} catch (Exception e) {
|
58
|
+
reportError(e);
|
59
|
+
System.exit(2);
|
60
|
+
}
|
61
|
+
|
62
|
+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
63
|
+
String line;
|
64
|
+
try {
|
65
|
+
//noinspection LoopStatementThatDoesntLoop
|
66
|
+
while ((line = in.readLine()) != null) {
|
67
|
+
if ("STOP".equals(line)) {
|
68
|
+
System.exit(0); // shutdown hook will handle stopping everything
|
69
|
+
} else {
|
70
|
+
System.out.println("FATAL: unknown control message \"" + line + '"');
|
71
|
+
System.exit(9);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
} catch (IOException e) {
|
75
|
+
reportError(e);
|
76
|
+
System.exit(3);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
@SuppressWarnings({ "InfiniteLoopStatement" })
|
81
|
+
private static void behaveBadly(String desiredFailureType) throws InterruptedException {
|
82
|
+
if ("before_start".equals(desiredFailureType)) {
|
83
|
+
reportError("Expected failure for testing");
|
84
|
+
System.exit(207);
|
85
|
+
} else if ("hang".equals(desiredFailureType)) {
|
86
|
+
while (true) { Thread.sleep(1000); }
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
@SuppressWarnings({"AccessStaticViaInstance"})
|
91
|
+
private static CommandLine parseArgs(String[] args) {
|
92
|
+
Options options = new Options()
|
93
|
+
.addOption(OptionBuilder.
|
94
|
+
withLongOpt("fail").hasArg().
|
95
|
+
withDescription("Force a failure (for testing)").
|
96
|
+
create('F'))
|
97
|
+
.addOption(OptionBuilder.
|
98
|
+
withLongOpt("port").hasArg().isRequired().
|
99
|
+
withDescription("Specify port to use").
|
100
|
+
create('p'))
|
101
|
+
.addOption(OptionBuilder.
|
102
|
+
withLongOpt("domain").hasArg().isRequired().
|
103
|
+
withDescription("Specify the domain (e.g., dc=example,dc=com)").
|
104
|
+
create('d'))
|
105
|
+
.addOption(OptionBuilder.
|
106
|
+
withLongOpt("ldif").hasArg().isRequired().
|
107
|
+
withDescription("Specify the LDIF data to load").
|
108
|
+
create('l'))
|
109
|
+
.addOption(OptionBuilder.
|
110
|
+
withLongOpt("tmpdir").hasArg().isRequired().
|
111
|
+
withDescription("Specify the temporary directory to use").
|
112
|
+
create('t'))
|
113
|
+
;
|
114
|
+
CommandLineParser parser = new GnuParser();
|
115
|
+
|
116
|
+
try {
|
117
|
+
return parser.parse(options, args);
|
118
|
+
} catch (ParseException e) {
|
119
|
+
reportError(e);
|
120
|
+
System.exit(18);
|
121
|
+
return null; // unreachable
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
private static void configureLog4j() {
|
126
|
+
ConsoleAppender appender = new ConsoleAppender();
|
127
|
+
appender.setWriter(new PrintWriter(System.err));
|
128
|
+
appender.setLayout(new PatternLayout("%p: %m%n"));
|
129
|
+
appender.setThreshold(Level.INFO);
|
130
|
+
BasicConfigurator.configure(appender);
|
131
|
+
}
|
132
|
+
|
133
|
+
private static void reportError(Exception e) {
|
134
|
+
reportError(e.getMessage());
|
135
|
+
e.printStackTrace(System.err);
|
136
|
+
}
|
137
|
+
|
138
|
+
private static void reportError(String message) {
|
139
|
+
System.out.println("FATAL: " + message);
|
140
|
+
}
|
141
|
+
}
|