in src/main/java/com/netflix/imflibrary/RESTfulInterfaces/IMPValidator.java [684:777]
private static List<ErrorLogger.ErrorObject> checkVirtualTrackAndEssencesHeaderPartitionPayloadRecords(List<VirtualTrack>
virtualTracks,
List<PayloadRecord> essencesHeaderPartition) throws IOException {
IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
Set<UUID> trackFileIDsSet = new HashSet<>();
for (PayloadRecord payloadRecord : essencesHeaderPartition){
if (payloadRecord.getPayloadAssetType() != PayloadRecord.PayloadAssetType.EssencePartition) {
throw new IMFException(String.format("Payload asset type is %s, expected asset type %s",
payloadRecord.getPayloadAssetType(), PayloadRecord.PayloadAssetType.EssencePartition.toString
()), imfErrorLogger);
}
HeaderPartition headerPartition = new HeaderPartition(new ByteArrayDataProvider(payloadRecord.getPayload()),
0L,
(long) payloadRecord.getPayload().length,
imfErrorLogger);
Preface preface = headerPartition.getPreface();
GenericPackage genericPackage = preface.getContentStorage().getEssenceContainerDataList().get(0).getLinkedPackage();
SourcePackage filePackage = (SourcePackage) genericPackage;
UUID packageUUID = filePackage.getPackageMaterialNumberasUUID();
trackFileIDsSet.add(packageUUID);
try {
/**
* Add the Top Level Package UUID to the set of TrackFileIDs, this is required to validate that the essences header partition that were passed in
* are in fact from the constituent resources of the VirtualTack
*/
MXFOperationalPattern1A.HeaderPartitionOP1A headerPartitionOP1A = MXFOperationalPattern1A.checkOperationalPattern1ACompliance(headerPartition, imfErrorLogger);
IMFConstraints.HeaderPartitionIMF headerPartitionIMF = IMFConstraints.checkIMFCompliance(headerPartitionOP1A, imfErrorLogger);
if (headerPartitionIMF.hasMatchingEssence(HeaderPartition.EssenceTypeEnum.IABEssence)) {
IABTrackFileConstraints.checkCompliance(headerPartitionIMF, imfErrorLogger);
}
if (headerPartitionIMF.hasMatchingEssence(HeaderPartition.EssenceTypeEnum.MGASADMEssence)) {
MGASADMTrackFileConstraints.checkCompliance(headerPartitionIMF, imfErrorLogger);
}
}
catch (IMFException | MXFException e){
if(headerPartition != null) {
}
imfErrorLogger.addError(new ErrorLogger.ErrorObject(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_ESSENCE_COMPONENT_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.FATAL, String.format("IMFTrackFile with ID %s has fatal errors", packageUUID.toString())));
if(e instanceof IMFException){
IMFException imfException = (IMFException)e;
imfErrorLogger.addAllErrors(imfException.getErrors());
}
else if(e instanceof MXFException){
MXFException mxfException = (MXFException)e;
imfErrorLogger.addAllErrors(mxfException.getErrors());
}
}
}
Set<UUID> virtualTrackResourceIDsSet = new HashSet<>();
for(Composition.VirtualTrack virtualTrack : virtualTracks){
if(virtualTrack instanceof IMFEssenceComponentVirtualTrack)
{
virtualTrackResourceIDsSet.addAll(IMFEssenceComponentVirtualTrack.class.cast(virtualTrack).getTrackResourceIds());
}
}
/**
* Following check ensures that the Header Partitions corresponding to all the Resources of the VirtualTracks were passed in.
*/
Set<UUID> unreferencedResourceIDsSet = new HashSet<>();
for(UUID uuid : virtualTrackResourceIDsSet){
if(!trackFileIDsSet.contains(uuid)){
unreferencedResourceIDsSet.add(uuid);
}
}
if(unreferencedResourceIDsSet.size() > 0){
imfErrorLogger.addError(new ErrorLogger.ErrorObject(IMFErrorLogger.IMFErrors.ErrorCodes.IMP_VALIDATOR_PAYLOAD_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.FATAL, String.format("It seems that no EssenceHeaderPartition data was passed in for " +
"VirtualTrack Resource Ids %s, please verify that the correct Header Partition payloads for the " +
"Virtual Track were passed in", Utilities.serializeObjectCollectionToString
(unreferencedResourceIDsSet))));
}
/**
* Following check ensures that the Header Partitions corresponding to only the Resource that are a part of the VirtualTracks were passed in.
*/
Set<UUID> unreferencedTrackFileIDsSet = new HashSet<>();
for(UUID uuid : trackFileIDsSet){
if(!virtualTrackResourceIDsSet.contains(uuid)){
unreferencedTrackFileIDsSet.add(uuid);
}
}
if(unreferencedTrackFileIDsSet.size() > 0){
imfErrorLogger.addError(new ErrorLogger.ErrorObject(IMFErrorLogger.IMFErrors.ErrorCodes.IMP_VALIDATOR_PAYLOAD_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.FATAL, String.format("It seems that EssenceHeaderPartition data was passed in for " +
"Resource Ids %s which are not part of this virtual track, please verify that only the Header " +
"Partition payloads for the Virtual Track were passed in", Utilities
.serializeObjectCollectionToString(unreferencedTrackFileIDsSet))));
}
return imfErrorLogger.getErrors();
}