From e1c9cf5948a508be88038454ffb204a87e3aeb24 Mon Sep 17 00:00:00 2001 From: danielhdz13-netflix <117850928+danielhdz13-netflix@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:12:18 -0400 Subject: [PATCH] Check for PKL UUID mismatches between the AssetMap and the PKL (#381) * Adding a check for ID mimsatches between the PKL and the PKL referenced in the AssetMap * Remove trailing spaces --- src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java | 7 ++++++- .../java/com/netflix/imflibrary/app/IMPAnalyzerTest.java | 4 ++++ .../ASSETMAP.xml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java b/src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java index 4775b117..59fd12e8 100755 --- a/src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java +++ b/src/main/java/com/netflix/imflibrary/app/IMPAnalyzer.java @@ -244,6 +244,11 @@ public static Map> 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 trackFileIDToHeaderPartitionPayLoadMap = new HashMap<>(); for (PackingList.Asset asset : packingList.getAssets()) { @@ -419,7 +424,7 @@ public static List analyzeApplicationCompositions( File Map> errorMap, Map trackFileIDToHeaderPartitionPayLoadMap) throws IOException { List applicationCompositionList = new ArrayList<>(); - + for (PackingList.Asset asset : packingList.getAssets()) { if (asset.getType().equals(PackingList.Asset.TEXT_XML_TYPE)) { URI path = assetMap.getPath(asset.getUUID()); diff --git a/src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java b/src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java index 81fde920..820124a2 100644 --- a/src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java +++ b/src/test/java/com/netflix/imflibrary/app/IMPAnalyzerTest.java @@ -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"); diff --git a/src/test/resources/TestIMP/MERIDIAN_Netflix_Photon_161006_ID_MISMATCH/ASSETMAP.xml b/src/test/resources/TestIMP/MERIDIAN_Netflix_Photon_161006_ID_MISMATCH/ASSETMAP.xml index d8e63b2e..cd10f993 100755 --- a/src/test/resources/TestIMP/MERIDIAN_Netflix_Photon_161006_ID_MISMATCH/ASSETMAP.xml +++ b/src/test/resources/TestIMP/MERIDIAN_Netflix_Photon_161006_ID_MISMATCH/ASSETMAP.xml @@ -53,7 +53,7 @@ - urn:uuid:f5e93462-aed2-44ad-a4ba-2adb65823e7c + urn:uuid:f5e93462-aed2-44ad-a4ba-2adb65823e7d true