コード例 #1
0
 /**
  * @param flavorAsset $object
  * @return bool true if should continue to the next consumer
  */
 private function addedFlavorAsset(flavorAsset $object)
 {
     if ($object instanceof flavorAsset && $object->getIsOriginal()) {
         if ($this->saveIfShouldScan($object)) {
             $profile = self::$flavorAssetIdsToScan[$object->getId()];
             // suitable virus scan profile found - create scan job
             $syncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             $srcFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
             kVirusScanJobsManager::addVirusScanJob(null, $object->getPartnerId(), $object->getEntryId(), $object->getId(), $srcFilePath, $profile->getEngineType(), $profile->getActionIfInfected());
             return false;
             // pause other event consumers until virus scan job is finished
         }
     }
     return true;
     // no scan jobs to do, object added event consumption may continue normally
 }
 /**
  * Scan flavor asset according to virus scan profile
  * 
  * @action scan
  * @param int $virusScanProfileId
  * @param string $flavorAssetId 
  * @return int job id
  *
  * @throws KalturaErrors::INVALID_OBJECT_ID
  * @throws KalturaErrors::INVALID_FLAVOR_ASSET_ID
  * @throws KalturaErrors::INVALID_FILE_SYNC_ID
  */
 function scanAction($flavorAssetId, $virusScanProfileId = null)
 {
     $dbFlavorAsset = assetPeer::retrieveById($flavorAssetId);
     if (!$dbFlavorAsset) {
         throw new KalturaAPIException(KalturaErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
     }
     if ($virusScanProfileId) {
         $dbVirusScanProfile = VirusScanProfilePeer::retrieveByPK($virusScanProfileId);
     } else {
         $dbVirusScanProfile = VirusScanProfilePeer::getSuitableProfile($dbFlavorAsset->getEntryId());
     }
     if (!$dbVirusScanProfile) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $virusScanProfileId);
     }
     $syncKey = $dbFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $srcFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
     if (!$srcFilePath) {
         throw new KalturaAPIException(KalturaErrors::INVALID_FILE_SYNC_ID, $syncKey);
     }
     $job = kVirusScanJobsManager::addVirusScanJob(null, $dbFlavorAsset->getPartnerId(), $dbFlavorAsset->getEntryId(), $dbFlavorAsset->getId(), $srcFilePath, $dbVirusScanProfile->getEngineType(), $dbVirusScanProfile->getActionIfInfected());
     return $job->getId();
 }