public function closeSubmit(KalturaDistributionSubmitJobData $data)
 {
     $statusXml = $this->fetchStatusXml($data, $data->distributionProfile, $data->providerData);
     if ($statusXml === false) {
         // try to get batch status xml to see if there is an internal error on youtube's batch
         $batchStatus = $this->fetchBatchStatus($data, $data->distributionProfile, $data->providerData);
         if ($batchStatus) {
             throw new Exception('Internal failure on YouTube, internal_failure-status.xml was found. Error [' . $batchStatus . ']');
         }
         return false;
         // return false to recheck again on next job closing iteration
     }
     $statusParser = new YouTubeDistributionRightsFeedLegacyStatusParser($statusXml);
     $status = $statusParser->getStatusForAction('Submit reference');
     // maybe we didn't submit a reference, so let's check the file status
     if (!$status) {
         $status = $statusParser->getStatusForAction('Process file');
     }
     if ($status != 'Success') {
         $errors = $statusParser->getErrorsSummary();
         throw new Exception('Distribution failed with status [' . $status . '] and errors [' . implode(',', $errors) . ']');
     }
     $referenceId = $statusParser->getReferenceId();
     $assetId = $statusParser->getAssetId();
     $videoId = $statusParser->getVideoId();
     $remoteIdHandler = new YouTubeDistributionRemoteIdHandler();
     $remoteIdHandler->setVideoId($videoId);
     $remoteIdHandler->setAssetId($assetId);
     $remoteIdHandler->setReferenceId($referenceId);
     $data->remoteId = $remoteIdHandler->getSerialized();
     $providerData = $data->providerData;
     $newPlaylists = $this->syncPlaylists($videoId, $providerData);
     $providerData->currentPlaylists = $newPlaylists;
     return true;
 }