01: /**
02: * Copyright 2004 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: * <p/>
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */package com.sun.portal.admin.console.logging.bean;
13:
14: import com.sun.portal.admin.console.logging.data.LoggingResourceBundle;
15: import com.sun.portal.admin.console.sra.SraBaseBean;
16: import com.sun.portal.admin.console.sra.monitoring.SRAProxiesBean;
17: import com.sun.web.ui.model.Option;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: public class SRAInstancesDropDownOptionsBean extends SraBaseBean {
23:
24: List instanceList = new ArrayList();
25: public static final String FOUR_SPACES = " ";
26: public static String INSTANCE_HEADER = "sra.instance.rowgroup.header";
27: public static final String INSTANCE_SELECT_OPTION = "common.instances.select.option";
28: private String on;
29:
30: public SRAInstancesDropDownOptionsBean() {
31: super (GATEWAY_SVC, new String[0]);
32: String onValue = LoggingResourceBundle
33: .getProperty(LoggingUIConstants.ON_STRING_VALUE);
34: on = " " + onValue + " ";
35: try {
36: init();
37: } catch (Exception e) {
38: e.printStackTrace();
39: }
40: }
41:
42: public void initData() {
43:
44: }
45:
46: public void init() {
47:
48: List profiles = new SRAProxiesBean().getProfiles();
49: instanceList.add(new Option(LoggingResourceBundle
50: .getProperty(INSTANCE_SELECT_OPTION),
51: LoggingResourceBundle
52: .getProperty(INSTANCE_SELECT_OPTION)));
53: for (int i = 0; i < profiles.size(); i++) {
54: SRAProxiesBean.Profile profile = (SRAProxiesBean.Profile) profiles
55: .get(i);
56: String profileName = profile.getName();
57: instanceList.add(new Option(profileName,
58: LoggingResourceBundle.getProperty(INSTANCE_HEADER)
59: + profileName, profileName, true));
60:
61: List instances = profile.getInstancesList();
62: for (int j = 0; j < instances.size(); j++) {
63: SRAProxiesBean.SRAInstance sraInstance = (SRAProxiesBean.SRAInstance) instances
64: .get(j);
65:
66: String value = profileName + ":"
67: + sraInstance.getTypeShort() + ":"
68: + sraInstance.getHostName();
69: String label = sraInstance.getType() + on
70: + sraInstance.getHostName();
71: instanceList.add(new Option(value, FOUR_SPACES + label,
72: "", false));
73: }
74: }
75: }
76:
77: List getInstanceNames() {
78: List instances = new ArrayList();
79: String value;
80: for (int i = 0; i < instanceList.size(); i++) {
81: value = (String) ((Option) instanceList.get(i)).getValue();
82: if (value.indexOf(":") != -1) // the value that contains : has the component,hostname and instance
83: instances.add(value);
84: }
85: return instances;
86: }
87:
88: public Option[] getInstances() {
89: return (Option[]) instanceList.toArray(new Option[0]);
90: }
91:
92: public void setInstances(Option[] listItems) {
93: }
94:
95: }
|