001: /**
002: * $Id: PSTabsBean.java,v 1.26 2007/01/26 03:47:20 portalbld Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.admin.console.common;
014:
015: import java.util.Collections;
016: import java.util.Set;
017: import java.util.LinkedList;
018: import java.util.logging.Level;
019:
020: import javax.faces.FactoryFinder;
021: import javax.faces.application.ApplicationFactory;
022: import javax.faces.context.FacesContext;
023: import javax.faces.el.EvaluationException;
024: import javax.faces.el.PropertyNotFoundException;
025: import javax.faces.el.ValueBinding;
026: import javax.management.ObjectName;
027: import javax.management.MBeanServerConnection;
028:
029: import com.sun.portal.admin.common.util.AdminClientUtil;
030: import com.sun.web.ui.component.Tab;
031: import com.sun.web.ui.component.TabSet;
032:
033: /**
034: *
035: */
036: public class PSTabsBean extends PSBaseBean {
037:
038: private TabSet topLevelTabs = null;
039:
040: private static String[][] topTabData = {
041: { "commonTasks", "#{common['tab.label.commonTasks']}",
042: "/faces/common/CommonTasks.jsp" },
043: { "portals", "#{common['tab.label.portals']}",
044: "/faces/fabric/PortalHome.jsp" },
045: { "searchServers", "#{common['tab.label.searchservers']}",
046: "/faces/search/SearchServersHome.jsp" },
047: { "sra", "#{common['tab.label.sra']}",
048: "/faces/sra/SRAHome.jsp" },
049: { "ssoadapter", "#{common['tab.label.ssoadapter']}",
050: "/faces/ssoa/SSOAHome.jsp" } };
051:
052: private TabSet portalTabs = null;
053:
054: private static String[][] portalTabData = {
055: { "desktop", "#{common['tab.label.desktop']}",
056: "/faces/desktop/DesktopHome.jsp" },
057: { "svr_instances",
058: "#{common['tab.label.server.instances']}",
059: "/faces/fabric/InstancesHome.jsp" },
060: { "wsrp", "#{common['tab.label.wsrp']}",
061: "/faces/wsrp/consumer/ConsumerHome.jsp" },
062: { "subscriptions", "#{common['tab.label.subscriptions']}",
063: "/faces/subscriptions/SubscriptionsHome.jsp" },
064: { "communities", "#{common['tab.label.communities']}",
065: "/faces/communities/CommunitiesHome.jsp" },
066: { "ubt", "#{common['tab.label.ubt']}",
067: "/faces/ubt/UBTReports.jsp" },
068: { "logging", "#{common['tab.label.logging']}",
069: "/faces/logging/LogViewer.jsp" },
070: { "status", "#{common['tab.label.status']}",
071: "/faces/monitoring/desktopStatistics/DesktopStatisticsHome.jsp" } };
072:
073: private static String[][] subscriptionsTabData = {
074: { "subscriptions_home",
075: "#{common['tab.label.subscriptions.home']}",
076: "/faces/subscriptions/SubscriptionsHome.jsp" },
077: {
078: "subscriptions_schedulingprofiler",
079: "#{common['tab.label.subscriptions.schedulingprofiler']}",
080: "/faces/subscriptions/SchedulingProfiler.jsp" } };
081:
082: private static String[][] wsrpTabData = {
083: { "consumer", "#{common['tab.label.consumer']}",
084: "/faces/wsrp/consumer/ConsumerHome.jsp" },
085: { "producer", "#{common['tab.label.producer']}",
086: "/faces/wsrp/producer/ProducerHome.jsp" } };
087:
088: private static String[][] ubtTabData = {
089: { "ubtreports", "#{common['tab.label.ubtreports']}",
090: "/faces/ubt/UBTReports.jsp" },
091: { "ubtsettings", "#{common['tab.label.ubtsettings']}",
092: "/faces/ubt/UBTSettings.jsp" } };
093:
094: private static String[][] loggingData = {
095: { "logviewer", "#{common['tab.label.logviewer']}",
096: "/faces/logging/LogViewer.jsp" },
097: { "commonloggersettings",
098: "#{common['tab.label.commonloggersettings']}",
099: "/faces/logging/CommonLoggerSettings.jsp" },
100: { "specificloggersettings",
101: "#{common['tab.label.specificloggersettings']}",
102: "/faces/logging/SpecificLoggerSettings.jsp" } };
103:
104: private static String[][] monitoringTabData = {
105: { "desktopStatistics",
106: "#{common['tab.label.desktop.statistics']}",
107: "/faces/monitoring/desktopStatistics/DesktopStatisticsHome.jsp" },
108: { "channelStatistics",
109: "#{common['tab.label.channel.statistics']}",
110: "/faces/monitoring/channelStatistics/ChannelActionStatisticsHome.jsp" },
111: { "settings", "#{common['tab.label.settings']}",
112: "/faces/monitoring/settings/SettingsHome.jsp" } };
113:
114: private TabSet searchTabs = null;
115:
116: private static String[][] searchTabData = {
117: { "serverhome", "#{common['tab.label.search.serverhome']}",
118: "/faces/search/ServerHome.jsp" },
119: { "robot", "#{common['tab.label.search.robot']}",
120: "/faces/search/RobotHome.jsp" },
121: { "databases", "#{common['tab.label.search.databases']}",
122: "/faces/search/DatabasesHome.jsp" },
123: { "categories", "#{common['tab.label.search.categories']}",
124: "/faces/search/CategoriesHome.jsp" },
125: { "scheduling", "#{common['tab.label.search.scheduling']}",
126: "/faces/search/SchedulingRobot.jsp" },
127: { "reports", "#{common['tab.label.search.reports']}",
128: "/faces/search/ReportLogsHome.jsp" } };
129:
130: private static String[][] searchRobotTabData = {
131: { "robot_overview",
132: "#{common['tab.label.search.robot.overview']}",
133: "/faces/search/RobotHome.jsp" },
134: { "robot_sites",
135: "#{common['tab.label.search.robot.sites']}",
136: "/faces/search/RobotSitesHome.jsp" },
137: { "robot_filters",
138: "#{common['tab.label.search.robot.filters']}",
139: "/faces/search/RobotFiltersHome.jsp" },
140: {
141: "robot_classificationrules",
142: "#{common['tab.label.search.robot.classificationrules']}",
143: "/faces/search/RobotClassificationRulesHome.jsp" },
144: { "robot_properties",
145: "#{common['tab.label.search.robot.properties']}",
146: "/faces/search/RobotPropertiesHome.jsp" },
147: { "robot_utilities",
148: "#{common['tab.label.search.robot.utilities']}",
149: "/faces/search/RobotUtilitiesHome.jsp" } };
150:
151: private static String[][] searchDatabaseTabData = {
152: {
153: "databases_management",
154: "#{common['tab.label.search.databases.management']}",
155: "/faces/search/DatabasesHome.jsp" },
156: {
157: "databases_importagents",
158: "#{common['tab.label.search.databases.importagents']}",
159: "/faces/search/DatabaseImportAgentsHome.jsp" },
160: { "databases_schemas",
161: "#{common['tab.label.search.databases.schemas']}",
162: "/faces/search/DatabaseSchemasHome.jsp" } };
163:
164: private static String[][] searchCategoryTabData = {
165: { "categories_home",
166: "#{common['tab.label.search.categories.home']}",
167: "/faces/search/CategoriesHome.jsp" },
168: {
169: "categories_autoclassify",
170: "#{common['tab.label.search.categories.autoclassify']}",
171: "/faces/search/CategoriesAutoclassifyHome.jsp" } };
172:
173: private static String[][] searchSchedulingTabData = {
174: { "scheduling_robot",
175: "#{common['tab.label.search.scheduling.robot']}",
176: "/faces/search/SchedulingRobot.jsp" },
177: {
178: "scheduling_importagents",
179: "#{common['tab.label.search.scheduling.importagents']}",
180: "/faces/search/SchedulingImportAgents.jsp" },
181: {
182: "scheduling_autoclassify",
183: "#{common['tab.label.search.scheduling.autoclassify']}",
184: "/faces/search/SchedulingAutoclassify.jsp" } };
185:
186: private static String[][] searchReportTabData = {
187: { "reports_logs",
188: "#{common['tab.label.search.reports.logs']}",
189: "/faces/search/ReportLogsHome.jsp" },
190: { "reports_robot",
191: "#{common['tab.label.search.reports.robot']}",
192: "/faces/search/ReportRobotHome.jsp" },
193: {
194: "reports_popularsearches",
195: "#{common['tab.label.search.reports.popularsearches']}",
196: "/faces/search/ReportPopularSearchesHome.jsp" },
197: {
198: "reports_excludedurls",
199: "#{common['tab.label.search.reports.excludedurls']}",
200: "/faces/search/ReportExcludedURLsHome.jsp" } };
201:
202: private TabSet sraTabs = new TabSet();
203:
204: private static String[][] sraTabData = {
205: { "profiles", "#{common['sra.tab.gateway.title']}",
206: "/faces/sra/SRAHome.jsp" },
207: { "netlet", "#{common['sra.tab.netlet.title']}",
208: "/faces/sra/netlet/Netlet.jsp" },
209: { "netfile", "#{common['sra.tab.netfile.title']}",
210: "/faces/sra/netfile/Netfile.jsp" },
211: { "access_list", "#{common['sra.tab.access_list.title']}",
212: "/faces/sra/accesslist/AccessList.jsp" },
213: { "proxylet", "#{common['sra.tab.proxylet.title']}",
214: "/faces/sra/proxylet/Proxylet.jsp" },
215: { "monitoring", "#{common['sra.tab.monitoring.title']}",
216: "/faces/sra/monitoring/Monitoring.jsp" },
217: { "logging", "#{common['sra.tab.logging.title']}",
218: "/faces/logging/SRALogViewer.jsp" },
219: { "manage_instance",
220: "#{common['sra.tab.manage_instance.title']}",
221: "/faces/sra/monitoring/Instances.jsp" },
222: { "rulesets", "#{common['sra.tab.rulesets.title']}",
223: "/faces/sra/ruleset/Ruleset.jsp" }
224:
225: };
226:
227: private static String[][] gatewayTabData = {
228: { "core", "#{gateway['core.title']}",
229: "/faces/sra/gateway/Gateway.jsp" },
230: { "deployment", "#{gateway['deployment.title']}",
231: "/faces/sra/gateway/Deployment.jsp" },
232: { "security", "#{gateway['security.title']}",
233: "/faces/sra/gateway/Security.jsp" },
234: { "performance", "#{gateway['performance.title']}",
235: "/faces/sra/gateway/Performance.jsp" },
236: { "rewriter", "#{gateway['rewriter.title']}",
237: "/faces/sra/gateway/Rewriter.jsp" } };
238:
239: public PSTabsBean() {
240: super ();
241: createTopLevelTabs();
242: createPortalTabs();
243: createSearchTabs();
244: }
245:
246: private String resolveTabLabel(String expr) {
247: String result = "";
248:
249: ApplicationFactory factory = (ApplicationFactory) FactoryFinder
250: .getFactory(FactoryFinder.APPLICATION_FACTORY);
251: ValueBinding vb = factory.getApplication().createValueBinding(
252: expr);
253: try {
254: result = (String) vb.getValue(FacesContext
255: .getCurrentInstance());
256: } catch (PropertyNotFoundException pnfe) {
257: log(Level.FINEST,
258: "PSTabsBean.resolveTabLabel(): Property not found, expr="
259: + expr, pnfe);
260: } catch (EvaluationException ee) {
261: log(Level.FINEST,
262: "PSTabsBean.resolveTabLabel(): Evaluation error, expr="
263: + expr, ee);
264: } catch (Exception e) {
265: log(Level.FINEST,
266: "PSTabsBean.resolveTabLabel(): Exception, expr="
267: + expr, e);
268: }
269: return result;
270: }
271:
272: private Tab addTab(Tab parent, String[] tdata) {
273: Tab tab = new Tab();
274: tab.setId(tdata[0]);
275: tab.setText(resolveTabLabel(tdata[1]));
276: if ((tdata[2] != null) && (tdata[2] != "")) {
277: tab.setUrl(tdata[2]);
278: }
279:
280: if (parent != null) {
281: parent.getChildren().add(tab);
282: }
283: return tab;
284: }
285:
286: private void createTopLevelTabs() {
287: this .topLevelTabs = new TabSet();
288: for (int i = 0; i < 5; i++) {
289: String[] tabData = topTabData[i];
290: boolean showThisToplevelTab = true;
291:
292: if (tabData[0].trim().equalsIgnoreCase("sra")
293: && !isSraEnabledForThisDomain()) {
294: showThisToplevelTab = false;
295: }
296: if (showThisToplevelTab) {
297: Tab t = addTab(null, tabData);
298: topLevelTabs.getChildren().add(t);
299: }
300: }
301: }
302:
303: /**
304: * @return will return true if any of the SRA Mbeans are found to be running
305: * for this domain ..
306: */
307: private boolean isSraInstalledForThisDomain() {
308: boolean sraInstalled = true;
309: ObjectName pattern = null;
310: try {
311: pattern = AdminClientUtil.getResourcesPattern(
312: AdminClientUtil.SRA_MBEAN_TYPE, Collections
313: .singletonList(getDomain()));
314: Set querySet = getMBeanServerConnection().queryMBeans(
315: pattern, null);
316: if (querySet.isEmpty())
317: sraInstalled = false;
318: } catch (Exception e) {
319: log(
320: Level.SEVERE,
321: "PSTabsBean.isSraInstalledForThisDomain(): Could not query MBean server for sra installation",
322: e);
323: }
324:
325: /*if (sraInstalled )
326: createSraTabs(); */
327:
328: return sraInstalled;
329: }
330:
331: /**
332: * @return will return true if any of the SRA Mbeans are found to be enabled
333: * for this domain ..
334: */
335: private boolean isSraEnabledForThisDomain() {
336: boolean sraEnabled = false;
337: ObjectName pattern = null;
338: try {
339: LinkedList path = new LinkedList();
340: path.addFirst(getDomain());
341: path.addFirst("sra");
342: ObjectName mBeanName = AdminClientUtil
343: .getResourceMBeanObjectName(
344: AdminClientUtil.SRA_MBEAN_TYPE, path);
345: MBeanServerConnection mBeanServerConnection = getMBeanServerConnection();
346: String sraStatus = (String) mBeanServerConnection.invoke(
347: mBeanName, "retrieveSRAStatus", null, null);
348: if (sraStatus.equalsIgnoreCase("on"))
349: sraEnabled = true;
350: else if (sraStatus.equalsIgnoreCase("off"))
351: sraEnabled = false;
352: else
353: sraEnabled = false;
354: } catch (Exception e) {
355: log(
356: Level.SEVERE,
357: "PSTabsBean.isSraEnabledForThisDomain(): Could not query MBean server for sra enable",
358: e);
359: }
360: if (sraEnabled) {
361: createSraTabs();
362: }
363: return sraEnabled;
364:
365: }
366:
367: private void createSraTabs() {
368: sraTabs.setMini(false);
369: for (int i = 0; i < sraTabData.length; i++) {
370: Tab t = addTab(null, sraTabData[i]);
371: sraTabs.getChildren().add(t);
372: }
373: }
374:
375: private void createPortalTabs() {
376: this .portalTabs = new TabSet();
377:
378: // Add the Desktop tab
379: Tab t = addTab(null, portalTabData[0]);
380: portalTabs.getChildren().add(t);
381:
382: // Add the Server Instance tab
383: t = addTab(null, portalTabData[1]);
384: portalTabs.getChildren().add(t);
385:
386: // Add the wsrp tab & children
387: t = addTab(null, portalTabData[2]);
388: portalTabs.getChildren().add(t);
389: addTab(t, wsrpTabData[0]);
390: addTab(t, wsrpTabData[1]);
391:
392: // Add the Subscription tab & children
393: t = addTab(null, portalTabData[3]);
394: portalTabs.getChildren().add(t);
395: addTab(t, subscriptionsTabData[0]);
396: addTab(t, subscriptionsTabData[1]);
397:
398: // Add the Community tab
399: t = addTab(null, portalTabData[4]);
400: portalTabs.getChildren().add(t);
401:
402: // Add the ubt tab & children
403: t = addTab(null, portalTabData[5]);
404: portalTabs.getChildren().add(t);
405: addTab(t, ubtTabData[0]);
406: addTab(t, ubtTabData[1]);
407:
408: // Add the logging tab & children
409: t = addTab(null, portalTabData[6]);
410: portalTabs.getChildren().add(t);
411: addTab(t, loggingData[0]);
412: addTab(t, loggingData[1]);
413: addTab(t, loggingData[2]);
414:
415: // Add the monitoring tab & children
416: t = addTab(null, portalTabData[7]);
417: portalTabs.getChildren().add(t);
418: addTab(t, monitoringTabData[0]);
419: addTab(t, monitoringTabData[1]);
420: addTab(t, monitoringTabData[2]);
421: }
422:
423: private void createSearchTabs() {
424: this .searchTabs = new TabSet();
425:
426: Tab t = addTab(null, searchTabData[0]);
427: searchTabs.getChildren().add(t);
428:
429: t = addTab(null, searchTabData[1]);
430: searchTabs.getChildren().add(t);
431: addTab(t, searchRobotTabData[0]);
432: addTab(t, searchRobotTabData[1]);
433: addTab(t, searchRobotTabData[2]);
434: addTab(t, searchRobotTabData[3]);
435: addTab(t, searchRobotTabData[4]);
436: addTab(t, searchRobotTabData[5]);
437:
438: t = addTab(null, searchTabData[2]);
439: searchTabs.getChildren().add(t);
440: addTab(t, searchDatabaseTabData[0]);
441: addTab(t, searchDatabaseTabData[1]);
442: addTab(t, searchDatabaseTabData[2]);
443:
444: t = addTab(null, searchTabData[3]);
445: searchTabs.getChildren().add(t);
446: addTab(t, searchCategoryTabData[0]);
447: addTab(t, searchCategoryTabData[1]);
448:
449: t = addTab(null, searchTabData[4]);
450: searchTabs.getChildren().add(t);
451: addTab(t, searchSchedulingTabData[0]);
452: addTab(t, searchSchedulingTabData[1]);
453: addTab(t, searchSchedulingTabData[2]);
454:
455: t = addTab(null, searchTabData[5]);
456: searchTabs.getChildren().add(t);
457: addTab(t, searchReportTabData[0]);
458: addTab(t, searchReportTabData[1]);
459: addTab(t, searchReportTabData[2]);
460: addTab(t, searchReportTabData[3]);
461: }
462:
463: public TabSet getTopLevelTabs() {
464: return this .topLevelTabs;
465: }
466:
467: public void setTopLevelTabs(TabSet tabs) {
468: this .topLevelTabs = tabs;
469: }
470:
471: public TabSet getPortalTabs() {
472: return this .portalTabs;
473: }
474:
475: public void setPortalTabs(TabSet tabs) {
476: this .portalTabs = tabs;
477: }
478:
479: public TabSet getSearchTabs() {
480: return this .searchTabs;
481: }
482:
483: public void setSearchTabs(TabSet tabs) {
484: this .searchTabs = tabs;
485: }
486:
487: public TabSet getSraTabs() {
488: return sraTabs;
489: }
490:
491: public void setSraTabs(TabSet tabs) {
492: sraTabs = tabs;
493: }
494:
495: }
|