Changed spelling to manifest
authorlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Oct 2006 22:19:16 +0000 (22:19 +0000)
committerlhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Oct 2006 22:19:16 +0000 (22:19 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1673 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java [deleted file]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Manifest.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepTwo.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepTwo.java

index 16faf4e..730e385 100644 (file)
@@ -39,7 +39,7 @@ public class DistributeRule {
         // Get Far packages list;\r
         // \r
         try {\r
-            farPkgList = myFar.mainfest.getPackageList();\r
+            farPkgList = myFar.manifest.getPackageList();\r
             Iterator pkgItems = farPkgList.iterator();\r
             while (pkgItems.hasNext()) {\r
                 PackageIdentification id = (PackageIdentification) pkgItems.next();\r
index ffaace8..6dbf1af 100644 (file)
@@ -35,9 +35,9 @@ import org.tianocore.frameworkwizard.workspace.Workspace;
 \r
 public class Far {\r
     //\r
-    // Class member Mainfest\r
+    // Class member Manifest\r
     //\r
-    public Mainfest mainfest = null;\r
+    public Manifest manifest = null;\r
 \r
     //\r
     // Jar file\r
@@ -60,7 +60,7 @@ public class Far {
     //\r
     public Far(JarFile farFile) throws Exception {\r
         jf = farFile;\r
-        this.mainfest = new Mainfest(getMainfestFile());\r
+        this.manifest = new Manifest(getManifestFile());\r
     }\r
 \r
     public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
@@ -70,23 +70,23 @@ public class Far {
         //\r
         // Generate Manifest and get file lists\r
         //\r
-        this.mainfest = new Mainfest();\r
-        this.mainfest.setFarHeader(fHeader);\r
-        this.mainfest.createManifest(pkgList, plfList, fileFilter);\r
+        this.manifest = new Manifest();\r
+        this.manifest.setFarHeader(fHeader);\r
+        this.manifest.createManifest(pkgList, plfList, fileFilter);\r
 \r
-        this.mainfest.hibernateToFile();\r
+        this.manifest.hibernateToFile();\r
 \r
         //\r
         // Write Mainifest file to JAR.\r
         //\r
-        if (this.mainfest.mfFile != null) {\r
-            writeToJar(this.mainfest.mfFile, jos);\r
+        if (this.manifest.mfFile != null) {\r
+            writeToJar(this.manifest.mfFile, jos);\r
         }\r
 \r
         //\r
         // Write all files to JAR\r
         //\r
-        Set<File> files = this.mainfest.files;\r
+        Set<File> files = this.manifest.files;\r
         Iterator<File> iter = files.iterator();\r
         while (iter.hasNext()) {\r
             writeToJar(iter.next(), jos);\r
@@ -109,7 +109,7 @@ public class Far {
     }\r
 \r
     public void InstallFar(String dir) throws Exception {\r
-        List<FarFileItem> allFile = mainfest.getAllFileItem();\r
+        List<FarFileItem> allFile = manifest.getAllFileItem();\r
         extract(allFile, dir);\r
     }\r
 \r
@@ -119,7 +119,7 @@ public class Far {
         Iterator<PlatformIdentification> plfIter = plfKeys.iterator();\r
         while (plfIter.hasNext()) {\r
             PlatformIdentification item = plfIter.next();\r
-            extract(this.mainfest.getPlatformContents(item), plfMap.get(item).getPath());\r
+            extract(this.manifest.getPlatformContents(item), plfMap.get(item).getPath());\r
         }\r
 \r
         Set<PackageIdentification> pkgKeys = pkgMap.keySet();\r
@@ -132,15 +132,15 @@ public class Far {
     }\r
 \r
     public void installPackage(PackageIdentification packageId, File installPath) throws Exception {\r
-        List<FarFileItem> contents = this.mainfest.getPackageContents(packageId);\r
+        List<FarFileItem> contents = this.manifest.getPackageContents(packageId);\r
         extract(contents, installPath.getPath());\r
     }\r
 \r
-    public InputStream getMainfestFile() throws Exception {\r
+    public InputStream getManifestFile() throws Exception {\r
         JarEntry je = null;\r
         for (Enumeration e = jf.entries(); e.hasMoreElements();) {\r
             je = (JarEntry) e.nextElement();\r
-            if (je.getName().equalsIgnoreCase(Mainfest.mfFileName))\r
+            if (je.getName().equalsIgnoreCase(Manifest.mfFileName))\r
                 return jf.getInputStream(je);\r
         }\r
         return null;\r
@@ -262,7 +262,7 @@ public class Far {
         PackageQuery pkgQ = new PackageQuery();\r
         List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
 \r
-        entry = this.mainfest.getPackgeSpd(pkgId);\r
+        entry = this.manifest.getPackgeSpd(pkgId);\r
         if (entry == null) {\r
             return result;\r
         }\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java
deleted file mode 100644 (file)
index 63517d3..0000000
+++ /dev/null
@@ -1,960 +0,0 @@
-/** @file\r
\r
- The file is used to create Far's mainfest file\r
\r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution.  The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
- **/\r
-package org.tianocore.frameworkwizard.far;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.LinkedHashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.transform.OutputKeys;\r
-import javax.xml.transform.Result;\r
-import javax.xml.transform.Source;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.apache.xmlbeans.XmlException;\r
-import org.tianocore.frameworkwizard.common.Tools;\r
-import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
-import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
-import org.tianocore.frameworkwizard.workspace.Workspace;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.NamedNodeMap;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-\r
-public class Mainfest implements ManifestInterface {\r
-    // /\r
-    // / mainfest document\r
-    // /\r
-    Document mainfestDoc = null;\r
-\r
-    // /\r
-    // / Mainfest file element name\r
-    // /\r
-    final static String mfFileName = "FrameworkArhciveMainfest.xml";\r
-\r
-    //\r
-    // Header\r
-    //\r
-    final static String farHeader = "FarHeader";\r
-\r
-    final static String farHeader_FarName = "FarName";\r
-\r
-    final static String farHeader_Abstract = "Abstract";\r
-\r
-    final static String farHeader_Description = "Description";\r
-\r
-    final static String farHeader_CopyRight = "Copyright";\r
-\r
-    final static String farHeader_License = "License";\r
-\r
-    final static String farHeader_Specification = "Specification";\r
-\r
-    //\r
-    // Package list\r
-    //\r
-    final static String farPackageList = "FarPackageList";\r
-\r
-    final static String farPlatformList = "FarPlatformList";\r
-\r
-    final static String contents = "Contents";\r
-\r
-    final static String userExtensions = "UserExtensions";\r
-\r
-    //\r
-    // Common node name\r
-    //\r
-\r
-    final static String guidValue = "GuidValue";\r
-\r
-    final static String version = "Version";\r
-\r
-    //\r
-    // FarPackage node name\r
-    //\r
-    final static String farPackageList_FarPackage = "FarPackage";\r
-\r
-    final static String farPackage_FarfileName = "FarFilename";\r
-\r
-    final static String farPackage_DefaultPath = "DefaultPath";\r
-\r
-    final static String farPlatformList_FarPlatform = "FarPlatform";\r
-\r
-    final static String farFileName_FarGuid = "FarGuid";\r
-\r
-    final static String farFileName_Md5sum = "Md5sum";\r
-\r
-    //\r
-    // mainfest header information.\r
-    //\r
-    FarHeader fhInfo = new FarHeader();\r
-\r
-    //\r
-    // FarPackage list\r
-    //\r
-    List<FarPackage> fPkgList = new ArrayList<FarPackage>();\r
-\r
-    //\r
-    // FarPlatform list\r
-    //\r
-    List<FarPlatformItem> fPlfList = new ArrayList<FarPlatformItem>();\r
-\r
-    Set<File> files = new LinkedHashSet<File>();\r
-\r
-    //\r
-    // Mainfest file\r
-    //\r
-    public File mfFile = null;\r
-\r
-    public FarHeader getHeader() {\r
-        return fhInfo;\r
-    }\r
-\r
-    public Mainfest() throws Exception {\r
-        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
-        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
-        Document document = dombuilder.newDocument();\r
-        this.mainfestDoc = document;\r
-\r
-    }\r
-\r
-    public Mainfest(InputStream mainfestInputStream) throws Exception {\r
-        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
-        try {\r
-            if (mainfestInputStream != null) {\r
-                DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
-                this.mainfestDoc = dombuilder.parse(mainfestInputStream);\r
-                parseMainfest();\r
-            }\r
-\r
-        } catch (Exception e) {\r
-            //\r
-            // Will change to throw Wizader exception.\r
-            //\r
-            throw new Exception(e.getMessage());\r
-        }\r
-    }\r
-\r
-    public void setFarHeader(FarHeader fHeader) {\r
-        this.fhInfo = fHeader;\r
-    }\r
-\r
-    public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
-                               Set<String> fileFilter) throws Exception {\r
-\r
-        //\r
-        // Add Package and it's contents to FarPackageList.\r
-        //\r
-        Iterator<PackageIdentification> pkgItem = pkgList.iterator();\r
-        while (pkgItem.hasNext()) {\r
-            PackageIdentification pkgId = pkgItem.next();\r
-\r
-            //\r
-            // Add package and it's contents to <FarPackageList>.\r
-            //\r
-            addPkgToPkgList(pkgId, fileFilter);\r
-        }\r
-\r
-        //\r
-        // Add FarPlatform to this.farPlatformList.\r
-        //\r
-        Iterator<PlatformIdentification> plfItem = plfList.iterator();\r
-        while (plfItem.hasNext()) {\r
-            PlatformIdentification plfId = plfItem.next();\r
-\r
-            //\r
-            // Add platform to Mainifest.\r
-            //\r
-            addPlatformIdToFarPlatformItemList(plfId);\r
-        }\r
-    }\r
-\r
-    public void setManifestFile(File mainfestFile) throws Exception {\r
-        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
-        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
-        InputStream is = new FileInputStream(mainfestFile);\r
-        this.mainfestDoc = dombuilder.parse(is);\r
-    }\r
-\r
-    public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {\r
-        files.add(packageId.getSpdFile());\r
-\r
-        FarPackage farPackage = new FarPackage();\r
-        //\r
-        // Add SPD file to FarPackage\r
-        //\r
-        File spdFile = new File(packageId.getPath());\r
-\r
-        FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));\r
-        farPackage.setFarFile(ffItem);\r
-\r
-        //\r
-        // Add package guid value.\r
-        //\r
-        farPackage.setGuidValue(packageId.getGuid());\r
-\r
-        //\r
-        // Add package version\r
-        //\r
-        farPackage.setVersion(packageId.getVersion());\r
-\r
-        //\r
-        // Add DefaultPat: Package absoulte path - Workspace absolut\r
-        // path.\r
-        //\r
-        String pkgDir = Tools.getFilePathOnly(packageId.getPath());\r
-        File rootDir = new File(pkgDir);\r
-        farPackage.setDefaultPath(Tools.getRelativePath(rootDir.getPath(), Workspace.getCurrentWorkspace()));\r
-\r
-        //\r
-        // Get package root dir contains.\r
-        //\r
-        Set<File> fileSet = new LinkedHashSet<File>();\r
-        Set<File> fpdFileSet = new LinkedHashSet<File>();\r
-\r
-        //\r
-        // Get all files and fpd files\r
-        //\r
-        recursiveDirectory(fileSet, fpdFileSet, rootDir, fileFilter);\r
-\r
-        //\r
-        // Remove current package's SPD file\r
-        //\r
-        fileSet.remove(packageId.getSpdFile());\r
-\r
-        files.addAll(fileSet);\r
-\r
-        Iterator<File> iter = fileSet.iterator();\r
-        List<FarFileItem> contents = new ArrayList<FarFileItem>();\r
-        while (iter.hasNext()) {\r
-            File normalFile = iter.next();\r
-            String fileRelativePath = Tools.getRelativePath(normalFile.getPath(), pkgDir);\r
-            ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));\r
-            contents.add(ffItem);\r
-        }\r
-\r
-        farPackage.setContentList(contents);\r
-\r
-        //        List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();\r
-        //\r
-        //        iter = fpdFileSet.iterator();\r
-        //\r
-        //        while (iter.hasNext()) {\r
-        //            File fpdFile = iter.next();\r
-        //            PlatformIdentification platformId = new PlatformIdentification(wsTool\r
-        //                    .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile\r
-        //                            .getPath())));\r
-        //            addPlatformIdToFarPlatformItemList(fpfList, platformId);\r
-        //        }\r
-        //        farPackage.setFarPlatformList(fpfList);\r
-        fPkgList.add(farPackage);\r
-    }\r
-\r
-    private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {\r
-        if (isFilter(dir, fileFilter)) {\r
-            return;\r
-        }\r
-        File[] allFilesInDir = dir.listFiles();\r
-        for (int i = 0; i < allFilesInDir.length; i++) {\r
-            if (allFilesInDir[i].isFile()) {\r
-                if (isFilter(allFilesInDir[i], fileFilter)) {\r
-                    continue;\r
-                }\r
-                //                if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {\r
-                //                    fpds.add(allFilesInDir[i]);\r
-                //                } else {\r
-                files.add(allFilesInDir[i]);\r
-                //                }\r
-            } else {\r
-                recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);\r
-            }\r
-        }\r
-    }\r
-\r
-    public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {\r
-        files.add(platformId.getFpdFile());\r
-\r
-        FarPlatformItem fpfItem = new FarPlatformItem();\r
-        FarFileItem ffItem;\r
-        String fpfPath = platformId.getPath();\r
-        File fpfFile = new File(fpfPath);\r
-        //\r
-        // Add farFileName\r
-        //\r
-        ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),\r
-                                 FarMd5.md5(fpfFile));\r
-        fpfItem.setFarFile(ffItem);\r
-\r
-        //\r
-        // Add guid value\r
-        //\r
-        fpfItem.setGuidValue(platformId.getGuid());\r
-\r
-        //\r
-        // Add version\r
-        //\r
-        fpfItem.setVersion(platformId.getVersion());\r
-\r
-        fPlfList.add(fpfItem);\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param\r
-     * @return Set<PackageIdentification> list of PackageIdentification.\r
-     */\r
-    public List<PackageIdentification> getPackageList() throws Exception {\r
-        //\r
-        // PackageIdentification set.\r
-        //\r
-        List<PackageIdentification> pkgList = new ArrayList<PackageIdentification>();\r
-        //\r
-        // \r
-        //\r
-        Iterator pkgItem = this.fPkgList.iterator();\r
-        while (pkgItem.hasNext()) {\r
-            FarPackage fPkg = (FarPackage) pkgItem.next();\r
-            //\r
-            // Get package information from SPD file and create a package\r
-            // identification.\r
-            //\r
-\r
-            PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(),\r
-                                                                    fPkg.getGuidValue(), fPkg.getVersion());\r
-            pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath()\r
-                          + File.separatorChar + fPkg.getFarFile().getRelativeFilename());\r
-            //            wsTool.getId(\r
-            //                    Workspace.getCurrentWorkspace() + File.separatorChar\r
-            //                            + fPkg.getDefaultPath(), OpenFile\r
-            //                            .openFpdFile(Workspace.getCurrentWorkspace()\r
-            //                                    + File.separatorChar\r
-            //                                    + fPkg.getDefaultPath()\r
-            //                                    + File.separatorChar\r
-            //                                    + fPkg.getFarFile().getRelativeFilename()));\r
-            pkgList.add(pkgId);\r
-        }\r
-        return pkgList;\r
-    }\r
-\r
-    /**\r
-     * \r
-     */\r
-    public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {\r
-        //\r
-        // PlatformIdentification set.\r
-        //\r
-        List<PlatformIdentification> plfList = new ArrayList<PlatformIdentification>();\r
-        Iterator plfItem = this.fPlfList.iterator();\r
-        while (plfItem.hasNext()) {\r
-            FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();\r
-            File file = new File(Workspace.getCurrentWorkspace() + File.separatorChar\r
-                                 + fpfItem.getFarFile().getRelativeFilename());\r
-            //\r
-            // Set platformIdentificaiton's path as absolutly path (include\r
-            // workspace and FPD relatively path)\r
-            //\r
-            PlatformIdentification plfId = new PlatformIdentification(fpfItem.getFarFile().getRelativeFilename(),\r
-                                                                      fpfItem.getGuidValue(), fpfItem.getVersion(),\r
-                                                                      file.getPath());\r
-\r
-            //                (PlatformIdentification) wsTool\r
-            //                    .getId(file.getParent(), OpenFile.openFpdFile(Workspace\r
-            //                            .getCurrentWorkspace()\r
-            //                            + File.separatorChar\r
-            //                            + fpfItem.getFarFile().getRelativeFilename()));\r
-            plfList.add(plfId);\r
-        }\r
-        return plfList;\r
-    }\r
-\r
-    public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {\r
-        List<FarFileItem> result = new ArrayList<FarFileItem>();\r
-        Iterator<FarPlatformItem> iter = this.fPlfList.iterator();\r
-\r
-        while (iter.hasNext()) {\r
-            FarPlatformItem item = iter.next();\r
-            if (item.isIdentityPlf(platformId)) {\r
-                FarFileItem farFileItem = item.getFarFile();\r
-                farFileItem.setDefaultPath(farFileItem.getRelativeFilename());\r
-                farFileItem.setRelativeFilename(Tools.getFileNameOnly(farFileItem.getRelativeFilename()));\r
-                result.add(farFileItem);\r
-                break;\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    public List<FarFileItem> getPackageContents(PackageIdentification packageId) {\r
-        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
-        Iterator pkgItem = this.fPkgList.iterator();\r
-        while (pkgItem.hasNext()) {\r
-            FarPackage pkg = (FarPackage) pkgItem.next();\r
-            if (pkg.isIdentityPkg(packageId)) {\r
-                //\r
-                // Add spd far file to list.\r
-                //\r
-                farFileList.add(pkg.getFarFile());\r
-                //\r
-                // Add all files in contents to list.\r
-                //\r
-                farFileList.addAll(pkg.getContentList());\r
-                //\r
-                // Add all farfiles in <FarPlatformList> to list.\r
-                //\r
-                //                List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
-                //                Iterator plfItem = plfList.iterator();\r
-                //                while (plfItem.hasNext()) {\r
-                //                    farFileList.add(((FarPlatformItem) plfItem.next())\r
-                //                            .getFarFile());\r
-                //                }\r
-\r
-                Iterator<FarFileItem> ffIter = farFileList.iterator();\r
-                while (ffIter.hasNext()) {\r
-                    FarFileItem ffItem = ffIter.next();\r
-                    ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());\r
-                }\r
-                break;\r
-            }\r
-        }\r
-\r
-        return farFileList;\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param pkgId\r
-     * @return String: return string represent jar file entry; \r
-     */\r
-    public String[] getPackgeSpd(PackageIdentification pkgId) {\r
-        Iterator pkgItem = this.fPkgList.iterator();\r
-        String[] entryStr = new String[2];\r
-        while (pkgItem.hasNext()) {\r
-            FarPackage pkg = (FarPackage) pkgItem.next();\r
-            if (pkg.isIdentityPkg(pkgId)) {\r
-                entryStr[0] = pkg.getFarFile().getRelativeFilename();\r
-                entryStr[1] = pkg.getDefaultPath();\r
-                return entryStr;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public List<FarFileItem> getPackageContents() {\r
-        //\r
-        // In this farFilelist,all FarFileItem's relativeFileName should be\r
-        // set as absolutely path.\r
-        //\r
-        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
-        Iterator pkgItem = this.fPkgList.iterator();\r
-        FarFileItem ffItem = null;\r
-\r
-        while (pkgItem.hasNext()) {\r
-            FarPackage pkg = (FarPackage) pkgItem.next();\r
-\r
-            //\r
-            // Add spd far file to list.\r
-            //\r
-            ffItem = pkg.getFarFile();\r
-            //\r
-            // Set farFileItem relativeFileName = absolutePath + file Name.\r
-            //\r
-            farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename(),\r
-                                            ffItem.getMd5Value()));\r
-            //\r
-            // Add all files in contents to list.\r
-            //\r
-            Iterator contentsItem = pkg.getContentList().iterator();\r
-            while (contentsItem.hasNext()) {\r
-                ffItem = (FarFileItem) contentsItem.next();\r
-                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
-                                                ffItem.getMd5Value()));\r
-            }\r
-            //\r
-            // Add all farfiles in <FarPlatformList> to list.\r
-            //\r
-            List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
-            Iterator plfItem = plfList.iterator();\r
-            while (plfItem.hasNext()) {\r
-                ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();\r
-                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
-                                                ffItem.getMd5Value()));\r
-            }\r
-        }\r
-        return farFileList;\r
-    }\r
-\r
-    public String getPackageDefaultPath(PackageIdentification packageId) {\r
-        Iterator pkgItr = this.fPkgList.iterator();\r
-        while (pkgItr.hasNext()) {\r
-            FarPackage farPackage = (FarPackage) pkgItr.next();\r
-            if (farPackage.isIdentityPkg(packageId)) {\r
-                return farPackage.getDefaultPath();\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    //    public void setPackageInstallPath(PackageIdentification packageId, String path) {\r
-    //        Iterator<FarPackage> pkgItr = this.fPkgList.iterator();\r
-    //        while (pkgItr.hasNext()) {\r
-    //            FarPackage farPackage = pkgItr.next();\r
-    //            if (farPackage.isIdentityPkg(packageId)) {\r
-    //                farPackage.setDefaultPath(path);\r
-    //                return ;\r
-    //            }\r
-    //        }\r
-    //    }\r
-    //\r
-    //    public void setPlatformInstallPath(PlatformIdentification platformId, String path) {\r
-    //        Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();\r
-    //        while (plfItr.hasNext()) {\r
-    //            FarPlatformItem farPlatform = plfItr.next();\r
-    //            if (farPlatform.i.isIdentity(platformId)) {\r
-    //                farPackage.setDefaultPath(path);\r
-    //                return ;\r
-    //            }\r
-    //        }\r
-    //    }\r
-\r
-    public List<FarFileItem> getAllFileItem() {\r
-        //\r
-        // The farFileName in this list are all abosulte path.\r
-        //\r
-        List<FarFileItem> ffiList = new ArrayList<FarFileItem>();\r
-        //\r
-        // Add far files in <FarPackageList> to list.\r
-        //\r
-        ffiList = this.getPackageContents();\r
-\r
-        //\r
-        // Add far files in <FarPlatformList> to list\r
-        //\r
-        NodeList elementList = this.mainfestDoc.getElementsByTagName(farPlatformList);\r
-        for (int i = 0; i < elementList.getLength(); i++) {\r
-            //\r
-            // Get <farPlatform> node list.\r
-            //\r
-            Node item = elementList.item(i);\r
-            NodeList plfElements = item.getChildNodes();\r
-            for (int j = 0; j < plfElements.getLength(); j++) {\r
-                //\r
-                // Get each <FarPlatform> content.\r
-                //\r
-                NodeList plfChildNode = plfElements.item(i).getChildNodes();\r
-                Node tempNode = null;\r
-                for (int t = 0; t < plfChildNode.getLength(); t++) {\r
-                    tempNode = plfChildNode.item(t);\r
-                    //\r
-                    // Get child node value and set to platformIdentification.\r
-                    //\r
-                    if (tempNode.getNodeName().equalsIgnoreCase(farPackage_FarfileName)) {\r
-                        NamedNodeMap farAttr = tempNode.getAttributes();\r
-                        //\r
-                        // Change relative path to absolute one\r
-                        //\r
-                        FarFileItem farFile = new FarFileItem(tempNode.getTextContent(),\r
-                                                              farAttr.getNamedItem(farFileName_Md5sum).getTextContent());\r
-                        ffiList.add(farFile);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return ffiList;\r
-    }\r
-\r
-    public void hibernateToFile() throws Exception {\r
-        //\r
-        // create mainfest root node\r
-        //\r
-        Element rootNode = this.mainfestDoc.createElement("FrameworkArchiveManifest");\r
-        this.mainfestDoc.appendChild(rootNode);\r
-\r
-        //\r
-        // create mainfest header node\r
-        //\r
-        Element headerNode = this.mainfestDoc.createElement(farHeader);\r
-        rootNode.appendChild(headerNode);\r
-        //\r
-        // Add FarHeader to headerNode.\r
-        //\r
-        Element farName = this.mainfestDoc.createElement(farHeader_FarName);\r
-        farName.setTextContent(this.fhInfo.getFarName());\r
-        headerNode.appendChild(farName);\r
-\r
-        Element gv = this.mainfestDoc.createElement(guidValue);\r
-        gv.setTextContent(this.fhInfo.getGuidValue());\r
-        headerNode.appendChild(gv);\r
-\r
-        Element ver = this.mainfestDoc.createElement(version);\r
-        ver.setTextContent(this.fhInfo.getVersion());\r
-        headerNode.appendChild(ver);\r
-\r
-        Element abstra = this.mainfestDoc.createElement(farHeader_Abstract);\r
-        abstra.setTextContent(this.fhInfo.getAbstractStr());\r
-        headerNode.appendChild(abstra);\r
-\r
-        Element descr = this.mainfestDoc.createElement(farHeader_Description);\r
-        descr.setTextContent(this.fhInfo.getDescription());\r
-        headerNode.appendChild(descr);\r
-\r
-        Element copyright = this.mainfestDoc.createElement(farHeader_CopyRight);\r
-        copyright.setTextContent(this.fhInfo.getCopyright());\r
-        headerNode.appendChild(copyright);\r
-\r
-        Element license = this.mainfestDoc.createElement(farHeader_License);\r
-        license.setTextContent(this.fhInfo.getLicense());\r
-        headerNode.appendChild(license);\r
-\r
-        Element spec = this.mainfestDoc.createElement(farHeader_Specification);\r
-        spec.setTextContent(this.fhInfo.getSpecification());\r
-        System.out.println(this.fhInfo.getSpecification());\r
-        headerNode.appendChild(spec);\r
-\r
-        //\r
-        // create mainfest FarPackageList node\r
-        //\r
-        Element pkgListNode = this.mainfestDoc.createElement(farPackageList);\r
-        rootNode.appendChild(pkgListNode);\r
-\r
-        //\r
-        // Save each item in farPackage list to <FarPackage>.\r
-        //\r
-        Iterator pkgItem = this.fPkgList.iterator();\r
-        while (pkgItem.hasNext()) {\r
-            pkgToFarPkgNode(pkgListNode, (FarPackage) pkgItem.next());\r
-\r
-        }\r
-\r
-        //\r
-        // create mainfest FarPlatformList node\r
-        //\r
-        Element plfListNode = this.mainfestDoc.createElement(farPlatformList);\r
-        rootNode.appendChild(plfListNode);\r
-\r
-        //\r
-        // Save farPakcage list info to <FarPackageList> node\r
-        //\r
-        Iterator plfItem = this.fPlfList.iterator();\r
-        while (plfItem.hasNext()) {\r
-            FarPlatformItem plfIterator = (FarPlatformItem) plfItem.next();\r
-            PlfToPlatformNode(plfListNode, plfIterator);\r
-        }\r
-\r
-        //\r
-        // Write the DOM document to the file\r
-        //\r
-        Transformer xformer = TransformerFactory.newInstance().newTransformer();\r
-        xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");\r
-        xformer.setOutputProperty(OutputKeys.INDENT, "yes");\r
-\r
-        //\r
-        // Prepare the DOM document for writing\r
-        //\r
-        Source source = new DOMSource(this.mainfestDoc);\r
-        //\r
-        // Prepare the output file, get the Mainifest file name from <FarHeader>\r
-        // <FarName>.\r
-        //\r
-        this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName);\r
-        //\r
-        // generate all directory path\r
-        //\r
-        Result result = new StreamResult(this.mfFile);\r
-        xformer.transform(source, result);\r
-        //\r
-        // Close result. Flush file by manual for Jdk1.5.0_04. \r
-        //\r
-        ((StreamResult) result).getOutputStream().close();\r
-    }\r
-\r
-    public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {\r
-        Element pkgNode = this.mainfestDoc.createElement(farPackageList_FarPackage);\r
-        //\r
-        // Add <FarFileName>\r
-        //\r
-        ffiToFfNode(pkgNode, pkgItem.getFarFile());\r
-        //\r
-        // Add <GuidValue>\r
-        //\r
-        setStrItemToNode(pkgNode, pkgItem.getGuidValue(), guidValue);\r
-        //\r
-        // Add <Version>\r
-        //\r
-        setStrItemToNode(pkgNode, pkgItem.getVersion(), version);\r
-        //\r
-        // Add <DefaultPath>\r
-        //\r
-        setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);\r
-\r
-        //\r
-        // Add <Contents>\r
-        //\r
-        Element contentNode = this.mainfestDoc.createElement(contents);\r
-        Iterator iterator = pkgItem.getContentList().iterator();\r
-        while (iterator.hasNext()) {\r
-            ffiToFfNode(contentNode, (FarFileItem) iterator.next());\r
-        }\r
-        pkgNode.appendChild(contentNode);\r
-        parentNode.appendChild(pkgNode);\r
-    }\r
-\r
-    public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {\r
-        Element fplNode = this.mainfestDoc.createElement(farPlatformList_FarPlatform);\r
-        //\r
-        // Add <FarFileName>\r
-        //\r
-        ffiToFfNode(fplNode, fplItem.getFarFile());\r
-        //\r
-        // Add <GuidValue>\r
-        //\r
-        setStrItemToNode(fplNode, fplItem.getGuidValue(), guidValue);\r
-        //\r
-        // Add <Version>\r
-        //\r
-        setStrItemToNode(fplNode, fplItem.getVersion(), version);\r
-        //\r
-        // Add to <PlatformList>\r
-        //\r
-        parentNode.appendChild(fplNode);\r
-\r
-    }\r
-\r
-    public void ffiToFfNode(Element parentNode, FarFileItem ffi) {\r
-        Element farFileName = this.mainfestDoc.createElement(farPackage_FarfileName);\r
-        farFileName.setTextContent(ffi.getRelativeFilename());\r
-        System.out.println(farFileName.getTextContent());\r
-        System.out.println(ffi.getRelativeFilename());\r
-        farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());\r
-        parentNode.appendChild(farFileName);\r
-    }\r
-\r
-    public void setStrItemToNode(Element parentNode, String strValue, String strName) {\r
-        Element node = this.mainfestDoc.createElement(strName);\r
-        node.setTextContent(strValue);\r
-        parentNode.appendChild(node);\r
-    }\r
-\r
-    private void parseMainfest() {\r
-\r
-        //\r
-        // Parse header\r
-        //\r
-        parseMfHeader();\r
-        //\r
-        // parse <farPackageList>\r
-        //\r
-        parseHeaderFarPackageList();\r
-\r
-        //\r
-        // parse <farPlatformList>\r
-        //\r
-        NodeList ele = this.mainfestDoc.getElementsByTagName(farPlatformList);\r
-        Node plfNode;\r
-        if (ele.getLength() > 0) {\r
-            //\r
-            // Only have one <FarPlatformList> node under mainfest root node.\r
-            //\r
-            plfNode = ele.item(0);\r
-            parseFarPlatformList(plfNode, this.fPlfList);\r
-        }\r
-    }\r
-\r
-    private void parseMfHeader() {\r
-        Node headerNode;\r
-        NodeList ele = this.mainfestDoc.getElementsByTagName(farHeader);\r
-        if (ele.getLength() > 0) {\r
-            //\r
-            // For mainfest file only have one <FarHeader>\r
-            //\r
-            headerNode = ele.item(0);\r
-        } else {\r
-            return;\r
-        }\r
-        NodeList childList = headerNode.getChildNodes();\r
-        Node node = null;\r
-        String nodeName = null;\r
-        for (int i = 0; i < childList.getLength(); i++) {\r
-            node = childList.item(i);\r
-            nodeName = node.getNodeName();\r
-            if (nodeName.equalsIgnoreCase(farHeader_FarName)) {\r
-                String nodeValue = node.getTextContent();\r
-                this.fhInfo.setFarName(nodeValue);\r
-            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
-                this.fhInfo.setGuidValue(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(version)) {\r
-                this.fhInfo.setVersion(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(farHeader_Abstract)) {\r
-                this.fhInfo.setAbstractStr(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(farHeader_Description)) {\r
-                this.fhInfo.setDescription(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(farHeader_CopyRight)) {\r
-                this.fhInfo.setCopyright(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(farHeader_License)) {\r
-                this.fhInfo.setLicense(node.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(farHeader_Specification)) {\r
-                this.fhInfo.setSpecification(node.getTextContent());\r
-            }\r
-        }\r
-    }\r
-\r
-    public void parseHeaderFarPackageList() {\r
-        Node farPkgNode;\r
-        NodeList ele = this.mainfestDoc.getElementsByTagName(farPackageList);\r
-        if (ele.getLength() > 0) {\r
-            //\r
-            // For mainfest file only have one <FarHeader>\r
-            //\r
-            farPkgNode = ele.item(0);\r
-        } else {\r
-            return;\r
-        }\r
-        NodeList fpnList = farPkgNode.getChildNodes();\r
-        for (int i = 0; i < fpnList.getLength(); i++) {\r
-            if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {\r
-                continue;\r
-            }\r
-            FarPackage fpItem = new FarPackage();\r
-            parseFarPackage(fpnList.item(i), fpItem);\r
-            this.fPkgList.add(fpItem);\r
-        }\r
-    }\r
-\r
-    public void parseFarPackage(Node farPkgNode, FarPackage fpItem) {\r
-        NodeList childList = farPkgNode.getChildNodes();\r
-        Node childNode;\r
-        String childName;\r
-        for (int i = 0; i < childList.getLength(); i++) {\r
-            childNode = childList.item(i);\r
-            childName = childNode.getNodeName();\r
-            if (childName.equalsIgnoreCase(farPackage_FarfileName)) {\r
-                fpItem.setFarFile(parseFarFile(childNode));\r
-            } else if (childName.equalsIgnoreCase(guidValue)) {\r
-                fpItem.setGuidValue(childNode.getTextContent());\r
-            } else if (childName.equalsIgnoreCase(version)) {\r
-                fpItem.setVersion(childNode.getTextContent());\r
-            } else if (childName.equalsIgnoreCase(farPackage_DefaultPath)) {\r
-                fpItem.setDefaultPath(childNode.getTextContent());\r
-            } else if (childName.equalsIgnoreCase(farPlatformList)) {\r
-                List<FarPlatformItem> plfList = new ArrayList<FarPlatformItem>();\r
-                parseFarPlatformList(childNode, plfList);\r
-                fpItem.setFarPlatformList(plfList);\r
-            } else if (childName.equalsIgnoreCase(contents)) {\r
-                List<FarFileItem> ffList = new ArrayList<FarFileItem>();\r
-                parseContents(childNode, ffList);\r
-                fpItem.setContentList(ffList);\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param fpfListNode\r
-     * @param plfList\r
-     */\r
-    public void parseFarPlatformList(Node fpfListNode, List<FarPlatformItem> plfList) {\r
-        //\r
-        // Get <FarPlatform> list.\r
-        //\r
-        NodeList child = fpfListNode.getChildNodes();\r
-        Node farPlfNode;\r
-        for (int i = 0; i < child.getLength(); i++) {\r
-            if (child.item(i).getNodeType() == Node.TEXT_NODE) {\r
-                continue;\r
-            }\r
-            farPlfNode = child.item(i);\r
-            plfList.add(parseFarPlatform(farPlfNode));\r
-        }\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param fpfNode\r
-     * @return\r
-     */\r
-    public FarPlatformItem parseFarPlatform(Node fpfNode) {\r
-        //\r
-        // New FarPlatformItem.\r
-        //\r
-        FarPlatformItem fplItem = new FarPlatformItem();\r
-        //\r
-        // Get <FarPlatform> elements;\r
-        //\r
-        NodeList childList = fpfNode.getChildNodes();\r
-        Node child;\r
-        String nodeName;\r
-        for (int i = 0; i < childList.getLength(); i++) {\r
-            child = childList.item(i);\r
-            nodeName = child.getNodeName();\r
-            if (nodeName.equalsIgnoreCase(farPackage_FarfileName)) {\r
-                fplItem.setFarFile(parseFarFile(child));\r
-            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
-                fplItem.setGuidValue(child.getTextContent());\r
-            } else if (nodeName.equalsIgnoreCase(version)) {\r
-                fplItem.setVersion(child.getTextContent());\r
-            }\r
-        }\r
-\r
-        return fplItem;\r
-    }\r
-\r
-    public void parseContents(Node contentsNode, List<FarFileItem> ffList) {\r
-        NodeList contentList = contentsNode.getChildNodes();\r
-        Node contentNode;\r
-        for (int i = 0; i < contentList.getLength(); i++) {\r
-            if (contentList.item(i).getNodeType() == Node.TEXT_NODE) {\r
-                continue;\r
-            }\r
-            contentNode = contentList.item(i);\r
-            //\r
-            // Parse each  <FarFileName>.\r
-            //\r
-            ffList.add(parseFarFile(contentNode));\r
-        }\r
-    }\r
-\r
-    public FarFileItem parseFarFile(Node farFileNode) {\r
-        String ffName = farFileNode.getTextContent();\r
-        NamedNodeMap attr = farFileNode.getAttributes();\r
-        FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(farFileName_Md5sum).getTextContent());\r
-        return ffItem;\r
-    }\r
-\r
-    public boolean isFilter(File file, Set<String> fileter) {\r
-        Iterator<String> iter = fileter.iterator();\r
-        while (iter.hasNext()) {\r
-            Pattern pattern = Pattern.compile(iter.next());\r
-            Matcher matcher = pattern.matcher(file.getName());\r
-\r
-            if (matcher.find()) {\r
-                return true;\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Manifest.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Manifest.java
new file mode 100644 (file)
index 0000000..89fb5b6
--- /dev/null
@@ -0,0 +1,960 @@
+/** @file\r
\r
+ The file is used to create Far's manifest file\r
\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution.  The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
+ **/\r
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.LinkedHashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.transform.OutputKeys;\r
+import javax.xml.transform.Result;\r
+import javax.xml.transform.Source;\r
+import javax.xml.transform.Transformer;\r
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.transform.dom.DOMSource;\r
+import javax.xml.transform.stream.StreamResult;\r
+\r
+import org.apache.xmlbeans.XmlException;\r
+import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.NamedNodeMap;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+public class Manifest implements ManifestInterface {\r
+    // /\r
+    // / manifest document\r
+    // /\r
+    Document manifestDoc = null;\r
+\r
+    // /\r
+    // / Manfiest file element name\r
+    // /\r
+    final static String mfFileName = "FrameworkArchiveManifest.xml";\r
+\r
+    //\r
+    // Header\r
+    //\r
+    final static String farHeader = "FarHeader";\r
+\r
+    final static String farHeader_FarName = "FarName";\r
+\r
+    final static String farHeader_Abstract = "Abstract";\r
+\r
+    final static String farHeader_Description = "Description";\r
+\r
+    final static String farHeader_CopyRight = "Copyright";\r
+\r
+    final static String farHeader_License = "License";\r
+\r
+    final static String farHeader_Specification = "Specification";\r
+\r
+    //\r
+    // Package list\r
+    //\r
+    final static String farPackageList = "FarPackageList";\r
+\r
+    final static String farPlatformList = "FarPlatformList";\r
+\r
+    final static String contents = "Contents";\r
+\r
+    final static String userExtensions = "UserExtensions";\r
+\r
+    //\r
+    // Common node name\r
+    //\r
+\r
+    final static String guidValue = "GuidValue";\r
+\r
+    final static String version = "Version";\r
+\r
+    //\r
+    // FarPackage node name\r
+    //\r
+    final static String farPackageList_FarPackage = "FarPackage";\r
+\r
+    final static String farPackage_FarfileName = "FarFilename";\r
+\r
+    final static String farPackage_DefaultPath = "DefaultPath";\r
+\r
+    final static String farPlatformList_FarPlatform = "FarPlatform";\r
+\r
+    final static String farFileName_FarGuid = "FarGuid";\r
+\r
+    final static String farFileName_Md5sum = "Md5sum";\r
+\r
+    //\r
+    // manifest header information.\r
+    //\r
+    FarHeader fhInfo = new FarHeader();\r
+\r
+    //\r
+    // FarPackage list\r
+    //\r
+    List<FarPackage> fPkgList = new ArrayList<FarPackage>();\r
+\r
+    //\r
+    // FarPlatform list\r
+    //\r
+    List<FarPlatformItem> fPlfList = new ArrayList<FarPlatformItem>();\r
+\r
+    Set<File> files = new LinkedHashSet<File>();\r
+\r
+    //\r
+    // Manifest file\r
+    //\r
+    public File mfFile = null;\r
+\r
+    public FarHeader getHeader() {\r
+        return fhInfo;\r
+    }\r
+\r
+    public Manifest() throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+        Document document = dombuilder.newDocument();\r
+        this.manifestDoc = document;\r
+\r
+    }\r
+\r
+    public Manifest(InputStream manifestInputStream) throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        try {\r
+            if (manifestInputStream != null) {\r
+                DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+                this.manifestDoc = dombuilder.parse(manifestInputStream);\r
+                parseManifest();\r
+            }\r
+\r
+        } catch (Exception e) {\r
+            //\r
+            // Will change to throw Wizader exception.\r
+            //\r
+            throw new Exception(e.getMessage());\r
+        }\r
+    }\r
+\r
+    public void setFarHeader(FarHeader fHeader) {\r
+        this.fhInfo = fHeader;\r
+    }\r
+\r
+    public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
+                               Set<String> fileFilter) throws Exception {\r
+\r
+        //\r
+        // Add Package and it's contents to FarPackageList.\r
+        //\r
+        Iterator<PackageIdentification> pkgItem = pkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            PackageIdentification pkgId = pkgItem.next();\r
+\r
+            //\r
+            // Add package and it's contents to <FarPackageList>.\r
+            //\r
+            addPkgToPkgList(pkgId, fileFilter);\r
+        }\r
+\r
+        //\r
+        // Add FarPlatform to this.farPlatformList.\r
+        //\r
+        Iterator<PlatformIdentification> plfItem = plfList.iterator();\r
+        while (plfItem.hasNext()) {\r
+            PlatformIdentification plfId = plfItem.next();\r
+\r
+            //\r
+            // Add platform to Mainifest.\r
+            //\r
+            addPlatformIdToFarPlatformItemList(plfId);\r
+        }\r
+    }\r
+\r
+    public void setManifestFile(File manifestFile) throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+        InputStream is = new FileInputStream(manifestFile);\r
+        this.manifestDoc = dombuilder.parse(is);\r
+    }\r
+\r
+    public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {\r
+        files.add(packageId.getSpdFile());\r
+\r
+        FarPackage farPackage = new FarPackage();\r
+        //\r
+        // Add SPD file to FarPackage\r
+        //\r
+        File spdFile = new File(packageId.getPath());\r
+\r
+        FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));\r
+        farPackage.setFarFile(ffItem);\r
+\r
+        //\r
+        // Add package guid value.\r
+        //\r
+        farPackage.setGuidValue(packageId.getGuid());\r
+\r
+        //\r
+        // Add package version\r
+        //\r
+        farPackage.setVersion(packageId.getVersion());\r
+\r
+        //\r
+        // Add DefaultPat: Package absoulte path - Workspace absolut\r
+        // path.\r
+        //\r
+        String pkgDir = Tools.getFilePathOnly(packageId.getPath());\r
+        File rootDir = new File(pkgDir);\r
+        farPackage.setDefaultPath(Tools.getRelativePath(rootDir.getPath(), Workspace.getCurrentWorkspace()));\r
+\r
+        //\r
+        // Get package root dir contains.\r
+        //\r
+        Set<File> fileSet = new LinkedHashSet<File>();\r
+        Set<File> fpdFileSet = new LinkedHashSet<File>();\r
+\r
+        //\r
+        // Get all files and fpd files\r
+        //\r
+        recursiveDirectory(fileSet, fpdFileSet, rootDir, fileFilter);\r
+\r
+        //\r
+        // Remove current package's SPD file\r
+        //\r
+        fileSet.remove(packageId.getSpdFile());\r
+\r
+        files.addAll(fileSet);\r
+\r
+        Iterator<File> iter = fileSet.iterator();\r
+        List<FarFileItem> contents = new ArrayList<FarFileItem>();\r
+        while (iter.hasNext()) {\r
+            File normalFile = iter.next();\r
+            String fileRelativePath = Tools.getRelativePath(normalFile.getPath(), pkgDir);\r
+            ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));\r
+            contents.add(ffItem);\r
+        }\r
+\r
+        farPackage.setContentList(contents);\r
+\r
+        //        List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();\r
+        //\r
+        //        iter = fpdFileSet.iterator();\r
+        //\r
+        //        while (iter.hasNext()) {\r
+        //            File fpdFile = iter.next();\r
+        //            PlatformIdentification platformId = new PlatformIdentification(wsTool\r
+        //                    .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile\r
+        //                            .getPath())));\r
+        //            addPlatformIdToFarPlatformItemList(fpfList, platformId);\r
+        //        }\r
+        //        farPackage.setFarPlatformList(fpfList);\r
+        fPkgList.add(farPackage);\r
+    }\r
+\r
+    private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {\r
+        if (isFilter(dir, fileFilter)) {\r
+            return;\r
+        }\r
+        File[] allFilesInDir = dir.listFiles();\r
+        for (int i = 0; i < allFilesInDir.length; i++) {\r
+            if (allFilesInDir[i].isFile()) {\r
+                if (isFilter(allFilesInDir[i], fileFilter)) {\r
+                    continue;\r
+                }\r
+                //                if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {\r
+                //                    fpds.add(allFilesInDir[i]);\r
+                //                } else {\r
+                files.add(allFilesInDir[i]);\r
+                //                }\r
+            } else {\r
+                recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);\r
+            }\r
+        }\r
+    }\r
+\r
+    public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {\r
+        files.add(platformId.getFpdFile());\r
+\r
+        FarPlatformItem fpfItem = new FarPlatformItem();\r
+        FarFileItem ffItem;\r
+        String fpfPath = platformId.getPath();\r
+        File fpfFile = new File(fpfPath);\r
+        //\r
+        // Add farFileName\r
+        //\r
+        ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),\r
+                                 FarMd5.md5(fpfFile));\r
+        fpfItem.setFarFile(ffItem);\r
+\r
+        //\r
+        // Add guid value\r
+        //\r
+        fpfItem.setGuidValue(platformId.getGuid());\r
+\r
+        //\r
+        // Add version\r
+        //\r
+        fpfItem.setVersion(platformId.getVersion());\r
+\r
+        fPlfList.add(fpfItem);\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param\r
+     * @return Set<PackageIdentification> list of PackageIdentification.\r
+     */\r
+    public List<PackageIdentification> getPackageList() throws Exception {\r
+        //\r
+        // PackageIdentification set.\r
+        //\r
+        List<PackageIdentification> pkgList = new ArrayList<PackageIdentification>();\r
+        //\r
+        // \r
+        //\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage fPkg = (FarPackage) pkgItem.next();\r
+            //\r
+            // Get package information from SPD file and create a package\r
+            // identification.\r
+            //\r
+\r
+            PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(),\r
+                                                                    fPkg.getGuidValue(), fPkg.getVersion());\r
+            pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath()\r
+                          + File.separatorChar + fPkg.getFarFile().getRelativeFilename());\r
+            //            wsTool.getId(\r
+            //                    Workspace.getCurrentWorkspace() + File.separatorChar\r
+            //                            + fPkg.getDefaultPath(), OpenFile\r
+            //                            .openFpdFile(Workspace.getCurrentWorkspace()\r
+            //                                    + File.separatorChar\r
+            //                                    + fPkg.getDefaultPath()\r
+            //                                    + File.separatorChar\r
+            //                                    + fPkg.getFarFile().getRelativeFilename()));\r
+            pkgList.add(pkgId);\r
+        }\r
+        return pkgList;\r
+    }\r
+\r
+    /**\r
+     * \r
+     */\r
+    public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {\r
+        //\r
+        // PlatformIdentification set.\r
+        //\r
+        List<PlatformIdentification> plfList = new ArrayList<PlatformIdentification>();\r
+        Iterator plfItem = this.fPlfList.iterator();\r
+        while (plfItem.hasNext()) {\r
+            FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();\r
+            File file = new File(Workspace.getCurrentWorkspace() + File.separatorChar\r
+                                 + fpfItem.getFarFile().getRelativeFilename());\r
+            //\r
+            // Set platformIdentificaiton's path as absolutly path (include\r
+            // workspace and FPD relatively path)\r
+            //\r
+            PlatformIdentification plfId = new PlatformIdentification(fpfItem.getFarFile().getRelativeFilename(),\r
+                                                                      fpfItem.getGuidValue(), fpfItem.getVersion(),\r
+                                                                      file.getPath());\r
+\r
+            //                (PlatformIdentification) wsTool\r
+            //                    .getId(file.getParent(), OpenFile.openFpdFile(Workspace\r
+            //                            .getCurrentWorkspace()\r
+            //                            + File.separatorChar\r
+            //                            + fpfItem.getFarFile().getRelativeFilename()));\r
+            plfList.add(plfId);\r
+        }\r
+        return plfList;\r
+    }\r
+\r
+    public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {\r
+        List<FarFileItem> result = new ArrayList<FarFileItem>();\r
+        Iterator<FarPlatformItem> iter = this.fPlfList.iterator();\r
+\r
+        while (iter.hasNext()) {\r
+            FarPlatformItem item = iter.next();\r
+            if (item.isIdentityPlf(platformId)) {\r
+                FarFileItem farFileItem = item.getFarFile();\r
+                farFileItem.setDefaultPath(farFileItem.getRelativeFilename());\r
+                farFileItem.setRelativeFilename(Tools.getFileNameOnly(farFileItem.getRelativeFilename()));\r
+                result.add(farFileItem);\r
+                break;\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<FarFileItem> getPackageContents(PackageIdentification packageId) {\r
+        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage pkg = (FarPackage) pkgItem.next();\r
+            if (pkg.isIdentityPkg(packageId)) {\r
+                //\r
+                // Add spd far file to list.\r
+                //\r
+                farFileList.add(pkg.getFarFile());\r
+                //\r
+                // Add all files in contents to list.\r
+                //\r
+                farFileList.addAll(pkg.getContentList());\r
+                //\r
+                // Add all farfiles in <FarPlatformList> to list.\r
+                //\r
+                //                List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
+                //                Iterator plfItem = plfList.iterator();\r
+                //                while (plfItem.hasNext()) {\r
+                //                    farFileList.add(((FarPlatformItem) plfItem.next())\r
+                //                            .getFarFile());\r
+                //                }\r
+\r
+                Iterator<FarFileItem> ffIter = farFileList.iterator();\r
+                while (ffIter.hasNext()) {\r
+                    FarFileItem ffItem = ffIter.next();\r
+                    ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());\r
+                }\r
+                break;\r
+            }\r
+        }\r
+\r
+        return farFileList;\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param pkgId\r
+     * @return String: return string represent jar file entry; \r
+     */\r
+    public String[] getPackgeSpd(PackageIdentification pkgId) {\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        String[] entryStr = new String[2];\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage pkg = (FarPackage) pkgItem.next();\r
+            if (pkg.isIdentityPkg(pkgId)) {\r
+                entryStr[0] = pkg.getFarFile().getRelativeFilename();\r
+                entryStr[1] = pkg.getDefaultPath();\r
+                return entryStr;\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    public List<FarFileItem> getPackageContents() {\r
+        //\r
+        // In this farFilelist,all FarFileItem's relativeFileName should be\r
+        // set as absolutely path.\r
+        //\r
+        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        FarFileItem ffItem = null;\r
+\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage pkg = (FarPackage) pkgItem.next();\r
+\r
+            //\r
+            // Add spd far file to list.\r
+            //\r
+            ffItem = pkg.getFarFile();\r
+            //\r
+            // Set farFileItem relativeFileName = absolutePath + file Name.\r
+            //\r
+            farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename(),\r
+                                            ffItem.getMd5Value()));\r
+            //\r
+            // Add all files in contents to list.\r
+            //\r
+            Iterator contentsItem = pkg.getContentList().iterator();\r
+            while (contentsItem.hasNext()) {\r
+                ffItem = (FarFileItem) contentsItem.next();\r
+                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
+                                                ffItem.getMd5Value()));\r
+            }\r
+            //\r
+            // Add all farfiles in <FarPlatformList> to list.\r
+            //\r
+            List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
+            Iterator plfItem = plfList.iterator();\r
+            while (plfItem.hasNext()) {\r
+                ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();\r
+                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
+                                                ffItem.getMd5Value()));\r
+            }\r
+        }\r
+        return farFileList;\r
+    }\r
+\r
+    public String getPackageDefaultPath(PackageIdentification packageId) {\r
+        Iterator pkgItr = this.fPkgList.iterator();\r
+        while (pkgItr.hasNext()) {\r
+            FarPackage farPackage = (FarPackage) pkgItr.next();\r
+            if (farPackage.isIdentityPkg(packageId)) {\r
+                return farPackage.getDefaultPath();\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    //    public void setPackageInstallPath(PackageIdentification packageId, String path) {\r
+    //        Iterator<FarPackage> pkgItr = this.fPkgList.iterator();\r
+    //        while (pkgItr.hasNext()) {\r
+    //            FarPackage farPackage = pkgItr.next();\r
+    //            if (farPackage.isIdentityPkg(packageId)) {\r
+    //                farPackage.setDefaultPath(path);\r
+    //                return ;\r
+    //            }\r
+    //        }\r
+    //    }\r
+    //\r
+    //    public void setPlatformInstallPath(PlatformIdentification platformId, String path) {\r
+    //        Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();\r
+    //        while (plfItr.hasNext()) {\r
+    //            FarPlatformItem farPlatform = plfItr.next();\r
+    //            if (farPlatform.i.isIdentity(platformId)) {\r
+    //                farPackage.setDefaultPath(path);\r
+    //                return ;\r
+    //            }\r
+    //        }\r
+    //    }\r
+\r
+    public List<FarFileItem> getAllFileItem() {\r
+        //\r
+        // The farFileName in this list are all abosulte path.\r
+        //\r
+        List<FarFileItem> ffiList = new ArrayList<FarFileItem>();\r
+        //\r
+        // Add far files in <FarPackageList> to list.\r
+        //\r
+        ffiList = this.getPackageContents();\r
+\r
+        //\r
+        // Add far files in <FarPlatformList> to list\r
+        //\r
+        NodeList elementList = this.manifestDoc.getElementsByTagName(farPlatformList);\r
+        for (int i = 0; i < elementList.getLength(); i++) {\r
+            //\r
+            // Get <farPlatform> node list.\r
+            //\r
+            Node item = elementList.item(i);\r
+            NodeList plfElements = item.getChildNodes();\r
+            for (int j = 0; j < plfElements.getLength(); j++) {\r
+                //\r
+                // Get each <FarPlatform> content.\r
+                //\r
+                NodeList plfChildNode = plfElements.item(i).getChildNodes();\r
+                Node tempNode = null;\r
+                for (int t = 0; t < plfChildNode.getLength(); t++) {\r
+                    tempNode = plfChildNode.item(t);\r
+                    //\r
+                    // Get child node value and set to platformIdentification.\r
+                    //\r
+                    if (tempNode.getNodeName().equalsIgnoreCase(farPackage_FarfileName)) {\r
+                        NamedNodeMap farAttr = tempNode.getAttributes();\r
+                        //\r
+                        // Change relative path to absolute one\r
+                        //\r
+                        FarFileItem farFile = new FarFileItem(tempNode.getTextContent(),\r
+                                                              farAttr.getNamedItem(farFileName_Md5sum).getTextContent());\r
+                        ffiList.add(farFile);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return ffiList;\r
+    }\r
+\r
+    public void hibernateToFile() throws Exception {\r
+        //\r
+        // create manifest root node\r
+        //\r
+        Element rootNode = this.manifestDoc.createElement("FrameworkArchiveManifest");\r
+        this.manifestDoc.appendChild(rootNode);\r
+\r
+        //\r
+        // create manifest header node\r
+        //\r
+        Element headerNode = this.manifestDoc.createElement(farHeader);\r
+        rootNode.appendChild(headerNode);\r
+        //\r
+        // Add FarHeader to headerNode.\r
+        //\r
+        Element farName = this.manifestDoc.createElement(farHeader_FarName);\r
+        farName.setTextContent(this.fhInfo.getFarName());\r
+        headerNode.appendChild(farName);\r
+\r
+        Element gv = this.manifestDoc.createElement(guidValue);\r
+        gv.setTextContent(this.fhInfo.getGuidValue());\r
+        headerNode.appendChild(gv);\r
+\r
+        Element ver = this.manifestDoc.createElement(version);\r
+        ver.setTextContent(this.fhInfo.getVersion());\r
+        headerNode.appendChild(ver);\r
+\r
+        Element abstra = this.manifestDoc.createElement(farHeader_Abstract);\r
+        abstra.setTextContent(this.fhInfo.getAbstractStr());\r
+        headerNode.appendChild(abstra);\r
+\r
+        Element descr = this.manifestDoc.createElement(farHeader_Description);\r
+        descr.setTextContent(this.fhInfo.getDescription());\r
+        headerNode.appendChild(descr);\r
+\r
+        Element copyright = this.manifestDoc.createElement(farHeader_CopyRight);\r
+        copyright.setTextContent(this.fhInfo.getCopyright());\r
+        headerNode.appendChild(copyright);\r
+\r
+        Element license = this.manifestDoc.createElement(farHeader_License);\r
+        license.setTextContent(this.fhInfo.getLicense());\r
+        headerNode.appendChild(license);\r
+\r
+        Element spec = this.manifestDoc.createElement(farHeader_Specification);\r
+        spec.setTextContent(this.fhInfo.getSpecification());\r
+        System.out.println(this.fhInfo.getSpecification());\r
+        headerNode.appendChild(spec);\r
+\r
+        //\r
+        // create manifest FarPackageList node\r
+        //\r
+        Element pkgListNode = this.manifestDoc.createElement(farPackageList);\r
+        rootNode.appendChild(pkgListNode);\r
+\r
+        //\r
+        // Save each item in farPackage list to <FarPackage>.\r
+        //\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            pkgToFarPkgNode(pkgListNode, (FarPackage) pkgItem.next());\r
+\r
+        }\r
+\r
+        //\r
+        // create manifest FarPlatformList node\r
+        //\r
+        Element plfListNode = this.manifestDoc.createElement(farPlatformList);\r
+        rootNode.appendChild(plfListNode);\r
+\r
+        //\r
+        // Save farPakcage list info to <FarPackageList> node\r
+        //\r
+        Iterator plfItem = this.fPlfList.iterator();\r
+        while (plfItem.hasNext()) {\r
+            FarPlatformItem plfIterator = (FarPlatformItem) plfItem.next();\r
+            PlfToPlatformNode(plfListNode, plfIterator);\r
+        }\r
+\r
+        //\r
+        // Write the DOM document to the file\r
+        //\r
+        Transformer xformer = TransformerFactory.newInstance().newTransformer();\r
+        xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");\r
+        xformer.setOutputProperty(OutputKeys.INDENT, "yes");\r
+\r
+        //\r
+        // Prepare the DOM document for writing\r
+        //\r
+        Source source = new DOMSource(this.manifestDoc);\r
+        //\r
+        // Prepare the output file, get the Mainifest file name from <FarHeader>\r
+        // <FarName>.\r
+        //\r
+        this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName);\r
+        //\r
+        // generate all directory path\r
+        //\r
+        Result result = new StreamResult(this.mfFile);\r
+        xformer.transform(source, result);\r
+        //\r
+        // Close result. Flush file by manual for Jdk1.5.0_04. \r
+        //\r
+        ((StreamResult) result).getOutputStream().close();\r
+    }\r
+\r
+    public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {\r
+        Element pkgNode = this.manifestDoc.createElement(farPackageList_FarPackage);\r
+        //\r
+        // Add <FarFileName>\r
+        //\r
+        ffiToFfNode(pkgNode, pkgItem.getFarFile());\r
+        //\r
+        // Add <GuidValue>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getGuidValue(), guidValue);\r
+        //\r
+        // Add <Version>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getVersion(), version);\r
+        //\r
+        // Add <DefaultPath>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);\r
+\r
+        //\r
+        // Add <Contents>\r
+        //\r
+        Element contentNode = this.manifestDoc.createElement(contents);\r
+        Iterator iterator = pkgItem.getContentList().iterator();\r
+        while (iterator.hasNext()) {\r
+            ffiToFfNode(contentNode, (FarFileItem) iterator.next());\r
+        }\r
+        pkgNode.appendChild(contentNode);\r
+        parentNode.appendChild(pkgNode);\r
+    }\r
+\r
+    public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {\r
+        Element fplNode = this.manifestDoc.createElement(farPlatformList_FarPlatform);\r
+        //\r
+        // Add <FarFileName>\r
+        //\r
+        ffiToFfNode(fplNode, fplItem.getFarFile());\r
+        //\r
+        // Add <GuidValue>\r
+        //\r
+        setStrItemToNode(fplNode, fplItem.getGuidValue(), guidValue);\r
+        //\r
+        // Add <Version>\r
+        //\r
+        setStrItemToNode(fplNode, fplItem.getVersion(), version);\r
+        //\r
+        // Add to <PlatformList>\r
+        //\r
+        parentNode.appendChild(fplNode);\r
+\r
+    }\r
+\r
+    public void ffiToFfNode(Element parentNode, FarFileItem ffi) {\r
+        Element farFileName = this.manifestDoc.createElement(farPackage_FarfileName);\r
+        farFileName.setTextContent(ffi.getRelativeFilename());\r
+        System.out.println(farFileName.getTextContent());\r
+        System.out.println(ffi.getRelativeFilename());\r
+        farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());\r
+        parentNode.appendChild(farFileName);\r
+    }\r
+\r
+    public void setStrItemToNode(Element parentNode, String strValue, String strName) {\r
+        Element node = this.manifestDoc.createElement(strName);\r
+        node.setTextContent(strValue);\r
+        parentNode.appendChild(node);\r
+    }\r
+\r
+    private void parseManifest() {\r
+\r
+        //\r
+        // Parse header\r
+        //\r
+        parseMfHeader();\r
+        //\r
+        // parse <farPackageList>\r
+        //\r
+        parseHeaderFarPackageList();\r
+\r
+        //\r
+        // parse <farPlatformList>\r
+        //\r
+        NodeList ele = this.manifestDoc.getElementsByTagName(farPlatformList);\r
+        Node plfNode;\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // Only have one <FarPlatformList> node under manifest root node.\r
+            //\r
+            plfNode = ele.item(0);\r
+            parseFarPlatformList(plfNode, this.fPlfList);\r
+        }\r
+    }\r
+\r
+    private void parseMfHeader() {\r
+        Node headerNode;\r
+        NodeList ele = this.manifestDoc.getElementsByTagName(farHeader);\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // For manifest file only have one <FarHeader>\r
+            //\r
+            headerNode = ele.item(0);\r
+        } else {\r
+            return;\r
+        }\r
+        NodeList childList = headerNode.getChildNodes();\r
+        Node node = null;\r
+        String nodeName = null;\r
+        for (int i = 0; i < childList.getLength(); i++) {\r
+            node = childList.item(i);\r
+            nodeName = node.getNodeName();\r
+            if (nodeName.equalsIgnoreCase(farHeader_FarName)) {\r
+                String nodeValue = node.getTextContent();\r
+                this.fhInfo.setFarName(nodeValue);\r
+            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
+                this.fhInfo.setGuidValue(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(version)) {\r
+                this.fhInfo.setVersion(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Abstract)) {\r
+                this.fhInfo.setAbstractStr(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Description)) {\r
+                this.fhInfo.setDescription(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_CopyRight)) {\r
+                this.fhInfo.setCopyright(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_License)) {\r
+                this.fhInfo.setLicense(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Specification)) {\r
+                this.fhInfo.setSpecification(node.getTextContent());\r
+            }\r
+        }\r
+    }\r
+\r
+    public void parseHeaderFarPackageList() {\r
+        Node farPkgNode;\r
+        NodeList ele = this.manifestDoc.getElementsByTagName(farPackageList);\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // For manifest file only have one <FarHeader>\r
+            //\r
+            farPkgNode = ele.item(0);\r
+        } else {\r
+            return;\r
+        }\r
+        NodeList fpnList = farPkgNode.getChildNodes();\r
+        for (int i = 0; i < fpnList.getLength(); i++) {\r
+            if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {\r
+                continue;\r
+            }\r
+            FarPackage fpItem = new FarPackage();\r
+            parseFarPackage(fpnList.item(i), fpItem);\r
+            this.fPkgList.add(fpItem);\r
+        }\r
+    }\r
+\r
+    public void parseFarPackage(Node farPkgNode, FarPackage fpItem) {\r
+        NodeList childList = farPkgNode.getChildNodes();\r
+        Node childNode;\r
+        String childName;\r
+        for (int i = 0; i < childList.getLength(); i++) {\r
+            childNode = childList.item(i);\r
+            childName = childNode.getNodeName();\r
+            if (childName.equalsIgnoreCase(farPackage_FarfileName)) {\r
+                fpItem.setFarFile(parseFarFile(childNode));\r
+            } else if (childName.equalsIgnoreCase(guidValue)) {\r
+                fpItem.setGuidValue(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(version)) {\r
+                fpItem.setVersion(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(farPackage_DefaultPath)) {\r
+                fpItem.setDefaultPath(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(farPlatformList)) {\r
+                List<FarPlatformItem> plfList = new ArrayList<FarPlatformItem>();\r
+                parseFarPlatformList(childNode, plfList);\r
+                fpItem.setFarPlatformList(plfList);\r
+            } else if (childName.equalsIgnoreCase(contents)) {\r
+                List<FarFileItem> ffList = new ArrayList<FarFileItem>();\r
+                parseContents(childNode, ffList);\r
+                fpItem.setContentList(ffList);\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param fpfListNode\r
+     * @param plfList\r
+     */\r
+    public void parseFarPlatformList(Node fpfListNode, List<FarPlatformItem> plfList) {\r
+        //\r
+        // Get <FarPlatform> list.\r
+        //\r
+        NodeList child = fpfListNode.getChildNodes();\r
+        Node farPlfNode;\r
+        for (int i = 0; i < child.getLength(); i++) {\r
+            if (child.item(i).getNodeType() == Node.TEXT_NODE) {\r
+                continue;\r
+            }\r
+            farPlfNode = child.item(i);\r
+            plfList.add(parseFarPlatform(farPlfNode));\r
+        }\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param fpfNode\r
+     * @return\r
+     */\r
+    public FarPlatformItem parseFarPlatform(Node fpfNode) {\r
+        //\r
+        // New FarPlatformItem.\r
+        //\r
+        FarPlatformItem fplItem = new FarPlatformItem();\r
+        //\r
+        // Get <FarPlatform> elements;\r
+        //\r
+        NodeList childList = fpfNode.getChildNodes();\r
+        Node child;\r
+        String nodeName;\r
+        for (int i = 0; i < childList.getLength(); i++) {\r
+            child = childList.item(i);\r
+            nodeName = child.getNodeName();\r
+            if (nodeName.equalsIgnoreCase(farPackage_FarfileName)) {\r
+                fplItem.setFarFile(parseFarFile(child));\r
+            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
+                fplItem.setGuidValue(child.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(version)) {\r
+                fplItem.setVersion(child.getTextContent());\r
+            }\r
+        }\r
+\r
+        return fplItem;\r
+    }\r
+\r
+    public void parseContents(Node contentsNode, List<FarFileItem> ffList) {\r
+        NodeList contentList = contentsNode.getChildNodes();\r
+        Node contentNode;\r
+        for (int i = 0; i < contentList.getLength(); i++) {\r
+            if (contentList.item(i).getNodeType() == Node.TEXT_NODE) {\r
+                continue;\r
+            }\r
+            contentNode = contentList.item(i);\r
+            //\r
+            // Parse each  <FarFileName>.\r
+            //\r
+            ffList.add(parseFarFile(contentNode));\r
+        }\r
+    }\r
+\r
+    public FarFileItem parseFarFile(Node farFileNode) {\r
+        String ffName = farFileNode.getTextContent();\r
+        NamedNodeMap attr = farFileNode.getAttributes();\r
+        FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(farFileName_Md5sum).getTextContent());\r
+        return ffItem;\r
+    }\r
+\r
+    public boolean isFilter(File file, Set<String> fileter) {\r
+        Iterator<String> iter = fileter.iterator();\r
+        while (iter.hasNext()) {\r
+            Pattern pattern = Pattern.compile(iter.next());\r
+            Matcher matcher = pattern.matcher(file.getName());\r
+\r
+            if (matcher.find()) {\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+}\r
index 5fd53a5..68d286c 100644 (file)
@@ -197,7 +197,7 @@ public class InstallStepTwo extends IDialog implements MouseListener {
         try {\r
             Far far = stepOne.getFar();\r
 \r
-            packageVector = far.mainfest.getPackageList();\r
+            packageVector = far.manifest.getPackageList();\r
             Iterator<PackageIdentification> iter = packageVector.iterator();\r
             while (iter.hasNext()) {\r
                 String[] str = new String[4];\r
@@ -257,7 +257,7 @@ public class InstallStepTwo extends IDialog implements MouseListener {
         try {\r
             Far far = stepOne.getFar();\r
 \r
-            platformVector = far.mainfest.getPlatformList();\r
+            platformVector = far.manifest.getPlatformList();\r
             Iterator<PlatformIdentification> iter = platformVector.iterator();\r
             while (iter.hasNext()) {\r
                 String[] str = new String[4];\r
@@ -384,7 +384,7 @@ public class InstallStepTwo extends IDialog implements MouseListener {
                 // Add to database\r
                 //\r
                 WorkspaceTools wt = new WorkspaceTools();\r
-                wt.addFarToDb(packageList, platformList, far.mainfest.getHeader());\r
+                wt.addFarToDb(packageList, platformList, far.manifest.getHeader());\r
             } catch (Exception ex) {\r
                 Log.wrn("Install far", ex.getMessage());\r
                 Log.err("Install far", ex.getMessage());\r
index 287d559..6785803 100644 (file)
@@ -181,7 +181,7 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
         model.setRowCount(0);\r
         try {\r
             Far far = stepOne.getFar();\r
-            List<PackageIdentification> packagesInFar = far.mainfest.getPackageList();\r
+            List<PackageIdentification> packagesInFar = far.manifest.getPackageList();\r
 \r
             WorkspaceTools wt = new WorkspaceTools();\r
             List<PackageIdentification> packagesInDb = wt.getAllPackages();\r