Source Code Cross Referenced for RobotAdvancedReportViewBean.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.*;
010:        import java.text.DateFormat;
011:        import java.util.Date;
012:        import java.util.logging.Logger;
013:        import java.util.logging.Level;
014:
015:        import com.sun.portal.search.admin.CSViewBeanBase;
016:        import com.sun.portal.search.util.DateParser;
017:
018:        import javax.servlet.http.HttpServletRequest;
019:        import javax.servlet.http.HttpServletResponse;
020:
021:        import com.iplanet.jato.RequestContext;
022:
023:        import com.iplanet.jato.view.event.DisplayEvent;
024:        import com.iplanet.jato.view.event.ChildDisplayEvent;
025:        import com.iplanet.jato.view.event.RequestInvocationEvent;
026:
027:        import com.iplanet.jato.view.html.StaticTextField;
028:        import com.iplanet.jato.view.html.ComboBox;
029:        import com.iplanet.jato.view.html.HiddenField;
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.iplanet.am.console.components.view.html.IPlanetButton;
043:
044:        import com.sun.portal.search.admin.cli.RobotController;
045:        import com.sun.portal.log.common.PortalLogger;
046:
047:        /**
048:         * iPS admin console view bean: TODO
049:         */
050:        public class RobotAdvancedReportViewBean extends CSViewBeanBase {
051:            public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/RobotAdvancedReport.jsp";
052:            public static final String PAGE_NAME = "RobotAdvancedReport";
053:            public static final String REPORTS_LIST = "Reports";
054:            public static final String REFRESH_BUTTON = "Refresh";
055:            public static final String REPORT_TEXT = "ReportText";
056:            public static final String ROBOT_RUNNING = "RobotRunning";
057:            public static final String ROBOT_NOTRUNNING = "RobotNotRunning";
058:
059:            public static String reportsLabels[] = { "Version",
060:                    "DNS Cache Dump", "Performance", "Servers Found - All",
061:                    "Servers Found - RDM", "Status - Current Configuration",
062:                    "Status - Database (internal)", "Status - Libnet",
063:                    "Status - Modules", "Status - Overview",
064:                    "URLs - ready for extraction", "URLs - ready for indexing",
065:                    "URLs - waiting for filtering (URL Pool)",
066:                    "URLs - waiting for indexing", "all reports" };
067:            public static String reportsQuerys[] = { "query?fn=version",
068:                    "query?fn=dns-mapping", "query?fn=performance",
069:                    "query?fn=sites-status", "query?fn=rdm-server",
070:                    "query?fn=run-status", "query?fn=database",
071:                    "query?fn=libnet", "query?fn=status",
072:                    "query?fn=robot-states", "query?fn=enum-ready",
073:                    "query?fn=rdgen-ready", "query?fn=enum-pool",
074:                    "query?fn=rdgen-pool", "all" };
075:
076:            RobotController rc = null;
077:
078:            // Create a Logger for this class
079:            private static Logger debugLogger = PortalLogger
080:                    .getLogger(RobotAdvancedReportViewBean.class);
081:
082:            /**
083:             * constructor
084:             *
085:             * @param PageName  of this view bean
086:             * @param displayURL  default display URL
087:             */
088:            public RobotAdvancedReportViewBean() {
089:                super (PAGE_NAME);
090:                setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
091:                registerChildren();
092:                rc = new RobotController(CSConfig.getServerRoot(), CSConfig
093:                        .getBinPath(), CSConfig.getLibDir(), CSConfig
094:                        .getLibPath(), null, null, null);
095:            }
096:
097:            /**
098:             * register child component
099:             */
100:            protected void registerChildren() {
101:                registerChild(REPORTS_LIST, ComboBox.class);
102:                registerChild(REPORT_TEXT, StaticTextField.class);
103:                registerChild(REFRESH_BUTTON, IPlanetButton.class);
104:
105:            }
106:
107:            /**
108:             * create child component
109:             *
110:             * @param name of component
111:             * @return child component
112:             */
113:            protected View createChild(String name) {
114:                debugLogger.log(Level.FINER, "PSSH_CSPSA0044", name);
115:                View Headerchild = super .createChild(name);
116:                if (Headerchild != null)
117:                    return Headerchild;
118:                if (name.equals(REPORTS_LIST)) {
119:                    ComboBox child = new ComboBox(this , REPORTS_LIST, "");
120:                    OptionList reportOptions = new OptionList(
121:                            getLocalizedStringArray("robot.adv.report.labels",
122:                                    ","), reportsQuerys);
123:                    child.setOptions(reportOptions);
124:                    return child;
125:                }
126:
127:                if (name.equals(this .REPORT_TEXT)) {
128:                    return new StaticTextField(this , this .REPORT_TEXT, "");
129:                }
130:                if (name.equals(REFRESH_BUTTON)) {
131:                    return new IPlanetButton(this , REFRESH_BUTTON, "");
132:                }
133:                throw new IllegalArgumentException("Invalid child name ["
134:                        + name + "]");
135:            }
136:
137:            String getLocalizedContent(byte[] bytes) {
138:                int tagStart;
139:                int tagDateStart;
140:                int tagEnd;
141:                int tagDateEnd;
142:                int currIndex = 0;
143:                StringBuffer sb = new StringBuffer();
144:                DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
145:                        DateFormat.LONG, getUserLocale());
146:
147:                try {
148:                    String str = new String(bytes, "UTF-8");
149:                    tagStart = str.indexOf("<i18nkey>", currIndex);
150:                    tagDateStart = str.indexOf("<i18ndatetime>", currIndex);
151:                    while (tagStart >= 0 || tagDateStart >= 0) {
152:                        if ((tagStart >= 0 && tagDateStart < 0)
153:                                || (tagStart >= 0 && tagDateStart >= 0 && tagStart < tagDateStart)) {
154:                            sb.append(str.substring(currIndex, tagStart));
155:                            currIndex = tagStart + 9;
156:                            tagEnd = str.indexOf("</i18nkey>", currIndex);
157:                            if (tagEnd > 0) {
158:                                currIndex = tagEnd + 10;
159:                                String i18nKey = str.substring(tagStart + 9,
160:                                        tagEnd);
161:                                if (i18nKey.equalsIgnoreCase("now")) {
162:                                    sb.append(df.format(new Date()));
163:                                } else {
164:                                    sb.append(this .getLocalizedString(i18nKey));
165:                                }
166:                            }
167:                        } else {
168:                            sb.append(str.substring(currIndex, tagDateStart));
169:                            currIndex = tagDateStart + 14;
170:                            tagDateEnd = str.indexOf("</i18ndatetime>",
171:                                    currIndex);
172:                            if (tagDateEnd > 0) {
173:                                currIndex = tagDateEnd + 15;
174:                                String i18nDate = str.substring(
175:                                        tagDateStart + 14, tagDateEnd);
176:                                try {
177:                                    sb.append(df.format(DateParser
178:                                            .parse(i18nDate)));
179:                                } catch (Exception e) {
180:                                    debugLogger.log(Level.INFO,
181:                                            "PSSH_CSPSA0101", new String[] {
182:                                                    i18nDate, e.getMessage() });
183:                                }
184:                            }
185:                        }
186:                        tagStart = str.indexOf("<i18nkey>", currIndex);
187:                        tagDateStart = str.indexOf("<i18ndatetime>", currIndex);
188:                    }
189:                    sb.append(str.substring(currIndex));
190:
191:                    return sb.toString();
192:                } catch (Exception e) {
193:                    return "";
194:                }
195:            }
196:
197:            String getContent(byte[] bytes) {
198:                try {
199:                    String str = getLocalizedContent(bytes);
200:                    char[] r = str.toCharArray();
201:                    StringBuffer buffer = new StringBuffer();
202:                    if (r == null)
203:                        return null;
204:                    boolean inTag = false;
205:                    for (int i = 0; i < r.length; i++) {
206:                        if (inTag) {
207:                            if (r[i] == '>') {
208:                                inTag = false;
209:                                continue;
210:                            }
211:                        } else {
212:                            if (r[i] == '<') {
213:                                inTag = true;
214:                                continue;
215:                            }
216:                            buffer.append(r[i]);
217:                        }
218:                    }
219:                    return buffer.toString();
220:                } catch (NullPointerException npe) {
221:                    return null;
222:                }
223:                /*
224:                String str = new String(r);
225:                int start= str.indexOf("<BODY>");
226:                if (start > 0) {
227:                    int end = str.indexOf("</BODY>", start + 6);
228:                    if (end > 0 ) {
229:                        return str.substring(start + 6, end);
230:                    }
231:                    return str.substring(start + 6);
232:                }
233:                return str;*/
234:            }
235:
236:            /** begin displaying page. we set the required information
237:             *
238:             * @param event   display event
239:             * @throws ModelControlException  if problem access value of component
240:             */
241:            public void beginDisplay(DisplayEvent event) {
242:                setPageEncoding();
243:                setDisplayFieldValue(REFRESH_BUTTON,
244:                        getLocalizedString("robot.adv.refresh"));
245:
246:                // Get request attributes and store them as Page Session Attributes
247:
248:                HttpServletRequest req = getRequestContext().getRequest();
249:                String reportSelected = (String) req
250:                        .getParameter("reportSelected");
251:                if (reportSelected == null) {
252:                    reportSelected = (String) getPageSessionAttribute("reportSelected");
253:                }
254:                if (reportSelected != null) {
255:                    setDisplayFieldValue(REPORTS_LIST, reportSelected);
256:                    debugLogger.log(Level.FINER, "PSSH_CSPSA0102",
257:                            reportSelected);
258:                    if (reportSelected.compareTo("all") != 0) {
259:                        byte[] r = rc.robotURLGet(reportSelected
260:                                + "&format=i18n");
261:                        this .setDisplayFieldValue(this .REPORT_TEXT, this 
262:                                .getContent(r));
263:                    } else {
264:                        StringBuffer buffer = new StringBuffer();
265:                        for (int i = 0; i < reportsQuerys.length - 1; i++) {
266:                            byte[] r = rc.robotURLGet(reportsQuerys[i]
267:                                    + "&format=i18n");
268:                            buffer.append(getContent(r));
269:                        }
270:                        setDisplayFieldValue(REPORT_TEXT, buffer.toString());
271:                    }
272:                }
273:
274:            }
275:
276:            public boolean beginRobotRunningDisplay(ChildDisplayEvent event) {
277:                return (rc.isRunning());
278:            }
279:
280:            public boolean beginRobotNotRunningDisplay(ChildDisplayEvent event) {
281:                return (!rc.isRunning());
282:            }
283:
284:            public void handleRefreshRequest(RequestInvocationEvent event) {
285:                this .setPageSessionAttribute("reportSelected",
286:                        getDisplayFieldStringValue(REPORTS_LIST));
287:                forwardTo();
288:            }
289:
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.