Exemplo n.º 1
0
function deleteObject(FileSync $fileSync)
{
    $object = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
    $key = $object->getSyncKey($fileSync->getObjectSubType());
    if ($key->version != $fileSync->getVersion()) {
        return;
    }
    switch ($fileSync->getObjectType()) {
        case FileSyncObjectType::UICONF:
            $object->setStatus(uiConf::UI_CONF_STATUS_DELETED);
            $object->save();
            break;
        case FileSyncObjectType::ENTRY:
            myEntryUtils::deleteEntry($object);
            try {
                $wrapper = objectWrapperBase::getWrapperClass($object);
                $wrapper->removeFromCache("entry", $object->getId());
            } catch (Exception $e) {
                KalturaLog::err($e);
            }
            break;
        case FileSyncObjectType::ASSET:
            $object->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
            $object->setDeletedAt(time());
            $object->save();
            break;
        case FileSyncObjectType::METADATA:
            $object->setStatus(Metadata::STATUS_DELETED);
            $object->save();
            break;
        default:
            return;
    }
    if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_LINK) {
        return;
    }
    $criteria = new Criteria();
    $criteria->add(FileSyncPeer::DC, $fileSync->getDc());
    $criteria->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_LINK);
    $criteria->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
    $links = FileSyncPeer::doSelect($criteria);
    foreach ($links as $link) {
        deleteObject($link);
    }
}
Exemplo n.º 2
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $prefix = $this->getObjectPrefix();
     $entry_id_to_delete = $this->getPM("{$prefix}_id");
     $kshow_id_for_entry_id_to_delete = $this->getP("kshow_id");
     $c = $this->getCriteria();
     if ($c == null) {
         $entry_to_delete = entryPeer::retrieveByPK($entry_id_to_delete);
     } else {
         $entry_to_delete = entryPeer::doSelectOne($c);
     }
     if (!$entry_to_delete) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, $prefix, $entry_id_to_delete);
         return;
     }
     if ($kshow_id_for_entry_id_to_delete != null) {
         // match the kshow_id
         if ($kshow_id_for_entry_id_to_delete != $entry_to_delete->getKshowId()) {
             $this->addError(APIErrors::CANNOT_DELETE_ENTRY, $entry_id_to_delete, $kshow_id_for_entry_id_to_delete);
             return;
         }
     }
     myEntryUtils::deleteEntry($entry_to_delete);
     /*
     	All move into myEntryUtils::deleteEntry
     
     	$entry_to_delete->setStatus ( entryStatus::DELETED );
     	
     	// make sure the moderation_status is set to moderation::MODERATION_STATUS_DELETE
     	$entry_to_delete->setModerationStatus ( moderation::MODERATION_STATUS_DELETE ); 
     	$entry_to_delete->setModifiedAt( time() ) ;
     	$entry_to_delete->save();
     	
     	myNotificationMgr::createNotification( kNotificationJobData::NOTIFICATION_TYPE_ENTRY_DELETE , $entry_to_delete );
     */
     $this->addMsg("deleted_" . $prefix, objectWrapperBase::getWrapperClass($entry_to_delete, objectWrapperBase::DETAIL_LEVEL_REGULAR));
 }
Exemplo n.º 3
0
 protected function deleteEntry($entryId, $entryType = null)
 {
     $entryToDelete = entryPeer::retrieveByPK($entryId);
     if (!$entryToDelete || $entryType !== null && $entryToDelete->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     myEntryUtils::deleteEntry($entryToDelete);
     try {
         $wrapper = objectWrapperBase::getWrapperClass($entryToDelete);
         $wrapper->removeFromCache("entry", $entryToDelete->getId());
     } catch (Exception $e) {
         KalturaLog::err($e);
     }
 }
Exemplo n.º 4
0
 protected function updatedVirusScanFinished(BatchJob $dbBatchJob, kVirusScanJobData $data, BatchJob $twinJob = null)
 {
     $flavorAsset = flavorAssetPeer::retrieveById($data->getFlavorAssetId());
     if (!$flavorAsset) {
         KalturaLog::err('Flavor asset not found with id [' . $data->getFlavorAssetId() . ']');
         throw new Exception('Flavor asset not found with id [' . $data->getFlavorAssetId() . ']');
     }
     switch ($data->getScanResult()) {
         case KalturaVirusScanJobResult::FILE_WAS_CLEANED:
         case KalturaVirusScanJobResult::FILE_IS_CLEAN:
             $this->resumeEvents($flavorAsset);
             break;
         case KalturaVirusScanJobResult::FILE_INFECTED:
             $entry = $flavorAsset->getentry();
             if (!$entry) {
                 KalturaLog::err('Entry not found with id [' . $entry->getId() . ']');
             } else {
                 $entry->setStatus(VirusScanPlugin::getEntryStatusCoreValue(VirusScanEntryStatus::INFECTED));
                 $entry->save();
             }
             // delete flavor asset and entry if defined in virus scan profile
             if ($data->getVirusFoundAction() == KalturaVirusFoundAction::CLEAN_DELETE || $data->getVirusFoundAction() == KalturaVirusFoundAction::DELETE) {
                 $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                 $filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
                 KalturaLog::debug('FlavorAsset [' . $flavorAsset->getId() . '] marked as deleted');
                 $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
                 $flavorAsset->setDeletedAt(time());
                 $flavorAsset->save();
                 KalturaLog::debug('Physically deleting file [' . $filePath . ']');
                 unlink($filePath);
                 if ($entry) {
                     myEntryUtils::deleteEntry($entry);
                 }
             } else {
                 $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
                 $flavorAsset->save();
             }
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $entry);
             // do not resume flavor asset added event consumption
             break;
     }
     return $dbBatchJob;
 }
Exemplo n.º 5
0
 /**
  * @param entry $entry
  * @param entry $tempEntry
  */
 public static function replaceEntry(entry $entry, entry $tempEntry = null)
 {
     if (!$tempEntry) {
         $tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId());
     }
     if (!$tempEntry) {
         KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found");
         return;
     }
     //Extract all assets of the temp entry
     $tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId());
     //Extract all assets of the existing entry
     $oldAssets = assetPeer::retrieveByEntryId($entry->getId());
     $newAssets = array();
     //Loop which creates a mapping between the new assets' paramsId and their type to the asset itself
     foreach ($tempAssets as $newAsset) {
         if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) {
             KalturaLog::info("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]");
             continue;
         }
         //If doesn't exist - create a new array for the current asset's type.
         if (!isset($newAssets[$newAsset->getType()])) {
             $newAssets[$newAsset->getType()] = array();
         }
         if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
             $newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
             KalturaLog::info("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
         } else {
             $newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
             KalturaLog::info("Added new asset [" . $newAsset->getId() . "] with no asset params");
         }
     }
     $defaultThumbAssetNew = null;
     $defaultThumbAssetOld = null;
     foreach ($oldAssets as $oldAsset) {
         /* @var $oldAsset asset */
         //If the newAssets map contains an asset of the same type and paramsId as the current old asset,
         // re-link the old asset to the new asset.
         if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
             $newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
             if ($oldAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) {
                 $newAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR));
             }
             /* @var $newAsset asset */
             KalturaLog::info("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
             $oldAsset->linkFromAsset($newAsset);
             $oldAsset->save();
             self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISM);
             self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISMC);
             self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_MPD);
             $newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
             if ($newFlavorMediaInfo) {
                 $oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
                 $oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
                 $oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
                 $oldFlavorNewMediaInfo->save();
             }
             unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
             if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                 $defaultThumbAssetNew = $oldAsset;
                 KalturaLog::info("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
             }
         } elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
             if ($oldAsset instanceof thumbAsset && $oldAsset->keepOnEntryReplacement()) {
                 KalturaLog::info("KeepManualThumbnails ind is set, manual thumbnail is not deleted [" . $oldAsset->getId() . "]");
                 if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                     $defaultThumbAssetOld = $oldAsset;
                 }
             } else {
                 KalturaLog::info("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
                 $oldAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
                 $oldAsset->setDeletedAt(time());
                 $oldAsset->save();
             }
         }
     }
     foreach ($newAssets as $newAssetsByTypes) {
         foreach ($newAssetsByTypes as $newAsset) {
             $createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
             KalturaLog::info("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
             if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                 $defaultThumbAssetNew = $newAsset;
                 KalturaLog::info("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
             }
         }
     }
     if ($defaultThumbAssetOld) {
         KalturaLog::info("Kepping ThumbAsset [" . $defaultThumbAssetOld->getId() . "] as the default ThumbAsset");
     } elseif ($defaultThumbAssetNew) {
         kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
         KalturaLog::info("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset");
     } else {
         KalturaLog::info("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]");
         $entry->setThumbnail(".jpg");
         // thumbnailversion++
         $entry->save();
         $tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         $realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey);
     }
     self::createIsmManifestFileSyncLinkFromReplacingEntry($tempEntry, $entry);
     $entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight());
     $entry->setLengthInMsecs($tempEntry->getLengthInMsecs());
     $entry->setConversionProfileId($tempEntry->getConversionProfileId());
     $entry->setConversionQuality($tempEntry->getConversionQuality());
     $entry->setReplacingEntryId(null);
     $entry->setReplacementStatus(entryReplacementStatus::NONE);
     $entry->setReplacementOptions(null);
     $entry->setStatus($tempEntry->getStatus());
     $entry->save();
     //flush deffered events to re-index sphinx before temp entry deletion
     kEventsManager::flushEvents();
     kBusinessConvertDL::checkForPendingLiveClips($entry);
     kEventsManager::raiseEvent(new kObjectReplacedEvent($entry, $tempEntry));
     myEntryUtils::deleteEntry($tempEntry, null, true);
     $te = new TrackEntry();
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY);
     $te->setEntryId($entry->getId());
     $te->setParam1Str($tempEntry->getId());
     $te->setDescription(__METHOD__ . "[" . __LINE__ . "]");
     TrackEntry::addTrackEntry($te);
 }
Exemplo n.º 6
0
 protected static function deleteErrorEntries()
 {
     $criteria = new Criteria();
     $criteria->add(entryPeer::STATUS, array(entryStatus::READY, entryStatus::DELETED), Criteria::NOT_IN);
     $criteria->add(entryPeer::UPDATED_AT, self::$errObjectsUpdatedAt, Criteria::LESS_THAN);
     $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . entryPeer::UPDATED_AT . '))');
     $stmt = entryPeer::doSelectStmt($criteria);
     $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
     if (!count($mins)) {
         return;
     }
     $errObjectsUpdatedAtStart = reset($mins);
     if (is_null($errObjectsUpdatedAtStart)) {
         return;
     }
     $errObjectsUpdatedAtEnd = min(self::$errObjectsUpdatedAt, $errObjectsUpdatedAtStart + 60 * 60 * 24 * 30);
     // month
     $criteria = new Criteria();
     $criteria->add(entryPeer::STATUS, array(entryStatus::READY, entryStatus::DELETED), Criteria::NOT_IN);
     $criteria->add(entryPeer::UPDATED_AT, $errObjectsUpdatedAtStart, Criteria::GREATER_EQUAL);
     $criteria->addAnd(entryPeer::UPDATED_AT, $errObjectsUpdatedAtEnd, Criteria::LESS_THAN);
     $criteria->addDescendingOrderByColumn(entryPeer::LENGTH_IN_MSECS);
     $criteria->setLimit(self::$queryLimit);
     $entries = entryPeer::doSelect($criteria);
     foreach ($entries as $entry) {
         /* @var $entry entry */
         KalturaLog::info("Deleting entry [" . $entry->getId() . "]");
         try {
             myEntryUtils::deleteEntry($entry);
         } catch (Exception $e) {
             KalturaLog::err($e);
         }
     }
     self::incrementSummary('entry', count($entries));
     kMemoryManager::clearMemory();
 }
Exemplo n.º 7
0
 protected function deleteEntry($entryId, $entryType = null)
 {
     $entryToDelete = entryPeer::retrieveByPK($entryId);
     if (!$entryToDelete || $entryType !== null && $entryToDelete->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $this->checkIfUserAllowedToUpdateEntry($entryToDelete);
     myEntryUtils::deleteEntry($entryToDelete);
     /*
     	All move into myEntryUtils::deleteEntry
     
     	$entryToDelete->setStatus(entryStatus::DELETED); 
     	KalturaLog::log("KalturaEntryService::delete Entry [$entryId] Partner [" . $entryToDelete->getPartnerId() . "]");
     	
     	// make sure the moderation_status is set to moderation::MODERATION_STATUS_DELETE
     	$entryToDelete->setModerationStatus(moderation::MODERATION_STATUS_DELETE); 
     	$entryToDelete->setModifiedAt(time());
     	$entryToDelete->save();
     	
     	myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_DELETE, $entryToDelete);
     */
     $wrapper = objectWrapperBase::getWrapperClass($entryToDelete);
     $wrapper->removeFromCache("entry", $entryToDelete->getId());
 }
Exemplo n.º 8
0
 /**
  * @param entry $tempEntry
  */
 public static function handleEntryReplacement(entry $tempEntry)
 {
     $entry = entryPeer::retrieveByPK($tempEntry->getReplacedEntryId());
     if (!$entry) {
         KalturaLog::err("Real entry id [" . $tempEntry->getReplacedEntryId() . "] not found");
         myEntryUtils::deleteEntry($tempEntry, null, true);
         return;
     }
     if ($tempEntry->getStatus() == entryStatus::ERROR_CONVERTING) {
         $entry->setReplacementStatus(entryReplacementStatus::FAILED);
         $entry->save();
         // NOTE: KalturaEntryService::cancelReplace() must be used to reset this status and delete the temp entry
         return;
     }
     switch ($entry->getReplacementStatus()) {
         case entryReplacementStatus::APPROVED_BUT_NOT_READY:
             KalturaLog::log("status changed to ready");
             kEventsManager::raiseEventDeferred(new kObjectReadyForReplacmentEvent($tempEntry));
             break;
         case entryReplacementStatus::READY_BUT_NOT_APPROVED:
             break;
         case entryReplacementStatus::NOT_READY_AND_NOT_APPROVED:
             $entry->setReplacementStatus(entryReplacementStatus::READY_BUT_NOT_APPROVED);
             $entry->save();
             break;
         case entryReplacementStatus::FAILED:
             // Do nothing. KalturaEntryService::cancelReplace() will be used to delete the entry.
             break;
         case entryReplacementStatus::NONE:
         default:
             KalturaLog::err("Real entry id [" . $tempEntry->getReplacedEntryId() . "] replacement canceled");
             myEntryUtils::deleteEntry($tempEntry, null, true);
             break;
     }
 }
 public function moderate($new_moderation_status, $fix_moderation_objects = false)
 {
     $error_msg = "Moderation status [{$new_moderation_status}] not supported by entry";
     switch ($new_moderation_status) {
         case moderation::MODERATION_STATUS_APPROVED:
             // a new notification that is sent when an entry was founc to be ok after moderation
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $this);
             break;
         case moderation::MODERATION_STATUS_BLOCK:
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_BLOCK, $this->getid());
             break;
         case moderation::MODERATION_STATUS_DELETE:
             // physical disk deletion
             myEntryUtils::deleteEntry($this);
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_BLOCK, $this->getid());
             break;
         case moderation::MODERATION_STATUS_PENDING:
             //				$this->setStatus(entryStatus::MODERATE);
             //				throw new Exception($error_msg);
             break;
         case moderation::MODERATION_STATUS_REVIEW:
             // in this case the status of the entry should not change
             //				throw new Exception($error_msg);
             break;
         default:
             throw new Exception($error_msg);
             break;
     }
     $this->setModerationStatus($new_moderation_status);
     // TODO - fix loop of updating from entry ot moderation back to entry ...
     if ($fix_moderation_objects) {
         myModerationMgr::updateModerationsForObject($this, $new_moderation_status);
     }
     $this->save();
 }
 /**
  * @param entry $entry
  * @param entry $tempEntry
  */
 public static function replaceEntry(entry $entry, entry $tempEntry = null)
 {
     KalturaLog::debug("in replaceEntry");
     if (!$tempEntry) {
         $tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId());
     }
     if (!$tempEntry) {
         KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found");
         return;
     }
     //Extract all assets of the temp entry
     $tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId());
     //Extract all assets of the existing entry
     $oldAssets = assetPeer::retrieveByEntryId($entry->getId());
     KalturaLog::debug("num of old assets: " . count($oldAssets));
     $newAssets = array();
     //Loop which creates a mapping between the new assets' paramsId and their type to the asset itself
     foreach ($tempAssets as $newAsset) {
         if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) {
             KalturaLog::debug("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]");
             continue;
         }
         //If doesn't exist - create a new array for the current asset's type.
         if (!isset($newAssets[$newAsset->getType()])) {
             $newAssets[$newAsset->getType()] = array();
         }
         if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
             $newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
             KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
         } else {
             $newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
             KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] with no asset params");
         }
     }
     $saveEntry = false;
     $defaultThumbAssetNew = null;
     foreach ($oldAssets as $oldAsset) {
         /* @var $oldAsset asset */
         kFileSyncUtils::clearWAMSDataForKey($oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET));
         //If the newAssets map contains an asset of the same type and paramsId as the current old asset,
         // re-link the old asset to the new asset.
         if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
             $newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
             /* @var $newAsset asset */
             KalturaLog::debug("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
             if ($oldAsset instanceof flavorAsset) {
                 $oldAsset->setBitrate($newAsset->getBitrate());
                 $oldAsset->setFrameRate($newAsset->getFrameRate());
                 $oldAsset->setVideoCodecId($newAsset->getVideoCodecId());
             }
             $oldAsset->setWidth($newAsset->getWidth());
             $oldAsset->setHeight($newAsset->getHeight());
             $oldAsset->setContainerFormat($newAsset->getContainerFormat());
             $oldAsset->setSize($newAsset->getSize());
             $oldAsset->setFileExt($newAsset->getFileExt());
             $oldAsset->setTags($newAsset->getTags());
             $oldAsset->setDescription($newAsset->getDescription());
             $oldAsset->incrementVersion();
             $oldAsset->setStatusLocalReady();
             $oldAsset->save();
             $oldFileSync = $oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             $newFileSync = $newAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             kFileSyncUtils::createSyncFileLinkForKey($oldFileSync, $newFileSync);
             $newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
             if ($newFlavorMediaInfo) {
                 $oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
                 $oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
                 $oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
                 $oldFlavorNewMediaInfo->save();
             }
             unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
             if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                 $defaultThumbAssetNew = $oldAsset;
                 KalturaLog::debug("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
             }
         } elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
             KalturaLog::debug("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
             $oldAsset->setStatus(flavorAsset::ASSET_STATUS_DELETED);
             $oldAsset->setDeletedAt(time());
             $oldAsset->save();
             $entry->removeFlavorParamsId($oldAsset->getFlavorParamsId());
             $saveEntry = true;
         }
     }
     foreach ($newAssets as $newAssetsByTypes) {
         foreach ($newAssetsByTypes as $newAsset) {
             $createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
             KalturaLog::debug("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
             if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
                 $defaultThumbAssetNew = $newAsset;
                 KalturaLog::debug("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
             }
         }
     }
     if ($defaultThumbAssetNew) {
         kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
         kalturalog::debug("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset");
     } else {
         kalturalog::debug("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]");
         $entry->setThumbnail(".jpg");
         // thumbnailversion++
         $entry->save();
         $tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         $realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
         kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey);
     }
     $entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight());
     $entry->setLengthInMsecs($tempEntry->getLengthInMsecs());
     $entry->setConversionProfileId($tempEntry->getConversionProfileId());
     $entry->setConversionQuality($tempEntry->getConversionQuality());
     $entry->setReplacingEntryId(null);
     $entry->setReplacementStatus(entryReplacementStatus::NONE);
     $entry->setStatus($tempEntry->getStatus());
     $entry->save();
     myEntryUtils::deleteEntry($tempEntry, null, true);
     $te = new TrackEntry();
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY);
     $te->setEntryId($entry->getId());
     $te->setParam1Str($tempEntry->getId());
     $te->setDescription(__METHOD__ . "[" . __LINE__ . "]");
     TrackEntry::addTrackEntry($te);
 }
Exemplo n.º 11
0
 public function updatedJob(BatchJob $dbBatchJob)
 {
     $dbBatchJobLock = $dbBatchJob->getBatchJobLock();
     try {
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
             kJobsManager::abortChildJobs($dbBatchJob);
         }
         $jobType = $dbBatchJob->getJobType();
         switch ($jobType) {
             case BatchJobType::IMPORT:
                 $dbBatchJob = $this->updatedImport($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::EXTRACT_MEDIA:
                 $dbBatchJob = $this->updatedExtractMedia($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT:
                 $dbBatchJob = $this->updatedConvert($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::POSTCONVERT:
                 $dbBatchJob = $this->updatedPostConvert($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::BULKUPLOAD:
                 $dbBatchJob = $this->updatedBulkUpload($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_PROFILE:
                 $dbBatchJob = $this->updatedConvertProfile($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::BULKDOWNLOAD:
                 $dbBatchJob = $this->updatedBulkDownload($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::PROVISION_PROVIDE:
                 $dbBatchJob = $this->updatedProvisionProvide($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::PROVISION_DELETE:
                 $dbBatchJob = $this->updatedProvisionDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_COLLECTION:
                 $dbBatchJob = $this->updatedConvertCollection($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::STORAGE_EXPORT:
                 $dbBatchJob = $this->updatedStorageExport($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::MOVE_CATEGORY_ENTRIES:
                 $dbBatchJob = $this->updatedMoveCategoryEntries($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::STORAGE_DELETE:
                 $dbBatchJob = $this->updatedStorageDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CAPTURE_THUMB:
                 $dbBatchJob = $this->updatedCaptureThumb($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::DELETE_FILE:
                 $dbBatchJob = $this->updatedDeleteFile($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::INDEX:
                 $dbBatchJob = $this->updatedIndex($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::COPY:
                 $dbBatchJob = $this->updatedCopy($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::DELETE:
                 $dbBatchJob = $this->updatedDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONCAT:
                 $dbBatchJob = $this->updatedConcat($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::CONVERT_LIVE_SEGMENT:
                 $dbBatchJob = $this->updatedConvertLiveSegment($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::LIVE_REPORT_EXPORT:
                 $dbBatchJob = $this->updatedLiveReportExport($dbBatchJob, $dbBatchJob->getData());
                 break;
             default:
                 break;
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_RETRY) {
             if ($dbBatchJobLock && $dbBatchJobLock->getExecutionAttempts() >= BatchJobLockPeer::getMaxExecutionAttempts($jobType)) {
                 $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FAILED);
             }
         }
         if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
             $jobEntry = $dbBatchJob->getEntry();
             if ($jobEntry && $jobEntry->getMarkedForDeletion()) {
                 myEntryUtils::deleteEntry($jobEntry, null, true);
             }
         }
     } catch (Exception $ex) {
         self::alert($dbBatchJob, $ex);
         KalturaLog::err("Error:" . $ex->getMessage());
     }
     return true;
 }
 /**
  * Cancels media replacement
  *
  * @action cancelReplace
  * @param string $entryId Media entry id to cancel
  * @return KalturaMediaEntry The canceled media entry
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 function cancelReplaceAction($entryId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if ($dbEntry->getReplacingEntryId()) {
         $dbTempEntry = entryPeer::retrieveByPK($dbEntry->getReplacingEntryId());
         if ($dbTempEntry) {
             myEntryUtils::deleteEntry($dbTempEntry);
         }
     }
     $dbEntry->setReplacingEntryId(null);
     $dbEntry->setReplacementStatus(entryReplacementStatus::NONE);
     $dbEntry->save();
     return $this->getEntry($entryId, -1, KalturaEntryType::MEDIA_CLIP);
 }
 /**
  * @param entry $tempEntry
  */
 public static function handleEntryReplacement(entry $tempEntry)
 {
     KalturaLog::debug("Handling temp entry id [" . $tempEntry->getId() . "] for real entry id [" . $tempEntry->getReplacedEntryId() . "]");
     $entry = entryPeer::retrieveByPK($tempEntry->getReplacedEntryId());
     if (!$entry) {
         KalturaLog::err("Real entry id [" . $tempEntry->getReplacedEntryId() . "] not found");
         myEntryUtils::deleteEntry($tempEntry, null, true);
         return;
     }
     switch ($entry->getReplacementStatus()) {
         case entryReplacementStatus::APPROVED_BUT_NOT_READY:
             KalturaLog::debug("status changed to ready");
             kEventsManager::raiseEventDeferred(new kObjectReadyForReplacmentEvent($tempEntry));
             break;
         case entryReplacementStatus::READY_BUT_NOT_APPROVED:
             break;
         case entryReplacementStatus::NOT_READY_AND_NOT_APPROVED:
             $entry->setReplacementStatus(entryReplacementStatus::READY_BUT_NOT_APPROVED);
             $entry->save();
             break;
         case entryReplacementStatus::NONE:
         default:
             KalturaLog::err("Real entry id [" . $tempEntry->getReplacedEntryId() . "] replacement canceled");
             myEntryUtils::deleteEntry($tempEntry, null, true);
             break;
     }
 }
Exemplo n.º 14
0
if ($argc != 2) {
    echo "Arguments missing.\n\n";
    echo "Usage: php removePartnerEntries.php {partner id}\n";
    exit;
}
$partnerId = $argv[1];
set_time_limit(0);
ini_set("memory_limit", "1024M");
define('ROOT_DIR', realpath(dirname(__FILE__) . '/../../'));
require_once ROOT_DIR . '/infra/bootstrap_base.php';
require_once ROOT_DIR . '/infra/KAutoloader.php';
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "metadata", "*"));
KAutoloader::setClassMapFilePath('../cache/classMap.cache');
KAutoloader::register();
error_reporting(E_ALL);
KalturaLog::setLogger(new KalturaStdoutLogger());
$typesToDelete = array(entryType::DATA, entryType::DOCUMENT);
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, $partnerId);
$c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN);
$entries = entryPeer::doSelect($c);
foreach ($entries as $entry) {
    KalturaLog::debug("Deletes entry [" . $entry->getId() . "]");
    myEntryUtils::deleteEntry($entry, $partnerId);
}
KalturaLog::debug("Done");
Exemplo n.º 15
0
$updatedAt = time() - $daysOld * 24 * 60 * 60;
chdir(dirname(__FILE__));
require_once dirname(__FILE__) . '/../bootstrap.php';
$typesToDelete = array();
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, 100, Criteria::GREATER_THAN);
$c->add(entryPeer::UPDATED_AT, $updatedAt, Criteria::LESS_THAN);
if (count($typesToDelete)) {
    $c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN);
}
$count = 0;
$entries = entryPeer::doSelect($c);
while ($entries) {
    $count += count($entries);
    foreach ($entries as $entry) {
        kCurrentContext::$ks_partner_id = $entry->getPartnerId();
        kCurrentContext::$partner_id = $entry->getPartnerId();
        kCurrentContext::$master_partner_id = $entry->getPartnerId();
        KalturaLog::debug("Deletes entry [" . $entry->getId() . "]");
        KalturaStatement::setDryRun($dryRun);
        myEntryUtils::deleteEntry($entry, $entry->getPartnerId());
        KalturaStatement::setDryRun(false);
    }
    kEventsManager::flushEvents();
    kMemoryManager::clearMemory();
    $entries = entryPeer::doSelect($c);
}
KalturaLog::debug("Deleted [{$count}] entries");
Exemplo n.º 16
0
 public function postUpdate(PropelPDO $con = null)
 {
     if (!$this->wasObjectSaved()) {
         return;
     }
     if ($this->alreadyInSave) {
         return parent::postUpdate($con);
     }
     $objectUpdated = $this->isModified();
     $objectDeleted = false;
     if ($this->isColumnModified(entryPeer::STATUS) && $this->getStatus() == entryStatus::DELETED) {
         $objectDeleted = true;
     }
     if ($this->isColumnModified(entryPeer::DATA) && $this->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $partner = $this->getPartner();
         if ($partner) {
             $dataArr = explode('.', $this->getData());
             $id = $this->getId();
             if ($id == $partner->getAudioThumbEntryId()) {
                 $partner->setAudioThumbEntryVersion($dataArr[0]);
                 $partner->save();
             }
             if ($id == $partner->getLiveThumbEntryId()) {
                 $partner->setLiveThumbEntryVersion($dataArr[0]);
                 $partner->save();
             }
         }
     }
     $trackColumns = $this->getTrackColumns();
     $changedProperties = array();
     foreach ($trackColumns as $namespace => $trackColumn) {
         if (is_array($trackColumn)) {
             if (isset($this->oldCustomDataValues[$namespace])) {
                 foreach ($trackColumn as $trackCustomData) {
                     if (isset($this->oldCustomDataValues[$namespace][$trackCustomData])) {
                         $column = $trackCustomData;
                         if ($namespace) {
                             $column = "{$namespace}.{$trackCustomData}";
                         }
                         $previousValue = $this->oldCustomDataValues[$namespace][$trackCustomData];
                         $previousValue = is_scalar($previousValue) ? $previousValue : $this->getTrackEntryString($namespace, $trackCustomData, $previousValue);
                         $newValue = $this->getFromCustomData($trackCustomData, $namespace);
                         $newValue = is_scalar($newValue) ? $newValue : $this->getTrackEntryString($namespace, $trackCustomData, $newValue);
                         $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]";
                     }
                 }
             }
         } elseif ($this->isColumnModified($trackColumn)) {
             $column = entryPeer::translateFieldName($trackColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_STUDLYPHPNAME);
             $previousValue = $this->getColumnsOldValue($trackColumn);
             $newValue = $this->getByName($trackColumn, BasePeer::TYPE_COLNAME);
             $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]";
         }
     }
     if ($this->getRedirectEntryId() && array_key_exists('', $this->oldCustomDataValues) && array_key_exists('redirectEntryId', $this->oldCustomDataValues[''])) {
         $redirectEntry = entryPeer::retrieveByPK($this->getRedirectEntryId());
         if ($redirectEntry) {
             $redirectEntry->setModerationStatus($this->getModerationStatus());
             $redirectEntry->save();
         }
     }
     $ret = parent::postUpdate($con);
     if ($objectDeleted) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($this));
         myStatisticsMgr::deleteEntry($this);
         $trackEntry = new TrackEntry();
         $trackEntry->setEntryId($this->getId());
         $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY);
         $trackEntry->setChangedProperties(implode("\n", $changedProperties));
         $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]");
         TrackEntry::addTrackEntry($trackEntry);
         //In case this entry has sub streams assigned to it we should delete them as well
         $subStreamEntries = entryPeer::retrieveChildEntriesByEntryIdAndPartnerId($this->id, $this->partner_id);
         foreach ($subStreamEntries as $subStreamEntry) {
             myEntryUtils::deleteEntry($subStreamEntry);
         }
     }
     if ($objectUpdated) {
         kEventsManager::raiseEvent(new kObjectUpdatedEvent($this));
         if (!$objectDeleted && count($changedProperties)) {
             $trackEntry = new TrackEntry();
             $trackEntry->setEntryId($this->getId());
             $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY);
             $trackEntry->setChangedProperties(implode("\n", $changedProperties));
             $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]");
             TrackEntry::addTrackEntry($trackEntry);
         }
     }
     return $ret;
 }
 public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
 {
     try {
         $jobType = $dbBatchJob->getJobType();
         if (is_null($dbBatchJob->getQueueTime()) && $dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING && $dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_RETRY) {
             $dbBatchJob->setQueueTime(time());
             $dbBatchJob->save();
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
             $dbBatchJob->setFinishTime(time());
             $dbBatchJob->save();
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_RETRY) {
             $dbBatchJob->setCheckAgainTimeout(time() + BatchJobPeer::getCheckAgainTimeout($jobType));
             $dbBatchJob->setQueueTime(null);
             $dbBatchJob->save();
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_ALMOST_DONE) {
             $dbBatchJob->setCheckAgainTimeout(time() + BatchJobPeer::getCheckAgainTimeout($jobType));
             $dbBatchJob->save();
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
             $dbBatchJob->setFinishTime(time());
             $dbBatchJob->save();
             kJobsManager::abortChildJobs($dbBatchJob);
         }
         switch ($jobType) {
             case BatchJobType::IMPORT:
                 $dbBatchJob = $this->updatedImport($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::EXTRACT_MEDIA:
                 $dbBatchJob = $this->updatedExtractMedia($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::CONVERT:
                 $dbBatchJob = $this->updatedConvert($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::POSTCONVERT:
                 $dbBatchJob = $this->updatedPostConvert($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::BULKUPLOAD:
                 $dbBatchJob = $this->updatedBulkUpload($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::CONVERT_PROFILE:
                 $dbBatchJob = $this->updatedConvertProfile($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::BULKDOWNLOAD:
                 $dbBatchJob = $this->updatedBulkDownload($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::PROVISION_PROVIDE:
                 $dbBatchJob = $this->updatedProvisionProvide($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::PROVISION_DELETE:
                 $dbBatchJob = $this->updatedProvisionDelete($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::CONVERT_COLLECTION:
                 $dbBatchJob = $this->updatedConvertCollection($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::STORAGE_EXPORT:
                 $dbBatchJob = $this->updatedStorageExport($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::MOVE_CATEGORY_ENTRIES:
                 $dbBatchJob = $this->updatedMoveCategoryEntries($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::STORAGE_DELETE:
                 $dbBatchJob = $this->updatedStorageDelete($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::CAPTURE_THUMB:
                 $dbBatchJob = $this->updatedCaptureThumb($dbBatchJob, $dbBatchJob->getData(), $twinJob);
                 break;
             case BatchJobType::DELETE_FILE:
                 $dbBatchJob = $this->updatedDeleteFile($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::INDEX:
                 $dbBatchJob = $this->updatedIndex($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::COPY:
                 $dbBatchJob = $this->updatedCopy($dbBatchJob, $dbBatchJob->getData());
                 break;
             case BatchJobType::DELETE:
                 $dbBatchJob = $this->updatedDelete($dbBatchJob, $dbBatchJob->getData());
                 break;
             default:
                 break;
         }
         if (!kConf::get("batch_ignore_duplication")) {
             if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) {
                 $twinBatchJobs = $dbBatchJob->getTwinJobs();
                 // update status at all twin jobs
                 foreach ($twinBatchJobs as $twinBatchJob) {
                     if ($twinBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
                         kJobsManager::updateBatchJob($twinBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
                     }
                 }
             }
         }
         if ($dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_RETRY && $dbBatchJob->getExecutionAttempts() >= BatchJobPeer::getMaxExecutionAttempts($jobType)) {
             $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FAILED);
         }
         if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
             $jobEntry = $dbBatchJob->getEntry();
             if ($jobEntry && $jobEntry->getMarkedForDeletion()) {
                 myEntryUtils::deleteEntry($jobEntry, null, true);
             }
         }
     } catch (Exception $ex) {
         self::alert($dbBatchJob, $ex);
         KalturaLog::err("Error:" . $ex->getMessage());
     }
     return true;
 }