Source Code Cross Referenced for EditRobotFilterBean.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 EditRobotFilterBean extends PSBaseBean {
036:
037:            private String filterName = "No Name";
038:            private String filterDesc = "";
039:            private String newSiteDefault = "true";
040:            private String documentMatch = "exclude";
041:            private DataProvider rules = null;
042:
043:            private TableRowGroup tableRowGroup = null;
044:            private TableSelectPhaseListener tspl = null;
045:
046:            private Option[] documentMatchOption;
047:            private Option[] sourceOption;
048:            private Option[] methodOption;
049:            private Option[] patternOption;
050:
051:            private String filterId = "";
052:
053:            public EditRobotFilterBean() {
054:                tspl = new TableSelectPhaseListener();
055:            }
056:
057:            /*
058:             * Button Actions
059:             */
060:            public String save() {
061:                try {
062:                    LinkedList path = new LinkedList();
063:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
064:                    path
065:                            .addFirst((String) getSessionAttribute("search.server.selected"));
066:                    path.addFirst("robot");
067:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
068:                            AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
069:
070:                    Boolean include, isdefault;
071:                    if (documentMatch.equalsIgnoreCase("exclude"))
072:                        include = Boolean.FALSE;
073:                    else
074:                        include = Boolean.TRUE;
075:
076:                    if (newSiteDefault.equalsIgnoreCase("true"))
077:                        isdefault = Boolean.TRUE;
078:                    else
079:                        isdefault = Boolean.FALSE;
080:
081:                    ArrayList al = new ArrayList();
082:                    ObjectListDataProvider oldp = (ObjectListDataProvider) rules;
083:                    oldp.commitChanges();
084:                    List l = oldp.getList();
085:                    for (int i = 0; i < l.size(); i++) {
086:                        FilterMatchRuleBean fmrb = (FilterMatchRuleBean) l
087:                                .get(i);
088:                        HashMap matchRule = new HashMap();
089:                        matchRule.put("FilterSource", fmrb.source);
090:                        matchRule.put("FilterMethod", fmrb.method);
091:                        matchRule.put("FilterString", fmrb.pattern);
092:                        al.add(matchRule);
093:                    }
094:
095:                    Object[] params = { filterId, filterName, filterDesc,
096:                            isdefault, include, al };
097:                    String[] signature = { "java.lang.String",
098:                            "java.lang.String", "java.lang.String",
099:                            "java.lang.Boolean", "java.lang.Boolean",
100:                            "java.util.ArrayList" };
101:                    getMBeanServerConnection().invoke(on, "editFilter", params,
102:                            signature);
103:                } catch (Exception e) {
104:                    log(Level.SEVERE,
105:                            "EditRobotFilterBean.save() failed to edit the robot filter Id "
106:                                    + filterId, e);
107:                }
108:
109:                filterId = "";
110:                tspl.clear();
111:                return "gotoRobotFiltersHome";
112:            }
113:
114:            public String cancel() {
115:                filterId = "";
116:                tspl.clear();
117:                return "gotoRobotFiltersHome";
118:            }
119:
120:            public String create() { //create a row to the filter rule table
121:                ObjectListDataProvider oldp = (ObjectListDataProvider) rules;
122:                oldp.addObject(new FilterMatchRuleBean("url", "is", ""));
123:                oldp.commitChanges();
124:                return "gotoEditRobotFilter";
125:            }
126:
127:            public String delete() { //delete a row from the filter rule table
128:                ObjectListDataProvider oldp = (ObjectListDataProvider) rules;
129:
130:                RowKey[] rowKeys = tableRowGroup.getRenderedRowKeys();
131:                for (int index = 0; index < rowKeys.length; index++) {
132:                    RowKey rowKey = rowKeys[index];
133:                    if (tspl.isSelected(rowKey)) {
134:                        oldp.removeRow(rowKey);
135:                    }
136:                }
137:
138:                oldp.commitChanges();
139:                tspl.clear();
140:                return "gotoEditRobotFilter";
141:            }
142:
143:            /*
144:             * Methods for UI options
145:             */
146:            public Option[] getDocumentMatchOption() {
147:                documentMatchOption = new Option[2];
148:                documentMatchOption[0] = new Option("exclude",
149:                        getLocalizedString("robot.filter.exclude"));
150:                documentMatchOption[1] = new Option("include",
151:                        getLocalizedString("robot.filter.include"));
152:                return documentMatchOption;
153:            }
154:
155:            public Option[] getSourceOption() {
156:                sourceOption = new Option[5];
157:                ArrayList sources = getStringList(getLocalizedString("robot.filter.source.listlabel"));
158:                sourceOption[0] = new Option("url", (String) sources.get(0));
159:                sourceOption[1] = new Option("protocol", (String) sources
160:                        .get(1));
161:                sourceOption[2] = new Option("host", (String) sources.get(2));
162:                sourceOption[3] = new Option("path", (String) sources.get(3));
163:                sourceOption[4] = new Option("MIME", (String) sources.get(4));
164:                return sourceOption;
165:            }
166:
167:            public Option[] getMethodOption() {
168:                methodOption = new Option[5];
169:                ArrayList methods = getStringList(getLocalizedString("robot.filter.method.listlabel"));
170:                methodOption[0] = new Option("is", (String) methods.get(0));
171:                methodOption[1] = new Option("contains", (String) methods
172:                        .get(1));
173:                methodOption[2] = new Option("begins with", (String) methods
174:                        .get(2));
175:                methodOption[3] = new Option("ends with", (String) methods
176:                        .get(3));
177:                methodOption[4] = new Option("regular", (String) methods.get(4));
178:                return methodOption;
179:            }
180:
181:            /*
182:             * Methods to Get/Set Bean elements
183:             */
184:            public String getFilterName() {
185:                if (!filterId
186:                        .equals((String) getSessionAttribute("robot.filter.selected"))) {
187:                    generateRobotFilter();
188:                    tspl.clear();
189:                }
190:                return filterName;
191:            }
192:
193:            public void setFilterName(String s) {
194:                this .filterName = s;
195:            }
196:
197:            public String getFilterDesc() {
198:                if (!filterId
199:                        .equals((String) getSessionAttribute("robot.filter.selected"))) {
200:                    generateRobotFilter();
201:                    tspl.clear();
202:                }
203:                return filterDesc;
204:            }
205:
206:            public void setFilterDesc(String s) {
207:                this .filterDesc = s;
208:            }
209:
210:            public String getNewSiteDefault() {
211:                if (!filterId
212:                        .equals((String) getSessionAttribute("robot.filter.selected"))) {
213:                    generateRobotFilter();
214:                    tspl.clear();
215:                }
216:                return newSiteDefault;
217:            }
218:
219:            public void setNewSiteDefault(String s) {
220:                if (s == null)
221:                    this .newSiteDefault = "false";
222:                else
223:                    this .newSiteDefault = "true";
224:            }
225:
226:            public String getDocumentMatch() {
227:                if (!filterId
228:                        .equals((String) getSessionAttribute("robot.filter.selected"))) {
229:                    generateRobotFilter();
230:                    tspl.clear();
231:                }
232:                return documentMatch;
233:            }
234:
235:            public void setDocumentMatch(String s) {
236:                this .documentMatch = s;
237:            }
238:
239:            public DataProvider getRules() {
240:                if (!filterId
241:                        .equals((String) getSessionAttribute("robot.filter.selected"))) {
242:                    generateRobotFilter();
243:                    tspl.clear();
244:                }
245:                return rules;
246:            }
247:
248:            public void setRules(DataProvider rules) {
249:                this .rules = rules;
250:            }
251:
252:            public TableRowGroup getTableRowGroup() {
253:                return tableRowGroup;
254:            }
255:
256:            public void setTableRowGroup(TableRowGroup tableRowGroup) {
257:                this .tableRowGroup = tableRowGroup;
258:            }
259:
260:            public Object getSelected() {
261:                return tspl.getSelected(getTableRow());
262:            }
263:
264:            public void setSelected(Object object) {
265:                tspl.setSelected(getTableRow(), object);
266:            }
267:
268:            /*
269:             * Private Methods
270:             */
271:            private Option[] getOptionList(ArrayList values, ArrayList labels) {
272:
273:                if (!values.isEmpty() && !labels.isEmpty()) {
274:
275:                    Option[] options = new Option[values.size()];
276:
277:                    for (int i = 0; i < values.size(); i++) {
278:                        options[i] = new Option((String) values.get(i),
279:                                (String) labels.get(i));
280:                    }
281:
282:                    return options;
283:                }
284:                return null;
285:            }
286:
287:            private ArrayList getStringList(String s) {
288:
289:                ArrayList s_list = new ArrayList();
290:                StringTokenizer st = new StringTokenizer(s, ",");
291:                while (st.hasMoreTokens()) {
292:                    String label = st.nextToken();
293:                    s_list.add(label);
294:                }
295:                return s_list;
296:            }
297:
298:            private String getLocalizedString(String key) {
299:                return super .getLocalizedString("search", key);
300:            }
301:
302:            private RowKey getTableRow() {
303:                FacesContext context = FacesContext.getCurrentInstance();
304:                ValueBinding vb = context.getApplication().createValueBinding(
305:                        "#{filterMatchRule.tableRow}");
306:                return (RowKey) vb.getValue(context);
307:            }
308:
309:            private void generateRobotFilter() {
310:                filterId = (String) getSessionAttribute("robot.filter.selected");
311:
312:                ArrayList filterlist = null;
313:                if (filterId != null && !filterId.equals("")) {
314:                    try {
315:                        LinkedList path = new LinkedList();
316:                        path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
317:                        path
318:                                .addFirst((String) getSessionAttribute("search.server.selected"));
319:                        path.addFirst("robot");
320:                        ObjectName on = AdminClientUtil
321:                                .getResourceMBeanObjectName(
322:                                        AdminClientUtil.SEARCH_ROBOT_MBEAN_TYPE,
323:                                        path);
324:
325:                        Object[] params = { filterId };
326:                        String[] signature = { "java.lang.String" };
327:
328:                        filterlist = (ArrayList) getMBeanServerConnection()
329:                                .invoke(on, "listFilters", params, signature);
330:
331:                    } catch (Exception e) {
332:                        log(Level.SEVERE,
333:                                "EditRobotFilterBean.generateRobotFilter() failed to get robot Filter Id "
334:                                        + filterId, e);
335:                    }
336:
337:                    ArrayList al = new ArrayList();
338:                    String source, method, pattern;
339:
340:                    if (filterlist != null) {
341:
342:                        HashMap fr = (HashMap) filterlist.get(0); //the only one
343:
344:                        if (fr != null) {
345:
346:                            filterName = (String) fr.get("FilterName");
347:                            if (filterName.startsWith("filter.default")) {
348:                                filterName = getLocalizedString((String) fr
349:                                        .get("FilterName"));
350:                            }
351:
352:                            filterDesc = (String) fr.get("FilterDesc");
353:
354:                            if (((Boolean) fr.get("NewSite")).booleanValue()) {
355:                                newSiteDefault = "true";
356:                            } else {
357:                                newSiteDefault = "false";
358:                            }
359:
360:                            if (((Boolean) fr.get("Include")).booleanValue()) {
361:                                documentMatch = "include";
362:                            } else {
363:                                documentMatch = "exclude";
364:                            }
365:
366:                            ArrayList defs = (ArrayList) fr.get("FilterDef");
367:                            for (int i = 0; i < defs.size(); i++) {
368:                                HashMap def = (HashMap) defs.get(i);
369:                                source = (String) def.get("FilterSource");
370:                                method = (String) def.get("FilterMethod");
371:                                pattern = (String) def.get("FilterString");
372:                                al.add(new FilterMatchRuleBean(source, method,
373:                                        pattern));
374:                            }
375:                            rules = new ObjectListDataProvider(al);
376:                        } // fr != null
377:
378:                    } // filterlist != null
379:
380:                }
381:
382:            }
383:
384:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.