1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * CDDL HEADER START
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc * The contents of this file are subject to the terms of the
cacbb5e3100fb85d23d1614cace3a8662801f2e6Eugen Kuksa * Common Development and Distribution License, Version 1.0 only
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu * (the "License"). You may not use this file except in compliance
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * with the License.
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * You can obtain a copy of the license at
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * trunk/opends/resource/legal-notices/OpenDS.LICENSE
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc * See the License for the specific language governing permissions
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * and limitations under the License.
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * When distributing Covered Code, include this CDDL HEADER in each
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * file and include the License file at
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder * add the following below this CDDL HEADER, with the fields enclosed
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc * by brackets "[]" replaced with your own identifying information:
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder * Portions Copyright [yyyy] [name of copyright owner]
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc * CDDL HEADER END
de03ed90ff6efbbc4751301bcf6b50d9790c1afbKarl Luc * Copyright 2008-2009 Sun Microsystems, Inc.
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksaimport org.opends.quicksetup.util.ProgressMessageFormatter;
a35bacbc16daf5c10f9accfdfadc4971e9d6f648Iulia Ignatovimport org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maederimport org.opends.quicksetup.event.ProgressUpdateListener;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maederimport org.opends.quicksetup.event.ProgressUpdateEvent;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maederimport org.opends.server.util.cli.CLIException;
3831cf8a3b0ea144a80d13fe0314cc2752e32107Christian Maeder * Class used by Launcher to start a CLI application.
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc /** Arguments passed in the command line. */
d6ce032cac688f3698be7133d27f53d3967e6749Christian Maeder Logger.getLogger(QuickSetupCli.class.getName());
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc * Creates a QuickSetupCli instance.
551f1476dea3f969775527cb15fd512e86279307Karl Luc * @param cliApp the application to be run
9e5811a3323b00d6ff8d3fe91a185de1ab31150bChristian Maeder * @param launcher that launched the app
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc public QuickSetupCli(CliApplication cliApp, Launcher launcher) {
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder * Gets the user data this application will use when running.
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder * @return UserData to use when running
c51d1f5ff88cce030fe543e271ca6b85625b70d8Karl Luc return this.userData;
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc * Parses the user data and prompts the user for data if required. If the
0b282d1269b8f9a658f7ce9090575ba1b00e8d66Christian Maeder * user provides all the required data it launches the application.
0b282d1269b8f9a658f7ce9090575ba1b00e8d66Christian Maeder * @return the return code (SUCCESSFUL, CANCELLED, USER_DATA_ERROR,
0b282d1269b8f9a658f7ce9090575ba1b00e8d66Christian Maeder * ERROR_ACCESSING_FILE_SYSTEM, ERROR_STOPPING_SERVER or BUG.
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa // Parse the arguments
d6ce032cac688f3698be7133d27f53d3967e6749Christian Maeder userData = cliApp.createUserData(launcher);
7b1111ca3b126f71cce47e60ce4b56e6f92422e9Karl Luc public void progressUpdate(ProgressUpdateEvent ev) {
1ea7fb6b0f66210bc0d3cb995f1b655277b33884Eugen Kuksa Thread appThread = new Thread(cliApp, "CLI Application");
de03ed90ff6efbbc4751301bcf6b50d9790c1afbKarl Luc while (!Thread.State.TERMINATED.equals(appThread.getState())) {
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc // do nothing;
9e5811a3323b00d6ff8d3fe91a185de1ab31150bChristian Maeder LOG.log(Level.INFO, "Application returnValue: "+returnValue);
c96c73387a0c41614ba325f737edad6abbf07e79Eugen Kuksa LOG.log(Level.INFO, "Application run error: "+ue, ue);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc // User cancelled operation.
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa LOG.log(Level.SEVERE, "UserDataException: "+uude, uude);
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa System.err.println(StaticUtils.wrapText(uude.getLocalizedMessage(),
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa LOG.log(Level.SEVERE, "ApplicationException: "+ae, ae);
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa LOG.log(Level.SEVERE, "Unexpected error: "+t, t);
037be4e5b0e867dd148db2ea89640d8edf009053Eugen Kuksa LOG.log(Level.INFO, "returnValue: "+returnValue.getReturnCode());