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: import java.text.*;
019:
020: import javax.faces.context.FacesContext;
021: import javax.faces.el.ValueBinding;
022: import javax.servlet.http.HttpServletRequest;
023: import javax.management.*;
024:
025: import com.sun.web.ui.model.*;
026:
027: import com.sun.data.provider.*;
028: import com.sun.data.provider.impl.ObjectListDataProvider;
029:
030: import com.sun.cacao.agent.JmxClient;
031:
032: import com.sun.portal.admin.common.util.AdminClientUtil;
033: import com.sun.portal.admin.console.common.PSBaseBean;
034:
035: public class ExcludedURLsBean extends PSBaseBean {
036:
037: private String date = null;
038: private ObjectListDataProvider excludedURLs = null;
039: private String reasonSummary = null;
040: private String reasons = null;
041:
042: public ExcludedURLsBean() {
043: date = "";
044: }
045:
046: public Option[] getAvailableDates() {
047: ArrayList al = new ArrayList();
048:
049: try {
050: LinkedList path = new LinkedList();
051: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
052: path
053: .addFirst((String) getSessionAttribute("search.server.selected"));
054: path.addFirst("robot");
055: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
056: AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
057:
058: Object[] params = {};
059: String[] signatures = {};
060: al = (ArrayList) getMBeanServerConnection().invoke(on,
061: "retrieveExcludedURLsReportDates", params,
062: signatures);
063: } catch (Exception e) {
064: log(
065: Level.SEVERE,
066: "ExcludedURLsBean.getAvailableDates() : Exception ",
067: e);
068: }
069:
070: Option[] options = new Option[al.size() + 1];
071: options[0] = new Option("", getLocalizedString("search",
072: "search.general.select"));
073:
074: DateFormat df1 = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",
075: Locale.US);
076: DateFormat df2 = DateFormat.getDateTimeInstance(
077: DateFormat.LONG, DateFormat.LONG, Locale.getDefault());
078: for (int index = 0; index < al.size(); index++) {
079: Date date = (Date) al.get(index);
080: options[index + 1] = new Option(df1.format(date), df2
081: .format(date));
082: }
083:
084: return options;
085: }
086:
087: public String getDate() {
088: return date;
089: }
090:
091: public void setDate(String date) {
092: this .date = date;
093: }
094:
095: public ObjectListDataProvider getExcludedURLs() {
096: return excludedURLs;
097: }
098:
099: public void setExcludedURLs(ObjectListDataProvider excludedURLs) {
100: this .excludedURLs = excludedURLs;
101: }
102:
103: public boolean isShowingExcludedURLs() {
104: if (date.equals("")) {
105: return false;
106: } else {
107: return true;
108: }
109: }
110:
111: public String show() {
112: ArrayList al = new ArrayList();
113: try {
114: LinkedList path = new LinkedList();
115: path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
116: path
117: .addFirst((String) getSessionAttribute("search.server.selected"));
118: path.addFirst("robot");
119: ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
120: AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
121:
122: Object[] params = { date };
123: String[] signatures = { "java.lang.String" };
124: HashMap hm = (HashMap) getMBeanServerConnection().invoke(
125: on, "getExcludedURLsReport", params, signatures);
126: Iterator i = hm.keySet().iterator();
127: while (i.hasNext()) {
128: String reasonSummary = (String) i.next();
129: ArrayList reasons = (ArrayList) hm.get(reasonSummary);
130:
131: ExcludedURLBean eurlb = new ExcludedURLBean();
132: eurlb.initialize(reasonSummary, reasons);
133: al.add(eurlb);
134: }
135: } catch (Exception e) {
136: log(Level.SEVERE,
137: "ExcludedURLsBean.getExcludedURLs() : Exception ",
138: e);
139: }
140: excludedURLs = new ObjectListDataProvider(al);
141: excludedURLs.setObjectType(ExcludedURLBean.class);
142:
143: return null;
144: }
145:
146: public String getReasonSummary() {
147: return reasonSummary;
148: }
149:
150: public void setReasonSummary(String reasonSummary) {
151: this .reasonSummary = reasonSummary;
152: }
153:
154: public String getReasons() {
155: return reasons;
156: }
157:
158: public void setReasons(String reasons) {
159: this .reasons = reasons;
160: }
161:
162: public String showReasons() {
163: FacesContext fc = FacesContext.getCurrentInstance();
164: ValueBinding vb = fc.getApplication().createValueBinding(
165: "#{excludedURL.value.reasonSummary}");
166: reasonSummary = (String) vb.getValue(fc);
167:
168: excludedURLs.commitChanges();
169: List l = excludedURLs.getList();
170: for (int index = 0; index < l.size(); index++) {
171: ExcludedURLBean eurlb = (ExcludedURLBean) l.get(index);
172: if (reasonSummary.equals(eurlb.reasonSummary)) {
173: reasons = eurlb.getReasons();
174: }
175: }
176:
177: return "gotoShowExcludedURLs";
178: }
179:
180: public String cancel() {
181: return "gotoExcludedURLsHome";
182: }
183:
184: }
|