forked from kaltura/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kaltura#5583 from kaltura/Lynx-12.16.0-PS-3045
Lynx 12.16.0 ps 3045
- Loading branch information
Showing
6 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
class kBulkUploadXmlFlowManager implements kBatchJobStatusEventConsumer | ||
{ | ||
/** | ||
* @param BatchJob $dbBatchJob | ||
* @return bool true if should continue to the next consumer | ||
*/ | ||
public function updatedJob(BatchJob $dbBatchJob) | ||
{ | ||
KalturaLog::debug("Handling finished ExtractMedia job!"); | ||
|
||
$profile = myPartnerUtils::getConversionProfile2ForEntry($dbBatchJob->getEntryId()); | ||
$mediaInfoXslt = $profile->getMediaInfoXslTransformation(); | ||
if (!$mediaInfoXslt) | ||
{ | ||
return true; | ||
} | ||
|
||
$mediaInfo = mediaInfoPeer::retrieveByPk($dbBatchJob->getData()->getMediaInfoId()); | ||
$mediaInfoRawData = $mediaInfo->getRawDataXml(); | ||
|
||
$transformedXml = kXml::transformXmlUsingXslt($mediaInfoRawData, $mediaInfoXslt, array("entryId" => $dbBatchJob->getEntryId())); | ||
$xml = new KDOMDocument(); | ||
if(!$xml->loadXML($transformedXml)) | ||
{ | ||
KalturaLog::err("Could not load xml string"); | ||
return true; | ||
} | ||
|
||
if(!$xml->getElementsByTagName("entryId")->item(0)) | ||
{ | ||
KalturaLog::err("XML structure is incorrect - must contain tag entry ID"); | ||
return true; | ||
} | ||
$transformedXml = $xml->saveXML(); | ||
|
||
//Save the file to a shared temporary location | ||
$tmpSharedFolder = myContentStorage::getFSContentRootPath() . "/tmp/bulkupload/"; | ||
$fileName = $dbBatchJob->getEntryId() . '_update_' . time() . ".xml"; | ||
$filePath = $tmpSharedFolder . DIRECTORY_SEPARATOR. $fileName; | ||
$res = file_put_contents($filePath, $transformedXml); | ||
chmod($filePath, 0640); | ||
|
||
$jobData = new kBulkUploadXmlJobData(); | ||
$jobData->setFileName($fileName); | ||
$jobData->setFilePath($filePath); | ||
$jobData->setBulkUploadObjectType(BulkUploadObjectType::ENTRY); | ||
$jobData->setObjectData(new kBulkUploadEntryData()); | ||
$bulkUploadCoreType = BulkUploadXmlPlugin::getBulkUploadTypeCoreValue(BulkUploadXmlType::XML); | ||
|
||
kJobsManager::addBulkUploadJob($dbBatchJob->getPartner(), $jobData, $bulkUploadCoreType); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @param BatchJob $dbBatchJob | ||
* @return bool true if the consumer should handle the event | ||
*/ | ||
public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) | ||
{ | ||
if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED && $dbBatchJob->getJobType() == BatchJobType::EXTRACT_MEDIA) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} |