Source Code Cross Referenced for EditRobotSiteBean.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.component.*;
024:        import com.sun.web.ui.model.*;
025:        import com.sun.web.ui.event.*;
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 EditRobotSiteBean extends PSBaseBean {
036:
037:            private String siteName = "";
038:            private String siteDesc = "";
039:            private String siteDNS = "";
040:            private String database = "";
041:            private String port = "";
042:            private String[] protocols = null;
043:            private String allfilematch = "allow";
044:            private DataProvider domains = null;
045:            private DataProvider servers = null;
046:            private DataProvider startpoints = null;
047:            private DataProvider filterdefs = null;
048:            private DataProvider allfilesmatch = null;
049:
050:            private Boolean renderDomain = null;
051:            private Boolean renderServer = null;
052:
053:            private TableSelectPhaseListener tspl1 = null;
054:            private TableSelectPhaseListener tspl2 = null;
055:            private TableSelectPhaseListener tspl3 = null;
056:            private TableSelectPhaseListener tspl4 = null;
057:
058:            private TableRowGroup tableRowGroup1 = null;
059:            private TableRowGroup tableRowGroup2 = null;
060:            private TableRowGroup tableRowGroup3 = null;
061:            private TableRowGroup tableRowGroup4 = null;
062:
063:            private Option[] typeOption;
064:            private Option[] protocolOption;
065:            private Option[] depthOption;
066:            private Option[] filterMatchOption;
067:            private Option[] filterRuleOption;
068:
069:            private String siteId = "";
070:
071:            public EditRobotSiteBean() {
072:                tspl1 = new TableSelectPhaseListener();
073:                tspl2 = new TableSelectPhaseListener();
074:                tspl3 = new TableSelectPhaseListener();
075:                tspl4 = new TableSelectPhaseListener();
076:            }
077:
078:            /*
079:             * Methods to Get/Set Bean elements
080:             */
081:            public String getSiteName() {
082:                if (!siteId
083:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
084:                    generateRobotSite();
085:                    tspl1.clear();
086:                    tspl2.clear();
087:                    tspl3.clear();
088:                    tspl4.clear();
089:                }
090:                return siteName;
091:            }
092:
093:            public void setSiteName(String s) {
094:                this .siteName = s;
095:            }
096:
097:            public String getSiteDesc() {
098:                if (!siteId
099:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
100:                    generateRobotSite();
101:                    tspl1.clear();
102:                    tspl2.clear();
103:                    tspl3.clear();
104:                    tspl4.clear();
105:                }
106:                return siteDesc;
107:            }
108:
109:            public void setSiteDesc(String s) {
110:                this .siteDesc = s;
111:            }
112:
113:            public String getSiteDNS() {
114:                if (!siteId
115:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
116:                    generateRobotSite();
117:                    tspl1.clear();
118:                    tspl2.clear();
119:                    tspl3.clear();
120:                    tspl4.clear();
121:                }
122:                return siteDNS;
123:            }
124:
125:            public void setSiteDNS(String s) {
126:                this .siteDNS = s;
127:            }
128:
129:            public String getDatabase() {
130:                if (!siteId
131:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
132:                    generateRobotSite();
133:                    tspl1.clear();
134:                    tspl2.clear();
135:                    tspl3.clear();
136:                    tspl4.clear();
137:                }
138:                return database;
139:            }
140:
141:            public void setDatabase(String d) {
142:                this .database = d;
143:            }
144:
145:            // domain table methods
146:
147:            public Boolean getRenderDomain() {
148:                if (!siteId
149:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
150:                    generateRobotSite();
151:                    tspl1.clear();
152:                }
153:                return renderDomain;
154:            }
155:
156:            public String getPort() {
157:                if (!siteId
158:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
159:                    generateRobotSite();
160:                    tspl1.clear();
161:                }
162:                return port;
163:            }
164:
165:            public void setPort(String s) {
166:                if (port != null) {
167:                    this .port = s;
168:                } else {
169:                    port = "";
170:                }
171:
172:            }
173:
174:            public String[] getProtocols() {
175:                if (!siteId
176:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
177:                    generateRobotSite();
178:                    tspl1.clear();
179:                }
180:                return protocols;
181:            }
182:
183:            public void setProtocols(String[] s) {
184:                this .protocols = s;
185:            }
186:
187:            public DataProvider getDomains() {
188:                if (!siteId
189:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
190:                    generateRobotSite();
191:                    tspl1.clear();
192:                }
193:                return domains;
194:            }
195:
196:            public void setDomains(DataProvider domains) {
197:                this .domains = domains;
198:            }
199:
200:            public TableRowGroup getTableRowGroup1() {
201:                return tableRowGroup1;
202:            }
203:
204:            public void setTableRowGroup1(TableRowGroup tableRowGroup1) {
205:                this .tableRowGroup1 = tableRowGroup1;
206:            }
207:
208:            public Object getSelected1() {
209:                return tspl1.getSelected(getTableRow1());
210:            }
211:
212:            public void setSelected1(Object object) {
213:                tspl1.setSelected(getTableRow1(), object);
214:            }
215:
216:            // server table methods
217:
218:            public Boolean getRenderServer() {
219:                if (!siteId
220:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
221:                    generateRobotSite();
222:                    tspl2.clear();
223:                }
224:                return renderServer;
225:            }
226:
227:            public DataProvider getServers() {
228:                if (!siteId
229:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
230:                    generateRobotSite();
231:                    tspl2.clear();
232:                }
233:                return servers;
234:            }
235:
236:            public void setServers(DataProvider servers) {
237:                this .servers = servers;
238:            }
239:
240:            public TableRowGroup getTableRowGroup2() {
241:                return tableRowGroup2;
242:            }
243:
244:            public void setTableRowGroup2(TableRowGroup tableRowGroup2) {
245:                this .tableRowGroup2 = tableRowGroup2;
246:            }
247:
248:            public Object getSelected2() {
249:                return tspl2.getSelected(getTableRow2());
250:            }
251:
252:            public void setSelected2(Object object) {
253:                tspl2.setSelected(getTableRow2(), object);
254:            }
255:
256:            // starting points table methods
257:
258:            public DataProvider getStartpoints() {
259:                if (!siteId
260:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
261:                    generateRobotSite();
262:                    tspl3.clear();
263:                }
264:                return startpoints;
265:            }
266:
267:            public void setStartpoints(DataProvider startpoints) {
268:                this .startpoints = startpoints;
269:            }
270:
271:            public TableRowGroup getTableRowGroup3() {
272:                return tableRowGroup3;
273:            }
274:
275:            public void setTableRowGroup3(TableRowGroup tableRowGroup3) {
276:                this .tableRowGroup3 = tableRowGroup3;
277:            }
278:
279:            public Object getSelected3() {
280:                return tspl3.getSelected(getTableRow3());
281:            }
282:
283:            public void setSelected3(Object object) {
284:                tspl3.setSelected(getTableRow3(), object);
285:            }
286:
287:            // filter defintion table methods
288:
289:            public DataProvider getFilterdefs() {
290:                if (!siteId
291:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
292:                    generateRobotSite();
293:                    tspl4.clear();
294:                }
295:                return filterdefs;
296:            }
297:
298:            public void setFilterdefs(DataProvider filterdefs) {
299:                this .filterdefs = filterdefs;
300:            }
301:
302:            public TableRowGroup getTableRowGroup4() {
303:                return tableRowGroup4;
304:            }
305:
306:            public void setTableRowGroup4(TableRowGroup tableRowGroup4) {
307:                this .tableRowGroup4 = tableRowGroup4;
308:            }
309:
310:            public Object getSelected4() {
311:                return tspl4.getSelected(getTableRow4());
312:            }
313:
314:            public void setSelected4(Object object) {
315:                tspl4.setSelected(getTableRow4(), object);
316:            }
317:
318:            public DataProvider getAllfilesmatch() {
319:                if (!siteId
320:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
321:                    generateRobotSite();
322:                    tspl4.clear();
323:                }
324:                return allfilesmatch;
325:            }
326:
327:            public void setAllfilesmatch(DataProvider allfilesmatch) {
328:                this .allfilesmatch = allfilesmatch;
329:            }
330:
331:            public String getAllfilematch() {
332:                if (!siteId
333:                        .equals((String) getSessionAttribute("robot.site.selected"))) {
334:                    generateRobotSite();
335:                    tspl4.clear();
336:                }
337:                return allfilematch;
338:            }
339:
340:            public void setAllfilematch(String s) {
341:                this .allfilematch = s;
342:            }
343:
344:            /*
345:             * Methods for UI options
346:             */
347:            public Option[] getTypeOption() {
348:                typeOption = new Option[4];
349:                ArrayList types = getStringList(getLocalizedString("robot.site.type.listlabel"));
350:                typeOption[0] = new Option("http", (String) types.get(0));
351:                typeOption[1] = new Option("file", (String) types.get(1));
352:                typeOption[2] = new Option("ftp", (String) types.get(2));
353:                typeOption[3] = new Option("https", (String) types.get(3));
354:                return typeOption;
355:            }
356:
357:            public Option[] getProtocolOption() {
358:                protocolOption = new Option[4];
359:                protocolOption[0] = new Option("http", "http");
360:                protocolOption[1] = new Option("file", "file");
361:                protocolOption[2] = new Option("ftp", "ftp");
362:                protocolOption[3] = new Option("https", "https");
363:                return protocolOption;
364:            }
365:
366:            public Option[] getDepthOption() {
367:                depthOption = new Option[12];
368:                ArrayList values = getStringList(getLocalizedString("robot.site.create.depthlistvalue"));
369:                ArrayList labels = getStringList(getLocalizedString("robot.site.create.depthlistlabel"));
370:                for (int i = 0; i < 12; i++) {
371:                    depthOption[i] = new Option((String) values.get(i),
372:                            (String) labels.get(i));
373:                }
374:                return depthOption;
375:            }
376:
377:            public Option[] getFilterMatchOption() {
378:                filterMatchOption = new Option[2];
379:                filterMatchOption[0] = new Option("deny",
380:                        getLocalizedString("robot.site.filterexclude"));
381:                filterMatchOption[1] = new Option("allow",
382:                        getLocalizedString("robot.site.filterinclude"));
383:                return filterMatchOption;
384:            }
385:
386:            public Option[] getFilterRuleOption() {
387:                try {
388:                    LinkedList path = new LinkedList();
389:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
390:                    path
391:                            .addFirst((String) getSessionAttribute("search.server.selected"));
392:                    path.addFirst("robot");
393:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
394:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
395:
396:                    Object[] params = {};
397:                    String[] signatures = {};
398:
399:                    String[] ruleLabels = (String[]) getMBeanServerConnection()
400:                            .invoke(on, "retrieveFilterRuleNames", params,
401:                                    signatures);
402:
403:                    String[] ruleValues = (String[]) getMBeanServerConnection()
404:                            .invoke(on, "retrieveFilterRuleIds", params,
405:                                    signatures);
406:
407:                    filterRuleOption = new Option[ruleLabels.length + 1];
408:                    filterRuleOption[0] = new Option("",
409:                            getLocalizedString("robot.site.filterrule.select"));
410:                    for (int i = 0, j = 1; i < ruleLabels.length; i++, j++) {
411:                        if (ruleLabels[i].startsWith("filter.default")) {
412:                            filterRuleOption[j] = new Option(
413:                                    (String) ruleValues[i],
414:                                    getLocalizedString(ruleLabels[i]));
415:                        } else {
416:                            filterRuleOption[j] = new Option(
417:                                    (String) ruleValues[i],
418:                                    (String) ruleLabels[i]);
419:                        }
420:                    }
421:
422:                } catch (Exception e) {
423:                    log(
424:                            Level.SEVERE,
425:                            "EditRobotSiteBean.getFilterRuleOption() failed to get the robot site filter rule option for site Id "
426:                                    + siteId, e);
427:                }
428:
429:                return filterRuleOption;
430:            }
431:
432:            /*
433:             * Button Actions
434:             */
435:            public String save() {
436:                try {
437:                    LinkedList path = new LinkedList();
438:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
439:                    path
440:                            .addFirst((String) getSessionAttribute("search.server.selected"));
441:                    path.addFirst("robot");
442:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
443:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
444:
445:                    ArrayList dl = new ArrayList();
446:                    ArrayList pl = new ArrayList();
447:                    ArrayList sl = new ArrayList();
448:                    ArrayList spl = new ArrayList();
449:                    ArrayList fl = new ArrayList();
450:
451:                    if (renderDomain.booleanValue() && domains != null) {
452:                        ObjectListDataProvider oldp = (ObjectListDataProvider) domains;
453:                        oldp.commitChanges();
454:                        List l = oldp.getList();
455:                        for (int i = 0; i < l.size(); i++) {
456:                            DomainSiteBean b = (DomainSiteBean) l.get(i);
457:                            dl.add(b.domainString);
458:                        }
459:
460:                        for (int i = 0; i < protocols.length; i++) {
461:                            pl.add(protocols[i]);
462:                        }
463:                    }
464:
465:                    if (renderServer.booleanValue() && servers != null) {
466:                        ObjectListDataProvider oldp = (ObjectListDataProvider) servers;
467:                        oldp.commitChanges();
468:                        List l = oldp.getList();
469:                        for (int i = 0; i < l.size(); i++) {
470:                            ServerSiteBean b = (ServerSiteBean) l.get(i);
471:                            HashMap server = new HashMap();
472:                            server.put("Host", b.server);
473:                            server.put("Protocol", b.protocol);
474:                            server.put("Port", b.port);
475:                            sl.add(server);
476:                        }
477:                    }
478:
479:                    if (startpoints != null) {
480:                        ObjectListDataProvider oldp = (ObjectListDataProvider) startpoints;
481:                        oldp.commitChanges();
482:                        List l = oldp.getList();
483:                        for (int i = 0; i < l.size(); i++) {
484:                            StartPointBean b = (StartPointBean) l.get(i);
485:                            HashMap sp = new HashMap();
486:                            if (!b.url.equals("")) {
487:                                sp.put("URL", b.url);
488:                                sp.put("Depth", b.depth);
489:                                spl.add(sp);
490:                            }
491:                        }
492:                    }
493:
494:                    if (filterdefs != null) {
495:                        ObjectListDataProvider oldp = (ObjectListDataProvider) filterdefs;
496:                        oldp.commitChanges();
497:                        List l = oldp.getList();
498:                        for (int j = 0; j < l.size(); j++) {
499:                            FilterDefinitionBean b = (FilterDefinitionBean) l
500:                                    .get(j);
501:                            HashMap filter = new HashMap();
502:                            filter.put("Rule", b.rule);
503:                            filter.put("Match", b.match);
504:                            fl.add(filter);
505:                        }
506:                    }
507:
508:                    Object[] params = { siteId, siteName, siteDesc, siteDNS,
509:                            database, dl, port, pl, sl, spl, fl, allfilematch };
510:                    String[] signature = { "java.lang.String",
511:                            "java.lang.String", "java.lang.String",
512:                            "java.lang.String", "java.lang.String",
513:                            "java.util.ArrayList", "java.lang.String",
514:                            "java.util.ArrayList", "java.util.ArrayList",
515:                            "java.util.ArrayList", "java.util.ArrayList",
516:                            "java.lang.String" };
517:
518:                    getMBeanServerConnection().invoke(on, "editSite", params,
519:                            signature);
520:
521:                } catch (Exception e) {
522:                    log(Level.SEVERE,
523:                            "EditRobotSiteBean.save() failed to edit the robot site Id "
524:                                    + siteId, e);
525:                }
526:
527:                siteId = "";
528:                renderDomain = null;
529:                renderServer = null;
530:                tspl1.clear();
531:                tspl2.clear();
532:                tspl3.clear();
533:                tspl4.clear();
534:                return "gotoRobotSitesHome";
535:            }
536:
537:            public String cancel() {
538:                siteId = "";
539:                renderDomain = null;
540:                renderServer = null;
541:                tspl1.clear();
542:                tspl2.clear();
543:                tspl3.clear();
544:                tspl4.clear();
545:                return "gotoRobotSitesHome";
546:            }
547:
548:            public String createDomain() { //create a row to the domain table
549:                ObjectListDataProvider oldp = (ObjectListDataProvider) domains;
550:                oldp.addObject(new DomainSiteBean(""));
551:                oldp.commitChanges();
552:                return "gotoEditRobotSite";
553:            }
554:
555:            public String deleteDomain() { //delete a row from the domain table
556:                ObjectListDataProvider oldp = (ObjectListDataProvider) domains;
557:
558:                RowKey[] rowKeys = tableRowGroup1.getRenderedRowKeys();
559:                for (int index = 0; index < rowKeys.length; index++) {
560:                    RowKey rowKey = rowKeys[index];
561:                    if (tspl1.isSelected(rowKey)) {
562:                        oldp.removeRow(rowKey);
563:                    }
564:                }
565:
566:                oldp.commitChanges();
567:                tspl1.clear();
568:                return "gotoEditRobotSite";
569:            }
570:
571:            public String createServer() { //create a row to the server table
572:                ObjectListDataProvider oldp = (ObjectListDataProvider) servers;
573:                oldp.addObject(new ServerSiteBean("", "", "http", "", ""));
574:                oldp.commitChanges();
575:                return "gotoEditRobotSite";
576:            }
577:
578:            public String deleteServer() { //delete a row from the server table
579:                ObjectListDataProvider oldp = (ObjectListDataProvider) servers;
580:
581:                RowKey[] rowKeys = tableRowGroup2.getRenderedRowKeys();
582:
583:                for (int index = 0; index < rowKeys.length; index++) {
584:                    RowKey rowKey = rowKeys[index];
585:                    if (tspl2.isSelected(rowKey)) {
586:                        oldp.removeRow(rowKey);
587:                    }
588:                }
589:
590:                oldp.commitChanges();
591:                tspl2.clear();
592:                return "gotoEditRobotSite";
593:            }
594:
595:            public String verifyServer() {
596:                ObjectListDataProvider oldp = (ObjectListDataProvider) servers;
597:                oldp.commitChanges();
598:
599:                RowKey[] rowKeys = tableRowGroup2.getRenderedRowKeys();
600:
601:                for (int index = 0; index < rowKeys.length; index++) {
602:                    RowKey rowKey = rowKeys[index];
603:                    if (tspl2.isSelected(rowKey)) {
604:                        ServerSiteBean ssb = (ServerSiteBean) oldp
605:                                .getObject(rowKey);
606:                        HashMap map = verifyServerName(ssb.getServer());
607:                        ServerSiteBean newssb = new ServerSiteBean(ssb
608:                                .getServer(), ssb.getPort(), ssb.getProtocol(),
609:                                (String) map.get("Status"), (String) map
610:                                        .get("RealName"));
611:                        oldp.setObject(rowKey, newssb);
612:                        break;
613:                    }
614:                }
615:                oldp.commitChanges();
616:                tspl2.clear();
617:                return "gotoEditRobotSite";
618:            }
619:
620:            public String createSP() { //create a row to the start points table
621:                ObjectListDataProvider oldp = (ObjectListDataProvider) startpoints;
622:                oldp.addObject(new StartPointBean("", "10"));
623:                oldp.commitChanges();
624:                return "gotoEditRobotSite";
625:            }
626:
627:            public String deleteSP() { //delete a row from the start points table
628:                ObjectListDataProvider oldp = (ObjectListDataProvider) startpoints;
629:
630:                RowKey[] rowKeys = tableRowGroup3.getRenderedRowKeys();
631:
632:                for (int index = 0; index < rowKeys.length; index++) {
633:                    RowKey rowKey = rowKeys[index];
634:                    if (tspl3.isSelected(rowKey)) {
635:                        oldp.removeRow(rowKey);
636:                    }
637:                }
638:
639:                oldp.commitChanges();
640:                tspl3.clear();
641:                return "gotoEditRobotSite";
642:            }
643:
644:            public String createFilterDef() { //create a row to the filter def table
645:                ObjectListDataProvider oldp = (ObjectListDataProvider) filterdefs;
646:                oldp.addObject(new FilterDefinitionBean("deny", ""));
647:                oldp.commitChanges();
648:                return "gotoEditRobotSite";
649:            }
650:
651:            public String deleteFilterDef() { //delete a row from the filter def table
652:                ObjectListDataProvider oldp = (ObjectListDataProvider) filterdefs;
653:
654:                RowKey[] rowKeys = tableRowGroup4.getRenderedRowKeys();
655:
656:                for (int index = 0; index < rowKeys.length; index++) {
657:                    RowKey rowKey = rowKeys[index];
658:                    if (tspl4.isSelected(rowKey)) {
659:                        oldp.removeRow(rowKey);
660:                    }
661:                }
662:
663:                oldp.commitChanges();
664:                tspl4.clear();
665:                return "gotoEditRobotSite";
666:            }
667:
668:            public String moveUp() { //move a row up
669:                ObjectListDataProvider oldp = (ObjectListDataProvider) filterdefs;
670:
671:                RowKey[] rowKeys = tableRowGroup4.getRenderedRowKeys();
672:
673:                RowKey prev_row = rowKeys[0];
674:
675:                for (int index = 0; index < rowKeys.length; index++) {
676:                    RowKey rowKey = rowKeys[index];
677:                    if (tspl4.isSelected(rowKey)) { //found it
678:                        if (index == 0) {
679:                            break; //don't do anything for the first row
680:                        } else {
681:                            FilterDefinitionBean temp = (FilterDefinitionBean) oldp
682:                                    .getObject(prev_row);
683:                            oldp.setObject(prev_row,
684:                                    (FilterDefinitionBean) oldp
685:                                            .getObject(rowKey));
686:                            oldp.setObject(rowKey, temp);
687:                            break;
688:                        }
689:                    }
690:                    prev_row = rowKey;
691:                }
692:
693:                oldp.commitChanges();
694:                tspl4.clear();
695:                return "gotoEditRobotSite";
696:            }
697:
698:            public String moveDown() { //move a row down
699:                ObjectListDataProvider oldp = (ObjectListDataProvider) filterdefs;
700:
701:                RowKey[] rowKeys = tableRowGroup4.getRenderedRowKeys();
702:
703:                for (int index = 0; index < rowKeys.length; index++) {
704:                    RowKey rowKey = rowKeys[index];
705:                    if (tspl4.isSelected(rowKey)) { //found it
706:                        if (index == (rowKeys.length - 1)) {
707:                            break; //don't do anything for the last row
708:                        } else {
709:                            RowKey next_row = rowKeys[index + 1];
710:                            FilterDefinitionBean temp = (FilterDefinitionBean) oldp
711:                                    .getObject(next_row);
712:                            oldp.setObject(next_row,
713:                                    (FilterDefinitionBean) oldp
714:                                            .getObject(rowKey));
715:                            oldp.setObject(rowKey, temp);
716:                            break;
717:                        }
718:                    }
719:                }
720:
721:                oldp.commitChanges();
722:                tspl4.clear();
723:                return "gotoEditRobotSite";
724:            }
725:
726:            /*
727:             * Private Methods
728:             */
729:            private RowKey getTableRow1() {
730:                FacesContext context = FacesContext.getCurrentInstance();
731:                ValueBinding vb = context.getApplication().createValueBinding(
732:                        "#{domainSite.tableRow}");
733:                return (RowKey) vb.getValue(context);
734:            }
735:
736:            private RowKey getTableRow2() {
737:                FacesContext context = FacesContext.getCurrentInstance();
738:                ValueBinding vb = context.getApplication().createValueBinding(
739:                        "#{serverSite.tableRow}");
740:                return (RowKey) vb.getValue(context);
741:            }
742:
743:            private RowKey getTableRow3() {
744:                FacesContext context = FacesContext.getCurrentInstance();
745:                ValueBinding vb = context.getApplication().createValueBinding(
746:                        "#{startPoint.tableRow}");
747:                return (RowKey) vb.getValue(context);
748:            }
749:
750:            private RowKey getTableRow4() {
751:                FacesContext context = FacesContext.getCurrentInstance();
752:                ValueBinding vb = context.getApplication().createValueBinding(
753:                        "#{filterDef.tableRow}");
754:                return (RowKey) vb.getValue(context);
755:            }
756:
757:            private Option[] getOptionList(ArrayList values, ArrayList labels) {
758:
759:                if (!values.isEmpty() && !labels.isEmpty()) {
760:
761:                    Option[] options = new Option[values.size()];
762:
763:                    for (int i = 0; i < values.size(); i++) {
764:                        options[i] = new Option((String) values.get(i),
765:                                (String) labels.get(i));
766:                    }
767:
768:                    return options;
769:                }
770:                return null;
771:            }
772:
773:            private ArrayList getStringList(String s) {
774:
775:                ArrayList s_list = new ArrayList();
776:                StringTokenizer st = new StringTokenizer(s, ",");
777:                while (st.hasMoreTokens()) {
778:                    String label = st.nextToken();
779:                    s_list.add(label);
780:                }
781:                return s_list;
782:            }
783:
784:            private String getLocalizedString(String key) {
785:                return super .getLocalizedString("search", key);
786:            }
787:
788:            private HashMap verifyServerName(String servername) {
789:                HashMap map = null;
790:                try {
791:                    LinkedList path = new LinkedList();
792:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
793:                    path
794:                            .addFirst((String) getSessionAttribute("search.server.selected"));
795:                    path.addFirst("robot");
796:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
797:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
798:
799:                    Object[] params = { servername };
800:                    String[] signature = { "java.lang.String" };
801:
802:                    map = (HashMap) getMBeanServerConnection().invoke(on,
803:                            "verifyServerName", params, signature);
804:
805:                } catch (Exception e) {
806:                    log(Level.SEVERE,
807:                            "EditRobotSiteBean.verifyServerName() failed to verify the server name "
808:                                    + servername, e);
809:                }
810:                return map;
811:            }
812:
813:            private void generateRobotSite() {
814:                siteId = (String) getSessionAttribute("robot.site.selected");
815:
816:                HashMap map = null;
817:                if (siteId != null && !siteId.equals("")) {
818:                    try {
819:                        LinkedList path = new LinkedList();
820:                        path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
821:                        path
822:                                .addFirst((String) getSessionAttribute("search.server.selected"));
823:                        path.addFirst("robot");
824:                        ObjectName on = AdminClientUtil
825:                                .getResourceMBeanObjectName(
826:                                        AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE,
827:                                        path);
828:
829:                        Object[] params = { siteId };
830:                        String[] signature = { "java.lang.String" };
831:
832:                        map = (HashMap) getMBeanServerConnection().invoke(on,
833:                                "listSites", params, signature);
834:
835:                    } catch (Exception e) {
836:                        log(Level.SEVERE,
837:                                "EditRobotSiteBean.generateRobotSite() failed to get robot site Id "
838:                                        + siteId, e);
839:                    }
840:
841:                    if (map != null) {
842:                        HashMap frs = (HashMap) map.get(siteId);
843:                        if (frs != null) {
844:                            siteName = (String) frs.get("SiteName");
845:                            siteDesc = (String) frs.get("Comments");
846:                            siteDNS = (String) frs.get("DNSTrans");
847:                            database = (String) frs.get("Database");
848:
849:                            LinkedList dgroup = (LinkedList) frs
850:                                    .get("DomainGroup");
851:                            if (dgroup != null && dgroup.size() > 0) {
852:                                renderDomain = Boolean.TRUE;
853:                                renderServer = Boolean.FALSE;
854:
855:                                //render port and protocol 
856:                                port = (String) frs.get("DomainPort");
857:                                protocols = (String[]) ((ArrayList) frs
858:                                        .get("DomainProtocol"))
859:                                        .toArray(new String[0]);
860:
861:                                //render domain group
862:                                ArrayList dl = new ArrayList();
863:                                for (int i = 0; i < dgroup.size(); i++) {
864:                                    String dstring = (String) dgroup.get(i);
865:                                    dl.add(new DomainSiteBean(dstring));
866:                                }
867:                                domains = new ObjectListDataProvider(dl);
868:                            }
869:
870:                            LinkedList sgroup = (LinkedList) frs
871:                                    .get("ServerGroup");
872:                            if (sgroup != null && sgroup.size() > 0) {
873:                                renderServer = Boolean.TRUE;
874:                                renderDomain = Boolean.FALSE;
875:                                ArrayList sl = new ArrayList();
876:                                for (int i = 0; i < sgroup.size(); i++) {
877:                                    HashMap server = (HashMap) sgroup.get(i);
878:                                    String status = "";
879:                                    if (((String) server.get("Status"))
880:                                            .equalsIgnoreCase("verified")) {
881:                                        status = getLocalizedString("robot.site.verified");
882:                                    } else {
883:                                        status = getLocalizedString((String) server
884:                                                .get("Status"));
885:                                    }
886:                                    String realname = getLocalizedString("robot.site.realname")
887:                                            + (String) server.get("RealName");
888:                                    sl
889:                                            .add(new ServerSiteBean(
890:                                                    (String) server
891:                                                            .get("Server"),
892:                                                    (String) server.get("Port"),
893:                                                    (String) server
894:                                                            .get("Protocol"),
895:                                                    status, realname));
896:                                }
897:                                servers = new ObjectListDataProvider(sl);
898:                            }
899:
900:                            LinkedList starts = (LinkedList) frs
901:                                    .get("StartingPoints");
902:                            if (starts.size() > 0) {
903:                                ArrayList spl = new ArrayList();
904:                                for (int i = 0; i < starts.size(); i++) {
905:                                    HashMap start = (HashMap) starts.get(i);
906:                                    String sp = (String) start.get("URLString");
907:                                    if (sp != null) {
908:                                        String urlStr = null;
909:                                        String depthStr = null;
910:                                        StringTokenizer st = new StringTokenizer(
911:                                                sp);
912:                                        if (st.hasMoreTokens()) {
913:                                            urlStr = st.nextToken();
914:                                        }
915:                                        if (st.hasMoreTokens()) {
916:                                            String ds = st.nextToken();
917:                                            int ndx = ds.indexOf("=");
918:                                            if (ndx != -1) {
919:                                                depthStr = ds
920:                                                        .substring(ndx + 1);
921:                                            }
922:                                        }
923:                                        if (urlStr != null && depthStr != null) {
924:                                            spl.add(new StartPointBean(urlStr,
925:                                                    depthStr));
926:                                        }
927:                                    }
928:
929:                                }
930:                                startpoints = new ObjectListDataProvider(spl);
931:                            }
932:
933:                            LinkedList fgroup = (LinkedList) frs
934:                                    .get("FilterGroup");
935:                            if (fgroup.size() > 0) {
936:                                ArrayList fl = new ArrayList();
937:                                for (int k = 0; k < fgroup.size(); k++) {
938:                                    HashMap filter = (HashMap) fgroup.get(k);
939:                                    String rule = (String) filter
940:                                            .get("FilterID");
941:                                    String match = (String) filter
942:                                            .get("FilterMatch");
943:                                    fl
944:                                            .add(new FilterDefinitionBean(rule,
945:                                                    match));
946:                                }
947:                                filterdefs = new ObjectListDataProvider(fl);
948:
949:                                allfilematch = (String) frs
950:                                        .get("FilterAllFiles");
951:                                ArrayList filel = new ArrayList();
952:                                filel.add("allow");
953:                                allfilesmatch = new ObjectListDataProvider(
954:                                        filel);
955:                            }
956:
957:                        } //frs != null
958:                    } //map != null
959:
960:                } //siteId != null
961:
962:            }
963:
964:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.