Source Code Cross Referenced for DatabasesBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » search » 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.admin.console.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2005 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.admin.console.search;
013:
014:        import java.util.*;
015:        import java.util.logging.Level;
016:        import java.io.*;
017:
018:        import javax.faces.context.FacesContext;
019:        import javax.faces.el.ValueBinding;
020:        import javax.servlet.http.HttpServletRequest;
021:        import javax.management.*;
022:
023:        import com.sun.web.ui.model.*;
024:        import com.sun.web.ui.event.*;
025:        import com.sun.web.ui.component.*;
026:
027:        import com.sun.data.provider.*;
028:        import com.sun.data.provider.impl.ObjectListDataProvider;
029:
030:        import com.sun.cacao.agent.JmxClient;
031:
032:        import com.sun.portal.admin.common.util.AdminClientUtil;
033:        import com.sun.portal.admin.console.common.PSBaseBean;
034:
035:        public class DatabasesBean extends PSBaseBean {
036:
037:            private ObjectListDataProvider databases = null;
038:
039:            public DatabasesBean() {
040:                ArrayList al1 = new ArrayList();
041:                try {
042:                    LinkedList path = new LinkedList();
043:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
044:                    path
045:                            .addFirst((String) getSessionAttribute("search.server.selected"));
046:                    path.addFirst("database");
047:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
048:                            AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
049:                    Object[] params1 = {};
050:                    String[] signatures1 = {};
051:                    ArrayList data = (ArrayList) getMBeanServerConnection()
052:                            .invoke(on, "retrieveAll", params1, signatures1);
053:
054:                    /* 
055:                     ** There is a weird bug where duplicate databases show up in the table.
056:                     ** This has been reported by QA but I have never seen it myself. But I have
057:                     ** added the code below to insure that the ObjectListDataProvider will
058:                     ** not contain any duplicate databases.
059:                     */
060:                    ArrayList al2 = new ArrayList();
061:                    for (int index = 0; index < data.size(); index++) {
062:                        String name = (String) data.get(index);
063:                        if (!al2.contains(name)) {
064:                            al2.add(name);
065:                        }
066:                    }
067:
068:                    for (int index = 0; index < al2.size(); index++) {
069:                        String name = (String) al2.get(index);
070:
071:                        Object[] params2 = { name };
072:                        String[] signatures2 = { "java.lang.String" };
073:                        Properties p = (Properties) getMBeanServerConnection()
074:                                .invoke(on, "getAttributes", params2,
075:                                        signatures2);
076:
077:                        DatabaseBean db = new DatabaseBean();
078:                        db.initialize(name, (p.containsKey("class")) ? true
079:                                : false);
080:                        al1.add(db);
081:                    }
082:                } catch (Exception e) {
083:                    log(Level.SEVERE, "DatabasesBean.DatabasesBean()", e);
084:                }
085:                databases = new ObjectListDataProvider(al1);
086:                databases.setObjectType(DatabaseBean.class);
087:
088:                setSessionAttribute("search.database.showreindexinformation",
089:                        "false");
090:                setSessionAttribute("search.database.showpurgeinformation",
091:                        "false");
092:                setSessionAttribute(
093:                        "search.database.showexpireresourcedescriptionsinformation",
094:                        "false");
095:                setSessionAttribute("search.database.showreindexerror", "false");
096:                setSessionAttribute("search.database.showpurgeerror", "false");
097:                setSessionAttribute(
098:                        "search.database.showexpireresourcedescriptionserror",
099:                        "false");
100:            }
101:
102:            public boolean getShowReindexInformation() {
103:                String value = (String) getSessionAttribute("search.database.showreindexinformation");
104:                if (value.equals("true")) {
105:                    return true;
106:                } else {
107:                    return false;
108:                }
109:            }
110:
111:            public boolean getShowPurgeInformation() {
112:                String value = (String) getSessionAttribute("search.database.showpurgeinformation");
113:                if (value.equals("true")) {
114:                    return true;
115:                } else {
116:                    return false;
117:                }
118:            }
119:
120:            public boolean getShowExpireInformation() {
121:                String value = (String) getSessionAttribute("search.database.showexpireresourcedescriptionsinformation");
122:                if (value.equals("true")) {
123:                    return true;
124:                } else {
125:                    return false;
126:                }
127:            }
128:
129:            public boolean getShowReindexError() {
130:                String value = (String) getSessionAttribute("search.database.showreindexerror");
131:                if (value.equals("true")) {
132:                    return true;
133:                } else {
134:                    return false;
135:                }
136:            }
137:
138:            public boolean getShowPurgeError() {
139:                String value = (String) getSessionAttribute("search.database.showpurgeerror");
140:                if (value.equals("true")) {
141:                    return true;
142:                } else {
143:                    return false;
144:                }
145:            }
146:
147:            public boolean getShowExpireError() {
148:                String value = (String) getSessionAttribute("search.database.showexpireresourcedescriptionserror");
149:                if (value.equals("true")) {
150:                    return true;
151:                } else {
152:                    return false;
153:                }
154:            }
155:
156:            public ObjectListDataProvider getDatabases() {
157:                return databases;
158:            }
159:
160:            public void setDatabases(ObjectListDataProvider databases) {
161:                this .databases = databases;
162:            }
163:
164:            public Option[] getAvailableDatabases() {
165:                ArrayList al = getNonfederatedDatabases();
166:
167:                Option[] options = new Option[al.size() + 1];
168:                options[0] = new Option("", getLocalizedString("search",
169:                        "search.general.select"));
170:                for (int index = 0; index < al.size(); index++) {
171:                    String name = (String) al.get(index);
172:                    options[index + 1] = new Option(name, name);
173:                }
174:                return options;
175:            }
176:
177:            public Option[] getAvailableDatabasesWithDefault() {
178:                ArrayList al = getNonfederatedDatabases();
179:
180:                Option[] options = new Option[al.size() + 1];
181:                options[0] = new Option("", getLocalizedString("search",
182:                        "search.general.usedefault"));
183:                for (int index = 0; index < al.size(); index++) {
184:                    String name = (String) al.get(index);
185:                    options[index + 1] = new Option(name, name);
186:                }
187:                return options;
188:            }
189:
190:            public Option[] getAvailableDatabasesWithAll() {
191:                ArrayList al = getNonfederatedDatabases();
192:
193:                Option[] options = new Option[al.size() + 1];
194:
195:                StringBuffer sb = new StringBuffer();
196:                for (int index = 0; index < al.size(); index++) {
197:                    String name = (String) al.get(index);
198:                    options[index] = new Option(name, name);
199:                    if (index == 0) {
200:                        sb.append(name);
201:                    } else {
202:                        sb.append(":" + name);
203:                    }
204:                }
205:                options[al.size()] = new Option(sb.toString(),
206:                        getLocalizedString("search",
207:                                "search.general.alldatabases"));
208:                return options;
209:            }
210:
211:            public String gotoCreateDatabase() {
212:                setSessionAttribute("search.createdatabase.name", null);
213:                setSessionAttribute("search.createdatabase.attributes", null);
214:                return "gotoCreateDatabase";
215:            }
216:
217:            public String gotoEditDatabase() {
218:                FacesContext fc = FacesContext.getCurrentInstance();
219:                ValueBinding vb = fc.getApplication().createValueBinding(
220:                        "#{database.value.name}");
221:                setSessionAttribute("search.database.selected", (String) vb
222:                        .getValue(fc));
223:                setSessionAttribute("search.editdatabaseattributes.attributes",
224:                        null);
225:                return "gotoEditDatabase";
226:            }
227:
228:            public String reindex() {
229:                try {
230:                    LinkedList path = new LinkedList();
231:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
232:                    path
233:                            .addFirst((String) getSessionAttribute("search.server.selected"));
234:                    path.addFirst("database");
235:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
236:                            AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
237:
238:                    List l = Checkbox.getSelected("checkbox");
239:                    for (int index = 0; index < l.size(); index++) {
240:                        Object[] params = { (String) l.get(index) };
241:                        String[] signatures = { "java.lang.String" };
242:                        getMBeanServerConnection().invoke(on, "reindex",
243:                                params, signatures);
244:                    }
245:                    setSessionAttribute(
246:                            "search.database.showreindexinformation", "true");
247:                    setSessionAttribute("search.database.showreindexerror",
248:                            "false");
249:                } catch (Exception e) {
250:                    setSessionAttribute(
251:                            "search.database.showreindexinformation", "false");
252:                    setSessionAttribute("search.database.showreindexerror",
253:                            "true");
254:                    log(Level.SEVERE, "DatabasesBean.reindex()", e);
255:                }
256:                return null;
257:            }
258:
259:            public String purge() {
260:                try {
261:                    LinkedList path = new LinkedList();
262:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
263:                    path
264:                            .addFirst((String) getSessionAttribute("search.server.selected"));
265:                    path.addFirst("database");
266:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
267:                            AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
268:
269:                    List l = Checkbox.getSelected("checkbox");
270:                    for (int index = 0; index < l.size(); index++) {
271:                        Object[] params = { (String) l.get(index) };
272:                        String[] signatures = { "java.lang.String" };
273:                        getMBeanServerConnection().invoke(on, "purge", params,
274:                                signatures);
275:                    }
276:                    setSessionAttribute("search.database.showpurgeinformation",
277:                            "true");
278:                    setSessionAttribute("search.database.showpurgeerror",
279:                            "false");
280:                } catch (Exception e) {
281:                    setSessionAttribute("search.database.showpurgeinformation",
282:                            "false");
283:                    setSessionAttribute("search.database.showpurgeerror",
284:                            "true");
285:                    log(Level.SEVERE, "DatabasesBean.purge()", e);
286:                }
287:                return null;
288:            }
289:
290:            public String gotoAnalysesHome() {
291:                List l = Checkbox.getSelected("checkbox");
292:                setSessionAttribute("search.database.selected", (String) l
293:                        .get(0));
294:                return "gotoAnalysesHome";
295:            }
296:
297:            public String gotoResourceDescriptionsHome() {
298:                List l = Checkbox.getSelected("checkbox");
299:                setSessionAttribute("search.database.selected", (String) l
300:                        .get(0));
301:                setSessionAttribute(
302:                        "search.resourcedescriptions.resourcedescriptions",
303:                        null);
304:                return "gotoResourceDescriptionsHome";
305:            }
306:
307:            public String expireResourceDescriptions() {
308:                try {
309:                    LinkedList path = new LinkedList();
310:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
311:                    path
312:                            .addFirst((String) getSessionAttribute("search.server.selected"));
313:                    path.addFirst("database");
314:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
315:                            AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
316:
317:                    List l = Checkbox.getSelected("checkbox");
318:                    for (int index = 0; index < l.size(); index++) {
319:                        Object[] params = { (String) l.get(index) };
320:                        String[] signatures = { "java.lang.String" };
321:                        getMBeanServerConnection().invoke(on, "expire", params,
322:                                signatures);
323:                    }
324:                    setSessionAttribute(
325:                            "search.database.showexpireresourcedescriptionsinformation",
326:                            "true");
327:                    setSessionAttribute(
328:                            "search.database.showexpireresourcedescriptionserror",
329:                            "false");
330:                } catch (Exception e) {
331:                    setSessionAttribute(
332:                            "search.database.showexpireresourcedescriptionsinformation",
333:                            "false");
334:                    setSessionAttribute(
335:                            "search.database.showexpireresourcedescriptionserror",
336:                            "true");
337:                    log(Level.SEVERE,
338:                            "DatabasesBean.expireResourceDescriptions()", e);
339:                }
340:                return null;
341:            }
342:
343:            private ArrayList getNonfederatedDatabases() {
344:                ArrayList al = new ArrayList();
345:                try {
346:                    LinkedList path = new LinkedList();
347:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
348:                    path
349:                            .addFirst((String) getSessionAttribute("search.server.selected"));
350:                    path.addFirst("database");
351:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
352:                            AdminClientUtil.SEARCH_DATABASE_MBEAN_TYPE, path);
353:                    Object[] params1 = {};
354:                    String[] signatures1 = {};
355:                    ArrayList data = (ArrayList) getMBeanServerConnection()
356:                            .invoke(on, "retrieveAll", params1, signatures1);
357:
358:                    /* 
359:                     ** There is a weird bug where duplicate databases show up in the table.
360:                     ** This has been reported by QA but I have never seen it myself. But I have
361:                     ** added the code below to insure that the ArrayList will not contain any
362:                     ** duplicate databases.
363:                     */
364:                    for (int index = 0; index < data.size(); index++) {
365:                        String name = (String) data.get(index);
366:                        Object[] params2 = { name };
367:                        String[] signatures2 = { "java.lang.String" };
368:                        Properties p = (Properties) getMBeanServerConnection()
369:                                .invoke(on, "getAttributes", params2,
370:                                        signatures2);
371:                        if (!p.containsKey("class") && !al.contains(name)) {
372:                            al.add(name);
373:                        }
374:                    }
375:                } catch (Exception e) {
376:                    log(Level.SEVERE,
377:                            "DatabasesBean.getNonfederatedDatabases()", e);
378:                }
379:                return al;
380:            }
381:
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.