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


001:        /*
002:         * ParFile.java
003:         *
004:         * Created on October 24, 2001, 4:43 PM
005:         */
006:
007:        package com.sun.portal.desktop.deployment;
008:
009:        import java.util.Vector;
010:
011:        import java.util.zip.ZipEntry;
012:
013:        import java.util.jar.JarFile;
014:
015:        import java.io.InputStream;
016:        import java.io.PrintStream;
017:
018:        /**
019:         * The basic Parfile class.  It extends JarFile to handle the specialized manifest
020:         * and extraction methods for the portal server.
021:         *
022:         * @author  yabob
023:         * @version 
024:         */
025:        public class ParFile extends JarFile {
026:
027:            // private constructor, so we can wrap exception thrown by the JarFile constructor.
028:
029:            private ParFile(String path) throws Exception {
030:                super (path);
031:                m_PMan = ParManifest.makeManifest(getManifest());
032:            }
033:
034:            // static routine which uses the private constructor to create a new ParFile.
035:
036:            public static ParFile makeParFile(String path)
037:                    throws ParFileException {
038:
039:                try {
040:                    return new ParFile(path);
041:                } catch (Exception ex) {
042:                    throw new ParFileException("errorParFileCreation", ex);
043:                }
044:            }
045:
046:            public ParManifest getParManifest() {
047:                return m_PMan;
048:            }
049:
050:            public void describe(PrintStream out) throws ParFileException {
051:
052:                // describe logic is handled by the manifest, but it needs a reference to
053:                // the par file so it can extract the XML documents to describe them.
054:
055:                m_PMan.describe(out, this );
056:            }
057:
058:            // Perform autoextraction of all of the .par file entries which have autoextraction
059:            // defined.  Really, we just get the op's out of the manifest and call performExtraction
060:            // with them.
061:
062:            public void performAutoExtraction(ParExtractionContext pex,
063:                    String dpnode) throws ParFileException {
064:
065:                Vector nl = m_PMan.getDPEntryList();
066:                int opcount = 0;
067:
068:                for (int i = 0; i < nl.size(); ++i) {
069:
070:                    String name = (String) nl.elementAt(i);
071:                    ExtractOp op = m_PMan.getDPEntryAutoExtract(name);
072:
073:                    if (op != null) {
074:                        ++opcount;
075:                        if (dpnode != null) {
076:                            op.setDPNode(dpnode);
077:                        }
078:                        op.setEntryName(name);
079:                        performExtraction(pex, op);
080:                    }
081:                }
082:
083:                if (opcount == 0) {
084:                    throw new ParFileException("errorNoOperations");
085:                }
086:            }
087:
088:            // Perform autoextraction of all of the .par file entries which have autoextraction
089:            // defined.  Really, we just get the op's out of the manifest and call performExtraction
090:            // with them.
091:
092:            public void performAutoExtraction(ParExtractionContext pex,
093:                    String dpnode, boolean extractDP) throws ParFileException {
094:
095:                Vector nl = m_PMan.getDPEntryList();
096:                int opcount = 0;
097:
098:                for (int i = 0; i < nl.size(); ++i) {
099:
100:                    String name = (String) nl.elementAt(i);
101:                    ExtractOp op = m_PMan.getDPEntryAutoExtract(name);
102:
103:                    if (op != null) {
104:                        ++opcount;
105:                        if (dpnode != null) {
106:                            op.setDPNode(dpnode);
107:                        }
108:                        op.setEntryName(name);
109:                        performExtraction(pex, op, extractDP);
110:                    }
111:                }
112:
113:                if (opcount == 0) {
114:                    throw new ParFileException("errorNoOperations");
115:                }
116:            }
117:
118:            // Perform an extraction operation
119:
120:            public void performExtraction(ParExtractionContext pex, ExtractOp op)
121:                    throws ParFileException {
122:
123:                // Just bracket the real work with initialize ... terminate, handling failure appropriately.
124:
125:                pex.initializeForOperation(op);
126:                try {
127:                    extractionOperation(pex, op);
128:                } catch (ParFileException ex) {
129:                    pex.terminateOperation(false);
130:                    throw ex;
131:                }
132:                pex.terminateOperation(true);
133:            }
134:
135:            // Perform an extraction operation
136:
137:            public void performExtraction(ParExtractionContext pex,
138:                    ExtractOp op, boolean extractDP) throws ParFileException {
139:
140:                // Just bracket the real work with initialize ... terminate, handling failure appropriately.
141:
142:                pex.initializeForOperation(op);
143:                try {
144:                    extractionOperation(pex, op, extractDP);
145:                } catch (ParFileException ex) {
146:                    pex.terminateOperation(false);
147:                    throw ex;
148:                }
149:                pex.terminateOperation(true);
150:            }
151:
152:            // Perform file extraction
153:            public void performFileExtraction(ParExtractionContext pex,
154:                    String entryName, int types) throws ParFileException {
155:                fileExtractionOperation(pex, entryName, types);
156:            }
157:
158:            // The real work of an extraction operation.
159:            private void extractionOperation(ParExtractionContext pex,
160:                    ExtractOp op) throws ParFileException {
161:
162:                // We HAVE to have a DPEntry file.  Extract it, and call putParEntryXMLFile to deploy it.
163:
164:                ZipEntry ze = m_PMan.getDPZip(op.getEntryName());
165:                InputStream is = getCheckedIS(ze);
166:                pex.putParEntryXMLFile(is, op.getTypes());
167:                fileExtractionOperation(pex, op.getEntryName(), op.getTypes());
168:            }
169:
170:            // The real work of an extraction operation.
171:            private void extractionOperation(ParExtractionContext pex,
172:                    ExtractOp op, boolean extractDP) throws ParFileException {
173:
174:                // We HAVE to have a DPEntry file.  Extract it, and call putParEntryXMLFile to deploy it.
175:                ZipEntry ze = m_PMan.getDPZip(op.getEntryName());
176:                InputStream is = getCheckedIS(ze);
177:                if (extractDP) {
178:                    pex.putParEntryXMLFile(is, op.getTypes());
179:                } else {
180:                    pex.setChannelPath(is, op.getTypes());
181:                }
182:                fileExtractionOperation(pex, op.getEntryName(), op.getTypes());
183:            }
184:
185:            // Gets file list in the par file, and put them back based on type
186:            private void fileExtractionOperation(ParExtractionContext pex,
187:                    String entryName, int types) throws ParFileException {
188:                // Get the files associated with our entry
189:
190:                Vector files = m_PMan.getDPEntryIncludeList(entryName, types);
191:                for (int i = 0; i < files.size(); ++i) {
192:
193:                    // obtain the ZipEntry and open a stram to it.
194:
195:                    // technically, we should use the get*Zip() calls to construct ZipEntry's
196:                    // from our specific types, but we know that all that is going to do is
197:                    // glue the path back together again, so we can save the trouble, and
198:                    // just get the normal jar entry.
199:
200:                    String path = (String) files.elementAt(i);
201:                    ZipEntry ze = getJarEntry(path);
202:                    InputStream is = getCheckedIS(ze);
203:
204:                    // Now, direct the stream according to the type of path.
205:
206:                    switch (m_PMan.getPathRootType(path)) {
207:                    case CLASSFILE:
208:                        String fn = m_PMan.getFullFromClassPath(path);
209:                        pex.putClassFile(fn, is);
210:                        break;
211:                    case PBFILE:
212:                        String prop = m_PMan.getPropertyFromPBFPath(path);
213:                        String relp = m_PMan.getPathFromPBFPath(path);
214:                        pex.putPropLocFile(prop, relp, is);
215:                        break;
216:                    case STATFILE:
217:                        String sp = m_PMan.getPathFromStaticPath(path);
218:                        pex.putStaticFile(sp, is);
219:                        break;
220:                    case WARFILE:
221:                        String wp = m_PMan.getPathFromWarPath(path);
222:                        pex.putWarFile(wp, is);
223:                        break;
224:                    case CONFFILE:
225:                        String cp = m_PMan.getPathFromConfPath(path);
226:                        pex.putConfigFile(cp, is);
227:                        break;
228:                    default:
229:                        throw new ParFileException("errorExportOp");
230:                    }
231:                }
232:
233:            }
234:
235:            // Wrap stream creation with our own exceptions.
236:
237:            private InputStream getCheckedIS(ZipEntry ze)
238:                    throws ParFileException {
239:
240:                try {
241:                    InputStream is = getInputStream(ze);
242:                    if (is == null) {
243:                        throw new ParFileException("errorZipOpen");
244:                    }
245:
246:                    return is;
247:                } catch (Exception ex) {
248:                    throw new ParFileException("errorZipOpen", ex);
249:                }
250:            }
251:
252:            private ParManifest m_PMan;
253:
254:            private static final int CLASSFILE = ParManifest.CLASSFILE;
255:            private static final int PBFILE = ParManifest.PBFILE;
256:            private static final int STATFILE = ParManifest.STATFILE;
257:            private static final int WARFILE = ParManifest.WARFILE;
258:            private static final int CONFFILE = ParManifest.CONFFILE;
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.