Source Code Cross Referenced for ListRobotSitesCommand.java in  » Portal » Open-Portal » com » sun » portal » admin » cli » commands » 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.cli.commands.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.admin.cli.commands.search;
006:
007:        import java.util.*;
008:        import java.util.logging.Logger;
009:        import java.util.logging.Level;
010:
011:        import javax.management.MBeanServerConnection;
012:        import javax.management.ObjectName;
013:        import javax.management.InstanceNotFoundException;
014:        import javax.management.MBeanException;
015:        import javax.management.ReflectionException;
016:
017:        import com.sun.enterprise.cli.framework.*;
018:
019:        import com.sun.portal.admin.cli.commands.GenericCommand;
020:        import com.sun.portal.admin.common.util.AdminUtil;
021:
022:        /**
023:         * This class implements the psadmin list-robot-sites subcommand. The
024:         * list-robot-sites subcommand calls the PortalDomainMBean and performs
025:         * the following tasks:
026:         * <UL>
027:         * <LI>list robot sites rules
028:         * <UL>
029:         */
030:
031:        public class ListRobotSitesCommand extends GenericCommand {
032:
033:            //public Logger logger = super.getLogger();
034:
035:            //command error messages
036:
037:            //command options
038:            private static final String SITE_ID = "site";
039:
040:            String siteID = null;
041:
042:            public void runCommand() throws CommandException,
043:                    CommandValidationException {
044:
045:                validateOptions();
046:                validateSearchServerID();
047:
048:                siteID = getOption(SITE_ID);
049:                if (siteID == null || siteID.equals("")) {
050:                    siteID = "";
051:                }
052:                HashMap sites = null;
053:                try {
054:                    LinkedList path = new LinkedList();
055:                    //path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
056:                    path.addFirst(getDomainId());
057:                    path.addFirst(getSearchServerId());
058:                    path.addFirst("robot");
059:                    ObjectName objName = AdminUtil.getResourceMBeanObjectName(
060:                            AdminUtil.SEARCH_ROBOT_MBEAN_TYPE, path);
061:
062:                    Object[] params = { siteID };
063:                    String[] signature = { "java.lang.String" };
064:                    MBeanServerConnection msc = getMBeanServerConnection(
065:                            getUserId(), getPassword(), getHost());
066:
067:                    sites = (HashMap) msc.invoke(objName, "listSites", params,
068:                            signature);
069:
070:                    handleReturnValue(sites);
071:
072:                } catch (InstanceNotFoundException ie) {
073:                    //logger.logp(Level.SEVERE, "ListRobotSitesCommand", 
074:                    //		      "runCommand()", ie.getMessage(), ie);
075:                    logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ie);
076:                    throw new CommandException(getLocalizedString(
077:                            ERROR_MBEAN_INSTANCE_NOT_FOUND,
078:                            new Object[] { "listSites" }), ie);
079:                } catch (MBeanException me) {
080:                    //logger.logp(Level.SEVERE, "ListRobotSitesCommand", 
081:                    //	      "runCommand()", me.getMessage(), me);
082:                    logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", me);
083:                    throw new CommandException(getLocalizedString(
084:                            ERROR_JMX_INVOKE, new Object[] { "listSites" }), me);
085:                } catch (ReflectionException re) {
086:                    //logger.logp(Level.SEVERE, "ListRobotSitesCommand", 
087:                    //		      "runCommand()", re.getMessage(), re);
088:                    logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", re);
089:                    throw new CommandException(getLocalizedString(
090:                            ERROR_MBEAN_REFLECTION_ERROR,
091:                            new Object[] { "listSites" }), re);
092:                } catch (CommandException ce) {
093:                    //logger.logp(Level.SEVERE, "ListRobotSitesCommand", 
094:                    //		      "runCommand()", ce.getMessage(), ce);
095:                    logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ce);
096:                    throw ce;
097:                } catch (Exception ex) {
098:                    ex.printStackTrace();
099:                    //logger.logp(Level.SEVERE, "ListRobotSitesCommand", 
100:                    //		      "runCommand()", ex.getMessage(), ex);
101:                    logger.log(Level.SEVERE, "PSALI_CSPACCSH0003", ex);
102:                    throw new CommandException(
103:                            getLocalizedString(COMMAND_FAILED), ex);
104:                } finally {
105:                    closeMBeanServerConnection();
106:                }
107:
108:            }
109:
110:            /**
111:             *  handles return value from mbean
112:             *  @param sites
113:             */
114:            protected void handleReturnValue(HashMap sites) {
115:
116:                if (sites == null) {
117:                    //could mean no robot sites created, shouldn't print error
118:                    CLILogger.getInstance().printMessage(
119:                            getLocalizedString("robot.site.notfound"));
120:                    //CLILogger.getInstance().printMessage(getLocalizedString(COMMAND_FAILED));  
121:                } else {
122:
123:                    StringBuffer sb = new StringBuffer();
124:                    HashMap frs = null;
125:
126:                    if (!siteID.equals("")) { // single site display
127:
128:                        frs = (HashMap) sites.get(siteID);
129:                        if (frs != null) {
130:                            sb.append(getLocalizedString("robot.site.id",
131:                                    new Object[] { siteID })
132:                                    + ", ");
133:                            sb
134:                                    .append(getLocalizedString(
135:                                            "robot.site.name",
136:                                            new Object[] { (String) frs
137:                                                    .get("SiteName") })
138:                                            + ", ");
139:                            if (((Boolean) frs.get("State")).booleanValue()) {
140:                                sb
141:                                        .append(getLocalizedString("robot.site.state")
142:                                                + " "
143:                                                + getLocalizedString("robot.site.enable")
144:                                                + "\n");
145:                            } else {
146:                                sb
147:                                        .append(getLocalizedString("robot.site.state")
148:                                                + " "
149:                                                + getLocalizedString("robot.site.disable")
150:                                                + "\n");
151:                            }
152:                            sb.append("\n");
153:
154:                            LinkedList domains = (LinkedList) frs
155:                                    .get("DomainGroup");
156:                            if (domains.size() > 0) {
157:                                sb
158:                                        .append(getLocalizedString("robot.site.domaingroup")
159:                                                + "\n");
160:                                for (int i = 0; i < domains.size(); i++) {
161:                                    String domain = (String) domains.get(i);
162:                                    sb.append(getLocalizedString(
163:                                            "robot.site.domain",
164:                                            new Object[] { domain })
165:                                            + "\n");
166:                                }
167:                                sb.append("\n");
168:                            }
169:
170:                            LinkedList servers = (LinkedList) frs
171:                                    .get("ServerGroup");
172:                            if (servers.size() > 0) {
173:                                sb
174:                                        .append(getLocalizedString("robot.site.servergroup")
175:                                                + "\n");
176:                                for (int i = 0; i < servers.size(); i++) {
177:                                    HashMap server = (HashMap) servers.get(i);
178:                                    sb.append(getLocalizedString(
179:                                            "robot.site.server",
180:                                            new Object[] { (String) server
181:                                                    .get("Server") })
182:                                            + ", ");
183:                                    sb.append(getLocalizedString(
184:                                            "robot.site.port",
185:                                            new Object[] { (String) server
186:                                                    .get("Port") })
187:                                            + ", ");
188:                                    String proto = (String) server
189:                                            .get("Protocol");
190:                                    sb
191:                                            .append(getLocalizedString(
192:                                                    "robot.site.type",
193:                                                    new Object[] { getProtocolType(proto) })
194:                                                    + "\n");
195:                                }
196:                                sb.append("\n");
197:                            }
198:
199:                            LinkedList starts = (LinkedList) frs
200:                                    .get("StartingPoints");
201:                            if (starts.size() > 0) {
202:                                sb
203:                                        .append(getLocalizedString("robot.site.startingpoints")
204:                                                + "\n");
205:                                for (int j = 0; j < starts.size(); j++) {
206:                                    HashMap start = (HashMap) starts.get(j);
207:                                    sb.append(getLocalizedString(
208:                                            "robot.site.url",
209:                                            new Object[] { (String) start
210:                                                    .get("URLString") })
211:                                            + "\n");
212:                                    //sb.append(getLocalizedString("robot.site.url", new Object[] {(String)start.get("URLString")}) + ", ");
213:                                    //sb.append(getLocalizedString("robot.site.depth", new Object[] {(String)start.get("Depth")}) + "\n");
214:                                }
215:                                sb.append("\n");
216:                            }
217:
218:                            LinkedList filters = (LinkedList) frs
219:                                    .get("FilterGroup");
220:                            if (filters.size() > 0) {
221:                                sb
222:                                        .append(getLocalizedString("robot.site.filterdef")
223:                                                + "\n");
224:                                for (int k = 0; k < filters.size(); k++) {
225:                                    HashMap filter = (HashMap) filters.get(k);
226:                                    sb.append(getLocalizedString(
227:                                            "robot.site.filterid",
228:                                            new Object[] { (String) filter
229:                                                    .get("FilterID") })
230:                                            + ", ");
231:                                    String nickkey = (String) filter
232:                                            .get("FilterNickname");
233:                                    String nickname = getLocalizedString(nickkey);
234:                                    sb.append(getLocalizedString(
235:                                            "robot.site.filternick",
236:                                            new Object[] { nickname })
237:                                            + ", ");
238:                                    String match = (String) filter
239:                                            .get("FilterMatch");
240:                                    if (match.equalsIgnoreCase("deny"))
241:                                        sb
242:                                                .append(getLocalizedString(
243:                                                        "robot.site.filtermatch",
244:                                                        new Object[] { getLocalizedString("robot.site.filterexclude") })
245:                                                        + "\n");
246:                                    else
247:                                        sb
248:                                                .append(getLocalizedString(
249:                                                        "robot.site.filtermatch",
250:                                                        new Object[] { getLocalizedString("robot.site.filterinclude") })
251:                                                        + "\n");
252:                                }
253:                                sb.append("\n");
254:                            }
255:
256:                            sb
257:                                    .append(getLocalizedString(
258:                                            "robot.site.desc",
259:                                            new Object[] { (String) frs
260:                                                    .get("Comments") })
261:                                            + "\n");
262:                            sb
263:                                    .append(getLocalizedString(
264:                                            "robot.site.dns",
265:                                            new Object[] { (String) frs
266:                                                    .get("DNSTrans") })
267:                                            + "\n");
268:                        }
269:
270:                    } else { // all sites display
271:
272:                        Iterator it = sites.keySet().iterator();
273:                        while (it.hasNext()) {
274:                            siteID = (String) it.next();
275:                            frs = (HashMap) sites.get(siteID);
276:                            if (frs != null) {
277:                                sb.append(getLocalizedString("robot.site.id",
278:                                        new Object[] { siteID })
279:                                        + ", ");
280:                                sb.append(getLocalizedString("robot.site.name",
281:                                        new Object[] { (String) frs
282:                                                .get("SiteName") })
283:                                        + ", ");
284:
285:                                LinkedList domains = (LinkedList) frs
286:                                        .get("DomainGroup");
287:                                if (domains.size() > 0) {
288:                                    sb
289:                                            .append(getLocalizedString("robot.site.type.domain")
290:                                                    + ", ");
291:                                } else {
292:                                    sb
293:                                            .append(getLocalizedString("robot.site.type.server")
294:                                                    + ", ");
295:                                }
296:
297:                                if (((Boolean) frs.get("State")).booleanValue()) {
298:                                    sb
299:                                            .append(getLocalizedString("robot.site.state")
300:                                                    + " "
301:                                                    + getLocalizedString("robot.site.enable")
302:                                                    + "\n");
303:                                } else {
304:                                    sb
305:                                            .append(getLocalizedString("robot.site.state")
306:                                                    + " "
307:                                                    + getLocalizedString("robot.site.disable")
308:                                                    + "\n");
309:                                }
310:                            }
311:                        }
312:                    } // end of all filters display
313:
314:                    CLILogger.getInstance().printMessage(sb.toString());
315:                } // sites != null
316:
317:            }
318:
319:            public String getProtocolType(String proto) {
320:                if (proto.compareToIgnoreCase("http") == 0)
321:                    return getLocalizedString("robot.site.type.http");
322:                if (proto.compareToIgnoreCase("file") == 0)
323:                    return getLocalizedString("robot.site.type.file");
324:                if (proto.compareToIgnoreCase("ftp") == 0)
325:                    return getLocalizedString("robot.site.type.ftp");
326:                if (proto.compareToIgnoreCase("https") == 0)
327:                    return getLocalizedString("robot.site.type.https");
328:                else
329:                    return "";
330:            }
331:
332:        }
w__w___w___.__j___a__v__a__2s.__co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.