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.ArrayList;
010: import java.util.logging.Level;
011: import java.util.logging.Logger;
012:
013: import com.sun.portal.search.admin.CSViewBeanBase; //import com.sun.portal.search.admin.cli.RobotController;
014:
015: import javax.servlet.http.HttpServletRequest;
016:
017: import com.iplanet.jato.RequestContext;
018: import com.iplanet.jato.model.*;
019: import com.iplanet.jato.view.event.DisplayEvent;
020: import com.iplanet.jato.view.event.RequestInvocationEvent;
021:
022: import com.iplanet.jato.view.html.StaticTextField;
023: import com.iplanet.jato.view.html.TextField;
024: import com.iplanet.jato.view.html.CheckBox;
025: import com.iplanet.jato.view.html.Button;
026: import com.iplanet.jato.view.html.ComboBox;
027: import com.iplanet.jato.view.html.ListBox;
028: import com.iplanet.jato.view.html.RadioButtonGroup;
029:
030: import com.iplanet.jato.view.html.Option;
031: import com.iplanet.jato.view.html.OptionList;
032:
033: import com.iplanet.jato.view.View;
034: import com.iplanet.jato.view.ViewBean;
035: import com.iplanet.jato.view.ViewBeanBase;
036: import com.iplanet.jato.view.event.ChildDisplayEvent;
037:
038: import com.iplanet.jato.ViewBeanManager;
039:
040: import com.iplanet.jato.model.ModelControlException;
041: import com.iplanet.jato.util.Encoder;
042:
043: //import com.iplanet.am.console.components.view.html.ParentagePath;
044: import com.iplanet.am.console.components.view.html.IPlanetButton;
045:
046: import com.iplanet.sso.SSOTokenManager;
047: import com.iplanet.sso.SSOToken;
048: import com.iplanet.sso.SSOException;
049: import com.iplanet.sso.SSOTokenID;
050:
051: import com.sun.portal.search.soif.SOIF;
052: import com.sun.portal.search.db.SToken;
053: import com.sun.portal.log.common.PortalLogger;
054:
055: /**
056: * iPS admin console view bean: TODO
057: */
058: public class RDFormViewBean extends CSViewBeanBase {
059: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/RDForm.jsp";
060: public static final String PAGE_NAME = "RDForm";
061: public static final String RD_VIEW = "RDView";
062: public static final String SUBMIT_BUTTON = "SubmitButton";
063: public static final String RESET_BUTTON = "ResetButton";
064: public static final String CLOSE_BUTTON = "CloseButton";
065: public static final String BROWSER_VIEW = "TaxonomyBrowser";
066: private SToken st = null;
067: private boolean isSingle = false;
068: private boolean isUpdated = false;
069:
070: // Create a Logger for this class
071: private static Logger debugLogger = PortalLogger
072: .getLogger(RDFormViewBean.class);
073:
074: /**
075: * constructor
076: *
077: * @param PageName of this view bean
078: * @param displayURL default display URL
079: */
080: public RDFormViewBean() {
081: super (PAGE_NAME);
082: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
083: registerChildren();
084:
085: }
086:
087: /**
088: * register child component
089: */
090: protected void registerChildren() {
091: registerChild(RD_VIEW, RDView.class);
092: registerChild(SUBMIT_BUTTON, IPlanetButton.class);
093: registerChild(RESET_BUTTON, IPlanetButton.class);
094: registerChild(CLOSE_BUTTON, IPlanetButton.class);
095: registerChild(BROWSER_VIEW, TaxonomyBrowserView.class);
096:
097: }
098:
099: /**
100: * create child component
101: *
102: * @param name of component
103: * @return child component
104: */
105: protected View createChild(String name) {
106: View Headerchild = super .createChild(name);
107: if (Headerchild != null)
108: return Headerchild;
109: if (name.equals(RD_VIEW)) {
110: return new RDView(this , RD_VIEW);
111: }
112: if (name.equals(SUBMIT_BUTTON)) {
113: IPlanetButton btn = new IPlanetButton(this , SUBMIT_BUTTON,
114: "");
115: btn.validate(true);
116: return btn;
117: }
118: if (name.equals(RESET_BUTTON)) {
119: return new IPlanetButton(this , RESET_BUTTON, "");
120: }
121: if (name.equals(CLOSE_BUTTON)) {
122: return new IPlanetButton(this , CLOSE_BUTTON, "");
123: }
124: if (name.equals(BROWSER_VIEW)) {
125: return new TaxonomyBrowserView(this , BROWSER_VIEW);
126: }
127: throw new IllegalArgumentException("Invalid child name ["
128: + name + "]");
129: }
130:
131: public boolean beginEditorSectionDisplay(ChildDisplayEvent event) {
132: String isBrowsing = (String) getPageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_BROWSING_ON);
133: debugLogger.log(Level.FINER, "PSSH_CSPSA0071", isBrowsing);
134: return (isBrowsing == null || !isBrowsing
135: .equalsIgnoreCase("true"))
136: && !beginBatchConfirmSectionDisplay(event);
137: }
138:
139: public boolean beginBrowseSectionDisplay(ChildDisplayEvent event) {
140: String isBrowsing = (String) getPageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_BROWSING_ON);
141: setPageSessionAttribute(TaxonomyBrowserView.CHILD_PAGE_HELP,
142: this .getLocalizedString("rd.edit.browse.help"));
143: debugLogger.log(Level.FINER, "PSSH_CSPSA0071", isBrowsing);
144: return (isBrowsing != null && isBrowsing
145: .equalsIgnoreCase("true"));
146: }
147:
148: public boolean beginBatchConfirmSectionDisplay(
149: ChildDisplayEvent event) {
150: return isUpdated && !isSingle;
151: }
152:
153: /** begin displaying page. we set the required information
154: *
155: * @param event display event
156: * @throws ModelControlException if problem access value of component
157: */
158: public void beginDisplay(DisplayEvent event) {
159: setPageEncoding();
160: if (getPageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_BROWSING_ON) != null) {
161: return;
162: }
163: String editTimeStamp = (String) getPageSessionAttribute("editTimeStamp");
164: if (editTimeStamp == null) {
165: editTimeStamp = getRequestContext().getRequest()
166: .getParameter("editTimeStamp");
167: if (editTimeStamp != null) {
168: setPageSessionAttribute("editTimeStamp", editTimeStamp);
169: }
170: }
171: ArrayList urlList = (ArrayList) getRequestContext()
172: .getRequest().getSession().getAttribute(
173: "urls" + editTimeStamp);
174: if (urlList == null) {
175: String urlsPar = getRequestContext().getRequest()
176: .getParameter("urls");
177: if (urlsPar != null) {
178: urlList = RDView.parseURLSString(urlsPar);
179: }
180: }
181: if ((urlList != null) && urlList.size() == 1) {
182: isSingle = true;
183: }
184: debugLogger.log(Level.FINER, "PSSH_CSPSA0088", Boolean
185: .toString(isSingle));
186: if (!isSingle && !isUpdated) {
187: infoMessage = getLocalizedString("rd.batchmode.desc");
188: }
189:
190: setDisplayFieldValue(SUBMIT_BUTTON,
191: getLocalizedString("submit.text"));
192: setDisplayFieldValue(RESET_BUTTON,
193: getLocalizedString("reset.text"));
194: setDisplayFieldValue(CLOSE_BUTTON,
195: getLocalizedString("close.text"));
196:
197: }
198:
199: private SToken getSToken() {
200: if (st == null) {
201: HttpServletRequest req = getRequestContext().getRequest();
202: try {
203: SSOTokenManager manager = SSOTokenManager.getInstance();
204: SSOToken token = null;
205: token = manager.createSSOToken(req);
206: st = new SToken((Object) token, true, true);
207: } catch (SSOException e) {
208: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
209: .getMessage());
210: // nothing, might be sso cookie is not there
211: }
212: }
213: return st;
214: }
215:
216: /**
217: * handles invocation of view bean
218: *
219: * @param event request invocation event
220: */
221: public void handleResetButtonRequest(RequestInvocationEvent event) {
222: this .forwardTo();
223: }
224:
225: public void handleSubmitButtonRequest(RequestInvocationEvent event) {
226: RDView rdview = (RDView) getChild(RD_VIEW);
227: try {
228: rdview.update();
229: infoMessage = getLocalizedString("rd.update.success");
230: String editTimeStamp = (String) getPageSessionAttribute("editTimeStamp");
231: removePageSessionAttribute("editTimeStamp");
232: removePageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX
233: + editTimeStamp);
234: removePageSessionAttribute(TaxonomyBrowserView.SESION_ATTR_SELECTED_TAX_ORG
235: + editTimeStamp);
236: isUpdated = true;
237: } catch (Exception e) {
238: errorMessage = getLocalizedString("rd.update.error");
239: }
240: forwardTo();
241:
242: }
243:
244: }
|