mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 22:24:37 +02:00
Enhance Installation, removing and creating FAR functionality.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@964 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3cc092acf2
commit
1898a0c348
@ -59,17 +59,8 @@ public class DistributeRule {
|
|||||||
AggregationOperation.union(farPkgList,
|
AggregationOperation.union(farPkgList,
|
||||||
dbPkgList));
|
dbPkgList));
|
||||||
|
|
||||||
//
|
return resultList;
|
||||||
// If dependencies don't meet, print the error message and return.
|
|
||||||
//
|
|
||||||
// if (resultList != null || resultList.size()> 0){
|
|
||||||
// Iterator resItem = resultList.iterator();
|
|
||||||
// while (resItem.hasNext()){
|
|
||||||
// System.out.println("Missing package:" + resItem.next().toString() + " !");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return resultList;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void installPackgCheck (PackageIdentification pkgId, String pkgPath){
|
// public void installPackgCheck (PackageIdentification pkgId, String pkgPath){
|
||||||
|
@ -62,9 +62,10 @@ public class Far {
|
|||||||
jf = farFile;
|
jf = farFile;
|
||||||
this.mainfest = new Mainfest(getMainfestFile());
|
this.mainfest = new Mainfest(getMainfestFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,
|
public void creatFar (List<PackageIdentification> pkgList,
|
||||||
Set<String> fileFilter, FarHeader fHeader) throws Exception {
|
List<PlatformIdentification> plfList, Set<String> fileFilter,
|
||||||
|
FarHeader fHeader) throws Exception{
|
||||||
jos = new JarOutputStream(new FileOutputStream(jarFile));
|
jos = new JarOutputStream(new FileOutputStream(jarFile));
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -93,28 +94,23 @@ public class Far {
|
|||||||
}
|
}
|
||||||
jos.close();
|
jos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToJar(File file, JarOutputStream jos) throws Exception {
|
private void writeToJar(File file, JarOutputStream jos) throws Exception{
|
||||||
byte[] buffer = new byte[(int) file.length()];
|
byte[] buffer = new byte[(int)file.length()];
|
||||||
FileInputStream fInput = new FileInputStream(file);
|
FileInputStream fInput = new FileInputStream(file);
|
||||||
JarEntry entry = new JarEntry(
|
JarEntry entry = new JarEntry(Tools.convertPathToUnixType(Tools.getRelativePath(file.getPath(),Workspace.getCurrentWorkspace())));
|
||||||
Tools
|
jos.putNextEntry(entry);
|
||||||
.convertPathToUnixType(Tools
|
fInput.read(buffer);
|
||||||
.getRelativePath(file.getPath(),
|
jos.write(buffer);
|
||||||
Workspace.getCurrentWorkspace())));
|
fInput.close();
|
||||||
jos.putNextEntry(entry);
|
|
||||||
fInput.read(buffer);
|
|
||||||
jos.write(buffer);
|
|
||||||
fInput.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InstallFar(String dir) throws Exception {
|
public void InstallFar(String dir) throws Exception {
|
||||||
List<FarFileItem> allFile = mainfest.getAllFileItem();
|
List<FarFileItem> allFile = mainfest.getAllFileItem();
|
||||||
extract(allFile, dir);
|
extract(allFile, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InstallFar(Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap)
|
public void InstallFar (Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap) throws Exception{
|
||||||
throws Exception {
|
|
||||||
Set<PlatformIdentification> plfKeys = plfMap.keySet();
|
Set<PlatformIdentification> plfKeys = plfMap.keySet();
|
||||||
Iterator<PlatformIdentification> plfIter = plfKeys.iterator();
|
Iterator<PlatformIdentification> plfIter = plfKeys.iterator();
|
||||||
while (plfIter.hasNext()) {
|
while (plfIter.hasNext()) {
|
||||||
@ -153,7 +149,39 @@ public class Far {
|
|||||||
public boolean hibernateToFile() {
|
public boolean hibernateToFile() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// public static void main(String[] args){
|
||||||
|
// try {
|
||||||
|
// JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));
|
||||||
|
// JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");
|
||||||
|
// InputStream is = jarFile.getInputStream(je);
|
||||||
|
// byte[] buffer = new byte[1];
|
||||||
|
// File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");
|
||||||
|
// File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");
|
||||||
|
// FileOutputStream fos1 = new FileOutputStream(tfile2);
|
||||||
|
// FileOutputStream fos = new FileOutputStream(tempFile);
|
||||||
|
// int size = is.read(buffer);
|
||||||
|
// int totoalSize = size;
|
||||||
|
// while ( size >= 0) {
|
||||||
|
// fos.write(buffer);
|
||||||
|
// size = is.read(buffer);
|
||||||
|
// totoalSize = totoalSize + size;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// is = jarFile.getInputStream(je);
|
||||||
|
//// is.read(totalbuffer);
|
||||||
|
//// fos.write(totalbuffer);
|
||||||
|
// fos.close();
|
||||||
|
// byte[] totalbuffer = new byte[(int)tempFile.length()];
|
||||||
|
// FileInputStream fis = new FileInputStream(tempFile);
|
||||||
|
// fis.read(totalbuffer);
|
||||||
|
// fos1.write(totalbuffer);
|
||||||
|
// fos1.close();
|
||||||
|
// }catch(Exception e){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public void extract(List<FarFileItem> allFile, String dir) throws Exception {
|
public void extract(List<FarFileItem> allFile, String dir) throws Exception {
|
||||||
|
|
||||||
Iterator filesItem = allFile.iterator();
|
Iterator filesItem = allFile.iterator();
|
||||||
@ -163,11 +191,7 @@ public class Far {
|
|||||||
dir += File.separatorChar;
|
dir += File.separatorChar;
|
||||||
while (filesItem.hasNext()) {
|
while (filesItem.hasNext()) {
|
||||||
try {
|
try {
|
||||||
ffItem = (FarFileItem) filesItem.next();
|
ffItem = (FarFileItem)filesItem.next();
|
||||||
// Enumeration<JarEntry> a = jf.entries();
|
|
||||||
// while (a.hasMoreElements()) {
|
|
||||||
// System.out.println("##" + a.nextElement().getName());
|
|
||||||
// }
|
|
||||||
je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));
|
je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));
|
||||||
InputStream entryStream = jf.getInputStream(je);
|
InputStream entryStream = jf.getInputStream(je);
|
||||||
File file = new File(dir + ffItem.getRelativeFilename());
|
File file = new File(dir + ffItem.getRelativeFilename());
|
||||||
@ -178,20 +202,29 @@ public class Far {
|
|||||||
// exists).
|
// exists).
|
||||||
//
|
//
|
||||||
FileOutputStream outputStream = new FileOutputStream(file);
|
FileOutputStream outputStream = new FileOutputStream(file);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//
|
//
|
||||||
// Read the entry data and write it to the output
|
// Read the entry data and write it to the output
|
||||||
// file.
|
// file.
|
||||||
//
|
//
|
||||||
int size = entryStream.available();
|
byte[] buffer = new byte[1];
|
||||||
byte[] buffer = new byte[size];
|
File tempFile = new File("tempFile");
|
||||||
outputStream.write(buffer);
|
FileOutputStream fos = new FileOutputStream(tempFile);
|
||||||
// if (!(FarMd5.md5(buffer)).equalsIgnoreCase(ffItem.getMd5Value())){
|
int size = entryStream.read(buffer);
|
||||||
// throw new Exception (je.getName() + " Md5 is invalided!");
|
while ( size >= 0) {
|
||||||
// }
|
fos.write(buffer);
|
||||||
|
size = entryStream.read(buffer);
|
||||||
// System.out.println(je.getName() + " extracted.");
|
}
|
||||||
|
|
||||||
|
fos.close();
|
||||||
|
byte[] totalBuffer = new byte[(int)tempFile.length()];
|
||||||
|
FileInputStream fis = new FileInputStream(tempFile);
|
||||||
|
fis.read(totalBuffer);
|
||||||
|
outputStream.write(totalBuffer);
|
||||||
|
fis.close();
|
||||||
|
tempFile.delete();
|
||||||
} finally {
|
} finally {
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
@ -200,26 +233,14 @@ public class Far {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
//jf.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void installFarPackage (PackageIdentification pkgId, String dir) throws Exception{
|
|
||||||
// String pkgDir = null;
|
public void addFileToFar (File file, JarOutputStream farOuputStream, String workDir){
|
||||||
// List<FarFileItem> farFileList = new ArrayList<FarFileItem>();
|
|
||||||
// farFileList = this.mainfest.getPackageContents(pkgId);
|
|
||||||
// if (dir == null){
|
|
||||||
// pkgDir = this.mainfest.getPackageDefaultPath(pkgId);
|
|
||||||
// }else {
|
|
||||||
// pkgDir = dir;
|
|
||||||
// }
|
|
||||||
// extract(farFileList,pkgDir);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
The file is used to save information of Far item.
|
||||||
|
|
||||||
|
Copyright (c) 2006, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
package org.tianocore.frameworkwizard.far;
|
package org.tianocore.frameworkwizard.far;
|
||||||
|
|
||||||
public class FarIdentification {
|
public class FarIdentification {
|
||||||
|
@ -57,7 +57,6 @@ public class Mainfest implements ManifestInterface {
|
|||||||
// / Mainfest file element name
|
// / Mainfest file element name
|
||||||
// /
|
// /
|
||||||
final static String mfFileName = "FarMainfest.MF";
|
final static String mfFileName = "FarMainfest.MF";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Header
|
// Header
|
||||||
//
|
//
|
||||||
@ -132,9 +131,9 @@ public class Mainfest implements ManifestInterface {
|
|||||||
File mfFile = null;
|
File mfFile = null;
|
||||||
|
|
||||||
public FarHeader getHeader() {
|
public FarHeader getHeader() {
|
||||||
return fhInfo;
|
return fhInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mainfest() throws Exception {
|
public Mainfest() throws Exception {
|
||||||
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder dombuilder = domfac.newDocumentBuilder();
|
DocumentBuilder dombuilder = domfac.newDocumentBuilder();
|
||||||
@ -164,8 +163,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
this.fhInfo = fHeader;
|
this.fhInfo = fHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,
|
public void createManifest(List<PackageIdentification> pkgList,
|
||||||
Set<String> fileFilter) throws Exception {
|
List<PlatformIdentification> plfList, Set<String> fileFilter) throws Exception {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add Package and it's contents to FarPackageList.
|
// Add Package and it's contents to FarPackageList.
|
||||||
@ -203,7 +202,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
|
|
||||||
public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {
|
public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {
|
||||||
files.add(packageId.getSpdFile());
|
files.add(packageId.getSpdFile());
|
||||||
|
|
||||||
FarPackage farPackage = new FarPackage();
|
FarPackage farPackage = new FarPackage();
|
||||||
//
|
//
|
||||||
// Add SPD file to FarPackage
|
// Add SPD file to FarPackage
|
||||||
@ -212,17 +211,17 @@ public class Mainfest implements ManifestInterface {
|
|||||||
|
|
||||||
FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));
|
FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));
|
||||||
farPackage.setFarFile(ffItem);
|
farPackage.setFarFile(ffItem);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add package guid value.
|
// Add package guid value.
|
||||||
//
|
//
|
||||||
farPackage.setGuidValue(packageId.getGuid());
|
farPackage.setGuidValue(packageId.getGuid());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add package version
|
// Add package version
|
||||||
//
|
//
|
||||||
farPackage.setVersion(packageId.getVersion());
|
farPackage.setVersion(packageId.getVersion());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add DefaultPat: Package absoulte path - Workspace absolut
|
// Add DefaultPat: Package absoulte path - Workspace absolut
|
||||||
// path.
|
// path.
|
||||||
@ -246,7 +245,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
// Remove current package's SPD file
|
// Remove current package's SPD file
|
||||||
//
|
//
|
||||||
fileSet.remove(packageId.getSpdFile());
|
fileSet.remove(packageId.getSpdFile());
|
||||||
|
|
||||||
files.addAll(fileSet);
|
files.addAll(fileSet);
|
||||||
|
|
||||||
Iterator<File> iter = fileSet.iterator();
|
Iterator<File> iter = fileSet.iterator();
|
||||||
@ -257,25 +256,26 @@ public class Mainfest implements ManifestInterface {
|
|||||||
ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));
|
ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));
|
||||||
contents.add(ffItem);
|
contents.add(ffItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
farPackage.setContentList(contents);
|
farPackage.setContentList(contents);
|
||||||
|
|
||||||
// List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();
|
// List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();
|
||||||
//
|
//
|
||||||
// iter = fpdFileSet.iterator();
|
// iter = fpdFileSet.iterator();
|
||||||
//
|
//
|
||||||
// while (iter.hasNext()) {
|
// while (iter.hasNext()) {
|
||||||
// File fpdFile = iter.next();
|
// File fpdFile = iter.next();
|
||||||
// PlatformIdentification platformId = new PlatformIdentification(wsTool
|
// PlatformIdentification platformId = new PlatformIdentification(wsTool
|
||||||
// .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile
|
// .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile
|
||||||
// .getPath())));
|
// .getPath())));
|
||||||
// addPlatformIdToFarPlatformItemList(fpfList, platformId);
|
// addPlatformIdToFarPlatformItemList(fpfList, platformId);
|
||||||
// }
|
// }
|
||||||
// farPackage.setFarPlatformList(fpfList);
|
// farPackage.setFarPlatformList(fpfList);
|
||||||
fPkgList.add(farPackage);
|
fPkgList.add(farPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {
|
private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir,
|
||||||
|
Set<String> fileFilter) {
|
||||||
if (isFilter(dir, fileFilter)) {
|
if (isFilter(dir, fileFilter)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -285,11 +285,11 @@ public class Mainfest implements ManifestInterface {
|
|||||||
if (isFilter(allFilesInDir[i], fileFilter)) {
|
if (isFilter(allFilesInDir[i], fileFilter)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {
|
// if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {
|
||||||
// fpds.add(allFilesInDir[i]);
|
// fpds.add(allFilesInDir[i]);
|
||||||
// } else {
|
// } else {
|
||||||
files.add(allFilesInDir[i]);
|
files.add(allFilesInDir[i]);
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);
|
recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
|
|
||||||
public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {
|
public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {
|
||||||
files.add(platformId.getFpdFile());
|
files.add(platformId.getFpdFile());
|
||||||
|
|
||||||
FarPlatformItem fpfItem = new FarPlatformItem();
|
FarPlatformItem fpfItem = new FarPlatformItem();
|
||||||
FarFileItem ffItem;
|
FarFileItem ffItem;
|
||||||
String fpfPath = platformId.getPath();
|
String fpfPath = platformId.getPath();
|
||||||
@ -306,8 +306,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Add farFileName
|
// Add farFileName
|
||||||
//
|
//
|
||||||
ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),
|
ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(),Workspace.getCurrentWorkspace()), FarMd5.md5(fpfFile));
|
||||||
FarMd5.md5(fpfFile));
|
|
||||||
fpfItem.setFarFile(ffItem);
|
fpfItem.setFarFile(ffItem);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -344,18 +343,16 @@ public class Mainfest implements ManifestInterface {
|
|||||||
// identification.
|
// identification.
|
||||||
//
|
//
|
||||||
|
|
||||||
PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(),
|
PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(), fPkg.getGuidValue(), fPkg.getVersion());
|
||||||
fPkg.getGuidValue(), fPkg.getVersion());
|
pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath() + File.separatorChar + fPkg.getFarFile().getRelativeFilename());
|
||||||
pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath()
|
// wsTool.getId(
|
||||||
+ File.separatorChar + fPkg.getFarFile().getRelativeFilename());
|
// Workspace.getCurrentWorkspace() + File.separatorChar
|
||||||
// wsTool.getId(
|
// + fPkg.getDefaultPath(), OpenFile
|
||||||
// Workspace.getCurrentWorkspace() + File.separatorChar
|
// .openFpdFile(Workspace.getCurrentWorkspace()
|
||||||
// + fPkg.getDefaultPath(), OpenFile
|
// + File.separatorChar
|
||||||
// .openFpdFile(Workspace.getCurrentWorkspace()
|
// + fPkg.getDefaultPath()
|
||||||
// + File.separatorChar
|
// + File.separatorChar
|
||||||
// + fPkg.getDefaultPath()
|
// + fPkg.getFarFile().getRelativeFilename()));
|
||||||
// + File.separatorChar
|
|
||||||
// + fPkg.getFarFile().getRelativeFilename()));
|
|
||||||
pkgList.add(pkgId);
|
pkgList.add(pkgId);
|
||||||
}
|
}
|
||||||
return pkgList;
|
return pkgList;
|
||||||
@ -364,7 +361,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {
|
public List<PlatformIdentification> getPlatformList() throws Exception,
|
||||||
|
IOException, XmlException {
|
||||||
//
|
//
|
||||||
// PlatformIdentification set.
|
// PlatformIdentification set.
|
||||||
//
|
//
|
||||||
@ -372,21 +370,21 @@ public class Mainfest implements ManifestInterface {
|
|||||||
Iterator plfItem = this.fPlfList.iterator();
|
Iterator plfItem = this.fPlfList.iterator();
|
||||||
while (plfItem.hasNext()) {
|
while (plfItem.hasNext()) {
|
||||||
FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();
|
FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();
|
||||||
File file = new File(Workspace.getCurrentWorkspace() + File.separatorChar
|
File file = new File(Workspace.getCurrentWorkspace()
|
||||||
+ fpfItem.getFarFile().getRelativeFilename());
|
+ File.separatorChar
|
||||||
|
+ fpfItem.getFarFile().getRelativeFilename());
|
||||||
//
|
//
|
||||||
// Set platformIdentificaiton's path as absolutly path (include
|
// Set platformIdentificaiton's path as absolutly path (include
|
||||||
// workspace and FPD relatively path)
|
// workspace and FPD relatively path)
|
||||||
//
|
//
|
||||||
PlatformIdentification plfId = new PlatformIdentification(fpfItem.getFarFile().getRelativeFilename(),
|
PlatformIdentification plfId = new PlatformIdentification (fpfItem.getFarFile().getRelativeFilename(), fpfItem.getGuidValue(),fpfItem.getVersion(),
|
||||||
fpfItem.getGuidValue(), fpfItem.getVersion(),
|
file.getPath());
|
||||||
file.getPath());
|
|
||||||
|
// (PlatformIdentification) wsTool
|
||||||
// (PlatformIdentification) wsTool
|
// .getId(file.getParent(), OpenFile.openFpdFile(Workspace
|
||||||
// .getId(file.getParent(), OpenFile.openFpdFile(Workspace
|
// .getCurrentWorkspace()
|
||||||
// .getCurrentWorkspace()
|
// + File.separatorChar
|
||||||
// + File.separatorChar
|
// + fpfItem.getFarFile().getRelativeFilename()));
|
||||||
// + fpfItem.getFarFile().getRelativeFilename()));
|
|
||||||
plfList.add(plfId);
|
plfList.add(plfId);
|
||||||
}
|
}
|
||||||
return plfList;
|
return plfList;
|
||||||
@ -395,19 +393,20 @@ public class Mainfest implements ManifestInterface {
|
|||||||
public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {
|
public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {
|
||||||
List<FarFileItem> result = new ArrayList<FarFileItem>();
|
List<FarFileItem> result = new ArrayList<FarFileItem>();
|
||||||
Iterator<FarPlatformItem> iter = this.fPlfList.iterator();
|
Iterator<FarPlatformItem> iter = this.fPlfList.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
FarPlatformItem item = iter.next();
|
FarPlatformItem item = iter.next();
|
||||||
if (item.isIdentityPlf(platformId)) {
|
if (item.isIdentityPlf(platformId)) {
|
||||||
FarFileItem farFileItem = item.getFarFile();
|
FarFileItem farFileItem = item.getFarFile();
|
||||||
farFileItem.setDefaultPath(farFileItem.getRelativeFilename());
|
farFileItem.setDefaultPath(farFileItem.getRelativeFilename());
|
||||||
|
farFileItem.setRelativeFilename(Tools.getFileNameOnly(farFileItem.getRelativeFilename()));
|
||||||
result.add(farFileItem);
|
result.add(farFileItem);
|
||||||
break;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FarFileItem> getPackageContents(PackageIdentification packageId) {
|
public List<FarFileItem> getPackageContents(PackageIdentification packageId) {
|
||||||
List<FarFileItem> farFileList = new ArrayList<FarFileItem>();
|
List<FarFileItem> farFileList = new ArrayList<FarFileItem>();
|
||||||
Iterator pkgItem = this.fPkgList.iterator();
|
Iterator pkgItem = this.fPkgList.iterator();
|
||||||
@ -425,22 +424,23 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Add all farfiles in <FarPlatformList> to list.
|
// Add all farfiles in <FarPlatformList> to list.
|
||||||
//
|
//
|
||||||
// List<FarPlatformItem> plfList = pkg.getFarPlatformList();
|
// List<FarPlatformItem> plfList = pkg.getFarPlatformList();
|
||||||
// Iterator plfItem = plfList.iterator();
|
// Iterator plfItem = plfList.iterator();
|
||||||
// while (plfItem.hasNext()) {
|
// while (plfItem.hasNext()) {
|
||||||
// farFileList.add(((FarPlatformItem) plfItem.next())
|
// farFileList.add(((FarPlatformItem) plfItem.next())
|
||||||
// .getFarFile());
|
// .getFarFile());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Iterator<FarFileItem> ffIter = farFileList.iterator();
|
Iterator<FarFileItem> ffIter = farFileList.iterator();
|
||||||
while (ffIter.hasNext()) {
|
while(ffIter.hasNext()){
|
||||||
FarFileItem ffItem = ffIter.next();
|
FarFileItem ffItem = ffIter.next();
|
||||||
ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());
|
ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return farFileList;
|
return farFileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,20 +449,20 @@ public class Mainfest implements ManifestInterface {
|
|||||||
* @param pkgId
|
* @param pkgId
|
||||||
* @return String: return string represent jar file entry;
|
* @return String: return string represent jar file entry;
|
||||||
*/
|
*/
|
||||||
public String[] getPackgeSpd(PackageIdentification pkgId) {
|
public String[] getPackgeSpd(PackageIdentification pkgId){
|
||||||
Iterator pkgItem = this.fPkgList.iterator();
|
Iterator pkgItem = this.fPkgList.iterator();
|
||||||
String[] entryStr = new String[2];
|
String[] entryStr = new String[2];
|
||||||
while (pkgItem.hasNext()) {
|
while (pkgItem.hasNext()) {
|
||||||
FarPackage pkg = (FarPackage) pkgItem.next();
|
FarPackage pkg = (FarPackage) pkgItem.next();
|
||||||
if (pkg.isIdentityPkg(pkgId)) {
|
if (pkg.isIdentityPkg(pkgId)) {
|
||||||
entryStr[0] = pkg.getFarFile().getRelativeFilename();
|
entryStr[0] = pkg.getFarFile().getRelativeFilename();
|
||||||
entryStr[1] = pkg.getDefaultPath();
|
entryStr[1] = pkg.getDefaultPath() ;
|
||||||
return entryStr;
|
return entryStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FarFileItem> getPackageContents() {
|
public List<FarFileItem> getPackageContents() {
|
||||||
//
|
//
|
||||||
// In this farFilelist,all FarFileItem's relativeFileName should be
|
// In this farFilelist,all FarFileItem's relativeFileName should be
|
||||||
@ -482,16 +482,18 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Set farFileItem relativeFileName = absolutePath + file Name.
|
// Set farFileItem relativeFileName = absolutePath + file Name.
|
||||||
//
|
//
|
||||||
farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename(),
|
farFileList.add(new FarFileItem(pkg.getDefaultPath()
|
||||||
ffItem.getMd5Value()));
|
+ File.separatorChar + ffItem.getRelativeFilename(), ffItem
|
||||||
|
.getMd5Value()));
|
||||||
//
|
//
|
||||||
// Add all files in contents to list.
|
// Add all files in contents to list.
|
||||||
//
|
//
|
||||||
Iterator contentsItem = pkg.getContentList().iterator();
|
Iterator contentsItem = pkg.getContentList().iterator();
|
||||||
while (contentsItem.hasNext()) {
|
while (contentsItem.hasNext()) {
|
||||||
ffItem = (FarFileItem) contentsItem.next();
|
ffItem = (FarFileItem) contentsItem.next();
|
||||||
farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),
|
farFileList.add(new FarFileItem(pkg.getDefaultPath()
|
||||||
ffItem.getMd5Value()));
|
+ File.separator + ffItem.getRelativeFilename(), ffItem
|
||||||
|
.getMd5Value()));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Add all farfiles in <FarPlatformList> to list.
|
// Add all farfiles in <FarPlatformList> to list.
|
||||||
@ -500,8 +502,9 @@ public class Mainfest implements ManifestInterface {
|
|||||||
Iterator plfItem = plfList.iterator();
|
Iterator plfItem = plfList.iterator();
|
||||||
while (plfItem.hasNext()) {
|
while (plfItem.hasNext()) {
|
||||||
ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();
|
ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();
|
||||||
farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),
|
farFileList.add(new FarFileItem(pkg.getDefaultPath()
|
||||||
ffItem.getMd5Value()));
|
+ File.separator + ffItem.getRelativeFilename(), ffItem
|
||||||
|
.getMd5Value()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return farFileList;
|
return farFileList;
|
||||||
@ -517,29 +520,29 @@ public class Mainfest implements ManifestInterface {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setPackageInstallPath(PackageIdentification packageId, String path) {
|
// public void setPackageInstallPath(PackageIdentification packageId, String path) {
|
||||||
// Iterator<FarPackage> pkgItr = this.fPkgList.iterator();
|
// Iterator<FarPackage> pkgItr = this.fPkgList.iterator();
|
||||||
// while (pkgItr.hasNext()) {
|
// while (pkgItr.hasNext()) {
|
||||||
// FarPackage farPackage = pkgItr.next();
|
// FarPackage farPackage = pkgItr.next();
|
||||||
// if (farPackage.isIdentityPkg(packageId)) {
|
// if (farPackage.isIdentityPkg(packageId)) {
|
||||||
// farPackage.setDefaultPath(path);
|
// farPackage.setDefaultPath(path);
|
||||||
// return ;
|
// return ;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public void setPlatformInstallPath(PlatformIdentification platformId, String path) {
|
// public void setPlatformInstallPath(PlatformIdentification platformId, String path) {
|
||||||
// Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();
|
// Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();
|
||||||
// while (plfItr.hasNext()) {
|
// while (plfItr.hasNext()) {
|
||||||
// FarPlatformItem farPlatform = plfItr.next();
|
// FarPlatformItem farPlatform = plfItr.next();
|
||||||
// if (farPlatform.i.isIdentity(platformId)) {
|
// if (farPlatform.i.isIdentity(platformId)) {
|
||||||
// farPackage.setDefaultPath(path);
|
// farPackage.setDefaultPath(path);
|
||||||
// return ;
|
// return ;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<FarFileItem> getAllFileItem() {
|
public List<FarFileItem> getAllFileItem() {
|
||||||
//
|
//
|
||||||
// The farFileName in this list are all abosulte path.
|
// The farFileName in this list are all abosulte path.
|
||||||
@ -553,7 +556,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Add far files in <FarPlatformList> to list
|
// Add far files in <FarPlatformList> to list
|
||||||
//
|
//
|
||||||
NodeList elementList = this.mainfestDoc.getElementsByTagName(farPlatformList);
|
NodeList elementList = this.mainfestDoc
|
||||||
|
.getElementsByTagName(farPlatformList);
|
||||||
for (int i = 0; i < elementList.getLength(); i++) {
|
for (int i = 0; i < elementList.getLength(); i++) {
|
||||||
//
|
//
|
||||||
// Get <farPlatform> node list.
|
// Get <farPlatform> node list.
|
||||||
@ -571,13 +575,15 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Get child node value and set to platformIdentification.
|
// Get child node value and set to platformIdentification.
|
||||||
//
|
//
|
||||||
if (tempNode.getNodeName().equalsIgnoreCase(farPackage_FarfileName)) {
|
if (tempNode.getNodeName().equalsIgnoreCase(
|
||||||
|
farPackage_FarfileName)) {
|
||||||
NamedNodeMap farAttr = tempNode.getAttributes();
|
NamedNodeMap farAttr = tempNode.getAttributes();
|
||||||
//
|
//
|
||||||
// Change relative path to absolute one
|
// Change relative path to absolute one
|
||||||
//
|
//
|
||||||
FarFileItem farFile = new FarFileItem(tempNode.getTextContent(),
|
FarFileItem farFile = new FarFileItem(tempNode
|
||||||
farAttr.getNamedItem(farFileName_Md5sum).getTextContent());
|
.getTextContent(), farAttr.getNamedItem(
|
||||||
|
farFileName_Md5sum).getTextContent());
|
||||||
ffiList.add(farFile);
|
ffiList.add(farFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,7 +596,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// create mainfest root node
|
// create mainfest root node
|
||||||
//
|
//
|
||||||
Element rootNode = this.mainfestDoc.createElement("FrameworkArchiveManifest");
|
Element rootNode = this.mainfestDoc
|
||||||
|
.createElement("FrameworkArchiveManifest");
|
||||||
this.mainfestDoc.appendChild(rootNode);
|
this.mainfestDoc.appendChild(rootNode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -668,7 +675,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
// Write the DOM document to the file
|
// Write the DOM document to the file
|
||||||
//
|
//
|
||||||
Transformer xformer = TransformerFactory.newInstance().newTransformer();
|
Transformer xformer = TransformerFactory.newInstance().newTransformer();
|
||||||
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
|
||||||
|
"2");
|
||||||
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -679,7 +687,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
// Prepare the output file, get the Mainifest file name from <FarHeader>
|
// Prepare the output file, get the Mainifest file name from <FarHeader>
|
||||||
// /<FarName>.
|
// /<FarName>.
|
||||||
//
|
//
|
||||||
this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName);
|
this.mfFile = new File(Workspace.getCurrentWorkspace()
|
||||||
|
+ File.separatorChar + mfFileName);
|
||||||
//
|
//
|
||||||
// generate all directory path
|
// generate all directory path
|
||||||
//
|
//
|
||||||
@ -688,7 +697,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {
|
public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {
|
||||||
Element pkgNode = this.mainfestDoc.createElement(farPackageList_FarPackage);
|
Element pkgNode = this.mainfestDoc
|
||||||
|
.createElement(farPackageList_FarPackage);
|
||||||
//
|
//
|
||||||
// Add <FarFileName>
|
// Add <FarFileName>
|
||||||
//
|
//
|
||||||
@ -704,7 +714,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
//
|
//
|
||||||
// Add <DefaultPath>
|
// Add <DefaultPath>
|
||||||
//
|
//
|
||||||
setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);
|
setStrItemToNode(pkgNode, pkgItem.getDefaultPath(),
|
||||||
|
farPackage_DefaultPath);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add <Contents>
|
// Add <Contents>
|
||||||
@ -719,7 +730,8 @@ public class Mainfest implements ManifestInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {
|
public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {
|
||||||
Element fplNode = this.mainfestDoc.createElement(farPlatformList_FarPlatform);
|
Element fplNode = this.mainfestDoc
|
||||||
|
.createElement(farPlatformList_FarPlatform);
|
||||||
//
|
//
|
||||||
// Add <FarFileName>
|
// Add <FarFileName>
|
||||||
//
|
//
|
||||||
@ -740,15 +752,17 @@ public class Mainfest implements ManifestInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ffiToFfNode(Element parentNode, FarFileItem ffi) {
|
public void ffiToFfNode(Element parentNode, FarFileItem ffi) {
|
||||||
Element farFileName = this.mainfestDoc.createElement(farPackage_FarfileName);
|
Element farFileName = this.mainfestDoc
|
||||||
|
.createElement(farPackage_FarfileName);
|
||||||
farFileName.setTextContent(ffi.getRelativeFilename());
|
farFileName.setTextContent(ffi.getRelativeFilename());
|
||||||
System.out.println(farFileName.getTextContent());
|
System.out.println(farFileName.getTextContent());
|
||||||
System.out.println(ffi.getRelativeFilename());
|
System.out.println(ffi.getRelativeFilename());
|
||||||
farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());
|
farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());
|
||||||
parentNode.appendChild(farFileName);
|
parentNode.appendChild(farFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStrItemToNode(Element parentNode, String strValue, String strName) {
|
public void setStrItemToNode(Element parentNode, String strValue,
|
||||||
|
String strName) {
|
||||||
Element node = this.mainfestDoc.createElement(strName);
|
Element node = this.mainfestDoc.createElement(strName);
|
||||||
node.setTextContent(strValue);
|
node.setTextContent(strValue);
|
||||||
parentNode.appendChild(node);
|
parentNode.appendChild(node);
|
||||||
@ -790,13 +804,13 @@ public class Mainfest implements ManifestInterface {
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NodeList childList = headerNode.getChildNodes();
|
NodeList childList = headerNode.getChildNodes();
|
||||||
Node node = null;
|
Node node = null;
|
||||||
String nodeName = null;
|
String nodeName = null;
|
||||||
for (int i = 0; i < childList.getLength(); i++) {
|
for (int i = 0; i < childList.getLength(); i++) {
|
||||||
node = childList.item(i);
|
node = childList.item(i);
|
||||||
nodeName = node.getNodeName();
|
nodeName = node.getNodeName();
|
||||||
if (nodeName.equalsIgnoreCase(farHeader_FarName)) {
|
if (nodeName.equalsIgnoreCase(farHeader_FarName)) {
|
||||||
String nodeValue = node.getTextContent();
|
String nodeValue = node.getTextContent();
|
||||||
this.fhInfo.setFarName(nodeValue);
|
this.fhInfo.setFarName(nodeValue);
|
||||||
} else if (nodeName.equalsIgnoreCase(guidValue)) {
|
} else if (nodeName.equalsIgnoreCase(guidValue)) {
|
||||||
@ -830,7 +844,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
}
|
}
|
||||||
NodeList fpnList = farPkgNode.getChildNodes();
|
NodeList fpnList = farPkgNode.getChildNodes();
|
||||||
for (int i = 0; i < fpnList.getLength(); i++) {
|
for (int i = 0; i < fpnList.getLength(); i++) {
|
||||||
if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {
|
if (fpnList.item(i).getNodeType()== Node.TEXT_NODE){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FarPackage fpItem = new FarPackage();
|
FarPackage fpItem = new FarPackage();
|
||||||
@ -871,14 +885,15 @@ public class Mainfest implements ManifestInterface {
|
|||||||
* @param fpfListNode
|
* @param fpfListNode
|
||||||
* @param plfList
|
* @param plfList
|
||||||
*/
|
*/
|
||||||
public void parseFarPlatformList(Node fpfListNode, List<FarPlatformItem> plfList) {
|
public void parseFarPlatformList(Node fpfListNode,
|
||||||
|
List<FarPlatformItem> plfList) {
|
||||||
//
|
//
|
||||||
// Get <FarPlatform> list.
|
// Get <FarPlatform> list.
|
||||||
//
|
//
|
||||||
NodeList child = fpfListNode.getChildNodes();
|
NodeList child = fpfListNode.getChildNodes();
|
||||||
Node farPlfNode;
|
Node farPlfNode;
|
||||||
for (int i = 0; i < child.getLength(); i++) {
|
for (int i = 0; i < child.getLength(); i++) {
|
||||||
if (child.item(i).getNodeType() == Node.TEXT_NODE) {
|
if (child.item(i).getNodeType()== Node.TEXT_NODE){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
farPlfNode = child.item(i);
|
farPlfNode = child.item(i);
|
||||||
@ -921,7 +936,7 @@ public class Mainfest implements ManifestInterface {
|
|||||||
NodeList contentList = contentsNode.getChildNodes();
|
NodeList contentList = contentsNode.getChildNodes();
|
||||||
Node contentNode;
|
Node contentNode;
|
||||||
for (int i = 0; i < contentList.getLength(); i++) {
|
for (int i = 0; i < contentList.getLength(); i++) {
|
||||||
if (contentList.item(i).getNodeType() == Node.TEXT_NODE) {
|
if (contentList.item(i).getNodeType()== Node.TEXT_NODE){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
contentNode = contentList.item(i);
|
contentNode = contentList.item(i);
|
||||||
@ -935,20 +950,21 @@ public class Mainfest implements ManifestInterface {
|
|||||||
public FarFileItem parseFarFile(Node farFileNode) {
|
public FarFileItem parseFarFile(Node farFileNode) {
|
||||||
String ffName = farFileNode.getTextContent();
|
String ffName = farFileNode.getTextContent();
|
||||||
NamedNodeMap attr = farFileNode.getAttributes();
|
NamedNodeMap attr = farFileNode.getAttributes();
|
||||||
FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(farFileName_Md5sum).getTextContent());
|
FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(
|
||||||
|
farFileName_Md5sum).getTextContent());
|
||||||
return ffItem;
|
return ffItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFilter(File file, Set<String> fileter) {
|
public boolean isFilter(File file, Set<String> fileter) {
|
||||||
Iterator<String> iter = fileter.iterator();
|
Iterator<String> iter = fileter.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Pattern pattern = Pattern.compile(iter.next());
|
Pattern pattern = Pattern.compile(iter.next());
|
||||||
Matcher matcher = pattern.matcher(file.getName());
|
Matcher matcher = pattern.matcher(file.getName());
|
||||||
|
|
||||||
if (matcher.find()) {
|
if(matcher.find()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@ -230,42 +231,51 @@ public class UpdateStepOne extends IDialog implements MouseListener {
|
|||||||
return jContentPane;
|
return jContentPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getSource() == jButtonCancel) {
|
if (e.getSource() == jButtonCancel) {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
} else if (e.getSource() == jButtonNext) {
|
}
|
||||||
//
|
else if (e.getSource() == jButtonNext) {
|
||||||
// Judge if FAR file is existed
|
//
|
||||||
//
|
// Judge if FAR file is existed
|
||||||
farFile = new File(jTextFieldFarFile.getText());
|
//
|
||||||
if (!farFile.exists() || !farFile.isFile()) {
|
farFile = new File(jTextFieldFarFile.getText());
|
||||||
Log.err("Please choose a FAR file already exists. ");
|
if ( ! farFile.exists() || ! farFile.isFile()) {
|
||||||
return;
|
Log.err("Please choose a FAR file already exists. ");
|
||||||
}
|
return ;
|
||||||
|
}
|
||||||
//
|
|
||||||
// Judge FAR is valid
|
//
|
||||||
//
|
// Judge FAR is valid
|
||||||
|
//
|
||||||
//
|
try{
|
||||||
// Add more logic process here
|
JarFile file = new JarFile(farFile);
|
||||||
//
|
this.far = new Far(file);
|
||||||
if (jListFarFromDb.getSelectedValue() == null) {
|
} catch (Exception ex){
|
||||||
Log.err("Please choose a FAR from framework database. ");
|
Log.err(ex.getMessage());
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (stepTwo == null) {
|
//
|
||||||
|
// Add more logic process here
|
||||||
|
//
|
||||||
|
if (jListFarFromDb.getSelectedValue() == null) {
|
||||||
|
Log.err("Please choose a FAR from framework database. ");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stepTwo == null) {
|
||||||
stepTwo = new UpdateStepTwo(this, true, this);
|
stepTwo = new UpdateStepTwo(this, true, this);
|
||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
stepTwo.prepareTable();
|
stepTwo.prepareTable();
|
||||||
stepTwo.setVisible(true);
|
stepTwo.setVisible(true);
|
||||||
} else if (e.getSource() == jButtonBrowser) {
|
}
|
||||||
JFileChooser fc = new JFileChooser();
|
else if (e.getSource() == jButtonBrowser) {
|
||||||
fc.setAcceptAllFileFilterUsed(false);
|
JFileChooser fc = new JFileChooser();
|
||||||
fc.addChoosableFileFilter(new IFileFilter(DataType.FAR_SURFACE_AREA_EXT));
|
fc.setAcceptAllFileFilterUsed(false);
|
||||||
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
|
fc.addChoosableFileFilter(new IFileFilter(DataType.FAR_SURFACE_AREA_EXT));
|
||||||
|
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
|
||||||
|
|
||||||
int result = fc.showSaveDialog(new JPanel());
|
int result = fc.showSaveDialog(new JPanel());
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
if (result == JFileChooser.APPROVE_OPTION) {
|
||||||
|
@ -17,8 +17,13 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
@ -29,11 +34,14 @@ import javax.swing.JTable;
|
|||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import org.tianocore.frameworkwizard.common.Log;
|
||||||
import org.tianocore.frameworkwizard.common.Tools;
|
import org.tianocore.frameworkwizard.common.Tools;
|
||||||
import org.tianocore.frameworkwizard.common.ui.IDialog;
|
import org.tianocore.frameworkwizard.common.ui.IDialog;
|
||||||
import org.tianocore.frameworkwizard.far.AggregationOperation;
|
import org.tianocore.frameworkwizard.far.AggregationOperation;
|
||||||
|
import org.tianocore.frameworkwizard.far.DistributeRule;
|
||||||
import org.tianocore.frameworkwizard.far.Far;
|
import org.tianocore.frameworkwizard.far.Far;
|
||||||
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
|
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
|
||||||
|
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
|
||||||
import org.tianocore.frameworkwizard.workspace.Workspace;
|
import org.tianocore.frameworkwizard.workspace.Workspace;
|
||||||
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
|
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
|
||||||
|
|
||||||
@ -63,6 +71,7 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||||||
private JTable jTablePackage = null;
|
private JTable jTablePackage = null;
|
||||||
|
|
||||||
private PartialTableModel model = null;
|
private PartialTableModel model = null;
|
||||||
|
List<PackageIdentification> updatPkgList = new ArrayList<PackageIdentification>();
|
||||||
|
|
||||||
public UpdateStepTwo(IDialog iDialog, boolean modal, UpdateStepOne stepOne) {
|
public UpdateStepTwo(IDialog iDialog, boolean modal, UpdateStepOne stepOne) {
|
||||||
this(iDialog, modal);
|
this(iDialog, modal);
|
||||||
@ -174,24 +183,25 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||||||
WorkspaceTools wt = new WorkspaceTools();
|
WorkspaceTools wt = new WorkspaceTools();
|
||||||
List<PackageIdentification> packagesInDb = wt.getAllPackages();
|
List<PackageIdentification> packagesInDb = wt.getAllPackages();
|
||||||
|
|
||||||
List<PackageIdentification> result = AggregationOperation.intersection(packagesInDb, packagesInFar);
|
updatPkgList = AggregationOperation.intersection(packagesInDb, packagesInFar);
|
||||||
//
|
//
|
||||||
// Change here to get packages and platforms from FAR
|
// Change here to get packages and platforms from FAR
|
||||||
//
|
//
|
||||||
Iterator<PackageIdentification> iter = result.iterator();//packageList.iterator();
|
Iterator<PackageIdentification> iter = updatPkgList.iterator() ;//packageList.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String[] str = new String[4];
|
String[] str = new String[4];
|
||||||
PackageIdentification item = iter.next();
|
PackageIdentification item = iter.next();
|
||||||
str[0] = item.getName();
|
str[0] = item.getName();
|
||||||
str[1] = item.getVersion();
|
str[1] = item.getVersion();
|
||||||
str[2] = item.getGuid();
|
str[2] = item.getGuid();
|
||||||
str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));
|
str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));
|
||||||
model.addRow(str);
|
model.addRow(str);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor
|
* This is the default constructor
|
||||||
@ -214,85 +224,184 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||||||
this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
|
this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method initializes jContentPane
|
* This method initializes jContentPane
|
||||||
*
|
*
|
||||||
* @return javax.swing.JPanel
|
* @return javax.swing.JPanel
|
||||||
*/
|
*/
|
||||||
private JPanel getJContentPane() {
|
private JPanel getJContentPane() {
|
||||||
if (jContentPane == null) {
|
if (jContentPane == null) {
|
||||||
jLabel = new JLabel();
|
jLabel = new JLabel();
|
||||||
jLabel.setBounds(new java.awt.Rectangle(30, 70, 281, 20));
|
jLabel.setBounds(new java.awt.Rectangle(30,70,281,20));
|
||||||
jLabel.setText("Following packages will be updated: ");
|
jLabel.setText("Following packages will be updated: ");
|
||||||
jContentPane = new JPanel();
|
jContentPane = new JPanel();
|
||||||
jContentPane.setLayout(null);
|
jContentPane.setLayout(null);
|
||||||
jContentPane.add(getJTextArea(), null);
|
jContentPane.add(getJTextArea(), null);
|
||||||
jContentPane.add(getJButtonCancel(), null);
|
jContentPane.add(getJButtonCancel(), null);
|
||||||
jContentPane.add(getJButtonFinish(), null);
|
jContentPane.add(getJButtonFinish(), null);
|
||||||
jContentPane.add(getJButtonPrevious(), null);
|
jContentPane.add(getJButtonPrevious(), null);
|
||||||
jContentPane.add(getJScrollPane(), null);
|
jContentPane.add(getJScrollPane(), null);
|
||||||
jContentPane.add(jLabel, null);
|
jContentPane.add(jLabel, null);
|
||||||
|
}
|
||||||
|
return jContentPane;
|
||||||
|
}
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (e.getSource() == jButtonCancel) {
|
||||||
|
this.setVisible(false);
|
||||||
|
}
|
||||||
|
else if (e.getSource() == jButtonFinish) {
|
||||||
|
//
|
||||||
|
// Check depedency ?
|
||||||
|
//
|
||||||
|
WorkspaceTools wsTools = new WorkspaceTools();
|
||||||
|
|
||||||
|
Iterator<PackageIdentification> iter = updatPkgList.iterator();
|
||||||
|
List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();
|
||||||
|
while (iter.hasNext()){
|
||||||
|
List<PackageIdentification> depPkgList = stepOne.getFar().getPackageDependencies(iter.next());
|
||||||
|
depResultList = AggregationOperation.union(depResultList, depPkgList);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PackageIdentification> dbPkgList = DistributeRule.vectorToList(wsTools.getAllPackages());
|
||||||
|
List<PackageIdentification> resultList = AggregationOperation.minus(depResultList, AggregationOperation.union(
|
||||||
|
this.updatPkgList, dbPkgList));
|
||||||
|
Iterator resultIter = resultList.iterator();
|
||||||
|
while (resultIter.hasNext()){
|
||||||
|
Log.err("Missing dependency package " + ((PackageIdentification)resultIter.next()).toString() + "in workspace!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove all update packages
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// For all packages, remove all files.
|
||||||
|
// Exception FPD file still in DB
|
||||||
|
//
|
||||||
|
Vector<PlatformIdentification> allPlatforms = wsTools.getAllPlatforms();
|
||||||
|
Set<File> allPlatformFiles = new LinkedHashSet<File>();
|
||||||
|
|
||||||
|
Iterator<PlatformIdentification> allPlfIter = allPlatforms.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
allPlatformFiles.add(allPlfIter.next().getFpdFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<PackageIdentification> packageIter = this.updatPkgList.iterator();
|
||||||
|
while (packageIter.hasNext()) {
|
||||||
|
PackageIdentification item = packageIter.next();
|
||||||
|
Set<File> deleteFiles = new LinkedHashSet<File>();
|
||||||
|
recursiveDir(deleteFiles, item.getSpdFile().getParentFile(), allPlatformFiles);
|
||||||
|
Iterator<File> iterDeleteFile = deleteFiles.iterator();
|
||||||
|
while (iterDeleteFile.hasNext()){
|
||||||
|
deleteFiles(iterDeleteFile.next());
|
||||||
}
|
}
|
||||||
return jContentPane;
|
//
|
||||||
}
|
// Remove all empty parent dir
|
||||||
|
//
|
||||||
public void mouseClicked(MouseEvent e) {
|
File parentDir = item.getSpdFile().getParentFile();
|
||||||
if (e.getSource() == jButtonCancel) {
|
while (parentDir.listFiles().length == 0) {
|
||||||
this.setVisible(false);
|
File tempFile = parentDir;
|
||||||
} else if (e.getSource() == jButtonFinish) {
|
parentDir = parentDir.getParentFile();
|
||||||
//
|
tempFile.delete();
|
||||||
// Check depedency ?
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Remove all update packages
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install all update packages
|
|
||||||
//
|
|
||||||
|
|
||||||
this.setVisible(false);
|
|
||||||
} else if (e.getSource() == jButtonPrevious) {
|
|
||||||
this.setVisible(false);
|
|
||||||
stepOne.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install all update packages
|
||||||
|
//
|
||||||
|
Iterator<PackageIdentification> updataIter = this.updatPkgList.iterator();
|
||||||
|
while (updataIter.hasNext()){
|
||||||
|
PackageIdentification pkgId = updataIter.next();
|
||||||
|
try{
|
||||||
|
stepOne.getFar().installPackage(pkgId, pkgId.getSpdFile());
|
||||||
|
}catch (Exception ex){
|
||||||
|
Log.err("Can install " + pkgId.toString() + " pakcage, please check it!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
else if (e.getSource() == jButtonPrevious) {
|
||||||
public void mousePressed(MouseEvent e) {
|
this.setVisible(false);
|
||||||
// TODO Auto-generated method stub
|
stepOne.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
private void recursiveDir(Set<File> files, File dir, Set<File> platformFiles) {
|
||||||
// TODO Auto-generated method stub
|
File[] fileList = dir.listFiles();
|
||||||
|
for (int i = 0; i < fileList.length; i ++) {
|
||||||
|
if (fileList[i].isFile()) {
|
||||||
|
if( ! platformFiles.contains(fileList[i])) {
|
||||||
|
files.add(fileList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isContain(fileList[i], platformFiles)) {
|
||||||
|
recursiveDir(files, fileList[i], platformFiles);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
files.add(fileList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
private void deleteFiles(File file) {
|
||||||
// TODO Auto-generated method stub
|
if (file.isDirectory()) {
|
||||||
|
File[] files = file.listFiles();
|
||||||
|
for (int i = 0; i < files.length; i ++) {
|
||||||
|
deleteFiles(files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) {
|
private boolean isContain(File dir, Set<File> platformFiles) {
|
||||||
// TODO Auto-generated method stub
|
Iterator<File> iter = platformFiles.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
File file = iter.next();
|
||||||
|
if (file.getPath().startsWith(dir.getPath())) {
|
||||||
|
//
|
||||||
|
// continue this FPD file
|
||||||
|
//
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class PartialTableModel extends DefaultTableModel {
|
class PartialTableModel extends DefaultTableModel {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public boolean isCellEditable(int row, int col) {
|
public boolean isCellEditable(int row, int col) {
|
||||||
switch (col) {
|
switch (col){
|
||||||
case 3:
|
case 3:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user