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.SRAFileContext;
013: import com.sun.portal.config.context.SRAPropertyContext;
014: import com.sun.portal.instance.common.ui.HeaderPanel;
015: import com.sun.portal.instance.sra.Instance;
016: import com.sun.portal.instance.sra.common.SRAInstanceFactory;
017: import com.sun.portal.instance.sra.common.SRAWSWHelper;
018: import com.sun.setup.panels.common.SetupSDKPanelBase;
019: import com.sun.setup.panels.common.wbDialog;
020: import com.sun.setup.util.wbResource;
021: import com.sun.wizards.core.Route;
022: import com.sun.wizards.core.WizardState;
023: import com.sun.wizards.core.WizardTreeManager;
024:
025: import java.awt.*;
026: import java.io.IOException;
027: import java.util.Vector;
028:
029: //
030:
031: /*
032: * Add only AWT specific utilities.
033: */
034: public abstract class Base extends SetupSDKPanelBase {
035: //
036: //
037: //
038: protected static final String DASH_GUI = "-Gui";
039: protected static final String GUI_ACTION = DASH_GUI + "-Action";
040: protected static final String GUI_ACTION_CREATE = GUI_ACTION
041: + "-Create";
042: protected static final String GUI_ACTION_DELETE = GUI_ACTION
043: + "-Delete";
044: protected static final String GUI_ACTION_MODIFY = GUI_ACTION
045: + "-Modify";
046: protected static final String GUI_ACTION_PROPERTIES = GUI_ACTION
047: + "-Properties";
048:
049: protected static final String GUI_ERROR = DASH_GUI + "-Error";
050: protected static final String PROPERTY_INSTALL_LOCATION = "installLocation";
051: protected static final String GUI_ERROR_INSTALL_LOCATION = GUI_ERROR
052: + "-Install-Location-Not-Specified";
053: protected static final String GUI_ERROR_NOT_INSTALLED = GUI_ERROR
054: + "-Not-Installed";
055: protected static final String GUI_ERROR_INPUT_EMPTY = GUI_ERROR
056: + "-Input-Empty";
057:
058: protected static final String GUI_YES = DASH_GUI + "-Yes";
059:
060: protected static final String GUI_PROMPT_KEY_SUFFIX = DASH_GUI
061: + "-Prompt";
062:
063: //
064: protected static final char PASSWORD_ECHO_CHAR = '*';
065: protected static final String EMPTY_STRING = "";
066:
067: protected static final String PROPERTIES_HEADER_GATEWAY = "S1PS:SRA Gateway Configuration Properties";
068: protected static final String PROPERTIES_HEADER_REWRITER_PROXY = "S1PS:SRA Rewriter Proxy Configuration Properties";
069: protected static final String PROPERTIES_HEADER_NETLET_PROXY = "S1PS:SRA Netlet Proxy Configuration Properties";
070:
071: //
072: //
073: //
074: protected static final int DEFAULT_EDIT_COLUMNS = 25;
075: protected static final int DEFAULT_NON_EDIT_COLUMNS = 50;
076:
077: protected static final int DEFAULT_HORIZONTAL_GAP = 0;
078: protected static final int DEFAULT_VERTICAL_GAP = 0;
079:
080: //
081: //
082: //
083: protected transient Panel main = null;
084: protected transient Panel child = null;
085:
086: //
087: //
088: //
089: public Base() {
090: }
091:
092: public Base(WizardState wizardState, String name) {
093: super (wizardState, name);
094: }
095:
096: public Base(String name, Route route,
097: WizardTreeManager wizardManager) {
098: super (name, route, wizardManager);
099: }
100:
101: //
102: //
103: //
104: protected static final int DEFAULT_INSETS_TOP = 2;
105: protected static final int DEFAULT_INSETS_LEFT = 2;
106: protected static final int DEFAULT_INSETS_BOTTOM = 2;
107: protected static final int DEFAULT_INSETS_RIGHT = 2;
108:
109: public Insets getDefaultInsets() {
110: return new Insets(DEFAULT_INSETS_TOP, DEFAULT_INSETS_LEFT,
111: DEFAULT_INSETS_BOTTOM, DEFAULT_INSETS_RIGHT);
112: }
113:
114: //
115: //
116: //
117: protected Label makeLabel(String rbKey) {
118: return new Label(wbResource.getString(rbKey), Label.RIGHT);
119: }
120:
121: protected Label makeLabel(String rbKey, Object[] rbArgs) {
122: return new Label(wbResource.getString(rbKey, rbArgs),
123: Label.RIGHT);
124: }
125:
126: protected TextArea makeTextArea(String rbKey) {
127: String text = wbResource.getString(rbKey);
128: int rows = text.length() / DEFAULT_NON_EDIT_COLUMNS;
129: TextArea result = new TextArea(text, rows + 1,
130: DEFAULT_NON_EDIT_COLUMNS, TextArea.SCROLLBARS_NONE);
131: result.setEditable(false);
132: return result;
133: }
134:
135: protected void makeupError(Panel p, String ePromptKey,
136: String eMessageKey) {
137: add(p, makeLabel(ePromptKey));
138: add(p, makeTextArea(eMessageKey));
139:
140: wswCleanup();
141: }
142:
143: protected Component makeupErrorPanel(String rbErrorKey,
144: Object[] rbErrorArgs) {
145: HeaderPanel header = new HeaderPanel();
146: header.add(makeLabel(rbErrorKey, rbErrorArgs));
147: return header;
148: }
149:
150: protected void add(Container container, Component c, int anchor) {
151: GridBagConstraints gbc = new GridBagConstraints();
152: gbc.insets = new Insets(DEFAULT_INSETS_TOP,
153: DEFAULT_INSETS_LEFT, DEFAULT_INSETS_BOTTOM,
154: DEFAULT_INSETS_RIGHT);
155: gbc.anchor = anchor;
156:
157: container.add(c, gbc);
158: }
159:
160: protected void add(Container container, Component c) {
161: add(container, c, GridBagConstraints.CENTER);
162: }
163:
164: protected void cleanup() {
165: child.removeAll();
166: main.removeAll();
167: }
168:
169: protected int showErrorDialog(String rbTitle, String rbError,
170: Object[] errorArgs, String[] buttonLabels) {
171: wbDialog error = new wbDialog(getFrame(), wbResource
172: .getString(rbTitle), makeupErrorPanel(rbError,
173: errorArgs), buttonLabels, true);
174: error.showDialog(true);
175:
176: return error.getPressedButton();
177: }
178:
179: //
180: //
181: // Calling this may prove fatal!
182: protected void wswCleanup() {
183: SRAWSWHelper.setWSWAction(getWizardState(), null);
184: SRAWSWHelper.setWSWInstanceName(getWizardState(), null);
185: SRAWSWHelper.setWSWIdentityPropertyContext(getWizardState(),
186: null);
187: SRAWSWHelper.setWSWSRAPropertyContext(getWizardState(), null);
188: SRAWSWHelper.setWSWSRAFileContext(getWizardState(), null);
189:
190: SRAWSWHelper.setWSWCanBeConfigured(getWizardState(),
191: Boolean.FALSE);
192: }
193:
194: protected boolean canProceedToManage() {
195: return SRAWSWHelper.getWSWCanBeConfigured(getWizardState())
196: .booleanValue();
197: }
198:
199: //
200: //
201: //
202: protected String getInstallLocation() {
203: return System.getProperty(PROPERTY_INSTALL_LOCATION);
204: }
205:
206: //
207: //
208: //
209: protected String[] getGatewayInstanceNames() {
210: String[] result = null;
211:
212: String installLocation = getInstallLocation();
213: if (installLocation != null) {
214: Instance i = SRAInstanceFactory.getInstance(
215: SRAWSWHelper.PROXY_TYPE_GW, installLocation);
216: SRAWSWHelper.setWSWInstanceGWObject(getWizardState(), i);
217: try {
218: result = i.list();
219: } catch (IOException ioe) {
220: ioe.printStackTrace();
221: DebugContext
222: .message("Install location <"
223: + installLocation
224: + "> did not have GWConfig.properties."
225: + " Assuming no Gateway instances present at this install location currently.");
226: }
227: }
228:
229: return result;
230: }
231:
232: protected String[] getRewriterProxyInstanceNames() {
233: String[] result = null;
234:
235: String installLocation = getInstallLocation();
236: if (installLocation != null) {
237: Instance i = SRAInstanceFactory.getInstance(
238: SRAWSWHelper.PROXY_TYPE_RWP, installLocation);
239: SRAWSWHelper.setWSWInstanceRWPObject(getWizardState(), i);
240: try {
241: result = i.list();
242: } catch (IOException ioe) {
243: ioe.printStackTrace();
244: DebugContext
245: .message("Install location <"
246: + installLocation
247: + "> did not have RWPConfig.properties."
248: + " Assuming no Rewriter Proxy instances present at this install location currently.");
249: }
250: }
251:
252: return result;
253: }
254:
255: protected String[] getNetletProxyInstanceNames() {
256: String[] result = null;
257:
258: String installLocation = getInstallLocation();
259: if (installLocation != null) {
260: Instance i = SRAInstanceFactory.getInstance(
261: SRAWSWHelper.PROXY_TYPE_NLP, installLocation);
262: SRAWSWHelper.setWSWInstanceNLPObject(getWizardState(), i);
263: try {
264: result = i.list();
265: } catch (IOException ioe) {
266: ioe.printStackTrace();
267: DebugContext
268: .message("Install location <"
269: + installLocation
270: + "> did not have NLPConfig.properties."
271: + " Assuming no Netlet Proxy instances present at this install location currently.");
272: }
273: }
274:
275: return result;
276: }
277:
278: protected String[] getInstanceNames() {
279: if (SRAWSWHelper.getWSWProxyType(getWizardState()).equals(
280: SRAWSWHelper.PROXY_TYPE_GW)) {
281: return getGatewayInstanceNames();
282: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
283: .equals(SRAWSWHelper.PROXY_TYPE_RWP)) {
284: return getRewriterProxyInstanceNames();
285: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
286: .equals(SRAWSWHelper.PROXY_TYPE_NLP)) {
287: return getNetletProxyInstanceNames();
288: }
289:
290: DebugContext.error(getName() + ": No proxy type set!");
291: return null;
292: }
293:
294: protected Boolean existsInstance(SRAFileContext fc,
295: String instanceName) {
296: if (SRAWSWHelper.getWSWProxyType(getWizardState()).equals(
297: SRAWSWHelper.PROXY_TYPE_GW)) {
298: return fc.existsGWInstance(instanceName);
299: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
300: .equals(SRAWSWHelper.PROXY_TYPE_RWP)) {
301: return fc.existsRWPInstance(instanceName);
302: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
303: .equals(SRAWSWHelper.PROXY_TYPE_NLP)) {
304: return fc.existsNLPInstance(instanceName);
305: }
306:
307: DebugContext.error(getName() + ": No proxy type set!");
308: return Boolean.TRUE;
309: }
310:
311: //
312: //
313: //
314: protected Instance getSRAInstance() {
315: String proxyType = SRAWSWHelper
316: .getWSWProxyType(getWizardState());
317: if (proxyType.equals(SRAWSWHelper.PROXY_TYPE_GW)) {
318: return SRAWSWHelper
319: .getWSWInstanceGWObject(getWizardState());
320: } else if (proxyType.equals(SRAWSWHelper.PROXY_TYPE_RWP)) {
321: return SRAWSWHelper
322: .getWSWInstanceRWPObject(getWizardState());
323: } else if (proxyType.equals(SRAWSWHelper.PROXY_TYPE_NLP)) {
324: return SRAWSWHelper
325: .getWSWInstanceNLPObject(getWizardState());
326: }
327:
328: DebugContext.error(getName() + ": No proxy type set!");
329: return null;
330: }
331:
332: protected SRAPropertyContext getSRAPropertyContext() {
333: SRAPropertyContext result = null;
334:
335: Instance i = getSRAInstance();
336: String instanceName = SRAWSWHelper
337: .getWSWInstanceName(getWizardState());
338: i.setName(instanceName);
339: result = i.getSRAPropertyContext();
340:
341: return result;
342: }
343:
344: protected SRAFileContext getSRAFileContext() {
345: SRAFileContext result = null;
346:
347: Instance i = getSRAInstance();
348: String instanceName = SRAWSWHelper
349: .getWSWInstanceName(getWizardState());
350: i.setName(instanceName);
351: result = i.getSRAFileContext();
352:
353: return result;
354: }
355:
356: protected IdentityPropertyContext getIdentityPropertyContext() {
357: IdentityPropertyContext result = null;
358: SRAFileContext sfc = getSRAFileContext();
359:
360: try {
361: result = sfc.getIdentityPropertyContext();
362: } catch (IOException ioe) {
363: ioe.printStackTrace();
364: DebugContext
365: .error(getName()
366: + ": Could not get Identity Server configuration file");
367: DebugContext.error(getName()
368: + ": Assuming Identity Server not installed");
369: }
370:
371: return result;
372: }
373:
374: protected String getPropertiesHeader() {
375: if (SRAWSWHelper.getWSWProxyType(getWizardState()).equals(
376: SRAWSWHelper.PROXY_TYPE_GW)) {
377: return PROPERTIES_HEADER_GATEWAY;
378: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
379: .equals(SRAWSWHelper.PROXY_TYPE_RWP)) {
380: return PROPERTIES_HEADER_REWRITER_PROXY;
381: } else if (SRAWSWHelper.getWSWProxyType(getWizardState())
382: .equals(SRAWSWHelper.PROXY_TYPE_NLP)) {
383: return PROPERTIES_HEADER_NETLET_PROXY;
384: }
385:
386: DebugContext.error(getName() + ": No proxy type set!");
387: return null;
388: }
389:
390: protected boolean isConfigurationEditable() {
391: DebugContext.message(getName()
392: + ": isConfigurationEditable: Entry");
393: boolean result = true;
394: String action = SRAWSWHelper.getWSWAction(getWizardState());
395:
396: if ((action.equals(GUI_ACTION_PROPERTIES))
397: || (action.equals(GUI_ACTION_DELETE))) {
398: result = false;
399: }
400:
401: DebugContext.message(getName()
402: + ": isConfigurationEditable: Exit; returning <"
403: + result + ">");
404: return result;
405: }
406:
407: //
408: //
409: //
410: public void addRuntimeResources(Vector v) {
411: super .addRuntimeResources(v);
412:
413: v.addElement("com.sun.setup.util.Debug");
414: v.addElement("com.sun.setup.panels.common.wbDialog");
415:
416: v
417: .addElement("com.sun.portal.config.context.ConfigurationFileFilter");
418: v.addElement("com.sun.portal.config.context.DebugContext");
419: v.addElement("com.sun.portal.config.context.GWPropertyContext");
420: v
421: .addElement("com.sun.portal.config.context.GWWindowsFileContext");
422: v
423: .addElement("com.sun.portal.config.context.IdentityPropertyContext");
424: v
425: .addElement("com.sun.portal.config.context.IdentityPropertyContextImpl");
426: v
427: .addElement("com.sun.portal.config.context.NLPPropertyContext");
428: v
429: .addElement("com.sun.portal.config.context.NLPWindowsFileContext");
430: v
431: .addElement("com.sun.portal.config.context.RWPPropertyContext");
432: v
433: .addElement("com.sun.portal.config.context.RWPWindowsFileContext");
434: v.addElement("com.sun.portal.config.context.SRAFileContext");
435: v
436: .addElement("com.sun.portal.config.context.SRAFileContextFactory");
437: v
438: .addElement("com.sun.portal.config.context.SRAPropertyContext");
439: v
440: .addElement("com.sun.portal.config.context.SRAPropertyContextImpl");
441: v
442: .addElement("com.sun.portal.config.context.SRAWindowsFileContext");
443: v.addElement("com.sun.portal.config.tasks.GWTasks");
444: v.addElement("com.sun.portal.config.tasks.GWTasksImpl");
445: v.addElement("com.sun.portal.config.tasks.GWWindowsTasks");
446: v.addElement("com.sun.portal.config.tasks.NLPTasks");
447: v.addElement("com.sun.portal.config.tasks.NLPTasksImpl");
448: v.addElement("com.sun.portal.config.tasks.NLPWindowsTasks");
449: v.addElement("com.sun.portal.config.tasks.RWPTasks");
450: v.addElement("com.sun.portal.config.tasks.RWPTasksImpl");
451: v.addElement("com.sun.portal.config.tasks.RWPWindowsTasks");
452: v.addElement("com.sun.portal.config.tasks.ProcessStreamReader");
453: v.addElement("com.sun.portal.config.tasks.SRATasks");
454: v.addElement("com.sun.portal.config.tasks.SRATasksImpl");
455: v.addElement("com.sun.portal.config.tasks.SRATasksFactory");
456: v.addElement("com.sun.portal.config.tasks.SRAWindowsTasks");
457: v.addElement("com.sun.portal.config.tasks.Tasks");
458: v.addElement("com.sun.portal.config.tasks.TasksImpl");
459:
460: v.addElement("com.sun.portal.instance.sra.Instance");
461: v
462: .addElement("com.sun.portal.instance.common.listener.ButtonClickHandler");
463: v
464: .addElement("com.sun.portal.instance.common.listener.ButtonListener");
465: v
466: .addElement("com.sun.portal.instance.common.listener.ChoiceListener");
467: v
468: .addElement("com.sun.portal.instance.common.listener.TextFieldListener");
469: v.addElement("com.sun.portal.instance.common.ui.Box");
470: v.addElement("com.sun.portal.instance.common.ui.FooterPanel");
471: v.addElement("com.sun.portal.instance.common.ui.HeaderPanel");
472: v.addElement("com.sun.portal.instance.common.ui.Separator");
473: v
474: .addElement("com.sun.portal.instance.sra.common.GatewayInstance");
475: v
476: .addElement("com.sun.portal.instance.sra.common.NetletProxyInstance");
477: v
478: .addElement("com.sun.portal.instance.sra.common.RewriterProxyInstance");
479: v.addElement("com.sun.portal.instance.sra.common.SRAInstance");
480: v
481: .addElement("com.sun.portal.instance.sra.common.SRAInstanceFactory");
482: v.addElement("com.sun.portal.instance.sra.common.SRAWSWHelper");
483: v.addElement("com.sun.portal.instance.sra.panel.Base");
484: }
485:
486: //
487: //
488: //
489: }
|