Skip to content

Commit

Permalink
Check for PKL UUID mismatches between the AssetMap and the PKL (#381)
Browse files Browse the repository at this point in the history
* Adding a check for ID mimsatches between the PKL and the PKL referenced in the AssetMap

* Remove trailing spaces
  • Loading branch information
danielhdz13-netflix authored Sep 24, 2024
1 parent e534614 commit e1c9cf5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public static Map<String, List<ErrorLogger.ErrorObject>> analyzePackage(File roo
IMFErrorLogger packingListErrorLogger = new IMFErrorLoggerImpl();
try {
PackingList packingList = new PackingList(new File(rootFile, packingListAsset.getPath().toString()));
if (!packingList.getUUID().equals(packingListAsset.getUUID())) {
assetMapErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_AM_ERROR,
IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL,
String.format("AssetMap references PKL with ID %s, but PKL contains ID %s", packingListAsset.getUUID().toString(), packingList.getUUID().toString()));
}
packingListErrorLogger.addAllErrors(packingList.getErrors());
Map<UUID, PayloadRecord> trackFileIDToHeaderPartitionPayLoadMap = new HashMap<>();
for (PackingList.Asset asset : packingList.getAssets()) {
Expand Down Expand Up @@ -419,7 +424,7 @@ public static List<ApplicationComposition> analyzeApplicationCompositions( File
Map<String, List<ErrorLogger.ErrorObject>> errorMap,
Map<UUID, PayloadRecord> trackFileIDToHeaderPartitionPayLoadMap) throws IOException {
List<ApplicationComposition> applicationCompositionList = new ArrayList<>();

for (PackingList.Asset asset : packingList.getAssets()) {
if (asset.getType().equals(PackingList.Asset.TEXT_XML_TYPE)) {
URI path = assetMap.getPath(asset.getUUID());
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public void IMPAnalyzerTestIDMismatches() throws IOException
if (e.getKey().matches("CPL.*Virtual Track Conformance")) {
Assert.assertEquals(e.getValue().size(), 1);
}
else if (e.getKey().matches("ASSETMAP.*")) {
Assert.assertEquals(e.getValue().size(), 1);
e.getValue().get(0).getErrorDescription().contains("ERROR-AssetMap references PKL with ID f5e93462-aed2-44ad-a4ba-2adb65823e7d, but PKL contains ID f5e93462-aed2-44ad-a4ba-2adb65823e7c");
}
else if (e.getKey().matches("CPL.*")) {
Assert.assertEquals(e.getValue().size(), 2);
e.getValue().get(0).getErrorDescription().contains("ERROR-UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca84 in the CPL is not same as UUID 0eb3d1b9-b77b-4d3f-bbe5-7c69b15dca85 of the CPL in the AssetMap");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</ChunkList>
</Asset>
<Asset>
<Id>urn:uuid:f5e93462-aed2-44ad-a4ba-2adb65823e7c</Id>
<Id>urn:uuid:f5e93462-aed2-44ad-a4ba-2adb65823e7d</Id>
<PackingList>true</PackingList>
<ChunkList>
<Chunk>
Expand Down

0 comments on commit e1c9cf5

Please sign in to comment.