001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.search.admin;
007:
008: import java.net.URL;
009: import java.util.*;
010:
011: import com.sun.portal.search.admin.CSViewBeanBase;
012: import com.sun.portal.search.robot.ProcessConfig;
013:
014: import javax.servlet.http.HttpServletRequest;
015:
016: import com.iplanet.jato.RequestContext;
017:
018: import com.iplanet.jato.view.event.DisplayEvent;
019: import com.iplanet.jato.view.event.RequestInvocationEvent;
020:
021: import com.iplanet.jato.view.html.StaticTextField;
022: import com.iplanet.jato.view.html.TextField;
023: import com.iplanet.jato.view.html.CheckBox;
024: import com.iplanet.jato.view.html.Button;
025: import com.iplanet.jato.view.html.ComboBox;
026: import com.iplanet.jato.view.html.RadioButtonGroup;
027:
028: import com.iplanet.jato.view.html.Option;
029: import com.iplanet.jato.view.html.OptionList;
030:
031: import com.iplanet.jato.view.View;
032: import com.iplanet.jato.view.ViewBean;
033: import com.iplanet.jato.view.ViewBeanBase;
034:
035: import com.iplanet.jato.ViewBeanManager;
036:
037: import com.iplanet.jato.model.ModelControlException;
038:
039: import com.iplanet.am.console.components.view.html.IPlanetButton;
040:
041: /**
042: * iPS admin console view bean: TODO
043: */
044: public class SiteProbeViewBean extends CSViewBeanBase {
045: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/SiteProbe.jsp";
046: public static final String PAGE_NAME = "SiteProbe";
047: public static final String URL_TEXT = "URLText";
048: public static final String DNS_CHECKBOX = "showDNS";
049: public static final String OK_BUTTON = "OKButton";
050: public static final String RESET_BUTTON = "ResetButton";
051: public static final String RUN_RESULT = "RunResult";
052:
053: /**
054: * constructor
055: *
056: * @param PageName of this view bean
057: * @param displayURL default display URL
058: */
059: public SiteProbeViewBean() {
060: super (PAGE_NAME);
061: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
062: registerChildren();
063: }
064:
065: /**
066: * register child component
067: */
068: protected void registerChildren() {
069: registerChild(URL_TEXT, TextField.class);
070: registerChild(DNS_CHECKBOX, CheckBox.class);
071: registerChild(OK_BUTTON, IPlanetButton.class);
072: registerChild(RESET_BUTTON, IPlanetButton.class);
073: registerChild(RUN_RESULT, StaticTextField.class);
074: }
075:
076: /**
077: * create child component
078: *
079: * @param name of component
080: * @return child component
081: */
082: protected View createChild(String name) {
083: View Headerchild = super .createChild(name);
084: if (Headerchild != null)
085: return Headerchild;
086: if (name.equals(URL_TEXT)) {
087: return new TextField(this , URL_TEXT, "");
088: }
089: if (name.equals(DNS_CHECKBOX)) {
090: return new CheckBox(this , DNS_CHECKBOX, "true", "false",
091: false);
092: }
093: if (name.equals(OK_BUTTON)) {
094: return new IPlanetButton(this , OK_BUTTON, "");
095: }
096: if (name.equals(RESET_BUTTON)) {
097: return new IPlanetButton(this , RESET_BUTTON, "");
098: }
099: if (name.equals(RUN_RESULT)) {
100: return new StaticTextField(this , RUN_RESULT, "");
101: }
102:
103: throw new IllegalArgumentException("Invalid child name ["
104: + name + "]");
105: }
106:
107: public void beginDisplay(DisplayEvent event) {
108: setPageEncoding();
109: setDisplayFieldValue(OK_BUTTON,
110: getLocalizedString("robot.siteprobe.runbutton"));
111: setDisplayFieldValue(RESET_BUTTON,
112: getLocalizedString("reset.text"));
113: }
114:
115: boolean isEnable(String buf) {
116: if (buf.equalsIgnoreCase("true") || buf.equalsIgnoreCase("on")
117: || buf.equalsIgnoreCase("yes"))
118: return true;
119: else
120: return false;
121: }
122:
123: public boolean get_shh() {
124: ProcessConfig pConf = CSConfig.getRobotConfig().processConf;
125: String tmp = (String) pConf.get("smart-host-heuristics");
126: return isEnable(tmp);
127: }
128:
129: public void handleOKButtonRequest(RequestInvocationEvent event) {
130: String url = (String) getDisplayFieldValue(URL_TEXT);
131: boolean showDNS = isEnable((String) getDisplayFieldValue(DNS_CHECKBOX));
132: FilterSimulator frsim = new FilterSimulator();
133: String root = CSConfig.getServerRoot();
134: boolean is_shh = get_shh();
135: String result;
136: try {
137: result = "<hr>\n<br><table>\n";
138: result += frsim.runProb(is_shh, root, showDNS, url);
139: result += "\n</table>\n";
140: } catch (Exception e) {
141: result = "<Strong>"
142: + getLocalizedString("robot.siteprobe.fail")
143: + "</Strong>";
144: }
145: setDisplayFieldValue(RUN_RESULT, result);
146: forwardTo();
147: }
148:
149: public void handleResetButtonRequest(RequestInvocationEvent event) {
150: setDisplayFieldValue(URL_TEXT, "");
151: setDisplayFieldValue(DNS_CHECKBOX, "false");
152: forwardTo();
153: }
154: }
|