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


001:        /**
002:         * $Id: PortalVersion.java,v 1.5 2007/01/26 03:48:33 portalbld 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.fabric.tasks;
014:
015:        import java.io.File;
016:        import java.io.FileNotFoundException;
017:        import java.io.IOException;
018:
019:        import java.util.logging.Level;
020:        import java.util.logging.Logger;
021:
022:        //PS Admin Common
023:        import com.sun.portal.fabric.util.FileUtil;
024:        import com.sun.portal.fabric.util.os.OSTasksFactory;
025:        import com.sun.portal.fabric.util.os.OSTasks;
026:
027:        import com.sun.portal.admin.common.PSMBeanException;
028:        import com.sun.portal.admin.common.PSConfigConstants;
029:        import com.sun.portal.admin.common.context.PSConfigContext;
030:        import com.sun.portal.log.common.PortalLogger;
031:
032:        import com.sun.portal.util.Platform;
033:
034:        /**
035:         * This class implements the psadmin version mbean operations.
036:         */
037:
038:        public class PortalVersion {
039:            static final String fs = Platform.fs;
040:            private PSConfigContext cc;
041:            private OSTasks osTasks;
042:            private static Logger logger = PortalLogger
043:                    .getLogger(PortalVersion.class);
044:
045:            public PortalVersion(PSConfigContext cc) {
046:                OSTasksFactory osTasksFactory = OSTasksFactory.getInstance();
047:                this .cc = cc;
048:                this .osTasks = osTasksFactory.getOSTasks(cc);
049:            }
050:
051:            public String getVersion() throws PSMBeanException {
052:                String psBaseDir = cc.getPSBaseDir();
053:                String psVersionPath = psBaseDir + fs + "lib" + fs
054:                        + "PSversion.properties";
055:                File psVersionFile = new File(psVersionPath);
056:                StringBuffer sb = new StringBuffer(256);
057:
058:                if (psVersionFile.exists()) {
059:                    String build = FileUtil.findTextInFile(psVersionFile,
060:                            "build=");
061:                    String productName = FileUtil.findTextInFile(psVersionFile,
062:                            "productname=");
063:                    String productVersion = FileUtil.findTextInFile(
064:                            psVersionFile, "productversion=");
065:                    sb.append(build.substring(6)).append(" ").append(
066:                            productName.substring(12)).append(" ").append(
067:                            productVersion.substring(15));
068:                } else {
069:                    Object tokens[] = { psVersionFile };
070:                    throw new PSMBeanException("error.psadmin.file.not.found",
071:                            tokens);
072:                }
073:                return sb.toString();
074:            }
075:
076:            public String getVersionFromJar(String jarFilePath)
077:                    throws PSMBeanException {
078:                StringBuffer sb = new StringBuffer(256);
079:                String versionFilePath = null;
080:
081:                try {
082:                    versionFilePath = "META-INF" + fs + "MANIFEST.MF";
083:                    File versionFile = FileUtil.extractFileFromJar(jarFilePath,
084:                            versionFilePath, false);
085:                    if (versionFile.exists()) {
086:                        String build = FileUtil.findTextInFile(versionFile,
087:                                "Created-At:");
088:                        String productName = FileUtil.findTextInFile(
089:                                versionFile, "Product:");
090:                        String productVersion = FileUtil.findTextInFile(
091:                                versionFile, "Version:");
092:                        while (productVersion != null
093:                                && productVersion.length() >= 7
094:                                && !productVersion.substring(0, 7).equals(
095:                                        "Version")) {
096:                            FileUtil.deleteLineInFile(versionFile,
097:                                    productVersion.substring(0, 6));
098:                            productVersion = FileUtil.findTextInFile(
099:                                    versionFile, "Version:");
100:                        }
101:
102:                        if (build != null && build.length() >= 12) {
103:                            sb.append(build.substring(12)).append(" ");
104:                        }
105:                        if (productName != null && build.length() >= 9) {
106:                            sb.append(productName.substring(9)).append(" ");
107:                        }
108:                        if (productVersion != null
109:                                && productVersion.length() >= 9) {
110:                            sb.append(productVersion.substring(9));
111:                        }
112:                        if (sb.toString().length() <= 0) {
113:                            Object tokens[] = { jarFilePath };
114:                            throw new PSMBeanException(
115:                                    "admin.error.version.info.not.found",
116:                                    tokens);
117:                        }
118:
119:                    } else {
120:                        Object tokens[] = { jarFilePath };
121:                        throw new PSMBeanException(
122:                                "admin.error.version.info.not.found", tokens);
123:                    }
124:                } catch (FileNotFoundException fe) {
125:                    Object tokens[] = { versionFilePath };
126:                    logger.log(Level.SEVERE, "PSFB_CSPFT0285", fe);
127:                    throw new PSMBeanException(
128:                            "admin.error.version.file.not.found", tokens);
129:                } catch (IOException ie) {
130:                    Object tokens[] = { jarFilePath };
131:                    logger.log(Level.SEVERE, "PSFB_CSPFT0285", ie);
132:                    throw new PSMBeanException(
133:                            "admin.error.version.info.not.found", tokens);
134:                }
135:                return sb.toString();
136:            }
137:
138:            public String getPatchInfo() throws PSMBeanException {
139:                String patchInfo = osTasks.getPatchInfo();
140:                if (patchInfo != null && patchInfo.length() != 0) {
141:                    return patchInfo;
142:                }
143:                throw new PSMBeanException("admin.error.patch.info.not.found");
144:            }
145:
146:            public String getPatchVerbose() throws PSMBeanException {
147:                String patchInfo = osTasks.getPatchVerbose();
148:                if (patchInfo != null && patchInfo.length() != 0) {
149:                    return patchInfo;
150:                }
151:                throw new PSMBeanException("admin.error.patch.info.not.found");
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.