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.search;
013:
014: import java.util.*;
015: import java.util.logging.Level;
016: import java.lang.*;
017: import java.io.*;
018:
019: import javax.faces.context.FacesContext;
020: import javax.faces.application.FacesMessage;
021: import javax.faces.component.UIComponent;
022: import javax.faces.validator.*;
023: import javax.faces.el.ValueBinding;
024: import javax.servlet.http.HttpServletRequest;
025: import javax.management.*;
026:
027: import com.sun.web.ui.model.*;
028: import com.sun.web.ui.event.*;
029: import com.sun.web.ui.component.*;
030:
031: import com.sun.data.provider.*;
032: import com.sun.data.provider.impl.ObjectListDataProvider;
033:
034: import com.sun.cacao.agent.JmxClient;
035:
036: import com.sun.portal.admin.common.util.AdminClientUtil;
037: import com.sun.portal.admin.console.common.PSBaseBean;
038:
039: public class LogsBean extends PSBaseBean {
040:
041: private String log = null;
042: private String lines = null;
043: private String text = null;
044:
045: public LogsBean() {
046: log = "";
047: lines = "25";
048: text = "";
049: }
050:
051: public Option[] getAvailableLogs() {
052: Option[] options = new Option[7];
053: options[0] = new Option("", getLocalizedString("search",
054: "search.general.select"));
055: options[1] = new Option("filter", getLocalizedString("search",
056: "search.logs.filter"));
057: options[2] = new Option("rdmanager", getLocalizedString(
058: "search", "search.logs.rdmanager"));
059: options[3] = new Option("rdm", getLocalizedString("search",
060: "search.logs.rdm"));
061: options[4] = new Option("rdmserver", getLocalizedString(
062: "search", "search.logs.rdmserver"));
063: options[5] = new Option("robot", getLocalizedString("search",
064: "search.logs.robot"));
065: options[6] = new Option("searchengine", getLocalizedString(
066: "search", "search.logs.searchengine"));
067: return options;
068: }
069:
070: public String getLog() {
071: return log;
072: }
073:
074: public void setLog(String log) {
075: this .log = log;
076: }
077:
078: public String getLines() {
079: return lines;
080: }
081:
082: public void setLines(String lines) {
083: this .lines = lines;
084: }
085:
086: public String getLogText() {
087: return text;
088: }
089:
090: public boolean isShowing() {
091: if (log.equals("")) {
092: return false;
093: } else {
094: return true;
095: }
096: }
097:
098: public void validate(FacesContext fc, UIComponent component,
099: Object value) throws ValidatorException {
100: String id = component.getId();
101: if (id.equals("log")) {
102: } else if (id.equals("lines")) {
103: if (!Validators.isNumber((String) value, true)) {
104: throw new ValidatorException(new FacesMessage(
105: FacesMessage.SEVERITY_ERROR,
106: getLocalizedString("search",
107: "search.error.error"),
108: getLocalizedString("search",
109: "search.error.positivenumber")));
110: }
111: }
112: }
113:
114: public String show() {
115: try {
116: LinkedList path = new LinkedList();
117: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
118: path
119: .addFirst((String) getSessionAttribute("search.server.selected"));
120: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
121: AdminClientUtil.SEARCHSERVER_MBEAN_TYPE, path);
122:
123: Object[] params = { log, new Integer(lines) };
124: String[] signatures = { "java.lang.String",
125: "java.lang.Integer" };
126: String result = (String) getMBeanServerConnection().invoke(
127: on, "getReport", params, signatures);
128: text = result.replaceAll("<", "<").replaceAll(">",
129: ">").replaceAll("\n", "<BR>");
130: } catch (Exception e) {
131: log(Level.SEVERE, "LogsBean.show() : Exception", e);
132: }
133: return null;
134: }
135:
136: }
|