protected static function addImportJob($dc, $entryUrl, asset $asset) { KalturaLog::debug("Importing asset [" . $asset->getId() . "] from dc [{$dc}] with URL [{$entryUrl}]"); $entryUrl = str_replace('//', '/', $entryUrl); $entryUrl = preg_replace('/^((https?)|(ftp)|(scp)|(sftp)):\\//', '$1://', $entryUrl); $jobData = new kImportJobData(); $jobData->setCacheOnly(true); $jobData->setSrcFileUrl($entryUrl); $jobData->setFlavorAssetId($asset->getId()); $batchJob = new BatchJob(); $batchJob->setDc($dc); $batchJob->setEntryId($asset->getEntryId()); $batchJob->setPartnerId($asset->getPartnerId()); return kJobsManager::addJob($batchJob, $jobData, BatchJobType::IMPORT); }
protected static function addImportJob($dc, $entryUrl, asset $asset) { $entryUrl = str_replace('//', '/', $entryUrl); $entryUrl = preg_replace('/^((https?)|(ftp)|(scp)|(sftp)):\\//', '$1://', $entryUrl); $jobData = new kImportJobData(); $jobData->setCacheOnly(true); $jobData->setSrcFileUrl($entryUrl); $jobData->setFlavorAssetId($asset->getId()); $batchJob = new BatchJob(); $batchJob->setDc($dc); $batchJob->setEntryId($asset->getEntryId()); $batchJob->setPartnerId($asset->getPartnerId()); $batchJob->setObjectId($asset->getId()); $batchJob->setObjectType(BatchJobObjectType::ASSET); return kJobsManager::addJob($batchJob, $jobData, BatchJobType::IMPORT); }
public static function addImportJob(BatchJob $parentJob = null, $entryId, $partnerId, $entryUrl, asset $asset = null, $subType = null, kImportJobData $jobData = null, $keepCurrentVersion = false) { $entryUrl = str_replace('//', '/', $entryUrl); $entryUrl = preg_replace('/^((https?)|(ftp)|(scp)|(sftp)):\\//', '$1://', $entryUrl); if (is_null($subType)) { if (stripos($entryUrl, 'sftp:') === 0) { $subType = kFileTransferMgrType::SFTP; } elseif (stripos($entryUrl, 'scp:') === 0) { $subType = kFileTransferMgrType::SCP; } elseif (stripos($entryUrl, 'ftp:') === 0) { $subType = kFileTransferMgrType::FTP; } elseif (stripos($entryUrl, 'https:') === 0) { $subType = kFileTransferMgrType::HTTPS; } else { $subType = kFileTransferMgrType::HTTP; } } if (!$jobData) { $jobData = new kImportJobData(); } $jobData->setSrcFileUrl($entryUrl); if ($asset) { if ($keepCurrentVersion) { if (!$asset->isLocalReadyStatus()) { $asset->setStatus(asset::FLAVOR_ASSET_STATUS_IMPORTING); } } else { $asset->incrementVersion(); $asset->setStatus(asset::FLAVOR_ASSET_STATUS_IMPORTING); } $asset->save(); $jobData->setFlavorAssetId($asset->getId()); } $entry = entryPeer::retrieveByPK($entryId); if ($entry) { $higherStatuses = array(entryStatus::PRECONVERT, entryStatus::READY); if (!in_array($entry->getStatus(), $higherStatuses)) { $entry->setStatus(entryStatus::IMPORT); $entry->save(); } } $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(BatchJobType::IMPORT, $subType); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entryId); $batchJob->setPartnerId($partnerId); } $batchJob->setObjectId($jobData->getFlavorAssetId()); $batchJob->setObjectType(BatchJobObjectType::ASSET); return self::addJob($batchJob, $jobData, BatchJobType::IMPORT, $subType); }
public static function addImportJob(BatchJob $parentJob = null, $entryId, $partnerId, $entryUrl) { $jobData = new kImportJobData(); $jobData->setSrcFileUrl($entryUrl); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entryId); $batchJob->setPartnerId($partnerId); } return self::addJob($batchJob, $jobData, BatchJobType::IMPORT); }