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


001:        /**
002:         * $Id: VersionCommand.java,v 1.6 2005/11/07 17:40:17 cathywu Exp $
003:         * Copyright 2004 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.cli.commands;
014:
015:        import java.io.*;
016:        import java.util.logging.Level;
017:
018:        // CLI framework
019:        import com.sun.enterprise.cli.framework.*;
020:
021:        // JMX
022:        import javax.management.MBeanServerConnection;
023:        import javax.management.ObjectName;
024:        import javax.management.InstanceNotFoundException;
025:        import javax.management.MBeanException;
026:        import javax.management.MalformedObjectNameException;
027:        import javax.management.ReflectionException;
028:
029:        //PS Admin Common
030:        import com.sun.portal.fabric.util.FileUtil;
031:        import com.sun.portal.fabric.util.os.OSTasksFactory;
032:        import com.sun.portal.fabric.util.os.OSTasks;
033:
034:        //PS Admin Common
035:        import com.sun.portal.admin.common.util.AdminClientUtil;
036:        import com.sun.portal.admin.common.PSMBeanException;
037:
038:        /**
039:         * This class implements the psadmin version subcommand.
040:         */
041:
042:        public class VersionCommand extends AdminBaseCommand {
043:
044:            static final String fs = File.separator;
045:            private String jarFullPath;
046:
047:            // subcommand specific options
048:            private static final String OPT_PATCHES = "patches";
049:            private static final String OPT_VERBOSE = "verbose";
050:            private static final String OPT_DISPLAY = "display";
051:            private static final String OPT_JARFILE = "jar";
052:
053:            /**
054:             * The version subcommand
055:             */
056:            public VersionCommand() {
057:                super ();
058:            }
059:
060:            public boolean validateOptions() throws CommandValidationException {
061:                return super .validateOptions();
062:
063:            }
064:
065:            public void validateJar() throws CommandException {
066:
067:                String jarFilePath = getOption(OPT_JARFILE);
068:                if (jarFilePath != null) {
069:                    File f = new File(jarFilePath);
070:                    jarFullPath = f.getAbsolutePath();
071:
072:                    if (!f.exists()) {
073:                        String token[] = { jarFullPath };
074:                        throw new CommandException(getLocalizedString(
075:                                ERROR_FILE_NOT_FOUND, token));
076:
077:                    }
078:                }
079:            }
080:
081:            /**
082:             *  An abstract method that Executes the command
083:             *  @throws CommandException
084:             */
085:            public void runCommand() throws CommandException,
086:                    CommandValidationException {
087:
088:                validateOptions();
089:                validateJar();
090:
091:                String operation = "";
092:
093:                try {
094:
095:                    // Get the MBean server connection
096:                    MBeanServerConnection msc = getMBeanServerConnection(
097:                            getUserId(), getPassword(), getHost());
098:
099:                    // Setting the params and signature
100:                    Boolean patch = new Boolean(getBooleanOption(OPT_PATCHES));
101:                    Boolean patchVerbose = new Boolean(
102:                            getBooleanOption(OPT_VERBOSE));
103:                    Boolean display = new Boolean(getBooleanOption(OPT_DISPLAY));
104:
105:                    Object[] params = { display, jarFullPath, patch,
106:                            patchVerbose };
107:                    String[] signature = { "java.lang.Boolean",
108:                            "java.lang.String", "java.lang.Boolean",
109:                            "java.lang.Boolean" };
110:                    operation = "getPortalVersion";
111:
112:                    // Get the Domain MBean object
113:                    ObjectName objName = AdminClientUtil
114:                            .getPortalDomainMBeanObjectName(getDomainId());
115:
116:                    // Invoke the create portal method on the domain MBean
117:                    String out = (String) msc.invoke(objName, operation,
118:                            params, signature);
119:
120:                    CLILogger.getInstance().printMessage(out);
121:                } catch (InstanceNotFoundException ie) {
122:                    logger.log(Level.SEVERE, "PSALI_CSPACC0005", ie);
123:                    throw new CommandException(getLocalizedString(
124:                            ERROR_MBEAN_INSTANCE_NOT_FOUND,
125:                            new Object[] { operation }), ie);
126:                } catch (MBeanException me) {
127:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
128:                    boolean isPE = me.getCause() instanceof  PSMBeanException;
129:                    if (isPE) {
130:                        PSMBeanException pe = (PSMBeanException) me.getCause();
131:                        String key = null;
132:                        Object tokens[] = pe.getTokens();
133:
134:                        if (pe.getErrorKey() != null) {
135:                            key = pe.getErrorKey();
136:                            CLILogger.getInstance().printMessage(
137:                                    getLocalizedString(key, tokens));
138:                        } else {
139:                            throw new CommandException(getLocalizedString(
140:                                    ERROR_JMX_INVOKE,
141:                                    new Object[] { operation }), pe);
142:                        }
143:                    } else {
144:                        throw new CommandException(getLocalizedString(
145:                                ERROR_JMX_INVOKE, new Object[] { operation }),
146:                                me);
147:                    }
148:                } catch (ReflectionException re) {
149:                    logger.log(Level.SEVERE, "PSALI_CSPACC0007", re);
150:                    throw new CommandException(getLocalizedString(
151:                            ERROR_MBEAN_REFLECTION_ERROR,
152:                            new Object[] { operation }), re);
153:                } catch (MalformedObjectNameException mle) {
154:                    logger.log(Level.SEVERE, "PSALI_CSPACC0004", mle);
155:                    throw new CommandException(
156:                            getLocalizedString(ERROR_OBJECT_NAME), mle);
157:                } catch (CommandException ce) {
158:                    logger.log(Level.SEVERE, "PSALI_CSPACC0008", ce);
159:                    throw ce;
160:                } catch (Exception ex) {
161:                    logger.log(Level.SEVERE, "PSALI_CSPACC0010", ex);
162:                    throw new CommandException(
163:                            getLocalizedString(COMMAND_FAILED), ex);
164:                } finally {
165:                    closeMBeanServerConnection();
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.