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