4cddce2f902f767567ad1ff303f38b716256521e
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / CollectPCDAction.java
1 /** @file
2 CollectPCDAction class.
3
4 This action class is to collect PCD information from MSA, SPD, FPD xml file.
5 This class will be used for wizard and build tools, So it can *not* inherit
6 from buildAction or wizardAction.
7
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18 package org.tianocore.build.pcd.action;
19
20 import java.io.File;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.UUID;
27
28 import org.apache.xmlbeans.XmlException;
29 import org.apache.xmlbeans.XmlObject;
30 import org.tianocore.FrameworkPlatformDescriptionDocument;
31 import org.tianocore.ModuleSADocument;
32 import org.tianocore.PackageSurfaceAreaDocument;
33 import org.tianocore.PcdBuildDeclarationsDocument.PcdBuildDeclarations.PcdBuildData;
34 import org.tianocore.PcdDefinitionsDocument.PcdDefinitions;
35 import org.tianocore.build.autogen.CommonDefinition;
36 import org.tianocore.build.global.GlobalData;
37 import org.tianocore.build.global.SurfaceAreaQuery;
38 import org.tianocore.build.pcd.action.ActionMessage;
39 import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
40 import org.tianocore.build.pcd.entity.SkuInstance;
41 import org.tianocore.build.pcd.entity.Token;
42 import org.tianocore.build.pcd.entity.UsageInstance;
43 import org.tianocore.build.pcd.exception.EntityException;
44
45 /** This action class is to collect PCD information from MSA, SPD, FPD xml file.
46 This class will be used for wizard and build tools, So it can *not* inherit
47 from buildAction or UIAction.
48 **/
49 public class CollectPCDAction {
50 /// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.
51 private MemoryDatabaseManager dbManager;
52
53 /// Workspacepath hold the workspace information.
54 private String workspacePath;
55
56 /// FPD file is the root file.
57 private String fpdFilePath;
58
59 /// Message level for CollectPCDAction.
60 private int originalMessageLevel;
61
62 /**
63 Set WorkspacePath parameter for this action class.
64
65 @param workspacePath parameter for this action
66 **/
67 public void setWorkspacePath(String workspacePath) {
68 this.workspacePath = workspacePath;
69 }
70
71 /**
72 Set action message level for CollectPcdAction tool.
73
74 The message should be restored when this action exit.
75
76 @param actionMessageLevel parameter for this action
77 **/
78 public void setActionMessageLevel(int actionMessageLevel) {
79 originalMessageLevel = ActionMessage.messageLevel;
80 ActionMessage.messageLevel = actionMessageLevel;
81 }
82
83 /**
84 Set FPDFileName parameter for this action class.
85
86 @param fpdFilePath fpd file path
87 **/
88 public void setFPDFilePath(String fpdFilePath) {
89 this.fpdFilePath = fpdFilePath;
90 }
91
92 /**
93 Common function interface for outer.
94
95 @param workspacePath The path of workspace of current build or analysis.
96 @param fpdFilePath The fpd file path of current build or analysis.
97 @param messageLevel The message level for this Action.
98
99 @throws Exception The exception of this function. Because it can *not* be predict
100 where the action class will be used. So only Exception can be throw.
101
102 **/
103 public void perform(String workspacePath, String fpdFilePath,
104 int messageLevel) throws Exception {
105 setWorkspacePath(workspacePath);
106 setFPDFilePath(fpdFilePath);
107 setActionMessageLevel(messageLevel);
108 checkParameter();
109 execute();
110 ActionMessage.messageLevel = originalMessageLevel;
111 }
112
113 /**
114 Core execution function for this action class.
115
116 This function work flows will be:
117 1) Get all token's platform information from FPD, and create token object into memory database.
118 2) Get all token's module information from MSA, and create usage instance for every module's PCD entry.
119 3) Get all token's inherited information from MSA's library, and create usage instance
120 for module who consume this library and create usage instance for library for building.
121 4) Collect token's package information from SPD, update these information for token in memory
122 database.
123
124 @throws EntityException Exception indicate failed to execute this action.
125
126 **/
127 private void execute() throws EntityException {
128 FrameworkPlatformDescriptionDocument fpdDoc = null;
129 Object[][] modulePCDArray = null;
130 Map<String, XmlObject> docMap = null;
131 ModuleSADocument.ModuleSA[] moduleSAs = null;
132 UsageInstance usageInstance = null;
133 String packageName = null;
134 String packageFullPath = null;
135 int index = 0;
136 int libraryIndex = 0;
137 int pcdArrayIndex = 0;
138 List<String> listLibraryInstance = null;
139 String componentTypeStr = null;
140
141 //
142 // Collect all PCD information defined in FPD file.
143 // Evenry token defind in FPD will be created as an token into
144 // memory database.
145 //
146 fpdDoc = createTokenInDBFromFPD();
147
148 //
149 // Searching MSA and SPD document.
150 // The information of MSA will be used to create usage instance into database.
151 // The information of SPD will be used to update the token information in database.
152 //
153
154 HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();
155 map.put("FrameworkPlatformDescription", fpdDoc);
156 SurfaceAreaQuery.setDoc(map);
157
158 moduleSAs = SurfaceAreaQuery.getFpdModules();
159 for(index = 0; index < moduleSAs.length; index ++) {
160 //
161 // Get module document and use SurfaceAreaQuery to get PCD information
162 //
163 docMap = GlobalData.getDoc(moduleSAs[index].getModuleName());
164 SurfaceAreaQuery.setDoc(docMap);
165 modulePCDArray = SurfaceAreaQuery.getModulePCDTokenArray();
166 componentTypeStr = SurfaceAreaQuery.getComponentType();
167 packageName =
168 GlobalData.getPackageNameForModule(moduleSAs[index].getModuleName());
169 packageFullPath = this.workspacePath + File.separator +
170 GlobalData.getPackagePath(packageName) +
171 packageName + ".spd";
172
173 if(modulePCDArray != null) {
174 //
175 // If current MSA contains <PCDs> information, then create usage
176 // instance for PCD information from MSA
177 //
178 for(pcdArrayIndex = 0; pcdArrayIndex < modulePCDArray.length;
179 pcdArrayIndex ++) {
180 usageInstance =
181 createUsageInstanceFromMSA(moduleSAs[index].getModuleName(),
182 modulePCDArray[pcdArrayIndex]);
183
184 if(usageInstance == null) {
185 continue;
186 }
187 //
188 // Get remaining PCD information from the package which this module belongs to
189 //
190 updateTokenBySPD(usageInstance, packageFullPath);
191 }
192 }
193
194 //
195 // Get inherit PCD information which inherit from library instance of this module.
196 //
197 listLibraryInstance =
198 SurfaceAreaQuery.getLibraryInstance(moduleSAs[index].getArch().toString(),
199 CommonDefinition.AlwaysConsumed);
200 if(listLibraryInstance != null) {
201 for(libraryIndex = 0; libraryIndex < listLibraryInstance.size();
202 libraryIndex ++) {
203 inheritPCDFromLibraryInstance(listLibraryInstance.get(libraryIndex),
204 moduleSAs[index].getModuleName(),
205 packageName,
206 componentTypeStr);
207 }
208 }
209 }
210 }
211
212 /**
213 This function will collect inherit PCD information from library for a module.
214
215 This function will create two usage instance for inherited PCD token, one is
216 for module and another is for library.
217 For module, if it inherited a PCD token from library, this PCD token's value
218 should be instanced in module level, and belongs to module.
219 For library, it also need a usage instance for build.
220
221 @param libraryName The name of library instance.
222 @param moduleName The name of module.
223 @param packageName The name of package while module belongs to.
224 @param parentcomponentType The component type of module.
225
226 @throws EntityException If the token does *not* exist in memory database.
227
228 **/
229 private void inheritPCDFromLibraryInstance(String libraryName,
230 String moduleName,
231 String packageName,
232 String parentcomponentType)
233 throws EntityException {
234 Map<String, XmlObject> docMap = null;
235 String primaryKeyString = null;
236 Object[][] libPcdDataArray = null;
237 UUID nullUUID = new UUID(0,0);
238 UUID platformUUID = nullUUID;
239 UUID tokenSpaceGuid = null;
240 int tokenIndex = 0;
241 Token token = null;
242 Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
243 UsageInstance usageInstance = null;
244 String packageFullPath = null;
245
246 //
247 // Query PCD information from library's document.
248 //
249 docMap = GlobalData.getDoc(libraryName);
250 SurfaceAreaQuery.setDoc(docMap);
251 libPcdDataArray = SurfaceAreaQuery.getModulePCDTokenArray();
252
253 if(libPcdDataArray == null) {
254 return;
255 }
256
257 for(tokenIndex = 0; tokenIndex < libPcdDataArray.length; tokenIndex ++) {
258 tokenSpaceGuid =((UUID)libPcdDataArray[tokenIndex][2] == null) ?
259 nullUUID :(UUID)libPcdDataArray[tokenIndex][2];
260
261 //
262 // Get token from memory database. The token must be created from FPD already.
263 //
264 primaryKeyString = Token.getPrimaryKeyString((String)libPcdDataArray[tokenIndex][0],
265 tokenSpaceGuid,
266 platformUUID
267 );
268
269 if(dbManager.isTokenInDatabase(primaryKeyString)) {
270 token = dbManager.getTokenByKey(primaryKeyString);
271 } else {
272 throw new EntityException("The PCD token " + primaryKeyString +
273 " defined in module " + moduleName +
274 " does not exist in FPD file!");
275 }
276
277 //
278 // Create usage instance for module.
279 //
280 pcdType = Token.getpcdTypeFromString((String)libPcdDataArray[tokenIndex][1]);
281 usageInstance = new UsageInstance(token,
282 Token.PCD_USAGE.ALWAYS_CONSUMED,
283 pcdType,
284 CommonDefinition.getComponentType(parentcomponentType),
285 libPcdDataArray[tokenIndex][3],
286 null,
287 (String) libPcdDataArray[tokenIndex][5],
288 "",
289 moduleName,
290 packageName,
291 true);
292 if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(moduleName)) {
293 token.addUsageInstance(usageInstance);
294
295 packageFullPath = this.workspacePath + File.separator +
296 GlobalData.getPackagePath(packageName) +
297 packageName + ".spd";
298 updateTokenBySPD(usageInstance, packageFullPath);
299 }
300
301 //
302 // We need create second usage instance for inherited case, which
303 // add library as an usage instance, because when build a module, and
304 // if module inherited from base library, then build process will build
305 // library at first.
306 //
307 if(Token.PCD_USAGE.UNKNOWN == token.isUsageInstanceExist(libraryName)) {
308 packageName = GlobalData.getPackageNameForModule(libraryName);
309 usageInstance = new UsageInstance(token,
310 Token.PCD_USAGE.ALWAYS_CONSUMED,
311 pcdType,
312 CommonDefinition.ComponentTypeLibrary,
313 libPcdDataArray[tokenIndex][3],
314 null,
315 (String)libPcdDataArray[tokenIndex][5],
316 "",
317 libraryName,
318 packageName,
319 false);
320 token.addUsageInstance(usageInstance);
321 }
322 }
323 }
324
325 /**
326 Create usage instance for PCD token defined in MSA document
327
328 A PCD token maybe used by many modules, and every module is one of usage
329 instance of this token. For ALWAY_CONSUMED, SOMETIMES_CONSUMED, it is
330 consumer type usage instance of this token, and for ALWAYS_PRODUCED,
331 SOMETIMES_PRODUCED, it is produce type usage instance.
332
333 @param moduleName The name of module
334 @param tokenInfoInMsa The PCD token information array retrieved from MSA.
335
336 @return UsageInstance The usage instance created in memroy database.
337
338 @throws EntityException If token did not exist in database yet.
339
340 **/
341 private UsageInstance createUsageInstanceFromMSA(String moduleName,
342 Object[] tokenInfoInMsa)
343 throws EntityException {
344 String packageName = null;
345 UsageInstance usageInstance = null;
346 UUID tokenSpaceGuid = null;
347 UUID nullUUID = new UUID(0,0);
348 String primaryKeyString = null;
349 UUID platformTokenSpace = nullUUID;
350 Token token = null;
351 Token.PCD_TYPE pcdType = Token.PCD_TYPE.UNKNOWN;
352 Token.PCD_USAGE pcdUsage = Token.PCD_USAGE.UNKNOWN;
353
354 tokenSpaceGuid =((UUID)tokenInfoInMsa[2] == null) ? nullUUID :(UUID)tokenInfoInMsa[2];
355
356 primaryKeyString = Token.getPrimaryKeyString((String)tokenInfoInMsa[0],
357 tokenSpaceGuid,
358 platformTokenSpace);
359
360 //
361 // Get token object from memory database firstly.
362 //
363 if(dbManager.isTokenInDatabase(primaryKeyString)) {
364 token = dbManager.getTokenByKey(primaryKeyString);
365 } else {
366 throw new EntityException("The PCD token " + primaryKeyString + " defined in module " +
367 moduleName + " does not exist in FPD file!" );
368 }
369 pcdType = Token.getpcdTypeFromString((String)tokenInfoInMsa[1]);
370 pcdUsage = Token.getUsageFromString((String)tokenInfoInMsa[4]);
371
372 packageName = GlobalData.getPackageNameForModule(moduleName);
373
374 if(Token.PCD_USAGE.UNKNOWN != token.isUsageInstanceExist(moduleName)) {
375 //
376 // BUGBUG: It is legal that same base name exist in one FPD file. In furture
377 // we should use "Guid, Version, Package" and "Arch" to differ a module.
378 // So currently, warning should be disabled.
379 //
380 //ActionMessage.warning(this,
381 // "In module " + moduleName + " exist more than one PCD token " + token.cName
382 // );
383 return null;
384 }
385
386 //
387 // BUGBUG: following code could be enabled at current schema. Because
388 // current schema does not provide usage information.
389 //
390 // For FEATRURE_FLAG, FIXED_AT_BUILD, PATCH_IN_MODULE type PCD token, his
391 // usage is always ALWAYS_CONSUMED
392 //
393 //if((pcdType != Token.PCD_TYPE.DYNAMIC) &&
394 // (pcdType != Token.PCD_TYPE.DYNAMIC_EX)) {
395 pcdUsage = Token.PCD_USAGE.ALWAYS_CONSUMED;
396 //}
397
398 usageInstance = new UsageInstance(token,
399 pcdUsage,
400 pcdType,
401 CommonDefinition.getComponentType(SurfaceAreaQuery.getComponentType()),
402 tokenInfoInMsa[3],
403 null,
404 (String) tokenInfoInMsa[5],
405 "",
406 moduleName,
407 packageName,
408 false);
409
410 //
411 // Use default value defined in MSA to update datum of token,
412 // if datum of token does not defined in FPD file.
413 //
414 if((token.datum == null) &&(tokenInfoInMsa[3] != null)) {
415 token.datum = tokenInfoInMsa[3];
416 }
417
418 token.addUsageInstance(usageInstance);
419
420 return usageInstance;
421 }
422
423 /**
424 Create token instance object into memory database, the token information
425 comes for FPD file. Normally, FPD file will contain all token platform
426 informations.
427
428 This fucntion should be executed at firsly before others collection work
429 such as searching token information from MSA, SPD.
430
431 @return FrameworkPlatformDescriptionDocument The FPD document instance for furture usage.
432
433 @throws EntityException Failed to parse FPD xml file.
434
435 **/
436 private FrameworkPlatformDescriptionDocument createTokenInDBFromFPD()
437 throws EntityException {
438 XmlObject doc = null;
439 FrameworkPlatformDescriptionDocument fpdDoc = null;
440 int index = 0;
441 List<PcdBuildData> pcdBuildDataArray = new ArrayList<PcdBuildData>();
442 PcdBuildData pcdBuildData = null;
443 Token token = null;
444 UUID nullUUID = new UUID(0,0);
445 UUID platformTokenSpace= nullUUID;
446 List skuDataArray = new ArrayList();
447 SkuInstance skuInstance = null;
448 int skuIndex = 0;
449
450 //
451 // Get all tokens from FPD file and create token into database.
452 //
453
454 try {
455 doc = XmlObject.Factory.parse(new File(fpdFilePath));
456 } catch(IOException ioE) {
457 throw new EntityException("Can't find the FPD xml fle:" + fpdFilePath);
458 } catch(XmlException xmlE) {
459 throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath);
460 }
461
462 //
463 // Get memoryDatabaseManager instance from GlobalData.
464 //
465 if((dbManager = GlobalData.getPCDMemoryDBManager()) == null) {
466 throw new EntityException("The instance of PCD memory database manager is null");
467 }
468
469 dbManager = new MemoryDatabaseManager();
470
471 if(!(doc instanceof FrameworkPlatformDescriptionDocument)) {
472 throw new EntityException("File " + fpdFilePath +
473 " is not a FrameworkPlatformDescriptionDocument");
474 }
475
476 fpdDoc =(FrameworkPlatformDescriptionDocument)doc;
477
478 //
479 // Add all tokens in FPD into Memory Database.
480 //
481 pcdBuildDataArray =
482 fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().getPcdBuildDataList();
483 for(index = 0;
484 index < fpdDoc.getFrameworkPlatformDescription().getPcdBuildDeclarations().sizeOfPcdBuildDataArray();
485 index ++) {
486 pcdBuildData = pcdBuildDataArray.get(index);
487 token = new Token(pcdBuildData.getCName(), new UUID(0, 0), new UUID(0, 0));
488 //
489 // BUGBUG: in FPD, <defaultValue> should be defined as <Value>
490 //
491 token.datum = pcdBuildData.getDefaultValue();
492 token.tokenNumber = Integer.decode(pcdBuildData.getToken().getStringValue());
493 token.hiiEnabled = pcdBuildData.getHiiEnable();
494 token.variableGuid = Token.getGUIDFromSchemaObject(pcdBuildData.getVariableGuid());
495 token.variableName = pcdBuildData.getVariableName();
496 token.variableOffset = Integer.decode(pcdBuildData.getDataOffset());
497 token.skuEnabled = pcdBuildData.getSkuEnable();
498 token.maxSkuCount = Integer.decode(pcdBuildData.getMaxSku());
499 token.skuId = Integer.decode(pcdBuildData.getSkuId());
500 token.skuDataArrayEnabled = pcdBuildData.getSkuDataArrayEnable();
501 token.assignedtokenNumber = Integer.decode(pcdBuildData.getToken().getStringValue());
502 skuDataArray = pcdBuildData.getSkuDataArray1();
503 token.datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());
504
505 if(skuDataArray != null) {
506 for(skuIndex = 0; skuIndex < skuDataArray.size(); skuIndex ++) {
507 //
508 // BUGBUG: Now in current schema, The value is defined as String type,
509 // it is not correct, the type should be same as the datumType
510 //
511 skuInstance = new SkuInstance(((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getId(),
512 ((PcdBuildData.SkuData)skuDataArray.get(skuIndex)).getValue());
513 token.skuData.add(skuInstance);
514 }
515 }
516
517 if(dbManager.isTokenInDatabase(Token.getPrimaryKeyString(token.cName,
518 token.tokenSpaceName,
519 platformTokenSpace))) {
520 //
521 // If found duplicate token, Should tool be hold?
522 //
523 ActionMessage.warning(this,
524 "Token " + token.cName + " exists in token database");
525 continue;
526 }
527 token.pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());
528 dbManager.addTokenToDatabase(Token.getPrimaryKeyString(token.cName,
529 token.tokenSpaceName,
530 platformTokenSpace),
531 token);
532 }
533
534 return fpdDoc;
535 }
536
537 /**
538 Update PCD token in memory database by help information in SPD.
539
540 After create token from FPD and create usage instance from MSA, we should collect
541 PCD package level information from SPD and update token information in memory
542 database.
543
544 @param usageInstance The usage instance defined in MSA and want to search in SPD.
545 @param packageFullPath The SPD file path.
546
547 @throws EntityException Failed to parse SPD xml file.
548
549 **/
550 private void updateTokenBySPD(UsageInstance usageInstance,
551 String packageFullPath)
552 throws EntityException {
553 PackageSurfaceAreaDocument pkgDoc = null;
554 PcdDefinitions pcdDefinitions = null;
555 List<PcdDefinitions.PcdEntry> pcdEntryArray = new ArrayList<PcdDefinitions.PcdEntry>();
556 int index = 0;
557 boolean isFoundInSpd = false;
558 Token.DATUM_TYPE datumType = Token.DATUM_TYPE.UNKNOWN;
559
560 try {
561 pkgDoc =(PackageSurfaceAreaDocument)XmlObject.Factory.parse(new File(packageFullPath));
562 } catch(IOException ioE) {
563 throw new EntityException("Can't find the FPD xml fle:" + packageFullPath);
564 } catch(XmlException xmlE) {
565 throw new EntityException("Can't parse the FPD xml fle:" + packageFullPath);
566 }
567 pcdDefinitions = pkgDoc.getPackageSurfaceArea().getPcdDefinitions();
568 //
569 // It is illege for SPD file does not contains any PCD information.
570 //
571 if (pcdDefinitions == null) {
572 return;
573 }
574
575 pcdEntryArray = pcdDefinitions.getPcdEntryList();
576 if (pcdEntryArray == null) {
577 return;
578 }
579 for(index = 0; index < pcdEntryArray.size(); index ++) {
580 if(pcdEntryArray.get(index).getCName().equalsIgnoreCase(
581 usageInstance.parentToken.cName)) {
582 isFoundInSpd = true;
583 //
584 // From SPD file , we can get following information.
585 // Token: Token number defined in package level.
586 // PcdItemType: This item does not single one. It means all supported item type.
587 // datumType: UINT8, UNIT16, UNIT32, UINT64, VOID*, BOOLEAN
588 // datumSize: The size of default value or maxmine size.
589 // defaultValue: This value is defined in package level.
590 // HelpText: The help text is provided in package level.
591 //
592
593 usageInstance.parentToken.tokenNumber = Integer.decode(pcdEntryArray.get(index).getToken());
594
595 if(pcdEntryArray.get(index).getDatumType() != null) {
596 datumType = Token.getdatumTypeFromString(
597 pcdEntryArray.get(index).getDatumType().toString());
598 if(usageInstance.parentToken.datumType == Token.DATUM_TYPE.UNKNOWN) {
599 usageInstance.parentToken.datumType = datumType;
600 } else {
601 if(datumType != usageInstance.parentToken.datumType) {
602 throw new EntityException("Different datum types are defined for Token :" +
603 usageInstance.parentToken.cName);
604 }
605 }
606
607 } else {
608 throw new EntityException("The datum type for token " + usageInstance.parentToken.cName +
609 " is not defind in SPD file " + packageFullPath);
610 }
611
612 usageInstance.defaultValueInSPD = pcdEntryArray.get(index).getDefaultValue();
613 usageInstance.helpTextInSPD = "Help Text in SPD";
614
615 //
616 // If token's datum is not valid, it indicate that datum is not provided
617 // in FPD and defaultValue is not provided in MSA, then use defaultValue
618 // in SPD as the datum of token.
619 //
620 if(usageInstance.parentToken.datum == null) {
621 if(pcdEntryArray.get(index).getDefaultValue() != null) {
622 usageInstance.parentToken.datum = pcdEntryArray.get(index).getDefaultValue();
623 } else {
624 throw new EntityException("FPD does not provide datum for token " + usageInstance.parentToken.cName +
625 ", MSA and SPD also does not provide <defaultValue> for this token!");
626 }
627 }
628 }
629 }
630 }
631
632 /**
633 check parameter for this action.
634
635 @throws EntityException Bad parameter.
636 **/
637 private void checkParameter() throws EntityException {
638 File file = null;
639
640 if((fpdFilePath == null) ||(workspacePath == null)) {
641 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
642 }
643
644 if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
645 throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
646 }
647
648 file = new File(workspacePath);
649 if(!file.exists()) {
650 throw new EntityException("WorkpacePath " + workspacePath + " does not exist!");
651 }
652
653 file = new File(fpdFilePath);
654
655 if(!file.exists()) {
656 throw new EntityException("FPD File " + fpdFilePath + " does not exist!");
657 }
658 }
659
660 /**
661 Test case function
662
663 @param argv parameter from command line
664 **/
665 public static void main(String argv[]) throws EntityException {
666 CollectPCDAction ca = new CollectPCDAction();
667 ca.setWorkspacePath("G:/mdk");
668 ca.setFPDFilePath("G:/mdk/EdkNt32Pkg/build/Nt32.fpd");
669 ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);
670 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
671 "G:/mdk");
672 ca.execute();
673 }
674 }