01: /*
02: * PPFAuxFile.java
03: *
04: * Created on October 25, 2001, 3:05 PM
05: */
06:
07: package com.sun.portal.desktop.deployment;
08:
09: import java.io.FileInputStream;
10: import java.io.InputStream;
11: import java.io.File;
12:
13: import java.util.zip.ZipEntry;
14:
15: /**
16: * ProviderPackageFile for encapsulating transfer between par files.
17: *
18: * Note - we go through the steps of actually parsing apart the old path
19: * with reference to the old manifest, and reconstructing them with
20: * reference to the new one so that it will work if the two manifests
21: * use different root directories.
22: *
23: * @author yabob
24: * @version
25: */
26: public class ParXferPPF extends ProviderPackageFile {
27:
28: public ParXferPPF(ParFile pf, String path, int types) {
29:
30: super (types);
31:
32: m_PF = pf;
33: m_Path = path;
34: }
35:
36: public InputStream getStream() throws ParFileException {
37: try {
38: return m_PF.getInputStream(m_PF.getEntry(m_Path));
39: } catch (Exception ex) {
40: throw new ParFileException("errorXFParOpen", ex);
41: }
42: }
43:
44: public void addManifestInclusion(ParManifest man, String name)
45: throws ParFileException {
46:
47: ParManifest mf = m_PF.getParManifest();
48:
49: switch (mf.getPathRootType(m_Path)) {
50: case CLASSFILE:
51: man.addDPEntryIncludeClass(name, mf
52: .getFullFromClassPath(m_Path), getTypes());
53: break;
54: case PBFILE:
55: man.addDPEntryIncludePBFile(name, mf
56: .getPropertyFromPBFPath(m_Path), mf
57: .getPathFromPBFPath(m_Path), getTypes());
58: break;
59: default:
60: throw new ParFileException("errorXFParRoot");
61: }
62: }
63:
64: public ZipEntry getZipEntry(ParManifest man)
65: throws ParFileException {
66:
67: ParManifest mf = m_PF.getParManifest();
68:
69: switch (mf.getPathRootType(m_Path)) {
70: case CLASSFILE:
71: return man.getClassZip(mf.getFullFromClassPath(m_Path));
72: case PBFILE:
73: return man.getPBFileZip(mf.getPropertyFromPBFPath(m_Path),
74: mf.getPathFromPBFPath(m_Path));
75: default:
76: throw new ParFileException("errorXFParRoot");
77: }
78:
79: // Not reached.
80: }
81:
82: private ParFile m_PF;
83: private String m_Path;
84:
85: private static final int CLASSFILE = ParManifest.CLASSFILE;
86: private static final int PBFILE = ParManifest.PBFILE;
87: }
|