/** * @param string $entryId * @param KalturaIdeticDistributionJobProviderData $providerData * @return DOMDocument */ public static function generateXML($entryId, KalturaIdeticDistributionJobProviderData $providerData) { $entry = entryPeer::retrieveByPKNoFilter($entryId); $mrss = kMrssManager::getEntryMrss($entry); if (!$mrss) { KalturaLog::err("No MRSS returned for entry [{$entryId}]"); return null; } $xml = new KDOMDocument(); if (!$xml->loadXML($mrss)) { KalturaLog::err("Could not load MRSS as XML for entry [{$entryId}]"); return null; } $xslPath = realpath(dirname(__FILE__) . '/../') . '/xml/submit.xsl'; if (!file_exists($xslPath)) { KalturaLog::err("XSL file not found [{$xslPath}]"); return null; } $xsl = new KDOMDocument(); $xsl->load($xslPath); // set variables in the xsl $varNodes = $xsl->getElementsByTagName('variable'); foreach ($varNodes as $varNode) { $nameAttr = $varNode->attributes->getNamedItem('name'); if (!$nameAttr) { continue; } $name = $nameAttr->value; if ($name && $providerData->{$name}) { $varNode->textContent = $providerData->{$name}; $varNode->appendChild($xsl->createTextNode($providerData->{$name})); KalturaLog::debug("Set variable [{$name}] to [{$providerData->{$name}}]"); } } $proc = new XSLTProcessor(); $proc->registerPHPFunctions(); $proc->importStyleSheet($xsl); $xml = $proc->transformToDoc($xml); if (!$xml) { KalturaLog::err("XML Transformation failed"); return null; } // TODO create validation XSD $xsdPath = realpath(dirname(__FILE__) . '/../') . '/xml/submit.xsd'; if (file_exists($xsdPath) && !$xml->schemaValidate($xsdPath)) { KalturaLog::err("Schema validation failed"); return null; } return $xml; }
$field = $matches[1]; // $providerData->$field = $matches[2]; } } $fileTransferMgr = kFileTransferMgr::getInstance(kFileTransferMgrType::FTP); if(!$fileTransferMgr) throw new Exception("SFTP manager not loaded"); $fileTransferMgr->login('ftp-int.vzw.real.com', 'vp_foxsports', 'X4ul3ap'); print_r($fileTransferMgr->listDir("/pub/in")); // $fileTransferMgr->putFile($destFile, $srcFile, true); return;*/ $entry = entryPeer::retrieveByPKNoFilter($entryId); $mrss = kMrssManager::getEntryMrss($entry); file_put_contents('mrss.xml', $mrss); KalturaLog::debug("MRSS [{$mrss}]"); $distributionJobData = new KalturaDistributionSubmitJobData(); $dbDistributionProfile = DistributionProfilePeer::retrieveByPK(3); $distributionProfile = new KalturaDailymotionDistributionProfile(); $distributionProfile->fromObject($dbDistributionProfile); $distributionJobData->distributionProfileId = $distributionProfile->id; $distributionJobData->distributionProfile = $distributionProfile; $dbEntryDistribution = EntryDistributionPeer::retrieveByPK(24); $entryDistribution = new KalturaEntryDistribution(); $entryDistribution->fromObject($dbEntryDistribution); $distributionJobData->entryDistributionId = $entryDistribution->id; $distributionJobData->entryDistribution = $entryDistribution; $myp = new DailymotionDistributionProfile(); print_r($myp->validateForSubmission($dbEntryDistribution, "submit"));
public function loadProperties(KalturaDistributionJobData $distributionJobData, KalturaGenericDistributionProfile $distributionProfile, $action) { $actionName = self::$actionAttributes[$action]; $genericProviderAction = GenericDistributionProviderActionPeer::retrieveByProviderAndAction($distributionProfile->genericProviderId, $action); if (!$genericProviderAction) { KalturaLog::err("Generic provider [{$distributionProfile->genericProviderId}] action [{$actionName}] not found"); return; } if (!$distributionJobData->entryDistribution) { KalturaLog::err("Entry Distribution object not provided"); return; } if (!$distributionProfile->{$actionName}->protocol) { $distributionProfile->{$actionName}->protocol = $genericProviderAction->getProtocol(); } if (!$distributionProfile->{$actionName}->serverUrl) { $distributionProfile->{$actionName}->serverUrl = $genericProviderAction->getServerAddress(); } if (!$distributionProfile->{$actionName}->serverPath) { $distributionProfile->{$actionName}->serverPath = $genericProviderAction->getRemotePath(); } if (!$distributionProfile->{$actionName}->username) { $distributionProfile->{$actionName}->username = $genericProviderAction->getRemoteUsername(); } if (!$distributionProfile->{$actionName}->password) { $distributionProfile->{$actionName}->password = $genericProviderAction->getRemotePassword(); } if (!$distributionProfile->{$actionName}->ftpPassiveMode) { $distributionProfile->{$actionName}->ftpPassiveMode = $genericProviderAction->getFtpPassiveMode(); } if (!$distributionProfile->{$actionName}->httpFieldName) { $distributionProfile->{$actionName}->httpFieldName = $genericProviderAction->getHttpFieldName(); } if (!$distributionProfile->{$actionName}->httpFileName) { $distributionProfile->{$actionName}->httpFileName = $genericProviderAction->getHttpFileName(); } $entry = entryPeer::retrieveByPKNoFilter($distributionJobData->entryDistribution->entryId); if (!$entry) { KalturaLog::err("Entry [" . $distributionJobData->entryDistribution->entryId . "] not found"); return; } $mrss = kMrssManager::getEntryMrss($entry); if (!$mrss) { KalturaLog::err("MRSS not returned for entry [" . $entry->getId() . "]"); return; } $xml = new KDOMDocument(); if (!$xml->loadXML($mrss)) { KalturaLog::err("MRSS not is not valid XML:\n{$mrss}\n"); return; } $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_TRANSFORMER); if (kFileSyncUtils::fileSync_exists($key)) { $xslPath = kFileSyncUtils::getLocalFilePathForKey($key); if ($xslPath) { $xsl = new KDOMDocument(); $xsl->load($xslPath); // set variables in the xsl $varNodes = $xsl->getElementsByTagName('variable'); foreach ($varNodes as $varNode) { $nameAttr = $varNode->attributes->getNamedItem('name'); if (!$nameAttr) { continue; } $name = $nameAttr->value; if ($name && $distributionJobData->{$name}) { $varNode->textContent = $distributionJobData->{$name}; $varNode->appendChild($xsl->createTextNode($distributionJobData->{$name})); } } $proc = new XSLTProcessor(); $proc->registerPHPFunctions(kXml::getXslEnabledPhpFunctions()); $proc->importStyleSheet($xsl); $xml = $proc->transformToDoc($xml); if (!$xml) { KalturaLog::err("Transform returned false"); return; } } } $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_MRSS_VALIDATOR); if (kFileSyncUtils::fileSync_exists($key)) { $xsdPath = kFileSyncUtils::getLocalFilePathForKey($key); if ($xsdPath && !$xml->schemaValidate($xsdPath)) { KalturaLog::err("Inavlid XML:\n" . $xml->saveXML()); KalturaLog::err("Schema [{$xsdPath}]:\n" . file_get_contents($xsdPath)); return; } } $this->xml = $xml->saveXML(); $key = $genericProviderAction->getSyncKey(GenericDistributionProviderAction::FILE_SYNC_DISTRIBUTION_PROVIDER_ACTION_RESULTS_TRANSFORMER); if (kFileSyncUtils::fileSync_exists($key)) { $this->resultParseData = kFileSyncUtils::file_get_contents($key, true, false); } $this->resultParserType = $genericProviderAction->getResultsParser(); }