001: /**
002: * Copyright 2005 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */package com.sun.portal.admin.console.ubt.data;
013:
014: import com.sun.portal.admin.console.common.PSBaseBean;
015: import com.sun.portal.admin.common.util.AdminClientUtil;
016: import com.sun.portal.admin.common.util.AdminUtil;
017:
018: import javax.faces.context.FacesContext;
019: import javax.management.*;
020: import java.util.Map;
021: import java.util.LinkedList;
022: import java.util.Hashtable;
023: import java.util.Locale;
024: import java.io.IOException;
025:
026: import net.sf.jasperreports.engine.JasperPrint;
027:
028: /**
029: *
030: */
031: public class UBTViewUtility extends PSBaseBean {
032: public String getPortalID() {
033: return (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
034: }
035:
036: public static Object getSessionAttribute(String name) {
037: Map smap = FacesContext.getCurrentInstance()
038: .getExternalContext().getSessionMap();
039: if ((smap != null) && (!smap.isEmpty())) {
040: return smap.get(name);
041: }
042: return null;
043: }
044:
045: public ObjectName getUBTReportMBeanName()
046: throws MalformedObjectNameException {
047: LinkedList path = new LinkedList();
048: path.addFirst(AdminUtil.DEFAULT_DOMAIN);
049: path.addFirst(getPortalID());
050: path.addFirst("UBTReportAggregator");
051: return AdminClientUtil.getResourceMBeanObjectName(
052: "PortalDomain.Portal.UBTReportAggregator", path);
053: }
054:
055: public JasperPrint[] getGeneratedReport(String reportName)
056: throws MalformedObjectNameException, ReflectionException,
057: IOException, InstanceNotFoundException, MBeanException {
058: Object[] params = new Object[] { reportName, getClientLocale() };
059: String[] signature = { "java.lang.String", "java.util.Locale" };
060: return (JasperPrint[]) getMBeanServerConnection().invoke(
061: getUBTReportMBeanName(), "generateUBTReport", params,
062: signature);
063: }
064:
065: private Locale getClientLocale() {
066: return FacesContext.getCurrentInstance().getViewRoot()
067: .getLocale();
068: }
069:
070: public ObjectName getUBTSettingsMBeanName()
071: throws MalformedObjectNameException {
072: LinkedList path = new LinkedList();
073: path.addFirst(AdminUtil.DEFAULT_DOMAIN);
074: path.addFirst(getPortalID());
075: path.addFirst("UBTSettingsHostBridge");
076: return AdminClientUtil.getResourceMBeanObjectName(
077: "PortalDomain.Portal.UBTSettingsHostBridge", path);
078: }
079:
080: public Hashtable getUBTSettings(String instance)
081: throws MalformedObjectNameException, ReflectionException,
082: IOException, InstanceNotFoundException, MBeanException {
083: Object[] params = new Object[] { instance };
084: String[] signature = { "java.lang.String" };
085: return (Hashtable) getMBeanServerConnection().invoke(
086: getUBTSettingsMBeanName(), "getUBTSettings", params,
087: signature);
088: }
089:
090: public void setUBTSettings(Hashtable values, String instance)
091: throws MalformedObjectNameException, ReflectionException,
092: IOException, InstanceNotFoundException, MBeanException {
093: Object[] params = new Object[] { values, instance };
094: String[] signature = { "java.util.Hashtable",
095: "java.lang.String" };
096: getMBeanServerConnection().invoke(getUBTSettingsMBeanName(),
097: "setUBTSettings", params, signature);
098: }
099:
100: }
|