Source Code Cross Referenced for SitesViewBean.java in  » Portal » Open-Portal » com » sun » portal » search » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.search.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.search.admin;
007:
008:        import java.net.URL;
009:        import java.io.IOException;
010:        import java.util.logging.Logger;
011:        import java.util.logging.Level;
012:
013:        import com.sun.portal.search.admin.CSViewBeanBase;
014:
015:        import javax.servlet.http.HttpServletRequest;
016:        import javax.servlet.http.HttpServletResponse;
017:
018:        import com.iplanet.jato.RequestContext;
019:
020:        import com.iplanet.jato.view.event.DisplayEvent;
021:        import com.iplanet.jato.view.event.ChildDisplayEvent;
022:        import com.iplanet.jato.view.event.RequestInvocationEvent;
023:
024:        import com.iplanet.jato.view.html.StaticTextField;
025:        import com.iplanet.jato.view.html.TextField;
026:        import com.iplanet.jato.view.html.CheckBox;
027:        import com.iplanet.jato.view.html.Button;
028:        import com.iplanet.jato.view.html.ComboBox;
029:        import com.iplanet.jato.view.html.RadioButtonGroup;
030:
031:        import com.iplanet.jato.view.html.Option;
032:        import com.iplanet.jato.view.html.OptionList;
033:
034:        import com.iplanet.jato.view.View;
035:        import com.iplanet.jato.view.ViewBean;
036:        import com.iplanet.jato.view.ViewBeanBase;
037:
038:        import com.iplanet.jato.ViewBeanManager;
039:
040:        import com.iplanet.jato.model.*;
041:
042:        import com.sun.portal.search.robot.*;
043:        import com.sun.portal.log.common.PortalLogger;
044:        import com.iplanet.am.console.components.view.html.IPlanetButton;
045:
046:        /**
047:         * iPS admin console view bean: TODO
048:         */
049:        public class SitesViewBean extends CSViewBeanBase {
050:            public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/Sites.jsp";
051:            public static final String PAGE_NAME = "Sites";
052:            public static final String NEW_SITE_SECTION = "NewSiteSection";
053:            public static final String ADD_COMBO = "AddCombo";
054:            public static final String URL_TEXT = "URLText";
055:            public static final String DEPTH_COMBO = "DepthCombo";
056:            public static final String CREATE_BUTTON = "CreateButton";
057:            public static final String CREATEEDIT_BUTTON = "CreateEditButton";
058:
059:            public static final String SITELIST_SECTION = "SitesListSection";
060:            public static final String SITELIST_VIEW = "SitesList";
061:            public static final String NEWSITE_BUTTON = "NewSiteButton";
062:            public static final String DELETE_BUTTON = "DeleteButton";
063:            public static final String SUBMIT_BUTTON = "SubmitButton";
064:            public static final String RESET_BUTTON = "ResetButton";
065:            public static final String CANCEL_BUTTON = "CancelButton";
066:
067:            private boolean isNewSite = false;
068:
069:            // Create a Logger for this class
070:            private static Logger debugLogger = PortalLogger
071:                    .getLogger(SitesViewBean.class);
072:
073:            /**
074:             * constructor
075:             *
076:             * @param PageName  of this view bean
077:             * @param displayURL  default display URL
078:             */
079:            public SitesViewBean() {
080:                super (PAGE_NAME);
081:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
082:                registerChildren();
083:            }
084:
085:            /**
086:             * register child component
087:             */
088:            protected void registerChildren() {
089:                registerChild(ADD_COMBO, ComboBox.class);
090:                registerChild(URL_TEXT, TextField.class);
091:                registerChild(DEPTH_COMBO, ComboBox.class);
092:                registerChild(CREATE_BUTTON, IPlanetButton.class);
093:                registerChild(CREATEEDIT_BUTTON, IPlanetButton.class);
094:                registerChild(SITELIST_VIEW, SitesListView.class);
095:                registerChild(NEWSITE_BUTTON, IPlanetButton.class);
096:                registerChild(DELETE_BUTTON, IPlanetButton.class);
097:                registerChild(SUBMIT_BUTTON, IPlanetButton.class);
098:                registerChild(RESET_BUTTON, IPlanetButton.class);
099:                registerChild(CANCEL_BUTTON, IPlanetButton.class);
100:
101:            }
102:
103:            /**
104:             * create child component
105:             *
106:             * @param name of component
107:             * @return child component
108:             */
109:            protected View createChild(String name) {
110:                View Headerchild = super .createChild(name);
111:                if (Headerchild != null)
112:                    return Headerchild;
113:                if (name.equals(ADD_COMBO)) {
114:                    ComboBox child = new ComboBox(this , ADD_COMBO, "");
115:                    OptionList AddOptions = new OptionList(
116:                            getLocalizedStringArray("sites.type.options", ","),
117:                            new String[] { "URL", "domain" }); // values
118:                    child.setOptions(AddOptions);
119:                    return child;
120:                }
121:                if (name.equals(URL_TEXT)) {
122:                    return new TextField(this , URL_TEXT, "");
123:                }
124:                if (name.equals(DEPTH_COMBO)) {
125:                    String depth = CSConfig.getRobotConfig().processConf
126:                            .get("depth");
127:                    if (depth == null) {
128:                        depth = "-1";
129:                    }
130:                    ComboBox child = new ComboBox(this , DEPTH_COMBO, depth);
131:                    OptionList DepthOptions = new OptionList(
132:                            getLocalizedStringArray(
133:                                    "sites.depth.options.label", ","),
134:                            getLocalizedStringArray(
135:                                    "sites.depth.options.value", ","));
136:                    child.setOptions(DepthOptions);
137:                    return child;
138:                }
139:                if (name.equals(CREATE_BUTTON)) {
140:                    return new IPlanetButton(this , CREATE_BUTTON, "");
141:                }
142:                if (name.equals(CREATEEDIT_BUTTON)) {
143:                    return new IPlanetButton(this , CREATEEDIT_BUTTON, "");
144:                }
145:                if (name.equals(SITELIST_VIEW)) {
146:                    return new SitesListView(this , SITELIST_VIEW);
147:                }
148:                if (name.equals(NEWSITE_BUTTON)) {
149:                    return new IPlanetButton(this , NEWSITE_BUTTON, "");
150:                }
151:                if (name.equals(DELETE_BUTTON)) {
152:                    return new IPlanetButton(this , DELETE_BUTTON, "");
153:                }
154:                if (name.equals(SUBMIT_BUTTON)) {
155:                    return new IPlanetButton(this , SUBMIT_BUTTON, "");
156:                }
157:                if (name.equals(RESET_BUTTON)) {
158:                    return new IPlanetButton(this , RESET_BUTTON, "");
159:                }
160:                if (name.equals(CANCEL_BUTTON)) {
161:                    return new IPlanetButton(this , CANCEL_BUTTON, "");
162:                }
163:
164:                throw new IllegalArgumentException("Invalid child name ["
165:                        + name + "]");
166:            }
167:
168:            /** begin displaying page. we set the required information
169:             *
170:             * @param event   display event
171:             * @throws ModelControlException  if problem access value of component
172:             */
173:            public void beginDisplay(DisplayEvent event) {
174:                setPageEncoding();
175:                setDisplayFieldValue(SUBMIT_BUTTON,
176:                        getLocalizedString("submit.text"));
177:                setDisplayFieldValue(NEWSITE_BUTTON,
178:                        getLocalizedString("new.text"));
179:                setDisplayFieldValue(DELETE_BUTTON,
180:                        getLocalizedString("delete.text"));
181:                setDisplayFieldValue(RESET_BUTTON,
182:                        getLocalizedString("reset.text"));
183:                setDisplayFieldValue(CANCEL_BUTTON,
184:                        getLocalizedString("cancel.text"));
185:                setDisplayFieldValue(CREATEEDIT_BUTTON,
186:                        getLocalizedString("createsite.edit.text"));
187:                setDisplayFieldValue(CREATE_BUTTON,
188:                        getLocalizedString("createsite.text"));
189:                RobotConfig rc = CSConfig.getRobotConfig();
190:                if (rc.numRuleset() == 0) {
191:                    IPlanetButton child = (IPlanetButton) getChild(DELETE_BUTTON);
192:                    child.setEnable(false);
193:                }
194:
195:            }
196:
197:            public boolean beginNewSiteSectionDisplay(ChildDisplayEvent event) {
198:                return isNewSite;
199:            }
200:
201:            public boolean beginSitesListSectionDisplay(ChildDisplayEvent event) {
202:                return !isNewSite;
203:            }
204:
205:            public boolean beginListTableDisplay(ChildDisplayEvent event) {
206:                RobotConfig rc = CSConfig.getRobotConfig();
207:                return rc.numRuleset() > 0;
208:            }
209:
210:            public boolean beginEmptyListDisplay(ChildDisplayEvent event) {
211:                RobotConfig rc = CSConfig.getRobotConfig();
212:                return rc.numRuleset() == 0;
213:            }
214:
215:            private String CreateSite() {
216:                RobotConfig rc = CSConfig.getRobotConfig();
217:                String typeText = (String) this .getDisplayFieldValue(ADD_COMBO);
218:                String urlText = (String) this .getDisplayFieldValue(URL_TEXT);
219:                String depthText = (String) this 
220:                        .getDisplayFieldValue(DEPTH_COMBO);
221:                int depth = Integer.parseInt(depthText);
222:                String newCreatedID = null;
223:                String newRuleID = null;
224:                try {
225:                    boolean isDomain = typeText.compareToIgnoreCase("DOMAIN") == 0;
226:                    URL url = null;
227:                    if (isDomain) {
228:                        FilterRuleset frs = rc
229:                                .findFiletrRulesetHasDomain(urlText
230:                                        .substring(2));
231:                        if (frs != null) {
232:                            this .errorMessage = getLocalizedString("createsite.error.existdomain")
233:                                    + frs.nickname;
234:                            return null;
235:                        }
236:                        url = new URL("http", "www" + urlText.substring(1), 80,
237:                                "/");
238:                    } else {
239:                        FilterRuleset frs = rc
240:                                .findFiletrRulesetHasStartingPoint(urlText);
241:                        if (frs != null) {
242:                            this .errorMessage = getLocalizedString("createsite.error.existstartingpoint")
243:                                    + frs.nickname;
244:                            return null;
245:                        }
246:                        url = new URL(urlText);
247:                    }
248:                    String path = url.getPath();
249:                    int n = path.lastIndexOf('/');
250:                    if (n >= 0 && path.length() > 1) {
251:                        String path_filter = path.substring(0, n + 1);
252:                        String file_name = path.substring(n + 1);
253:                        if (file_name.indexOf('.') < 0) {
254:                            path_filter = path;
255:                        }
256:                        debugLogger.log(Level.FINER, "PSSH_CSPSA0113",
257:                                path_filter);
258:                        newRuleID = rc.newPathFilterRule(path_filter);
259:                    }
260:
261:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0114",
262:                            new String[] { url.toString(),
263:                                    String.valueOf(depth), newRuleID });
264:                    FilterRuleset frs = rc.newRuleset(url, depth, isDomain,
265:                            newRuleID);
266:                    if (frs != null) {
267:                        newCreatedID = frs.id;
268:                    }
269:                    rc.updateFile();
270:                } catch (java.net.MalformedURLException e) {
271:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0115", urlText);
272:                }
273:                return newCreatedID;
274:            }
275:
276:            /**
277:             * handles invocation of view bean
278:             *
279:             * @param event   request invocation event
280:             */
281:            public void handleCreateButtonRequest(RequestInvocationEvent event) {
282:                if (CreateSite() == null) {
283:                    isNewSite = true;
284:                }
285:                forwardTo();
286:            }
287:
288:            /**
289:             * handles invocation of view bean
290:             *
291:             * @param event   request invocation event
292:             */
293:            public void handleCreateEditButtonRequest(
294:                    RequestInvocationEvent event) {
295:                String id = CreateSite();
296:                if (id != null) {
297:                    HttpServletResponse response = getRequestContext()
298:                            .getResponse();
299:                    try {
300:                        response.sendRedirect("Site?id=" + id);
301:                    } catch (IOException e) {
302:                        //TOFIX: handle this
303:                    }
304:                } else {
305:                    isNewSite = true;
306:                    forwardTo();
307:                }
308:            }
309:
310:            public void handleSubmitButtonRequest(RequestInvocationEvent event) {
311:                SitesListView child = (SitesListView) getChild(SITELIST_VIEW);
312:                try {
313:                    ModelExecutionContext modExe = new ModelExecutionContextBase(
314:                            ModelExecutionContext.OPERATION_UPDATE);
315:                    child.executeAutoUpdatingModels(modExe);
316:                } catch (ModelControlException e) {
317:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
318:                            .getMessage());
319:                }
320:                forwardTo();
321:            }
322:
323:            public void handleResetButtonRequest(RequestInvocationEvent event) {
324:                forwardTo();
325:            }
326:
327:            public void handleDeleteButtonRequest(RequestInvocationEvent event) {
328:                SitesListView child = (SitesListView) getChild(SITELIST_VIEW);
329:                try {
330:                    ModelExecutionContext modExe = new ModelExecutionContextBase(
331:                            ModelExecutionContext.OPERATION_DELETE);
332:                    child.executeAutoDeletingModels(modExe);
333:                } catch (ModelControlException e) {
334:                    debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
335:                            .getMessage());
336:                }
337:                forwardTo();
338:            }
339:
340:            public void handleNewSiteButtonRequest(RequestInvocationEvent event) {
341:                isNewSite = true;
342:                forwardTo();
343:            }
344:
345:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.