001: /*
002: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.instance.sra.panel;
007:
008: //
009:
010: import com.sun.portal.config.context.DebugContext;
011: import com.sun.portal.config.context.IdentityPropertyContext;
012: import com.sun.portal.config.context.SRAPropertyContext;
013: import com.sun.portal.instance.common.ui.HeaderPanel;
014: import com.sun.portal.instance.sra.common.SRAWSWHelper;
015: import com.sun.portal.instance.sra.Instance;
016: import com.sun.setup.util.wbResource;
017: import com.sun.wizards.core.Route;
018: import com.sun.wizards.core.WizardState;
019: import com.sun.wizards.core.WizardTreeManager;
020:
021: import java.awt.*;
022: import java.io.DataInput;
023: import java.io.DataOutput;
024: import java.io.IOException;
025: import java.util.Vector;
026:
027: //
028:
029: public class SummaryPanel extends Base {
030: //
031: //
032: //
033: private static final String GUI_NAMEVALUE_SEPARATOR = DASH_GUI
034: + "-NameValue-Separator";
035: private static final String GUI_VERIFY_DIALOG_TITLE = DASH_GUI
036: + "-Verify-Dialog-Title";
037: private static final String GUI_VERIFY_ACTION_CREATE = DASH_GUI
038: + "-Verify-Action-Create";
039: private static final String GUI_VERIFY_ACTION_MODIFY = DASH_GUI
040: + "-Verify-Action-Modify";
041: private static final String GUI_VERIFY_ACTION_DELETE = DASH_GUI
042: + "-Verify-Action-Delete";
043: private static final String GUI_CONTINUE_BUTTON = DASH_GUI
044: + "-Continue-Button";
045: private static final String GUI_CANCEL_BUTTON = DASH_GUI
046: + "-Cancel-Button";
047:
048: //
049: private static final String SRAPI_GUI_PROMPT_PROTOCOL = "SRAProxyInformation-Gui-Prompt-Protocol";
050: private static final String SRAPI_GUI_PROMPT_HOSTNAME = "SRAProxyInformation-Gui-Prompt-HostName";
051: private static final String SRAPI_GUI_PROMPT_IP = "SRAProxyInformation-Gui-Prompt-IP";
052: private static final String SRAPI_GUI_PROMPT_PORT = "SRAProxyInformation-Gui-Prompt-Port";
053: private static final String SRAPI_GUI_PROMPT_START_AFTER_CONFIGURATION = "SRAProxyInformation-Gui-Prompt-Start-After-Configuration";
054: private static final String SRAPI_GUI_PROMPT_START_AT_SYSTEM_BOOTUP = "SRAProxyInformation-Gui-Prompt-Start-At-System-Bootup";
055:
056: //
057: private static final String ECI_GUI_PROMPT_PORTAL_WEBAPP_CONTEXT = "ExternalComponentsInformation-Gui-Prompt-Portal-WebApp-Context";
058: private static final String ECI_GUI_PROMPT_DO_CREATE_NEW_IDENTITY_SDK_INSTANCE = "ExternalComponentsInformation-Gui-Do-Create-New-Identity-SDK-Instance";
059: private static final String ECI_GUI_PROMPT_IDENTITY_PROTOCOL = "ExternalComponentsInformation-Gui-Prompt-Identity-Protocol";
060: private static final String ECI_GUI_PROMPT_IDENTITY_HOSTNAME = "ExternalComponentsInformation-Gui-Prompt-Identity-HostName";
061: private static final String ECI_GUI_PROMPT_IDENTITY_PORT = "ExternalComponentsInformation-Gui-Prompt-Identity-Port";
062: private static final String ECI_GUI_PROMPT_IDENTITY_SESSION_SERVICE_WEBAPP_CONTEXT = "ExternalComponentsInformation-Gui-Prompt-Identity-Session-Service-WebApp-Context";
063: private static final String ECI_GUI_PROMPT_IDENTITY_ORGANIZATION_DN = "ExternalComponentsInformation-Gui-Prompt-Identity-Organization-DN";
064: private static final String ECI_GUI_PROMPT_IDENTITY_ENCRYPTION_KEY = "ExternalComponentsInformation-Gui-Prompt-Identity-Encryption-Key";
065:
066: //
067: private static final String SSCI_GUI_PROMPT_SSC_INFORMATION = "SummaryPanel-Gui-SelfSignedCertificate-Information";
068:
069: //
070: private static final String GUI_ERROR_DIALOG_TITLE = GUI_ERROR
071: + "-Dialog-Title";
072: private static final String GUI_FATAL_ERROR = GUI_ERROR + "-Fatal";
073:
074: //
075: //
076: //
077: public SummaryPanel() {
078: }
079:
080: public SummaryPanel(WizardState wizardState, String name) {
081: super (wizardState, name);
082: }
083:
084: public SummaryPanel(String name, Route route,
085: WizardTreeManager wizardManager) {
086: super (name, route, wizardManager);
087: }
088:
089: //
090: //
091: //
092: private String getPrompt(String rbKey) {
093: return wbResource.getString(rbKey);
094: }
095:
096: private static final String SPACE = " ";
097: private static final String LINE_SEPARATOR = System
098: .getProperty("line.separator");
099:
100: private String getLine(String rbKey, String sep, String value) {
101: return getPrompt(rbKey) + sep + SPACE + value + LINE_SEPARATOR;
102: }
103:
104: private TextArea getSummaryInformation(IdentityPropertyContext ipc,
105: SRAPropertyContext spc) {
106: TextArea result = new TextArea();
107: result.setEditable(false);
108:
109: //
110: String sep = wbResource.getString(getName()
111: + GUI_NAMEVALUE_SEPARATOR);
112:
113: //
114: result.append(getLine(SRAPI_GUI_PROMPT_PROTOCOL, sep, spc
115: .getProtocol()));
116: result.append(getLine(SRAPI_GUI_PROMPT_HOSTNAME, sep, spc
117: .getHost()));
118: result.append(getLine(SRAPI_GUI_PROMPT_IP, sep, spc.getIP()));
119: result
120: .append(getLine(SRAPI_GUI_PROMPT_PORT, sep, spc
121: .getPort()));
122: result.append(getLine(
123: SRAPI_GUI_PROMPT_START_AFTER_CONFIGURATION, sep, spc
124: .doStartAfterInstall().toString()));
125: result.append(getLine(SRAPI_GUI_PROMPT_START_AT_SYSTEM_BOOTUP,
126: sep, spc.doStartAtSystemBoot().toString()));
127:
128: result.append(LINE_SEPARATOR);
129: result.append(LINE_SEPARATOR);
130:
131: //
132: result.append(getLine(ECI_GUI_PROMPT_PORTAL_WEBAPP_CONTEXT,
133: sep, spc.getPortalWebAppContext()));
134: result.append(getLine(
135: ECI_GUI_PROMPT_DO_CREATE_NEW_IDENTITY_SDK_INSTANCE,
136: sep, spc.doCreateNewIdentitySDKInstance().toString()));
137: if (spc.doCreateNewIdentitySDKInstance().booleanValue()) {
138: result.append(getLine(ECI_GUI_PROMPT_IDENTITY_PROTOCOL,
139: sep, ipc.getSessionServiceProtocol()));
140: result.append(getLine(ECI_GUI_PROMPT_IDENTITY_HOSTNAME,
141: sep, ipc.getSessionServiceHost()));
142: result.append(getLine(ECI_GUI_PROMPT_IDENTITY_PORT, sep,
143: ipc.getSessionServicePort()));
144: result
145: .append(getLine(
146: ECI_GUI_PROMPT_IDENTITY_SESSION_SERVICE_WEBAPP_CONTEXT,
147: sep,
148: ipc
149: .getSessionServiceWebAppContextFromNamingURL()));
150: result.append(getLine(
151: ECI_GUI_PROMPT_IDENTITY_ORGANIZATION_DN, sep, ipc
152: .getDefaultOrganization()));
153: result.append(getLine(
154: ECI_GUI_PROMPT_IDENTITY_ENCRYPTION_KEY, sep, ipc
155: .getEncryptionKey()));
156: }
157:
158: result.append(LINE_SEPARATOR);
159: result.append(LINE_SEPARATOR);
160:
161: //
162: result.append(getLine(SSCI_GUI_PROMPT_SSC_INFORMATION, sep, spc
163: .getSelfSignedCertificateInformation()));
164:
165: result.append(LINE_SEPARATOR);
166: result.append(LINE_SEPARATOR);
167:
168: //
169: return result;
170: }
171:
172: private void makeup(Panel p, IdentityPropertyContext ipc,
173: SRAPropertyContext spc) {
174: DebugContext.message(getName()
175: + ": makeup(child, ipc, spc): Entry");
176:
177: // 2x1 Grid
178: GridBagConstraints gbc = new GridBagConstraints();
179: gbc.insets = getDefaultInsets();
180:
181: // row 1
182: HeaderPanel header = new HeaderPanel();
183: String labelText = wbResource.getString(SRAWSWHelper
184: .getWSWAction(getWizardState()))
185: + ": "
186: + SRAWSWHelper.getWSWInstanceName(getWizardState());
187: header.add(new Label(labelText, Label.RIGHT));
188:
189: gbc.fill = GridBagConstraints.HORIZONTAL;
190: gbc.gridwidth = GridBagConstraints.REMAINDER;
191: p.add(header, gbc);
192:
193: // row 2
194: TextArea summary = getSummaryInformation(ipc, spc);
195: p.add(summary, gbc);
196:
197: //
198: DebugContext.message(getName()
199: + ": makeup(child, ipc, spc): Exit");
200: }
201:
202: private void makeup(Panel p) {
203: DebugContext.message(getName() + ": makeup(child): Entry");
204: p.setLayout(new GridBagLayout());
205:
206: if (getInstallLocation() == null) {
207: makeupError(p, GUI_ERROR, GUI_ERROR_INSTALL_LOCATION);
208: } else {
209: IdentityPropertyContext ipc = SRAWSWHelper
210: .getWSWIdentityPropertyContext(getWizardState());
211: SRAPropertyContext spc = SRAWSWHelper
212: .getWSWSRAPropertyContext(getWizardState());
213: makeup(p, ipc, spc);
214: }
215:
216: DebugContext.message(getName() + ": makeup(child): Exit");
217: }
218:
219: //
220: //
221: //
222: public void createUI() {
223: DebugContext.message(getName() + ": createUI: Entry");
224: super .createUI();
225:
226: main = new Panel(new FlowLayout(FlowLayout.CENTER,
227: DEFAULT_HORIZONTAL_GAP, DEFAULT_VERTICAL_GAP));
228: child = new Panel();
229: DebugContext.message(getName() + ": createUI: Exit");
230: }
231:
232: public void beginDisplay() {
233: DebugContext.message(getName() + ": beginDisplay: Entry");
234: super .beginDisplay();
235:
236: if (getTreeManager().hasGUI()) {
237: cleanup();
238:
239: makeup(child);
240:
241: main.add(child);
242: add(main);
243: }
244:
245: DebugContext.message(getName() + ": beginDisplay: Exit");
246: }
247:
248: public boolean isDisplayComplete() {
249: DebugContext.message(getName() + ": isDisplayComplete: Entry");
250: boolean isDisplayComplete = doAllowNextPress();
251:
252: //
253: if (isDisplayComplete) {
254: manageInstance();
255: }
256:
257: // Go back
258: if (isDisplayComplete) {
259: wswCleanup();
260: getTreeManager().warpToLeaf(getRootComponent().next());
261: }
262:
263: DebugContext.message(getName()
264: + ": isDisplayComplete: Exit; returning <"
265: + isDisplayComplete + ">");
266: return isDisplayComplete;
267: }
268:
269: public boolean skip() {
270: DebugContext.message(getName() + ": skip: Entry");
271: boolean skip = super .skip();
272: super .initializeRuntime();
273:
274: if (SRAWSWHelper.getWSWProxyType(getWizardState()) == null) {
275: skip = true;
276: }
277:
278: if (!skip) {
279: String action = SRAWSWHelper.getWSWAction(getWizardState());
280: if (action == null) {
281: skip = true;
282: }
283: }
284:
285: if (!skip) {
286: if (SRAWSWHelper.getWSWInstanceName(getWizardState()) == null)
287: skip = true;
288: }
289:
290: DebugContext.message(getName() + ": skip: Exit; returning <"
291: + skip + ">");
292: return skip;
293: }
294:
295: public void consoleInteraction() {
296: }
297:
298: //
299: //
300: //
301: public String getHelp(Object context) {
302: Object[] msgArgs = { getProductName() };
303: return wbResource.getString(getName() + "-Gui-OnlineHelp",
304: msgArgs);
305: }
306:
307: public void serialize(DataOutput out) {
308: super .serialize(out);
309: }
310:
311: public void deserialize(DataInput in) {
312: super .deserialize(in);
313: }
314:
315: public void addRuntimeResources(Vector v) {
316: super .addRuntimeResources(v);
317:
318: v.addElement("com.sun.portal.instance.sra.panel.SummaryPanel");
319: }
320:
321: //
322: //
323: //
324: private boolean doAllowNextPress() {
325: boolean result = true;
326:
327: String action = SRAWSWHelper.getWSWAction(getWizardState());
328: String rbKeySuffixVerifyMessage = null;
329: if (action.equals(GUI_ACTION_CREATE)) {
330: rbKeySuffixVerifyMessage = GUI_VERIFY_ACTION_CREATE;
331: } else if (action.equals(GUI_ACTION_MODIFY)) {
332: rbKeySuffixVerifyMessage = GUI_VERIFY_ACTION_MODIFY;
333: } else if (action.equals(GUI_ACTION_DELETE)) {
334: rbKeySuffixVerifyMessage = GUI_VERIFY_ACTION_DELETE;
335: }
336:
337: if (rbKeySuffixVerifyMessage != null) {
338: int buttonPress = showErrorDialog(getName()
339: + GUI_VERIFY_DIALOG_TITLE, getName()
340: + rbKeySuffixVerifyMessage, null,
341: new String[] {
342: wbResource.getString(getName()
343: + GUI_CONTINUE_BUTTON),
344: wbResource.getString(getName()
345: + GUI_CANCEL_BUTTON) });
346:
347: DebugContext.message(getName() + ": buttonPress <"
348: + buttonPress + ">");
349: if (buttonPress == 1) {
350: // Cancel pressed
351: result = false;
352: }
353: }
354:
355: return result;
356: }
357:
358: //
359: //
360: //
361: private Boolean createInstance() {
362: DebugContext.message(getName() + ": createInstance: Entry");
363: Boolean noError = Boolean.TRUE;
364: Instance i = getSRAInstance();
365:
366: noError = i.updateConfigurationFile(
367: getIdentityPropertyContext(), SRAWSWHelper
368: .getWSWSRAPropertyContext(getWizardState()),
369: getPropertiesHeader());
370: if (noError.booleanValue()) {
371: try {
372: i.create();
373: } catch (IOException ioe) {
374: ioe.printStackTrace();
375: noError = Boolean.FALSE;
376: }
377: }
378:
379: DebugContext.message(getName()
380: + ": createInstance: Exit; returning <"
381: + noError.toString() + ">");
382: return noError;
383: }
384:
385: private Boolean deleteInstance() {
386: DebugContext.message(getName() + ": deleteInstance: Entry");
387: Boolean noError = Boolean.TRUE;
388:
389: try {
390: noError = getSRAInstance().remove();
391: } catch (IOException ioe) {
392: ioe.printStackTrace();
393: noError = Boolean.FALSE;
394: }
395:
396: DebugContext.message(getName()
397: + ": deleteInstance: Exit; returning <"
398: + noError.toString() + ">");
399: return noError;
400: }
401:
402: private void manageInstance() {
403: Boolean noError = Boolean.TRUE;
404: String action = SRAWSWHelper.getWSWAction(getWizardState());
405:
406: if (action.equals(GUI_ACTION_CREATE)) {
407: noError = createInstance();
408: } else if (action.equals(GUI_ACTION_MODIFY)) {
409: noError = deleteInstance();
410: if (noError.booleanValue()) {
411: noError = createInstance();
412: }
413: } else if (action.equals(GUI_ACTION_DELETE)) {
414: noError = deleteInstance();
415: } else {
416: DebugContext.error(getName() + ": Action unknown <"
417: + action + ">");
418: }
419:
420: if (!noError.booleanValue()) {
421: showErrorDialog(getName() + GUI_ERROR_DIALOG_TITLE,
422: getName() + GUI_FATAL_ERROR, null, null);
423: }
424: }
425:
426: //
427: //
428: //
429: }
|