Source Code Cross Referenced for ImportAgentViewBean.java in  » Portal » Open-Portal » com » sun » portal » search » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.search.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.*;
011:        import java.util.logging.Logger;
012:        import java.util.logging.Level;
013:
014:        import com.sun.portal.search.admin.CSViewBeanBase;
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:        import com.iplanet.jato.view.html.HiddenField;
032:
033:        import com.iplanet.jato.view.html.Option;
034:        import com.iplanet.jato.view.html.OptionList;
035:
036:        import com.iplanet.jato.view.View;
037:        import com.iplanet.jato.view.ViewBean;
038:        import com.iplanet.jato.view.ViewBeanBase;
039:
040:        import com.iplanet.jato.ViewBeanManager;
041:
042:        import com.iplanet.jato.model.*;
043:
044:        import com.iplanet.am.console.components.view.html.IPlanetButton;
045:        import com.iplanet.am.console.components.view.html.MessageBox;
046:
047:        import com.sun.portal.search.admin.model.ImportAgentModel;
048:        import com.sun.portal.search.admin.util.DBUtil;
049:        import com.sun.portal.log.common.PortalLogger;
050:
051:        /**
052:         * iPS admin console view bean: TODO
053:         */
054:        public class ImportAgentViewBean extends CSViewBeanBase {
055:            public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/ImportAgent.jsp";
056:            public static final String PAGE_NAME = "ImportAgent";
057:            public static final String ID_TEXT = "ID";
058:            public static final String CHILD_CC_MSGBOX = "ccMessageBox";
059:            public static final String AGENT_TYPE = "AgentType";
060:            public static final String LOACLFILE = "LocalFile";
061:            public static final String SERVERPORT = "ServerPort";
062:            public static final String INSTANCE_NAME = "InstanceName";
063:            public static final String SEARCH_URI = "SearchURI";
064:            public static final String SEARCH_DB = "SearchDB";
065:            public static final String LOCAL_DB = "LocalDB";
066:            public static final String IS_COMPASS = "IsCompass";
067:            public static final String IS_SSL = "IsSSL";
068:            public static final String SOIF_CHARSET = "soifCharset";
069:            public static final String USE_AUTH = "UseAuth";
070:            public static final String USER = "User";
071:            public static final String PASSWORD = "Password";
072:            public static final String USE_GATHERER = "UseGatherer";
073:            public static final String TIME_STAMP = "TimeStamp";
074:            public static final String CLEAR_TIME_STAMP = "ClearTimeStamp";
075:            public static final String SCOPE = "Scope";
076:            public static final String VIEW_ATTRIBUTES = "ViewAttributes";
077:            public static final String VIEW_HITS = "ViewHits";
078:            public static final String NICKNAME = "NickName";
079:            public static final String TIME_OUT = "TimeOut";
080:
081:            public static final String SUBMIT_BUTTON = "SubmitButton";
082:            public static final String RESET_BUTTON = "ResetButton";
083:            public static final String CANCEL_BUTTON = "CancelButton";
084:            public static final String CHANGE_BUTTON = "ChangeButton";
085:
086:            String importID = null;
087:            ImportAgentModel model = null;
088:            String msg = null;
089:            int agentType = -1; //don't know yet
090:
091:            // Create a logger for this class
092:            private static Logger debugLogger = PortalLogger
093:                    .getLogger(ImportAgentViewBean.class);
094:
095:            /**
096:             * constructor
097:             *
098:             * @param PageName  of this view bean
099:             * @param displayURL  default display URL
100:             */
101:            public ImportAgentViewBean() {
102:                super (PAGE_NAME);
103:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
104:                registerChildren();
105:            }
106:
107:            /**
108:             * register child component
109:             */
110:            protected void registerChildren() {
111:                registerChild(ID_TEXT, HiddenField.class);
112:                registerChild(CHILD_CC_MSGBOX, MessageBox.class);
113:                registerChild(AGENT_TYPE, RadioButtonGroup.class);
114:                registerChild(LOACLFILE, TextField.class);
115:                registerChild(SERVERPORT, TextField.class);
116:                registerChild(INSTANCE_NAME, TextField.class);
117:                registerChild(SEARCH_URI, TextField.class);
118:                registerChild(SEARCH_DB, TextField.class);
119:                registerChild(LOCAL_DB, ComboBox.class);
120:                registerChild(IS_COMPASS, CheckBox.class);
121:                registerChild(IS_SSL, CheckBox.class);
122:                registerChild(SOIF_CHARSET, TextField.class);
123:                registerChild(USE_AUTH, RadioButtonGroup.class);
124:                registerChild(USER, TextField.class);
125:                registerChild(PASSWORD, TextField.class);
126:                registerChild(USE_GATHERER, RadioButtonGroup.class);
127:                registerChild(TIME_STAMP, TextField.class);
128:                registerChild(CLEAR_TIME_STAMP, IPlanetButton.class);
129:                registerChild(SCOPE, TextField.class);
130:                registerChild(VIEW_ATTRIBUTES, TextField.class);
131:                registerChild(VIEW_HITS, TextField.class);
132:                registerChild(NICKNAME, TextField.class);
133:                registerChild(TIME_OUT, TextField.class);
134:                registerChild(SUBMIT_BUTTON, IPlanetButton.class);
135:                registerChild(RESET_BUTTON, IPlanetButton.class);
136:                registerChild(CANCEL_BUTTON, IPlanetButton.class);
137:                registerChild(CHANGE_BUTTON, IPlanetButton.class);
138:
139:            }
140:
141:            OptionList getDBListOption() {
142:                try {
143:                    String[] dbs = DBUtil.getDBStringArray(CSConfig
144:                            .getServerRoot());
145:                    return new OptionList(dbs, dbs);
146:                } catch (Exception e) {
147:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
148:                            .getMessage());
149:                }
150:
151:                return new OptionList();
152:
153:            }
154:
155:            /**
156:             * create child component
157:             *
158:             * @param name of component
159:             * @return child component
160:             */
161:            protected View createChild(String name) {
162:                debugLogger.log(Level.FINER, "PSSH_CSPSA0044", name);
163:                View Headerchild = super .createChild(name);
164:                if (Headerchild != null)
165:                    return Headerchild;
166:                if (name.equals(ID_TEXT)) {
167:                    return new HiddenField(this , getModel(), ID_TEXT,
168:                            ImportConfig.ID, "", null);
169:                }
170:                if (name.equals(CHILD_CC_MSGBOX)) {
171:                    return new MessageBox(this , CHILD_CC_MSGBOX, "");
172:                }
173:                if (name.equals(AGENT_TYPE)) {
174:                    RadioButtonGroup child = new RadioButtonGroup(this ,
175:                            getModel(), this .AGENT_TYPE,
176:                            ImportConfig.AGENT_TYPE, "", null);
177:                    OptionList agentTypeOptions = new OptionList(
178:                            getLocalizedStringArray("import.agenttype.options",
179:                                    ","), // labels
180:                            new String[] { ImportConfig.TYPE_LOCALFILE,
181:                                    ImportConfig.TYPE_COMPASS }); // values
182:                    child.setOptions(agentTypeOptions);
183:                    return child;
184:                }
185:                if (name.equals(LOACLFILE)) {
186:                    return new TextField(this , getModel(), LOACLFILE,
187:                            ImportConfig.SRCFILE, "", null);
188:                }
189:                if (name.equals(SERVERPORT)) {
190:                    return new TextField(this , getModel(), SERVERPORT,
191:                            ImportConfig.SERVER_PORT, "", null);
192:                }
193:                if (name.equals(this .INSTANCE_NAME)) {
194:                    return new TextField(this , getModel(), this .INSTANCE_NAME,
195:                            ImportConfig.INSTANCE_NAME, "", null);
196:                }
197:                if (name.equals(this .SEARCH_URI)) {
198:                    return new TextField(this , getModel(), this .SEARCH_URI,
199:                            ImportConfig.SEARCH_URI, "", null);
200:                }
201:                if (name.equals(this .SEARCH_DB)) {
202:                    return new TextField(this , getModel(), this .SEARCH_DB,
203:                            ImportConfig.SEARCH_DB, "default", null);
204:                }
205:                if (name.equals(this .LOCAL_DB)) {
206:                    ComboBox child = new ComboBox(this , getModel(),
207:                            this .LOCAL_DB, ImportConfig.LOCAL_DB, "default",
208:                            getDBListOption(), null);
209:                    return child;
210:                }
211:                if (name.equals(this .IS_COMPASS)) {
212:                    return new CheckBox(this , getModel(), this .IS_COMPASS,
213:                            ImportConfig.IS_COMPASS, "true", "false", false,
214:                            null);
215:                }
216:                if (name.equals(this .IS_SSL)) {
217:                    return new CheckBox(this , getModel(), this .IS_SSL,
218:                            ImportConfig.IS_SSL, "true", "false", false, null);
219:                }
220:                if (name.equals(SOIF_CHARSET)) {
221:                    return new TextField(this , getModel(), SOIF_CHARSET,
222:                            ImportConfig.CHARSET, "", null);
223:                }
224:                if (name.equals(this .USE_AUTH)) {
225:                    RadioButtonGroup child = new RadioButtonGroup(this ,
226:                            getModel(), this .USE_AUTH, ImportConfig.US_AUTH,
227:                            "false", null);
228:                    OptionList useAuthOptions = new OptionList(
229:                            getLocalizedStringArray("import.auth.options", ","), // labels
230:                            new String[] { "false", "true" }); // values
231:                    child.setOptions(useAuthOptions);
232:                    return child;
233:                }
234:                if (name.equals(this .USER)) {
235:                    return new TextField(this , getModel(), this .USER,
236:                            ImportConfig.USER, "", null);
237:                }
238:                if (name.equals(this .PASSWORD)) {
239:                    return new TextField(this , getModel(), this .PASSWORD,
240:                            ImportConfig.PASSWORD, "", null);
241:                }
242:                if (name.equals(this .USE_GATHERER)) {
243:                    RadioButtonGroup child = new RadioButtonGroup(this ,
244:                            getModel(), this .USE_GATHERER,
245:                            ImportConfig.RDM_QUERY_LANGUAGE,
246:                            ImportConfig.QL_GATHERER, null);
247:                    OptionList useGathererOptions = new OptionList(
248:                            getLocalizedStringArray("import.gather.options",
249:                                    ","), // labels
250:                            new String[] { ImportConfig.QL_GATHERER,
251:                                    ImportConfig.QL_SEARCH }); // values
252:                    child.setOptions(useGathererOptions);
253:                    return child;
254:                }
255:                if (name.equals(this .TIME_STAMP)) {
256:                    return new TextField(this , getModel(), this .TIME_STAMP,
257:                            ImportConfig.TIME_STAMP, "", null);
258:                }
259:                if (name.equals(this .CLEAR_TIME_STAMP)) {
260:                    return new IPlanetButton(this , CLEAR_TIME_STAMP,
261:                            getLocalizedString("import.cleartimestamp"));
262:                }
263:                if (name.equals(this .SCOPE)) {
264:                    return new TextField(this , getModel(), this .SCOPE,
265:                            ImportConfig.SCOPE, "", null);
266:                }
267:                if (name.equals(this .VIEW_ATTRIBUTES)) {
268:                    return new TextField(this , getModel(),
269:                            this .VIEW_ATTRIBUTES, ImportConfig.VIEW_ATTRIBUTES,
270:                            "", null);
271:                }
272:                if (name.equals(this .VIEW_HITS)) {
273:                    return new TextField(this , getModel(), this .VIEW_HITS,
274:                            ImportConfig.VIEW_HITS, "", null);
275:                }
276:                if (name.equals(this .NICKNAME)) {
277:                    return new TextField(this , getModel(), this .NICKNAME,
278:                            ImportConfig.NICKNAME, "", null);
279:                }
280:                if (name.equals(this .TIME_OUT)) {
281:                    return new TextField(this , model, this .TIME_OUT,
282:                            ImportConfig.TIMEOUT, "", null);
283:                }
284:                if (name.equals(SUBMIT_BUTTON)) {
285:                    return new IPlanetButton(this , SUBMIT_BUTTON, "");
286:                }
287:                if (name.equals(RESET_BUTTON)) {
288:                    return new IPlanetButton(this , RESET_BUTTON, "");
289:                }
290:                if (name.equals(CANCEL_BUTTON)) {
291:                    return new IPlanetButton(this , CANCEL_BUTTON, "");
292:                }
293:                if (name.equals(CHANGE_BUTTON)) {
294:                    return new IPlanetButton(this , CHANGE_BUTTON, "");
295:                }
296:                throw new IllegalArgumentException("Invalid child name ["
297:                        + name + "]");
298:            }
299:
300:            public boolean beginSrcFileSectionDisplay(ChildDisplayEvent event) {
301:                if (agentType < 0) {
302:                    ImportAgentModel model = getModel();
303:                    String type = (String) model
304:                            .getValue(ImportConfig.AGENT_TYPE);
305:                    if (type != null
306:                            && type.equals(ImportConfig.TYPE_LOCALFILE)) {
307:                        agentType = 1;
308:                    } else {
309:                        agentType = 2;
310:                    }
311:                }
312:                debugLogger.log(Level.FINER, "PSSH_CSPSA0045", String
313:                        .valueOf(agentType));
314:                return (agentType == 1);
315:
316:            }
317:
318:            public boolean beginSrcServerSectionDisplay(ChildDisplayEvent event) {
319:                return !beginSrcFileSectionDisplay(event);
320:            }
321:
322:            public boolean beginNotCompassSectionDisplay(ChildDisplayEvent event) {
323:                return !getDisplayFieldBooleanValue(IS_COMPASS);
324:            }
325:
326:            /** begin displaying page. we set the required information
327:             *
328:             * @param event   display event
329:             * @throws ModelControlException  if problem access value of component
330:             */
331:            public void beginDisplay(DisplayEvent event) {
332:                setPageEncoding();
333:                setDisplayFieldValue(SUBMIT_BUTTON,
334:                        getLocalizedString("submit.text"));
335:                setDisplayFieldValue(RESET_BUTTON,
336:                        getLocalizedString("reset.text"));
337:                setDisplayFieldValue(CANCEL_BUTTON,
338:                        getLocalizedString("cancel.text"));
339:
340:                // Get request attributes and store them as Page Session Attributes
341:                ImportAgentModel model = getModel();
342:                if (msg != null) {
343:                    MessageBox msgBox = (MessageBox) getChild(CHILD_CC_MSGBOX);
344:                    msgBox.setType(MessageBox.TYPE_ERROR);
345:                    msgBox.setEnabled(false);
346:                    if (msg != null) {
347:                        msgBox.setMessage(msg);
348:                        msgBox.setEnabled(true);
349:                    }
350:                }
351:
352:                setDefaultModel(model);
353:
354:            }
355:
356:            protected ImportAgentModel getModel() {
357:                if (model == null) {
358:                    RequestContext rc = getRequestContext();
359:                    HttpServletRequest req = rc.getRequest();
360:                    importID = (String) req.getParameter("id");
361:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0046", importID);
362:                    model = new ImportAgentModel();
363:                    if (importID != null) {
364:                        model.setID(importID);
365:                        try {
366:                            model.retrieve(null);
367:                        } catch (Exception e) {
368:                        }
369:                    } else {
370:                        model.setValue(ImportConfig.AGENT_TYPE,
371:                                ImportConfig.TYPE_LOCALFILE);
372:                    }
373:                }
374:                return model;
375:            }
376:
377:            public void handleSubmitButtonRequest(RequestInvocationEvent event) {
378:                String type = (String) getDisplayFieldStringValue(AGENT_TYPE);
379:                if (type.equals(ImportConfig.TYPE_LOCALFILE)) {
380:                    String filePath = (String) getDisplayFieldStringValue(LOACLFILE);
381:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0047", filePath);
382:                    File f = new File(filePath.trim());
383:                    if (!f.exists()) {
384:                        msg = getLocalizedString("import.filenotexist");
385:                    } else if (f.isDirectory()) {
386:                        msg = getLocalizedString("import.isdir");
387:                    }
388:                    if (msg != null) {
389:                        forwardTo(getRequestContext());
390:                        return;
391:                    }
392:                } else {
393:                    String server = (String) getDisplayFieldStringValue(this .SERVERPORT);
394:                    if (server == null || server.trim().length() == 0) {
395:                        msg = getLocalizedString("import.errmsg.emptyserver");
396:                        forwardTo(getRequestContext());
397:                        return;
398:                    }
399:                    String instance = (String) getDisplayFieldStringValue(this .INSTANCE_NAME);
400:                    if (instance == null || instance.trim().length() == 0) {
401:                        msg = getLocalizedString("import.errmsg.emptyinstance");
402:                        forwardTo(getRequestContext());
403:                        return;
404:                    }
405:                }
406:
407:                ImportAgentModel model = getModel();
408:                try {
409:                    ModelExecutionContext modExe = new ModelExecutionContextBase(
410:                            ModelExecutionContext.OPERATION_UPDATE);
411:                    model.update(modExe);
412:                    if (model.getErrorMsg() != null) {
413:                        msg = getLocalizedString("import.errmsg.duplicate");
414:                        forwardTo();
415:                        return;
416:                    }
417:                } catch (ModelControlException e) {
418:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
419:                            .getMessage());
420:                }
421:                HttpServletResponse response = this .getRequestContext()
422:                        .getResponse();
423:                try {
424:                    response.sendRedirect("ImportAgents");
425:                } catch (IOException e) {
426:                    //TOFIX: handle this
427:                }
428:            }
429:
430:            public void handleChangeButtonRequest(RequestInvocationEvent event) {
431:                forwardTo(getRequestContext());
432:
433:            }
434:
435:            public void handleResetButtonRequest(RequestInvocationEvent event) {
436:                String id = getDisplayFieldStringValue(ID_TEXT);
437:                HttpServletResponse response = this .getRequestContext()
438:                        .getResponse();
439:                try {
440:                    if (id != null && id.trim().length() > 0) {
441:                        response.sendRedirect("ImportAgent?id=" + id);
442:                    } else {
443:                        //reset was called from a new agent form
444:                        response.sendRedirect("ImportAgent");
445:                    }
446:                } catch (IOException e) {
447:                    //TOFIX: handle this
448:                }
449:            }
450:
451:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.