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.io.*;
010: import java.lang.*;
011: import java.util.*;
012:
013: import com.sun.portal.search.robot.ProcessConfig;
014: import com.sun.portal.search.admin.CSViewBeanBase; //import com.sun.portal.search.admin.cli.RobotController;
015:
016: import javax.servlet.http.HttpServletRequest;
017:
018: import com.iplanet.jato.RequestContext;
019:
020: import com.iplanet.jato.view.event.DisplayEvent;
021: import com.iplanet.jato.view.event.RequestInvocationEvent;
022:
023: import com.iplanet.jato.view.html.*;
024:
025: import com.iplanet.jato.view.View;
026: import com.iplanet.jato.view.ViewBean;
027: import com.iplanet.jato.view.ViewBeanBase;
028:
029: import com.iplanet.jato.ViewBeanManager;
030:
031: import com.iplanet.jato.model.ModelControlException;
032:
033: //import com.iplanet.am.console.components.view.html.ParentagePath;
034: import com.iplanet.am.console.components.view.html.IPlanetButton;
035:
036: //import com.sun.portal.search.admin.model.PropertiesModel;
037: //import com.sun.portal.search.admin.model.PropertiesModelImpl;
038:
039: public class IndexingViewBean extends CSViewBeanBase {
040: /**
041: * constructor
042: *
043: * @param PageName of this view bean
044: * @param displayURL default display URL
045: */
046: public IndexingViewBean() {
047: super (PAGE_NAME);
048: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
049: registerChildren();
050: filterConfigurator.readFilterToArray();
051: }
052:
053: /**
054: * register child component
055: */
056: protected void registerChildren() {
057: //
058: // Indexing
059: //
060: registerChild(INDEXING_RADIO, RadioButtonGroup.class);
061: registerChild(INDEXING_TEXT, TextField.class);
062: //
063: // Document Converters
064: //
065: registerChild(DOC_LIST, ConverterListView.class);
066: registerChild(CONTIMEOUT_TEXT, TextField.class);
067: //
068: // Advanced
069: //
070: registerChild(EXTRACTTOC_CHECK, CheckBox.class);
071: registerChild(EXTRACTMETA_CHECK, CheckBox.class);
072: registerChild(ALLOW_NONEXIST_CLASS_CHECK, CheckBox.class);
073:
074: registerChild(RESET_BUTTON, IPlanetButton.class);
075: registerChild(SUBMIT_BUTTON, IPlanetButton.class);
076:
077: }
078:
079: /**
080: * create child component
081: *
082: * @param name of component
083: * @return child component
084: */
085: protected View createChild(String name) {
086: View Headerchild = super .createChild(name);
087: if (Headerchild != null)
088: return Headerchild;
089: //
090: // Indexing
091: //
092: if (name.equals(INDEXING_RADIO)) {
093: RadioButtonGroup child = new RadioButtonGroup(this ,
094: INDEXING_RADIO, "partial");
095: OptionList IndexingOptions = new OptionList(
096: getLocalizedStringArray(
097: "robot.indexing.extraction.indexlistlabel",
098: ","), getLocalizedStringArray(
099: "robot.indexing.extraction.indexlistvalue",
100: ","));
101: child.setOptions(IndexingOptions);
102: return child;
103: }
104: if (name.equals(INDEXING_TEXT)) {
105: return new TextField(this , INDEXING_TEXT, "");
106: }
107: //
108: // Document Converters
109: //
110: if (name.equals(DOC_LIST)) {
111: return new ConverterListView(this , DOC_LIST);
112: }
113: if (name.equals(CONTIMEOUT_TEXT)) {
114: return new TextField(this , CONTIMEOUT_TEXT, "");
115: }
116: //
117: // Advanced
118: //
119: if (name.equals(EXTRACTTOC_CHECK)) {
120: return new CheckBox(this , EXTRACTTOC_CHECK, "true",
121: "false", true);
122: }
123: if (name.equals(EXTRACTMETA_CHECK)) {
124: return new CheckBox(this , EXTRACTMETA_CHECK, "true",
125: "false", true);
126: }
127: if (name.equals(ALLOW_NONEXIST_CLASS_CHECK)) {
128: return new CheckBox(this , ALLOW_NONEXIST_CLASS_CHECK,
129: "true", "false", true);
130: }
131: if (name.equals(SUBMIT_BUTTON)) {
132: return new IPlanetButton(this , SUBMIT_BUTTON, "");
133: }
134: if (name.equals(RESET_BUTTON)) {
135: return new IPlanetButton(this , RESET_BUTTON, "");
136: }
137:
138: throw new IllegalArgumentException("Invalid child name ["
139: + name + "]");
140: }
141:
142: /** begin displaying page. we set the required information
143: *
144: * @param event display event
145: * @throws ModelControlException if problem access value of component
146: */
147: public void beginDisplay(DisplayEvent event) {
148: setPageEncoding();
149: setDisplayFieldValue(SUBMIT_BUTTON,
150: getLocalizedString("submit.text"));
151: setDisplayFieldValue(RESET_BUTTON,
152: getLocalizedString("reset.text"));
153:
154: ProcessConfig processConf = CSConfig.getRobotConfig().processConf;
155: // One ring from robot.conf
156: // filterConfigurator.readFilterToArray();
157: // Strange interdependecies on the first two
158: String bytesIndex = filterConfigurator.getFilterConfVars(
159: "Generate", "extract-full-text", "truncate", "0");
160: if (bytesIndex.equals("0")) {
161: whichExtract = "full";
162: extractFirst = "";
163: } else {
164: whichExtract = "partial";
165: extractFirst = bytesIndex;
166: }
167: this .setDisplayFieldValue(this .INDEXING_TEXT, extractFirst);
168: this .setDisplayFieldValue(this .INDEXING_RADIO, whichExtract);
169: this .setDisplayFieldValue(this .EXTRACTTOC_CHECK,
170: filterConfigurator.getFilterConfVars("Generate",
171: "extract-html-toc", "enable", "true"));
172: this .setDisplayFieldValue(this .EXTRACTMETA_CHECK,
173: filterConfigurator.getFilterConfVars("Generate",
174: "extract-html-meta", "enable", "true"));
175: // Converter Timeout
176: String conv_timeout = (String) processConf
177: .get("convert-timeout");
178: this .setDisplayFieldValue(this .CONTIMEOUT_TEXT, conv_timeout);
179: String allowNonClass = (String) processConf
180: .get("allow-nonexist-classification");
181: if (allowNonClass != null) {
182: if (!allowNonClass.equalsIgnoreCase("true")
183: && !allowNonClass.equalsIgnoreCase("yes")) {
184: setDisplayFieldValue(ALLOW_NONEXIST_CLASS_CHECK,
185: "false");
186: }
187: }
188:
189: }
190:
191: public void handleSubmitButtonRequest(RequestInvocationEvent event)
192: throws ModelControlException {
193:
194: // First update the converter wraiths
195: ConverterListView child = (ConverterListView) this
196: .getChild(this .DOC_LIST);
197: child.updateData();
198:
199: // Then do the one thing to the robot.conf
200: ProcessConfig processConf = CSConfig.getRobotConfig().processConf;
201: // Command Priviledges
202: String conv_timeoutout = this
203: .getDisplayFieldStringValue(this .CONTIMEOUT_TEXT);
204: processConf.put("convert-timeout", conv_timeoutout);
205: boolean allowNonClass = this
206: .getDisplayFieldBooleanValue(ALLOW_NONEXIST_CLASS_CHECK);
207: processConf.put("allow-nonexist-classification",
208: (allowNonClass ? "true" : "false"));
209: // update robot.conf
210: processConf.updateFile();
211:
212: // Lastly, the very nasty filter.conf stuff.
213: // filterConfigurator.readFilterToArray();
214: // index extration text (2 places)
215: String index_ext_txt = this
216: .getDisplayFieldStringValue(this .INDEXING_TEXT);
217: String index_radio_but = this
218: .getDisplayFieldStringValue(this .INDEXING_RADIO);
219: if (index_radio_but.equals("full")) {
220: index_ext_txt = "0"; //no limit
221: }
222: filterConfigurator.setFilterConfVars("Generate",
223: "extract-full-text", "truncate", index_ext_txt);
224: filterConfigurator.setFilterConfVars("Generate",
225: "extract-html-text", "truncate", index_ext_txt);
226:
227: // Extract things
228: String toc_tst = this
229: .getDisplayFieldStringValue(this .EXTRACTTOC_CHECK);
230: filterConfigurator.setFilterConfVars("Generate",
231: "extract-html-toc", "enable", toc_tst);
232: String meta_tst = this
233: .getDisplayFieldStringValue(this .EXTRACTMETA_CHECK);
234: filterConfigurator.setFilterConfVars("Generate",
235: "extract-html-meta", "enable", meta_tst);
236:
237: filterConfigurator.updateFilterConf();
238:
239: this .forwardTo();
240:
241: }
242:
243: public void handleResetButtonRequest(RequestInvocationEvent event)
244: throws ModelControlException {
245: clearPageSessionAttributes();
246: forwardTo();
247: }
248:
249: String extractFirst = null;
250: String whichExtract = null;
251: String showMeta = "false";
252: String showHtml = "false";
253:
254: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/Indexing.jsp";
255: public static final String PAGE_NAME = "Indexing";
256: //
257: // Indexing
258: //
259: public static final String INDEXING_RADIO = "IndexingRadio";
260: public static final String INDEXING_TEXT = "IndexingText";
261: //
262: // Document Converters
263: //
264:
265: public static final String DOC_LIST = "ConverterList";
266: public static final String CONTIMEOUT_TEXT = "ConTimeOutText";
267:
268: //
269: // Advanced
270: //
271: public static final String EXTRACTTOC_CHECK = "ExtractTOCCheck";
272: public static final String EXTRACTMETA_CHECK = "ExtractMetaCheck";
273: public static final String ALLOW_NONEXIST_CLASS_CHECK = "AllowNonexistClassCheck";
274:
275: public static final String RESET_BUTTON = "ResetButton";
276: public static final String SUBMIT_BUTTON = "SubmitButton";
277:
278: // Option lists
279: }
|