public function checkIsLive($url)
 {
     KalturaLog::info('url to check:' . $url);
     $parts = parse_url($url);
     parse_str($parts['query'], $query);
     $token = $query[$this->getParamName()];
     $data = $this->urlExists($url, array($this->getHdsManifestContentType()));
     if (!$data) {
         KalturaLog::Info("URL [{$url}] returned no valid data. Exiting.");
         return false;
     }
     KalturaLog::info('Velocix HDS manifest data:' . $data);
     $dom = new KDOMDocument();
     $dom->loadXML($data);
     $element = $dom->getElementsByTagName('baseURL')->item(0);
     if (!$element) {
         KalturaLog::Info("No base url was given");
         return false;
     }
     $baseUrl = $element->nodeValue;
     foreach ($dom->getElementsByTagName('media') as $media) {
         $href = $media->getAttribute('href');
         $streamUrl = $baseUrl . $href;
         $streamUrl .= $token ? '?' . $this->getParamName() . "={$token}" : '';
         if ($this->urlExists($streamUrl, array(), '0-0') !== false) {
             KalturaLog::info('is live:' . $streamUrl);
             return true;
         }
     }
     return false;
 }
function check(&$msg, $url)
{
    $service = 'session';
    $action = 'start';
    $secret = '@BATCH_PARTNER_ADMIN_SECRET@';
    $partnerId = -1;
    $userId = 'xymon';
    $type = 2;
    $getKS = "http://{$url}/api_v3/index.php?service={$service}&action={$action}&secret={$secret}&partnerId={$partnerId}&userId={$userId}&type={$type}&nocache";
    try {
        $content = @file_get_contents($getKS);
    } catch (Exception $e) {
        $msg = $e->getMessage();
        return false;
    }
    if (!$content) {
        $msg = "unable to get data";
        return false;
    }
    $arr = null;
    if (!preg_match('/<result>([^<]+)<\\/result>/', $content, $arr)) {
        $msg = "invalid return data\n{$content}";
        return false;
    }
    $ks = $arr[1];
    $service = 'batchControl';
    $action = 'getFullStatus';
    $getStatus = "http://{$url}/api_v3/index.php?service={$service}&action={$action}&ks={$ks}&nocache";
    // Load the XML source
    if (class_exists('DOMDocument') && class_exists('XSLTProcessor')) {
        $xml = new KDOMDocument();
        $xml->load($getStatus);
        //file_put_contents('fullStatus.xml', $xml->saveXML());
        $resultElements = $xml->getElementsByTagName("result");
        $resultElement = $resultElements->item(0);
        $resultElement->setAttribute('timestamp', time());
        $xsl = new KDOMDocument();
        $xsl->load(dirname(__FILE__) . '/fullstatus.xsl');
        // Configure the transformer
        $proc = new XSLTProcessor();
        $proc->importStyleSheet($xsl);
        // attach the xsl rules
        $msg = $proc->transformToXML($xml);
    } else {
        $msg = "batches are ok\nXSL is required to parse the XML data.";
    }
    //	echo "'$msg'\n";
    //	echo "-----------------------------------------------\n\n";
    //	echo $xml->saveHTML();
    //	exit;
    return true;
}
예제 #3
0
 public function checkIsLive($url)
 {
     $data = $this->urlExists($url, array('video/f4m'));
     if (is_bool($data)) {
         return $data;
     }
     $element = new KDOMDocument();
     $element->loadXML($data);
     $streamType = $element->getElementsByTagName('streamType')->item(0);
     if ($streamType->nodeValue == 'live') {
         return true;
     }
     return false;
 }
 /**
  * @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;
 }
 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();
 }
 /**
  * @param string $xsdPath
  * @param string $appInfoField
  * @param string $appInfoValue
  * @return array of xPaths
  */
 public static function findXpathsByAppInfo($xsdPath, $appInfoField, $appInfoValue, $isPath = true)
 {
     $xsd = new KDOMDocument();
     if ($isPath) {
         $xsd->load($xsdPath);
     } else {
         $xsd->loadXML($xsdPath);
     }
     $xPaths = array();
     $appInfos = $xsd->getElementsByTagName('appinfo');
     foreach ($appInfos as $appInfo) {
         $fields = $appInfo->getElementsByTagName($appInfoField);
         $found = false;
         foreach ($fields as $field) {
             if ($field->nodeValue == $appInfoValue) {
                 $found = true;
             }
         }
         if (!$found) {
             continue;
         }
         $name = self::getXsdElementName($appInfo);
         $type = self::getXsdNodeType($appInfo);
         $xPath = self::getXsdXpath($appInfo);
         $data = array();
         if ($name) {
             $data['name'] = $name;
         }
         if ($type) {
             $data['type'] = $type;
         }
         foreach ($appInfo->childNodes as $childNode) {
             if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_COMMENT_NODE) {
                 continue;
             }
             $data[$childNode->localName] = $childNode->nodeValue;
         }
         $xPaths[$xPath] = $data;
     }
     return $xPaths;
 }
 public function parse($content)
 {
     $xml = new KDOMDocument();
     try {
         $xml->loadXML(trim($content, " \r\n\t"));
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage());
         return array();
     }
     // parse styles
     $xmlNS = $xml->lookupNamespaceURI('xml');
     $this->ttsNS = $xml->lookupNamespaceURI('tts');
     $elements = $xml->getElementsByTagName('style');
     $this->styles = array();
     foreach ($elements as $element) {
         if ($element->hasAttribute('id')) {
             $id = $element->getAttribute('id');
         } else {
             if ($element->hasAttributeNS($xmlNS, 'id')) {
                 $id = $element->getAttributeNS($xmlNS, 'id');
             } else {
                 continue;
             }
         }
         $style = $this->parseStyles($element);
         $this->styles[$id] = $style;
     }
     // parse content
     $itemsData = $this->parseBody($xml);
     if (!$itemsData) {
         KalturaLog::err("XML element <p> not found");
         return array();
     }
     return $itemsData;
 }
예제 #8
0
 /**
  * @param KalturaDistributionJobData $data
  * @param KalturaExampleDistributionProfile $distributionProfile
  * @param KalturaExampleDistributionJobProviderData $providerData
  */
 protected function handleUpdate(KalturaDistributionJobData $data, KalturaExampleDistributionProfile $distributionProfile, KalturaExampleDistributionJobProviderData $providerData)
 {
     $entryId = $data->entryDistribution->entryId;
     $partnerId = $distributionProfile->partnerId;
     $entry = $this->getEntry($partnerId, $entryId);
     $feed = new KDOMDocument();
     $feed->load($this->updateXmlTemplate);
     $feed->documentElement->setAttribute('mediaId', $data->remoteId);
     $nodes = array('title' => 'name', 'description' => 'description', 'width' => 'width', 'height' => 'height');
     foreach ($nodes as $nodeName => $entryAttribute) {
         $nodeElements = $feed->getElementsByTagName($nodeName);
         foreach ($nodeElements as $nodeElement) {
             $nodeElement->textContent = $entry->{$entryAttribute};
         }
     }
     // get the first asset id
     $thumbAssetIds = explode(',', $data->entryDistribution->thumbAssetIds);
     $thumbAssetId = reset($thumbAssetIds);
     $thumbElements = $feed->getElementsByTagName('thumb');
     $thumbElement = reset($thumbElements);
     $thumbElement->textContent = $this->getThumbAssetUrl($thumbAssetId);
     $videosElements = $feed->getElementsByTagName('videos');
     $videosElement = reset($videosElements);
     $flavorAssets = $this->getFlavorAssets($partnerId, $data->entryDistribution->flavorAssetIds);
     KBatchBase::impersonate($partnerId);
     foreach ($flavorAssets as $flavorAsset) {
         $url = $this->getFlavorAssetUrl($flavorAsset->id);
         $videoElement = $feed->createElement('video');
         $videoElement->textContent = $url;
         $videosElement->appendChild($videoElement);
     }
     KBatchBase::unimpersonate();
     $localFile = tempnam(sys_get_temp_dir(), 'example-update-');
     $feed->save($localFile);
     // loads ftp manager
     $engineOptions = isset(KBatchBase::$taskConfig->engineOptions) ? KBatchBase::$taskConfig->engineOptions->toArray() : array();
     $ftpManager = kFileTransferMgr::getInstance(kFileTransferMgrType::FTP, $engineOptions);
     $ftpManager->login(self::FTP_SERVER_URL, $distributionProfile->username, $distributionProfile->password);
     // put the XML file on the FTP
     $remoteFile = $entryId . '.xml';
     $ftpManager->putFile($remoteFile, $localFile);
     return true;
 }
 /**
  * Load XML file
  * @param DropFolder $folder
  * @param DropFolderFile $file
  * @throws Exception
  */
 private function getContentResources(DropFolder $folder, DropFolderFile $file)
 {
     KalturaLog::debug('Parsing content resources from Xml');
     $contentResources = array();
     $engineOptions = array('useCmd' => false, 'asperaTempFolder' => kConf::get('temp_folder') . '/aspera_upload');
     $fileTransferManager = kFileTransferMgr::getInstance($folder->getFileTransferMgrType(), $engineOptions);
     $loginStatus = $folder->loginByCredentialsType($fileTransferManager);
     if ($fileTransferManager->fileSize($folder->getPath() . '/' . $file->getFileName()) > kDropFolderXmlEventsConsumer::MAX_XML_FILE_SIZE) {
         throw new Exception(DropFolderXmlBulkUploadPlugin::XML_FILE_SIZE_EXCEED_LIMIT_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::XML_FILE_SIZE_EXCEED_LIMIT));
     }
     $xmlPath = $folder->getLocalFilePath($file->getFileName(), $file->getId(), $fileTransferManager);
     KalturaLog::debug('Local XML path [' . $xmlPath . ']');
     $xmlContent = $this->getOriginalOrTransformIfNeeded($folder, $xmlPath);
     $xmlDoc = new KDOMDocument();
     $res = $xmlDoc->loadXML($xmlContent);
     $localResourceNodes = $xmlDoc->getElementsByTagName(kDropFolderXmlEventsConsumer::DROP_FOLDER_RESOURCE_NODE_NAME);
     foreach ($localResourceNodes as $localResourceNode) {
         $contentResources[] = $localResourceNode->getAttribute(kDropFolderXmlEventsConsumer::DROP_FOLDER_RESOURCE_PATH_ATTRIBUTE);
     }
     return $contentResources;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshowId = $this->getP("kshow_id");
     $numberOfVersions = $this->getP("number_of_versions", 5);
     // must be int and not more than 50
     $numberOfVersions = (int) $numberOfVersions;
     $numberOfVersions = min($numberOfVersions, 50);
     $kshow = kshowPeer::retrieveByPK($kshowId);
     if (!$kshow) {
         $this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS);
         return;
     }
     $showEntry = $kshow->getShowEntry();
     if (!$showEntry) {
         $this->addError(APIErrors::ROUGHCUT_NOT_FOUND);
         return;
     }
     $sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     $showEntryDataPath = kFileSyncUtils::getLocalFilePathForKey($sync_key);
     $versionsInfoFilePath = $showEntryDataPath . '.info';
     $lastVersionDoc = new KDOMDocument();
     $lastVersionDoc->loadXML(kFileSyncUtils::file_get_contents($sync_key, true, false));
     $lastVersion = myContentStorage::getVersion($showEntryDataPath);
     // check if we need to refresh the data in the info file
     $refreshInfoFile = true;
     if (file_exists($versionsInfoFilePath)) {
         $versionsInfoDoc = new KDOMDocument();
         $versionsInfoDoc->load($versionsInfoFilePath);
         $lastVersionInInfoFile = kXml::getLastElementAsText($versionsInfoDoc, "ShowVersion");
         if ($lastVersionInInfoFile && $lastVersion == $lastVersionInInfoFile) {
             $refreshInfoFile = false;
         } else {
             $refreshInfoFile = true;
         }
     } else {
         $refreshInfoFile = true;
     }
     // refresh or create the data in the info file
     if ($refreshInfoFile) {
         $versionsInfoDoc = new KDOMDocument();
         $xmlElement = $versionsInfoDoc->createElement("xml");
         // start from the first edited version (100001) and don't use 100000
         for ($i = myContentStorage::MIN_OBFUSCATOR_VALUE + 1; $i <= $lastVersion; $i++) {
             $version_sync_key = $showEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $i);
             if (kFileSyncUtils::file_exists($version_sync_key, false)) {
                 $xmlContent = kFileSyncUtils::file_get_contents($version_sync_key);
                 //echo "[" . htmlspecialchars( $xmlContent ) . "]<br>";
                 $xmlDoc = new KDOMDocument();
                 $xmlDoc->loadXML($xmlContent);
                 $elementToCopy = kXml::getFirstElement($xmlDoc, "MetaData");
                 //echo "[$i]";
                 $elementCloned = $elementToCopy->cloneNode(true);
                 $elementImported = $versionsInfoDoc->importNode($elementCloned, true);
                 $xmlElement->appendChild($elementImported);
             }
         }
         $versionsInfoDoc->appendChild($xmlElement);
         kFile::setFileContent($versionsInfoFilePath, $versionsInfoDoc->saveXML());
         // FileSync OK - created a temp file on DC's disk
     }
     $metadataNodes = $versionsInfoDoc->getElementsByTagName("MetaData");
     $count = 0;
     $versionsInfo = array();
     for ($i = $metadataNodes->length - 1; $i >= 0; $i--) {
         $metadataNode = $metadataNodes->item($i);
         $node = kXml::getFirstElement($metadataNode, "ShowVersion");
         $showVersion = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "PuserId");
         $puserId = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "ScreenName");
         $screenName = $node ? $node->nodeValue : "";
         $node = kXml::getFirstElement($metadataNode, "UpdatedAt");
         $updatedAt = $node ? $node->nodeValue : "";
         $versionsInfo[] = array("version" => $showVersion, "puserId" => $puserId, "screenName" => $screenName, "updatedAt" => $updatedAt);
         $count++;
         if ($count >= $numberOfVersions) {
             break;
         }
     }
     $this->addMsg("show_versions", $versionsInfo);
 }
 public function handle()
 {
     $this->tempDirectory = sys_get_temp_dir();
     if (!is_dir($this->tempDirectory)) {
         KalturaLog::err('Missing temporary directory');
         return false;
     }
     // check prerequisites
     $checkConfig = $this->checkConfig();
     if (!$checkConfig) {
         KalturaLog::err('Missing required configurations');
         return false;
     }
     $this->fileTransferMgr = DropFolderBatchUtils::getFileTransferManager($this->dropFolder);
     if (!$this->fileTransferMgr) {
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::INTERNAL_ERROR;
         $this->dropFolderFile->errorDescription = 'Internal server error - cannot initiate file transfer manager';
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         return false;
     }
     $xmlPath = $this->getLocalXmlFilePath();
     if (!$xmlPath) {
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::ERROR_READING_FILE;
         $this->dropFolderFile->errorDescription = 'Cannot read file at path [' . $this->dropFolder->path . '/' . $this->dropFolderFile->fileName . ']';
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         return false;
     }
     $xmlDoc = new KDOMDocument();
     $xmlDoc->load($xmlPath);
     if (!$xmlDoc) {
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::ERROR_READING_FILE;
         $this->dropFolderFile->errorDescription = "Cannot parse XML file at [{$xmlPath}]";
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         return false;
     }
     $localResources = $xmlDoc->getElementsByTagName(self::DROP_FOLDER_RESOURCE_NODE_NAME);
     if (!$localResources) {
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::ERROR_READING_FILE;
         $this->dropFolderFile->errorDescription = "Cannot parse XML file at [{$xmlPath}]";
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         return false;
     }
     $replaceResources = array();
     $localResourcesLength = $localResources->length;
     foreach ($localResources as $local) {
         // already have drop folder file id
         if (!is_null($this->getDropFolderFileId($local))) {
             continue;
         }
         // replacement/modification of $local must not happen inside this foreach loop
         $dropFolderFileId = $this->checkFileExists($local);
         if (is_null($dropFolderFileId)) {
             KalturaLog::debug('Some required files do not exist in the drop folder - changing status to WAITING');
             $this->dropFolderFile->status = KalturaDropFolderFileStatus::WAITING;
             KalturaLog::debug('Changing status to WAITING');
             $this->updateDropFolderFile();
             return false;
         }
         $localVerified = $this->verifyLocalResource($local);
         if (!$localVerified) {
             $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
             // error code and description already set
             KalturaLog::err($this->dropFolderFile->errorDescription);
             $this->updateDropFolderFile();
             return false;
         }
         $replaceResources[] = array($local, $dropFolderFileId);
     }
     foreach ($replaceResources as $replace) {
         $this->replaceResource($replace[0], $replace[1], $xmlDoc);
     }
     // create a temporary XML file from the modified $xmlDoc
     $tempFile = $this->tempDirectory . DIRECTORY_SEPARATOR . uniqid() . '_' . $this->dropFolderFile->fileName;
     $xmlDoc->save($tempFile);
     $tempFileRealPath = realpath($tempFile);
     if (!$tempFileRealPath || !is_file($tempFileRealPath)) {
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::ERROR_WRITING_TEMP_FILE;
         $this->dropFolderFile->errorDescription = "Error writing temporary file [{$tempFileRealPath}]";
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         return false;
     }
     $conversionProfile = $this->getConversionProfile();
     // add bulk upload of type KalturaBulkUploadType::DROP_FOLDER_XML
     try {
         $this->impersonate($this->dropFolderFile->partnerId);
         $this->kClient->bulkUpload->add($conversionProfile->id, $tempFileRealPath, KalturaBulkUploadType::DROP_FOLDER_XML, $this->uploadedBy, $this->dropFolderFile->fileName);
         $this->unimpersonate();
     } catch (Exception $e) {
         $this->unimpersonate();
         $this->dropFolderFile->status = KalturaDropFolderFileStatus::ERROR_HANDLING;
         $this->dropFolderFile->errorCode = KalturaDropFolderFileErrorCode::ERROR_ADDING_BULK_UPLOAD;
         $this->dropFolderFile->errorDescription = 'Error adding bulk upload - ' . $e->getMessage();
         KalturaLog::err($this->dropFolderFile->errorDescription);
         $this->updateDropFolderFile();
         KalturaLog::err($this->dropFolderFile->errorDescription);
         return false;
     }
     //delete the temporary file
     @unlink($tempFileRealPath);
     $dropFolderFilePlugin = KalturaDropFolderClientPlugin::get($this->kClient);
     $dropFolderFilePlugin->dropFolderFile->updateStatus($this->dropFolderFile->id, KalturaDropFolderFileStatus::HANDLED);
     KalturaLog::debug('Drop folder file [' . $this->dropFolderFile->id . '] handled successfully');
     return true;
     // file handled
 }