Source Code Cross Referenced for DatabaseManageViewBean.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.*;
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.cli.RunImportAgent;
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.HiddenField;
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:        import com.sun.portal.search.admin.util.DBUtil;
045:        import com.sun.portal.search.soif.*;
046:        import com.sun.portal.search.rdm.RDM;
047:        import com.sun.portal.log.common.PortalLogger;
048:
049:        public class DatabaseManageViewBean extends CSViewBeanBase {
050:            public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/DatabaseManage.jsp";
051:            public static final String PAGE_NAME = "DatabaseManage";
052:            public static final String NEW_BUTTON = "NewButton";
053:            public static final String OK_BUTTON = "OkButton";
054:            public static final String DELETE_BUTTON = "DeleteButton";
055:            public static final String DATABASE_LIST = "DatabaseList";
056:            public static final String CREATEDB_BUTTON = "CreateDBButton";
057:            public static final String UPDATEDB_BUTTON = "UpdateDBButton";
058:            public static final String CANCEL_BUTTON = "CancelButton";
059:            public static final String RESET_BUTTON = "ResetButton";
060:            public static final String DBNAME_HIDDEN = "HiddenDBName";
061:            public static final String DBNAME_TEXT = "DBName";
062:            public static final String DBTITLE_TEXT = "DBTitle";
063:            public static final String DBDESC_TEXT = "DBDesc";
064:            public static final String REINDEX_BUTTON = "ReindexButton";
065:            public static final String PURGE_BUTTON = "PurgeButton";
066:            public static final String EXPIRE_BUTTON = "ExpireButton";
067:            public static final String SELECTEDDB_PARA = "SelectDBPara";
068:
069:            public static final String ACTION_DELETE = "delete";
070:            public static final String ACTION_PURGE = "purge";
071:            public static final String ACTION_REINDEX = "reindex";
072:            public static final String ACTION_EXPIRE = "expire";
073:            public static final String PARAMETER_ACTION = "Action";
074:
075:            public static final String STATUS_EDIT = "statusAddNew";
076:            public static final String STATUS_ADDNEW = "statusEdit";
077:            public static final String STATUS_LIST = "statusList";
078:            public static final String STATUS_CONFIRM = "statusConfirm";
079:            public static final String STATUS_PROCESSED = "statusProcessed";
080:            public static final String PARAMETER_STATUS = "pageStatus";
081:            public static final String PARAMETER_SELECTEDDBS = "pageSelectedDBs";
082:            public static final String PARAMETER_EDITDB = "pageEditDB";
083:
084:            private String pageStatus = STATUS_LIST;
085:            private String pageAction = null;
086:            private boolean addNew = false;
087:
088:            // Create a logger for this class
089:            private static Logger debugLogger = PortalLogger
090:                    .getLogger(DatabaseManageViewBean.class);
091:
092:            /**
093:             * constructor
094:             *
095:             * @param PageName  of this view bean
096:             * @param displayURL  default display URL
097:             */
098:            public DatabaseManageViewBean() {
099:                super (PAGE_NAME);
100:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
101:                registerChildren();
102:            }
103:
104:            /**
105:             * register child component
106:             */
107:            protected void registerChildren() {
108:                registerChild(NEW_BUTTON, IPlanetButton.class);
109:                registerChild(DELETE_BUTTON, IPlanetButton.class);
110:                registerChild(REINDEX_BUTTON, IPlanetButton.class);
111:                registerChild(PURGE_BUTTON, IPlanetButton.class);
112:                registerChild(EXPIRE_BUTTON, IPlanetButton.class);
113:                registerChild(RESET_BUTTON, IPlanetButton.class);
114:                registerChild(DATABASE_LIST, DatabaseListView.class);
115:                registerChild(CREATEDB_BUTTON, IPlanetButton.class);
116:                registerChild(UPDATEDB_BUTTON, IPlanetButton.class);
117:                registerChild(CANCEL_BUTTON, IPlanetButton.class);
118:                registerChild(OK_BUTTON, IPlanetButton.class);
119:                registerChild(DBNAME_TEXT, TextField.class);
120:                registerChild(DBNAME_HIDDEN, TextField.class);
121:                registerChild(DBTITLE_TEXT, TextField.class);
122:                registerChild(DBDESC_TEXT, TextField.class);
123:                registerChild(SELECTEDDB_PARA, StaticTextField.class);
124:            }
125:
126:            /**
127:             * create child component
128:             *
129:             * @param name of component
130:             * @return child component
131:             */
132:            protected View createChild(String name) {
133:                View Headerchild = super .createChild(name);
134:                if (Headerchild != null)
135:                    return Headerchild;
136:                if (name.equals(NEW_BUTTON)) {
137:                    return new IPlanetButton(this , NEW_BUTTON, "");
138:                }
139:                if (name.equals(DELETE_BUTTON)) {
140:                    return new IPlanetButton(this , DELETE_BUTTON, "");
141:                }
142:                if (name.equals(REINDEX_BUTTON)) {
143:                    return new IPlanetButton(this , REINDEX_BUTTON, "");
144:                }
145:                if (name.equals(PURGE_BUTTON)) {
146:                    return new IPlanetButton(this , PURGE_BUTTON, "");
147:                }
148:                if (name.equals(EXPIRE_BUTTON)) {
149:                    return new IPlanetButton(this , EXPIRE_BUTTON, "");
150:                }
151:                if (name.equals(RESET_BUTTON)) {
152:                    return new IPlanetButton(this , RESET_BUTTON, "");
153:                }
154:                if (name.equals(DATABASE_LIST)) {
155:                    return new DatabaseListView(this , DATABASE_LIST);
156:                }
157:                if (name.equals(DBNAME_TEXT)) {
158:                    return new TextField(this , DBNAME_TEXT, "");
159:                }
160:                if (name.equals(DBNAME_HIDDEN)) {
161:                    return new HiddenField(this , DBNAME_HIDDEN, "");
162:                }
163:                if (name.equals(DBTITLE_TEXT)) {
164:                    return new TextField(this , DBTITLE_TEXT, "");
165:                }
166:                if (name.equals(DBDESC_TEXT)) {
167:                    return new TextField(this , DBDESC_TEXT, "");
168:                }
169:                if (name.equals(CREATEDB_BUTTON)) {
170:                    return new IPlanetButton(this , CREATEDB_BUTTON, "");
171:                }
172:                if (name.equals(UPDATEDB_BUTTON)) {
173:                    return new IPlanetButton(this , UPDATEDB_BUTTON, "");
174:                }
175:                if (name.equals(CANCEL_BUTTON)) {
176:                    return new IPlanetButton(this , CANCEL_BUTTON, "");
177:                }
178:                if (name.equals(OK_BUTTON)) {
179:                    return new IPlanetButton(this , OK_BUTTON, "");
180:                }
181:                if (name.equals(SELECTEDDB_PARA)) {
182:                    return new TextField(this , SELECTEDDB_PARA, "");
183:                }
184:                throw new IllegalArgumentException(getClass().getName()
185:                        + ":Invalid child name [" + name + "]");
186:            }
187:
188:            public void beginDisplay(DisplayEvent event) {
189:                setPageEncoding();
190:                String status = (String) getPageSessionAttribute(PARAMETER_STATUS);
191:                if (status != null) {
192:                    pageStatus = status;
193:                    if (pageStatus.equals(STATUS_EDIT)) {
194:                        String dbName = (String) getPageSessionAttribute(PARAMETER_EDITDB);
195:                        SOIF s = DBUtil.getDBSoif(CSConfig.getServerRoot(),
196:                                dbName);
197:                        if (s != null) {
198:                            String dbDesc = s.getValue(RDM.A_RDM_DESC);
199:                            String dbTitle = s.getValue("Title");
200:                            setDisplayFieldValue(DBNAME_TEXT, dbName);
201:                            setDisplayFieldValue(DBNAME_HIDDEN, dbName);
202:                            setDisplayFieldValue(DBTITLE_TEXT,
203:                                    dbTitle == null ? "" : dbTitle);
204:                            setDisplayFieldValue(DBDESC_TEXT,
205:                                    dbDesc == null ? "" : dbDesc);
206:                        }
207:                    }
208:                }
209:                String action = (String) getPageSessionAttribute(PARAMETER_ACTION);
210:                if (action != null) {
211:                    pageAction = action;
212:                }
213:                setDisplayFieldValue(NEW_BUTTON, getLocalizedString("new.text"));
214:                setDisplayFieldValue(DELETE_BUTTON,
215:                        getLocalizedString("delete.text"));
216:                setDisplayFieldValue(RESET_BUTTON,
217:                        getLocalizedString("reset.text"));
218:                setDisplayFieldValue(UPDATEDB_BUTTON,
219:                        getLocalizedString("db.update"));
220:                setDisplayFieldValue(CREATEDB_BUTTON,
221:                        getLocalizedString("db.create"));
222:                setDisplayFieldValue(CANCEL_BUTTON,
223:                        getLocalizedString("cancel.text"));
224:                setDisplayFieldValue(OK_BUTTON, getLocalizedString("ok.text"));
225:                setDisplayFieldValue(REINDEX_BUTTON,
226:                        getLocalizedString("db.action.reindex"));
227:                setDisplayFieldValue(PURGE_BUTTON,
228:                        getLocalizedString("db.action.purge"));
229:                setDisplayFieldValue(EXPIRE_BUTTON,
230:                        getLocalizedString("db.action.expire"));
231:            }
232:
233:            public boolean beginNewDBSectionDisplay(ChildDisplayEvent event) {
234:                return pageStatus.equals(STATUS_ADDNEW);
235:            }
236:
237:            public boolean beginEditDBSectionDisplay(ChildDisplayEvent event) {
238:                return pageStatus.equals(STATUS_EDIT);
239:            }
240:
241:            public boolean beginDBListSectionDisplay(ChildDisplayEvent event) {
242:                return pageStatus.equals(STATUS_LIST);
243:            }
244:
245:            public boolean beginListTableDisplay(ChildDisplayEvent event) {
246:                DatabaseListView child = (DatabaseListView) getChild(DATABASE_LIST);
247:                try {
248:                    return DBUtil.getDBList(CSConfig.getServerRoot()).size() > 0;
249:                } catch (Exception e) {
250:                    return false;
251:                }
252:            }
253:
254:            public boolean beginEmptyListDisplay(ChildDisplayEvent event) {
255:                return !beginListTableDisplay(event);
256:            }
257:
258:            public boolean beginConfirmationSectionDisplay(
259:                    ChildDisplayEvent event) {
260:                return pageStatus.equals(STATUS_CONFIRM);
261:            }
262:
263:            public void handleNewButtonRequest(RequestInvocationEvent event) {
264:                pageStatus = STATUS_ADDNEW;
265:                infoMessage = getLocalizedString("db.name.validchars");
266:                setPageSessionAttribute(PARAMETER_STATUS, STATUS_ADDNEW);
267:                forwardTo();
268:            }
269:
270:            public void handleResetButtonRequest(RequestInvocationEvent event) {
271:                handleCancelButtonRequest(event);
272:            }
273:
274:            public void handleCancelButtonRequest(RequestInvocationEvent event) {
275:                clearPageSessionAttributes();
276:                forwardTo();
277:            }
278:
279:            public void handleOkButtonRequest(RequestInvocationEvent event) {
280:                handleCancelButtonRequest(event);
281:            }
282:
283:            public void handleOk1ButtonRequest(RequestInvocationEvent event) {
284:                String action = (String) getPageSessionAttribute(PARAMETER_ACTION);
285:                String[] dbs = (String[]) getPageSessionAttribute(PARAMETER_SELECTEDDBS);
286:                boolean res = true;
287:                if (action.equals(ACTION_DELETE)) {
288:                    for (int i = 0; i < dbs.length; i++) {
289:                        DBUtil.deleteDatabase(CSConfig.getServerRoot(), dbs[i],
290:                                null);
291:                    }
292:                } else if (action.equals(this .ACTION_EXPIRE)) {
293:                    for (int i = 0; i < dbs.length; i++) {
294:                        if (!DBUtil.expireDatabase(CSConfig.getServerRoot(),
295:                                dbs[i], null)) {
296:                            res = false;
297:                        }
298:                    }
299:                } else if (action.equals(this .ACTION_PURGE)) {
300:                    for (int i = 0; i < dbs.length; i++) {
301:                        if (!DBUtil.purgeDatabase(CSConfig.getServerRoot(),
302:                                dbs[i], null)) {
303:                            res = false;
304:                        }
305:                    }
306:                } else if (action.equals(this .ACTION_REINDEX)) {
307:                    for (int i = 0; i < dbs.length; i++) {
308:                        if (!DBUtil.reindexDatabase(CSConfig.getServerRoot(),
309:                                dbs[i], null)) {
310:                            res = false;
311:                        }
312:                    }
313:                }
314:
315:                this .infoMessage = getLocalizedString("db.action." + action)
316:                        + " " + getLocalizedString("db.action.executed");
317:                clearPageSessionAttributes();
318:                forwardTo();
319:            }
320:
321:            private boolean validateDBName(String dbname) {
322:                if (dbname != null && dbname.length() > 0) {
323:                    char[] cs = dbname.toCharArray();
324:                    for (int i = 0; i < cs.length; i++) {
325:                        if (!((cs[i] >= '0' && cs[i] <= '9')
326:                                || (cs[i] >= 'a' && cs[i] <= 'z')
327:                                || (cs[i] >= 'A' && cs[i] <= 'Z')
328:                                || cs[i] == '_' || cs[i] == '-')) {
329:                            return false;
330:                        }
331:                    }
332:                    return true;
333:                }
334:                return false;
335:            }
336:
337:            public void handleCreateDBButtonRequest(RequestInvocationEvent event) {
338:                String dbName = getDisplayFieldStringValue(DBNAME_TEXT).trim();
339:                String dbTitle = getDisplayFieldStringValue(DBTITLE_TEXT)
340:                        .trim();
341:                String dbDesc = getDisplayFieldStringValue(DBDESC_TEXT).trim();
342:                if (!validateDBName(dbName)) {
343:                    errorMessage = getLocalizedString("db.create.error.invalidname");
344:                } else {
345:                    try {
346:                        if (DBUtil.isDBExist(CSConfig.getServerRoot(), dbName)) {
347:                            errorMessage = getLocalizedString("db.create.error.dbexist");
348:                        } else {
349:
350:                            DBUtil.addNewDB(CSConfig.getServerRoot(), dbName,
351:                                    dbTitle, dbDesc);
352:                            clearPageSessionAttributes();
353:                        }
354:                    } catch (Exception e) {
355:
356:                    }
357:
358:                }
359:                forwardTo();
360:            }
361:
362:            public void handleUpdateDBButtonRequest(RequestInvocationEvent event) {
363:                String dbName = getDisplayFieldStringValue(DBNAME_HIDDEN)
364:                        .trim();
365:                String dbTitle = getDisplayFieldStringValue(DBTITLE_TEXT)
366:                        .trim();
367:                String dbDesc = getDisplayFieldStringValue(DBDESC_TEXT).trim();
368:                try {
369:                    DBUtil.updateDB(CSConfig.getServerRoot(), dbName, dbTitle,
370:                            dbDesc);
371:                    clearPageSessionAttributes();
372:                } catch (Exception e) {
373:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0024", e
374:                            .getMessage());
375:                }
376:                forwardTo();
377:            }
378:
379:            private void Action(String action) {
380:                DatabaseListView child = (DatabaseListView) getChild(DATABASE_LIST);
381:                try {
382:                    String[] dbs = child.getModel().getSelectDBs();
383:                    if (dbs.length > 0) {
384:                        setPageSessionAttribute(PARAMETER_SELECTEDDBS, dbs);
385:                        setPageSessionAttribute(PARAMETER_ACTION, action);
386:                        setPageSessionAttribute(PARAMETER_STATUS,
387:                                STATUS_CONFIRM);
388:                        StringBuffer sb = new StringBuffer(this 
389:                                .getLocalizedString("db.action.ask." + action));
390:                        StringBuffer selectedPara = new StringBuffer(
391:                                PARAMETER_ACTION + "=" + action + "&"
392:                                        + PARAMETER_SELECTEDDBS + "=");
393:                        for (int i = 0; dbs != null && i < dbs.length; i++) {
394:                            sb.append("<li>" + dbs[i]);
395:                            selectedPara.append(dbs[i]);
396:                            if (i < dbs.length - 1) {
397:                                selectedPara.append(",");
398:                            }
399:                        }
400:                        warningMessage = sb.toString();
401:                        setDisplayFieldValue(SELECTEDDB_PARA, selectedPara
402:                                .toString());
403:                    } else {
404:                        errorMessage = this 
405:                                .getLocalizedString("db.list.noselect");
406:                    }
407:                } catch (Exception e) {
408:                    errorMessage = e.getMessage();
409:                }
410:                forwardTo();
411:
412:            }
413:
414:            public void handleReindexButtonRequest(RequestInvocationEvent event) {
415:                Action(ACTION_REINDEX);
416:            }
417:
418:            public void handlePurgeButtonRequest(RequestInvocationEvent event) {
419:                Action(ACTION_PURGE);
420:            }
421:
422:            public void handleExpireButtonRequest(RequestInvocationEvent event) {
423:                Action(ACTION_EXPIRE);
424:            }
425:
426:            public void handleDeleteButtonRequest(RequestInvocationEvent event) {
427:                Action(ACTION_DELETE);
428:            }
429:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.