1. Fix EDKT457 Multiple FPD, MSA or SPD files in a directory is prohibited

2. Fix EDKT450 Please don't allow user to set same Guid in clone operation

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1855 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
hche10x 2006-10-30 05:26:27 +00:00
parent 92cfaeee66
commit d8be5b148b
5 changed files with 139 additions and 33 deletions

View File

@ -569,15 +569,19 @@ public class Clone extends IDialog {
@retval false Any one of name, guid and version is invalid
**/
private boolean checkId() {
private boolean checkId(int mode) {
String name = this.jTextFieldBaseName.getText();
String guid = this.jTextFieldGuid.getText();
String version = this.jTextFieldVersion.getText();
//
// Check Basename
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
if (isEmpty(name)) {
Log.wrn("Clone", "The Name is required!");
return false;
}
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
if (!DataValidation.isBaseName(name)) {
Log
.wrn("Clone",
"<html>Incorrect data type for the Name, it must<br>be a single word, starting with an alpha character.</html>");
@ -587,11 +591,11 @@ public class Clone extends IDialog {
//
// Check Guid
//
if (isEmpty(this.jTextFieldGuid.getText())) {
if (isEmpty(guid)) {
Log.wrn("Clone", "A Guid is required!!");
return false;
}
if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {
if (!DataValidation.isGuid(guid)) {
Log
.wrn(
"Clone",
@ -602,11 +606,11 @@ public class Clone extends IDialog {
//
// Check Version
//
if (isEmpty(this.jTextFieldVersion.getText())) {
if (isEmpty(version)) {
Log.wrn("Clone", "A Version must be entered!");
return false;
}
if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
if (!DataValidation.isVersion(version)) {
Log
.wrn(
"Clone",
@ -614,6 +618,29 @@ public class Clone extends IDialog {
return false;
}
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();
String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();
if (GlobalData.findModuleIdByGuidVersion(guid, version, packageGuid, packageVersion) != null) {
Log.wrn("Clone", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
if (GlobalData.findPackageIdByGuidVersion(guid, version) != null) {
Log.wrn("Clone", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
if (GlobalData.findPlatformIdByGuidVersion(guid, version) != null) {
Log.wrn("Clone", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
//
// Save information to id
//
@ -673,7 +700,7 @@ public class Clone extends IDialog {
//
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
trg = this.getModulePath();
if (src.equals(trg)) {
if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {
Log.wrn("Clone", "The source and destination paths for cloning a module must be different!");
return false;
}
@ -682,7 +709,7 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The target module already exists!");
return false;
}
return checkId();
return checkId(mode);
}
//
@ -703,7 +730,7 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The target package already exists!");
return false;
}
return checkId();
return checkId(mode);
}
//
@ -714,12 +741,16 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The platform clone must be located in the current workspace!");
return false;
}
if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {
Log.wrn("Clone", "The source and destination paths for cloning a platform must be different!");
return false;
}
trgFile = new File(trg);
if (trgFile.exists()) {
Log.wrn("Clone", "The target platform already exists.");
return false;
}
return checkId();
return checkId(mode);
}
return true;

View File

@ -210,7 +210,8 @@ public class GlobalData {
@return
**/
public static ModuleIdentification findIdByGuidVersion(String moduleGuid, String moduleVersion, String packageGuid, String packageVersion) {
public static ModuleIdentification findModuleIdByGuidVersion(String moduleGuid, String moduleVersion,
String packageGuid, String packageVersion) {
ModuleIdentification mid = null;
for (int index = 0; index < vModuleList.size(); index++) {
if (vModuleList.elementAt(index).equals(moduleGuid, moduleVersion, packageGuid, packageVersion)) {
@ -220,4 +221,42 @@ public class GlobalData {
}
return mid;
}
/**
Get a package id
@param packageGuid
@param packageVersion
@return
**/
public static PackageIdentification findPackageIdByGuidVersion(String packageGuid, String packageVersion) {
PackageIdentification pid = null;
for (int index = 0; index < vPackageList.size(); index++) {
if (vPackageList.elementAt(index).equals(packageGuid, packageVersion)) {
pid = vPackageList.elementAt(index);
break;
}
}
return pid;
}
/**
Get a platform id
@param platformGuid
@param platformVersion
@return
**/
public static PlatformIdentification findPlatformIdByGuidVersion(String platformGuid, String platformVersion) {
PlatformIdentification pid = null;
for (int index = 0; index < vPlatformList.size(); index++) {
if (vPlatformList.elementAt(index).equals(platformGuid, platformVersion)) {
pid = vPlatformList.elementAt(index);
break;
}
}
return pid;
}
}

View File

@ -286,7 +286,7 @@ public class FindResultDetailInfo extends IFrame {
// Write Module Sa Info
//
ModuleIdentification moduleSaId = GlobalData
.findIdByGuidVersion(
.findModuleIdByGuidVersion(
msa
.getModuleGuid(),
msa
@ -539,7 +539,7 @@ public class FindResultDetailInfo extends IFrame {
if (mid.equals(i.getModuleGuid(), i.getModuleVersion(), i.getPackageGuid(),
i.getPackageVersion())) {
ModuleIdentification moduleSaId = GlobalData
.findIdByGuidVersion(
.findModuleIdByGuidVersion(
msa
.getModuleGuid(),
msa

View File

@ -43,4 +43,22 @@ public class PackageIdentification extends Identification{
public String toString() {
return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getSpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";
}
public boolean equals(String packageGuid, String packageVersion) {
boolean b = false;
if (this.getGuid().equals(packageGuid)) {
b = true;
//
// Check Version
//
if (packageVersion != null) {
if (!Tools.isEmpty(packageVersion)) {
if (!packageVersion.equals(this.getVersion())) {
b = false;
}
}
}
}
return b;
}
}

View File

@ -40,4 +40,22 @@ public class PlatformIdentification extends Identification{
public String toString() {
return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getFpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";
}
public boolean equals(String platformGuid, String platformVersion) {
boolean b = false;
if (this.getGuid().equals(platformGuid)) {
b = true;
//
// Check Version
//
if (platformVersion != null) {
if (!Tools.isEmpty(platformVersion)) {
if (!platformVersion.equals(this.getVersion())) {
b = false;
}
}
}
}
return b;
}
}