Source Code Cross Referenced for RobotOverviewBean.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.IOException;
017:        import java.lang.InterruptedException;
018:        import java.text.*;
019:
020:        import javax.management.ObjectName;
021:        import javax.management.MBeanServerConnection;
022:        import javax.faces.event.ActionEvent;
023:        import javax.faces.context.FacesContext;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import com.sun.data.provider.DataProvider;
028:        import com.sun.data.provider.impl.ObjectListDataProvider;
029:        import com.sun.web.ui.component.RadioButton;
030:
031:        import com.sun.portal.admin.common.util.AdminClientUtil;
032:        import com.sun.portal.admin.console.common.PSBaseBean;
033:
034:        public class RobotOverviewBean extends PSBaseBean {
035:
036:            private String statusFlag = getLocalizedString("robot.is.off");
037:            private String updateTime = " ";
038:            private String startingPoints = " ";
039:            private String urlPool = " ";
040:            private String extracting = " ";
041:            private String filtering = " ";
042:            private String indexing = " ";
043:            private String excludedByFilter = " ";
044:            private String excludedByError = " ";
045:            private String rdNumber = " ";
046:            private String rdSize = " ";
047:            private String urlRetrieved = " ";
048:            private String rdAverageSize = " ";
049:            private String runningTime = " ";
050:
051:            private boolean disableStartButton = false;
052:            private boolean disableStopButton = true;
053:            private boolean disablePauseButton = true;
054:            private boolean disableResumeButton = true;
055:            private boolean refreshButton = false;
056:
057:            private String[] states = { "0", "0", "0", "0", "0", "0", "0", "0",
058:                    "0", "0", "0", "0", "0" };
059:
060:            public RobotOverviewBean() {
061:                getRobotStatus();
062:                generateOverview();
063:            }
064:
065:            public void getRobotStatus() {
066:                try {
067:                    LinkedList path = new LinkedList();
068:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
069:                    path
070:                            .addFirst((String) getSessionAttribute("search.server.selected"));
071:                    path.addFirst("robot");
072:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
073:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
074:
075:                    Object[] params = {};
076:                    String[] signatures = {};
077:                    states = (String[]) getMBeanServerConnection().invoke(on,
078:                            "retrieveRobotStatus", params, signatures);
079:                } catch (Exception e) {
080:                    log(
081:                            Level.SEVERE,
082:                            "RobotOverviewBean.getRobotStatus() failed to get robot status",
083:                            e);
084:                }
085:            }
086:
087:            public void generateOverview() {
088:
089:                FacesContext context = FacesContext.getCurrentInstance();
090:                HttpServletRequest req = (HttpServletRequest) context
091:                        .getExternalContext().getRequest();
092:                Locale locale = req.getLocale();
093:                if (locale == null) {
094:                    locale = Locale.getDefault();
095:                }
096:                DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
097:                        DateFormat.LONG, locale);
098:
099:                if (states[0].equalsIgnoreCase("Off")) {
100:
101:                    statusFlag = getLocalizedString("robot.is.off");
102:                    disableStartButton = false;
103:                    disableStopButton = true;
104:                    disablePauseButton = true;
105:                    disableResumeButton = true;
106:                    refreshButton = false;
107:
108:                } else {
109:
110:                    if (states[0].equalsIgnoreCase("Running")) {
111:                        statusFlag = getLocalizedString("robot.is.running");
112:                        disableStartButton = true;
113:                        disableStopButton = false;
114:                        disablePauseButton = false;
115:                        disableResumeButton = true;
116:                        refreshButton = true;
117:                    }
118:
119:                    if (states[0].equalsIgnoreCase("Idle")) {
120:                        statusFlag = getLocalizedString("robot.is.idle");
121:                        disableStartButton = true;
122:                        disableStopButton = false;
123:                        disablePauseButton = false;
124:                        disableResumeButton = true;
125:                        refreshButton = true;
126:                    }
127:
128:                    if (states[0].equalsIgnoreCase("Paused")) {
129:                        statusFlag = getLocalizedString("robot.is.paused");
130:                        disableStartButton = true;
131:                        disableStopButton = false;
132:                        disablePauseButton = true;
133:                        disableResumeButton = false;
134:                        refreshButton = true;
135:                    }
136:
137:                    if (states[0].equalsIgnoreCase("Unknown")) {
138:                        statusFlag = getLocalizedString("robot.is.unknown");
139:                    }
140:
141:                }
142:
143:                updateTime = getLocalizedString("robot.updatedat",
144:                        new Object[] { (String) df.format(new Date()) });
145:                startingPoints = getLocalizedString(
146:                        "robot.startingpoints.defined",
147:                        new Object[] { (String) states[1] });
148:                urlPool = getLocalizedString("robot.urlpool.waiting",
149:                        new Object[] { (String) states[2] });
150:                extracting = getLocalizedString("robot.extracting.persecond",
151:                        new Object[] { (String) states[3] });
152:                filtering = getLocalizedString("robot.filtering.rejected",
153:                        new Object[] { (String) states[4] });
154:                indexing = getLocalizedString("robot.indexing.persecond",
155:                        new Object[] { (String) states[5] });
156:                excludedByFilter = getLocalizedString(
157:                        "robot.excludedurls.byfilter",
158:                        new Object[] { (String) states[6] });
159:                excludedByError = getLocalizedString(
160:                        "robot.excludedurls.byerror",
161:                        new Object[] { (String) states[7] });
162:                rdNumber = getLocalizedString("robot.rds.contributed",
163:                        new Object[] { (String) states[8] });
164:                rdSize = getLocalizedString("robot.rds.generated",
165:                        new Object[] { getUnitString((String) states[9]) });
166:                urlRetrieved = getLocalizedString(
167:                        "robot.generalstatus.retrieved",
168:                        new Object[] { (String) states[10] });
169:                rdAverageSize = getLocalizedString(
170:                        "robot.generalstatus.avgsize",
171:                        new Object[] { (String) states[11] });
172:                runningTime = getLocalizedString(
173:                        "robot.generalstatus.runningtime",
174:                        new Object[] { getRunTime(states[12]) });
175:
176:            }
177:
178:            /*
179:             * Methods for Get/Set Bean Elements
180:             */
181:            public String getStatusFlag() {
182:                return statusFlag;
183:            }
184:
185:            public void setStatusFlag(String s) {
186:                this .statusFlag = s;
187:            }
188:
189:            public String getUpdateTime() {
190:                return updateTime;
191:            }
192:
193:            public void setUpdateTime(String s) {
194:                this .updateTime = s;
195:            }
196:
197:            public String getStartingPoints() {
198:                return startingPoints;
199:            }
200:
201:            public void setStartingPoints(String s) {
202:                this .startingPoints = s;
203:            }
204:
205:            public String getUrlPool() {
206:                return urlPool;
207:            }
208:
209:            public void setUrlPool(String s) {
210:                this .urlPool = s;
211:            }
212:
213:            public String getExtracting() {
214:                return extracting;
215:            }
216:
217:            public void setExtracting(String s) {
218:                this .extracting = s;
219:            }
220:
221:            public String getFiltering() {
222:                return filtering;
223:            }
224:
225:            public void setFiltering(String s) {
226:                this .filtering = s;
227:            }
228:
229:            public String getIndexing() {
230:                return indexing;
231:            }
232:
233:            public void setIndexing(String s) {
234:                this .indexing = s;
235:            }
236:
237:            public String getExcludedByFilter() {
238:                return excludedByFilter;
239:            }
240:
241:            public void setExcludedByFilter(String s) {
242:                this .excludedByFilter = s;
243:            }
244:
245:            public String getExcludedByError() {
246:                return excludedByError;
247:            }
248:
249:            public void setExcludedByError(String s) {
250:                this .excludedByError = s;
251:            }
252:
253:            public String getRdNumber() {
254:                return rdNumber;
255:            }
256:
257:            public void setRdNumber(String s) {
258:                this .rdNumber = s;
259:            }
260:
261:            public String getRdSize() {
262:                return rdSize;
263:            }
264:
265:            public void setRdSize(String s) {
266:                this .rdSize = s;
267:            }
268:
269:            public String getUrlRetrieved() {
270:                return urlRetrieved;
271:            }
272:
273:            public void setUrlRetrieved(String s) {
274:                this .urlRetrieved = s;
275:            }
276:
277:            public String getRdAverageSize() {
278:                return rdAverageSize;
279:            }
280:
281:            public void setRdAverageSize(String s) {
282:                this .rdAverageSize = s;
283:            }
284:
285:            public String getRunningTime() {
286:                return runningTime;
287:            }
288:
289:            public void setRunningTime(String s) {
290:                this .runningTime = s;
291:            }
292:
293:            public boolean getDisableStartButton() {
294:                return disableStartButton;
295:            }
296:
297:            public boolean getDisableStopButton() {
298:                return disableStopButton;
299:            }
300:
301:            public boolean getDisablePauseButton() {
302:                return disablePauseButton;
303:            }
304:
305:            public boolean getDisableResumeButton() {
306:                return disableResumeButton;
307:            }
308:
309:            public boolean getRefreshButton() {
310:                return refreshButton;
311:            }
312:
313:            /* 
314:             * Button Actions
315:             */
316:            public String startRobot() {
317:                try {
318:                    LinkedList path = new LinkedList();
319:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
320:                    path
321:                            .addFirst((String) getSessionAttribute("search.server.selected"));
322:                    path.addFirst("robot");
323:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
324:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
325:
326:                    Object[] params = {};
327:                    String[] signature = {};
328:
329:                    getMBeanServerConnection().invoke(on, "start", params,
330:                            signature);
331:
332:                } catch (Exception e) {
333:                    log(
334:                            Level.SEVERE,
335:                            "RobotOverviewBean.startRobot() failed to start robot",
336:                            e);
337:                }
338:
339:                return "gotoRobotHome";
340:            }
341:
342:            public String stopRobot() {
343:                try {
344:                    LinkedList path = new LinkedList();
345:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
346:                    path
347:                            .addFirst((String) getSessionAttribute("search.server.selected"));
348:                    path.addFirst("robot");
349:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
350:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
351:
352:                    Object[] params = {};
353:                    String[] signature = {};
354:
355:                    getMBeanServerConnection().invoke(on, "stop", params,
356:                            signature);
357:
358:                } catch (Exception e) {
359:                    log(
360:                            Level.SEVERE,
361:                            "RobotOverviewBean.stopRobot() failed to stop robot",
362:                            e);
363:                }
364:
365:                return "gotoRobotHome";
366:            }
367:
368:            public String refresh() {
369:                try {
370:                    LinkedList path = new LinkedList();
371:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
372:                    path
373:                            .addFirst((String) getSessionAttribute("search.server.selected"));
374:                    path.addFirst("robot");
375:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
376:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
377:
378:                    Object[] params = {};
379:                    String[] signature = {};
380:
381:                    getMBeanServerConnection().invoke(on, "refresh", params,
382:                            signature);
383:                } catch (Exception e) {
384:                    log(
385:                            Level.SEVERE,
386:                            "RobotOverviewBean.refresh() failed to refresh robot",
387:                            e);
388:                }
389:                return "gotoRobotHome";
390:            }
391:
392:            public String pause() {
393:                try {
394:                    LinkedList path = new LinkedList();
395:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
396:                    path
397:                            .addFirst((String) getSessionAttribute("search.server.selected"));
398:                    path.addFirst("robot");
399:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
400:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
401:
402:                    Object[] params = {};
403:                    String[] signature = {};
404:
405:                    getMBeanServerConnection().invoke(on, "pause", params,
406:                            signature);
407:
408:                } catch (Exception e) {
409:                    log(Level.SEVERE,
410:                            "RobotOverviewBean.pause() failed to pause robot",
411:                            e);
412:                }
413:                return "gotoRobotHome";
414:            }
415:
416:            public String resume() {
417:                try {
418:                    LinkedList path = new LinkedList();
419:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
420:                    path
421:                            .addFirst((String) getSessionAttribute("search.server.selected"));
422:                    path.addFirst("robot");
423:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
424:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
425:
426:                    Object[] params = {};
427:                    String[] signature = {};
428:
429:                    getMBeanServerConnection().invoke(on, "resume", params,
430:                            signature);
431:
432:                } catch (Exception e) {
433:                    log(
434:                            Level.SEVERE,
435:                            "RobotOverviewBean.resume() failed to resume robot",
436:                            e);
437:                }
438:                return "gotoRobotHome";
439:            }
440:
441:            /*
442:             * Private Methods
443:             */
444:            private String getUnitString(String s) {
445:
446:                double generated = 0;
447:                int unit = 0;
448:                String[] unitString = { "robot.bytes", "robot.kbytes",
449:                        "robot.mbytes", "robot.gbytes" };
450:                try {
451:                    generated = (double) Long.parseLong(s);
452:                    if (generated > 1000.0) {
453:                        generated = generated / 1000.0;
454:                        if (generated > 1000.0) {
455:                            generated = generated / 1000.0;
456:                            unit = 2;
457:                        } else {
458:                            unit = 1;
459:                        }
460:                    }
461:                } catch (Exception e) {
462:                }
463:                NumberFormat nf = NumberFormat.getInstance();
464:                nf = NumberFormat.getInstance();
465:                nf.setMaximumFractionDigits(2);
466:                return nf.format(generated) + " "
467:                        + getLocalizedString(unitString[unit]);
468:            }
469:
470:            private String getRunTime(String s) {
471:
472:                String runTime = "";
473:                long run_time = Long.parseLong(s);
474:                long day = 0, hour = 0, minute = 0, second = 0;
475:                if (run_time >= 86400) {
476:                    day = run_time / 86400;
477:                    run_time = run_time % 86400;
478:                    if (day == 1) {
479:                        runTime = "1 " + getLocalizedString("time.day") + " ";
480:                    } else {
481:                        runTime = Long.toString(day) + " "
482:                                + getLocalizedString("time.days") + " ";
483:                    }
484:                }
485:                if (run_time > 3600) {
486:                    hour = run_time / 3600;
487:                    run_time = run_time % 3600;
488:                    if (hour == 1) {
489:                        runTime = runTime + "1 "
490:                                + getLocalizedString("time.hour") + " ";
491:                    } else {
492:                        runTime = runTime + Long.toString(hour) + " "
493:                                + getLocalizedString("time.hours") + " ";
494:                    }
495:                }
496:                if (run_time > 60) {
497:                    minute = run_time / 60;
498:                    run_time = run_time % 60;
499:                    if (minute == 1) {
500:                        runTime = runTime + "1 "
501:                                + getLocalizedString("time.minute") + " ";
502:                    } else {
503:                        runTime = runTime + Long.toString(minute) + " "
504:                                + getLocalizedString("time.minutes") + " ";
505:                    }
506:                }
507:                if (run_time == 1) {
508:                    runTime = runTime + "1 "
509:                            + getLocalizedString("time.second") + " ";
510:                } else {
511:                    runTime = runTime + Long.toString(run_time) + " "
512:                            + getLocalizedString("time.seconds") + " ";
513:                }
514:
515:                return runTime;
516:            }
517:
518:            private String getLocalizedString(String key) {
519:                return super .getLocalizedString("search", key);
520:            }
521:
522:            private String getLocalizedString(String key, Object[] arguments) {
523:                String pattern = super .getLocalizedString("search", key);
524:                MessageFormat msgFormat = new MessageFormat("");
525:                msgFormat.applyPattern(pattern);
526:                return msgFormat.format(arguments);
527:            }
528:
529:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.