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:
011: import com.sun.portal.search.admin.CSViewBeanBase;
012: import com.sun.portal.search.admin.model.ScheduleModel;
013: import com.sun.portal.search.admin.cli.CronController;
014: import com.sun.portal.search.admin.util.ScheduleFactory;
015:
016: import javax.servlet.http.HttpServletRequest;
017: import javax.servlet.http.HttpServletResponse;
018:
019: import com.iplanet.jato.RequestContext;
020:
021: import com.iplanet.jato.view.event.DisplayEvent;
022: import com.iplanet.jato.view.event.ChildDisplayEvent;
023: import com.iplanet.jato.view.event.RequestInvocationEvent;
024:
025: import com.iplanet.jato.view.html.StaticTextField;
026: import com.iplanet.jato.view.html.TextField;
027: import com.iplanet.jato.view.html.CheckBox;
028: import com.iplanet.jato.view.html.Button;
029: import com.iplanet.jato.view.html.ComboBox;
030: import com.iplanet.jato.view.html.RadioButtonGroup;
031:
032: import com.iplanet.jato.view.html.Option;
033: import com.iplanet.jato.view.html.OptionList;
034:
035: import com.iplanet.jato.view.View;
036: import com.iplanet.jato.view.ViewBean;
037: import com.iplanet.jato.view.ViewBeanBase;
038:
039: import com.iplanet.jato.ViewBeanManager;
040:
041: import com.iplanet.jato.model.*;
042:
043: import com.iplanet.am.console.components.view.html.IPlanetButton;
044:
045: /**
046: * iPS admin console view bean: TODO
047: */
048: public class ScheduleViewBean extends CSViewBeanBase {
049: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/Schedule.jsp";
050: public static final String PAGE_NAME = "Schedule";
051: public static final String STARTROBOT_VIEW = "StartRobot";
052: public static final String STOPROBOT_VIEW = "StopRobot";
053: public static final String STARTIMPORT_VIEW = "StartImport";
054: public static final String STARTAUTOCLASSIFY_VIEW = "StartAutoclassify";
055: public static final String SUBMIT_BUTTON = "SubmitButton";
056: public static final String RESET_BUTTON = "ResetButton";
057: static final String[] schedules = { STARTROBOT_VIEW,
058: STOPROBOT_VIEW, STARTIMPORT_VIEW, STARTAUTOCLASSIFY_VIEW };
059:
060: /**
061: * constructor
062: *
063: * @param PageName of this view bean
064: * @param displayURL default display URL
065: */
066: public ScheduleViewBean() {
067: super (PAGE_NAME);
068: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
069: registerChildren();
070: }
071:
072: /**
073: * register child component
074: */
075: protected void registerChildren() {
076: registerChild(SUBMIT_BUTTON, IPlanetButton.class);
077: registerChild(RESET_BUTTON, IPlanetButton.class);
078: for (int i = 0; i < schedules.length; i++) {
079: registerChild(schedules[i], ScheduleView.class);
080: }
081: }
082:
083: /**
084: * create child component
085: *
086: * @param name of component
087: * @return child component
088: */
089: protected View createChild(String name) {
090: View Headerchild = super .createChild(name);
091: if (Headerchild != null)
092: return Headerchild;
093: if (name.equals(SUBMIT_BUTTON)) {
094: return new IPlanetButton(this , SUBMIT_BUTTON, "");
095: }
096: if (name.equals(RESET_BUTTON)) {
097: return new IPlanetButton(this , RESET_BUTTON, "");
098: }
099: for (int i = 0; i < schedules.length; i++) {
100: if (name.equals(schedules[i])) {
101: return new ScheduleView(this , schedules[i]);
102: }
103: }
104:
105: throw new IllegalArgumentException("Invalid child name ["
106: + name + "]");
107: }
108:
109: /** begin displaying page. we set the required information
110: *
111: * @param event display event
112: * @throws ModelControlException if problem access value of component
113: */
114: public void beginDisplay(DisplayEvent event) {
115: setPageEncoding();
116: setDisplayFieldValue(SUBMIT_BUTTON,
117: getLocalizedString("submit.text"));
118: setDisplayFieldValue(RESET_BUTTON,
119: getLocalizedString("reset.text"));
120: HttpServletRequest req = getRequestContext().getRequest();
121: String serverURL = (req.isSecure() ? "https" : "http") + "://"
122: + req.getServerName() + ":" + req.getServerPort()
123: + req.getContextPath() + "/search";
124: String cmd;
125: if (System.getProperty("os.name").startsWith("win")
126: || System.getProperty("os.name").startsWith("Win")
127: || System.getProperty("os.name").startsWith("WIN")) {
128: cmd = CSConfig.getServerRoot() + File.separator
129: + "run-cs-cli.bat autoclassify -s " + serverURL;
130: } else {
131: cmd = CSConfig.getServerRoot() + File.separator
132: + "run-cs-cli autoclassify -s " + serverURL;
133: }
134: ScheduleFactory.registerCmd(this .STARTAUTOCLASSIFY_VIEW, cmd);
135: }
136:
137: public void handleSubmitButtonRequest(RequestInvocationEvent event) {
138:
139: ScheduleView child = null;
140: for (int i = 0; i < schedules.length; i++) {
141: child = (ScheduleView) getChild(schedules[i]);
142: child.store();
143: }
144: forwardTo();
145: }
146:
147: public void handleResetButtonRequest(RequestInvocationEvent event) {
148:
149: ScheduleView child = null;
150: for (int i = 0; i < schedules.length; i++) {
151: child = (ScheduleView) getChild(schedules[i]);
152: child.reset();
153: }
154: forwardTo();
155:
156: }
157:
158: }
|