private function saveIfShouldScan($flavorAsset) { if (!PermissionPeer::isAllowedPlugin(VirusScanPlugin::PLUGIN_NAME, $flavorAsset->getPartnerId())) { return false; } if (isset(self::$flavorAssetIdsToScan[$flavorAsset->getId()])) { return true; } $profile = VirusScanProfilePeer::getSuitableProfile($flavorAsset->getEntryId()); if ($profile) { self::$flavorAssetIdsToScan[$flavorAsset->getId()] = $profile; return true; } return false; }
/** * 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(); }