/**
  * @param BaseObject $object
  * @return bool true if should continue to the next consumer
  */
 public function objectAdded(BaseObject $object)
 {
     if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE || $object->getDc() == kDataCenterMgr::getCurrentDcId()) {
         return true;
     }
     $c = new Criteria();
     $c->addAnd(FileSyncPeer::OBJECT_ID, $object->getObjectId());
     $c->addAnd(FileSyncPeer::VERSION, $object->getVersion());
     $c->addAnd(FileSyncPeer::OBJECT_TYPE, $object->getObjectType());
     $c->addAnd(FileSyncPeer::OBJECT_SUB_TYPE, $object->getObjectSubType());
     $c->addAnd(FileSyncPeer::ORIGINAL, '1');
     $original_filesync = FileSyncPeer::doSelectOne($c);
     if (!$original_filesync) {
         KalturaLog::err('Original filesync not found for object_id[' . $object->getObjectId() . '] version[' . $object->getVersion() . '] type[' . $object->getObjectType() . '] subtype[' . $object->getObjectSubType() . ']');
         return true;
     }
     $sourceFileUrl = $original_filesync->getExternalUrl();
     if (!$sourceFileUrl) {
         KalturaLog::err('External URL not found for filesync id [' . $object->getId() . ']');
         return true;
     }
     $job = kMultiCentersManager::addFileSyncImportJob($this->getEntryId($object), $object->getPartnerId(), $object->getId(), $sourceFileUrl);
     $job->setDc($object->getDc());
     $job->save();
     return true;
 }
 public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns)
 {
     if ($object instanceof Metadata && in_array(MetadataPeer::STATUS, $modifiedColumns) && $object->getStatus() == Metadata::STATUS_INVALID) {
         return true;
     }
     return false;
 }
 public function shouldConsumeCreatedEvent(BaseObject $object)
 {
     if ($object instanceof asset && $object->getStatus() == asset::FLAVOR_ASSET_STATUS_READY) {
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 public function shouldConsumeAddedEvent(BaseObject $object)
 {
     if ($object instanceof FileSync && $object->getStatus() == FileSync::FILE_SYNC_STATUS_PENDING && $object->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE && $object->getDc() != kDataCenterMgr::getCurrentDcId() && $this->shouldSyncFileObjectType($object->getObjectType(), $object->getObjectSubType())) {
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 public function shouldConsumeAddedEvent(BaseObject $object)
 {
     if (class_exists('CaptionAsset') && $object instanceof CaptionAsset && CaptionSearchPlugin::isAllowedPartner($object->getPartnerId()) && $object->getStatus() == CaptionAsset::ASSET_STATUS_READY && $object->getLanguage() != CaptionAsset::MULTI_LANGUAGE) {
         return true;
     }
     return false;
 }
 /**
  * @param BaseObject $object
  * @return bool true if should continue to the next consumer
  */
 public function objectCreated(BaseObject $object)
 {
     if ($object instanceof asset && $object->getStatus() == asset::FLAVOR_ASSET_STATUS_READY) {
         return self::onAssetReadyOrDeleted($object);
     }
     return true;
 }
Exemplo n.º 7
0
 public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns)
 {
     try {
         if ($object instanceof DropFolderFile && in_array(DropFolderFilePeer::STATUS, $modifiedColumns)) {
             if ($object->getStatus() == DropFolderFileStatus::PENDING) {
                 $folder = DropFolderPeer::retrieveByPK($object->getDropFolderId());
                 if ($folder->getFileHandlerType() == DropFolderFileHandlerType::CONTENT) {
                     return true;
                 }
             }
         } elseif ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && ($object->getStatus() == entryStatus::READY || $object->getStatus() == entryStatus::ERROR_CONVERTING)) {
             return true;
         }
     } catch (Exception $e) {
         KalturaLog::err('Failed to process shouldConsumeChangedEvent - ' . $e->getMessage());
     }
     return false;
 }
 public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns)
 {
     try {
         if ($object instanceof DropFolderFile && ($object->getStatus() == DropFolderFileStatus::PENDING || $object->getStatus() == DropFolderFileStatus::PURGED) && in_array(DropFolderFilePeer::STATUS, $modifiedColumns)) {
             $folder = DropFolderPeer::retrieveByPK($object->getDropFolderId());
             if (!$folder) {
                 KalturaLog::err('Failed to process shouldConsumeChangedEvent - Failed to retrieve drop folder with ID ' . $object->getDropFolderId());
                 return false;
             }
             if ($folder->getFileHandlerType() == DropFolderXmlBulkUploadPlugin::getFileHandlerTypeCoreValue(DropFolderXmlFileHandlerType::XML)) {
                 return true;
             }
         }
     } catch (Exception $e) {
         KalturaLog::err('Failed to process shouldConsumeChangedEvent - ' . $e->getMessage());
     }
     return false;
 }
Exemplo n.º 9
0
 public static function isTimedThumbAssetChangedToReady(BaseObject $object, array $modifiedColumns)
 {
     if ($object instanceof timedThumbAsset && in_array(assetPeer::STATUS, $modifiedColumns) && $object->getStatus() == asset::ASSET_STATUS_READY) {
         return true;
     }
 }
 public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns)
 {
     if ($object instanceof Permission && $object->getPartnerId() && in_array($object->getType(), self::$partnerLevelPermissionTypes) && in_array(PermissionPeer::STATUS, $modifiedColumns) && $object->getStatus() == PermissionStatus::ACTIVE) {
         return true;
     }
     return false;
 }
Exemplo n.º 11
0
 public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns)
 {
     $noneValidStatuses = array(FileSync::FILE_SYNC_STATUS_DELETED, FileSync::FILE_SYNC_STATUS_PURGED);
     if ($object instanceof FileSync && $object->getLinkCount() && in_array(FileSyncPeer::STATUS, $modifiedColumns) && !in_array($object->getStatus(), $noneValidStatuses)) {
         return true;
     }
     return false;
 }
Exemplo n.º 12
0
 /**
 	Will set the 'display_in_search' field according to business-logic per object type
 	// kuser | kshow | entry
 	// for objects that are search worthy - search_text will hold text from relevant columns depending on the object type 
 */
 public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null)
 {
     if ($obj == null) {
         return;
     }
     // update the displayInSearch with the logic above only when the object is new or null
     if ($obj->isNew() || $obj->getDisplayInSearch() === null) {
         $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId());
         $obj_id = $obj->getId();
         if ($obj_id && is_numeric($obj_id)) {
             self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY);
         }
         if ($res) {
             if ($obj instanceof kuser) {
                 // if the status is not
                 self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE);
             } elseif ($obj instanceof kshow) {
                 self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null);
                 // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else
                 // update all entries
                 if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) {
                     $entries = $obj->getentrys();
                     foreach ($entries as $entry) {
                         // run this code for each entry
                         self::setDisplayInSearch($entry, $obj);
                     }
                 }
             } elseif ($obj instanceof entry) {
                 // status=READY , type=MEDIACLIP, view permissions of kshow
                 self::setRes($res, true);
             } else {
                 throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj));
             }
         }
         $obj->setDisplayInSearch($res);
     } else {
         // if not new - use the value from the object
         $res = $obj->getDisplayInSearch();
     }
     //	echo __METHOD__ . " (" . get_class ( $obj ) . ") res [$res]\n";
     $words = "";
     $fields_to_use = $obj->getColumnNames();
     foreach ($fields_to_use as $field) {
         $field_str = $obj->getByName($field, BasePeer::TYPE_FIELDNAME);
         //  call_user_func ( array ( $obj , $func_name ) );
         $words .= " " . $field_str;
     }
     $extra_invisible_data = null;
     if ($obj instanceof kshow) {
         $type = $obj->getType();
         if (empty($type)) {
             $type = kshow::KSHOW_TYPE_OTHER;
         }
         // add the category to the search
         $words .= " _CAT_" . $type;
     } elseif ($obj instanceof entry) {
         $extra_invisible_data = "_MEDIA_TYPE_" . $obj->getMediaType();
         $type = $obj->getType();
         // add the SEARCH_ENTRY_TYPE_RC to the words
         if ($type == entryType::MIX) {
             $extra_invisible_data .= " " . self::SEARCH_ENTRY_TYPE_RC;
         }
     }
     $prepared_text = self::prepareSearchText($words);
     $partner_id = $obj->getPartnerId();
     // if res == 1 - only for partner , if == 2 - also for kaltura network
     $obj->setSearchText(self::addPartner($partner_id, $prepared_text, $res, $extra_invisible_data));
 }
Exemplo n.º 13
0
 public function objectChanged(BaseObject $object, array $modifiedColumns)
 {
     if ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && ($object->getStatus() == entryStatus::READY || $object->getStatus() == entryStatus::ERROR_CONVERTING) && $object->getReplacedEntryId()) {
         kFlowHelper::handleEntryReplacement($object);
         return true;
     }
     if ($object instanceof UploadToken && in_array(UploadTokenPeer::STATUS, $modifiedColumns) && $object->getStatus() == UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
         kFlowHelper::handleUploadFinished($object);
         return true;
     }
     if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD && $object->getStatus() == BatchJob::BATCHJOB_STATUS_ABORTED && in_array(BatchJobPeer::STATUS, $modifiedColumns) && in_array($object->getColumnsOldValue(BatchJobPeer::STATUS), BatchJobPeer::getClosedStatusList())) {
         $partner = $object->getPartner();
         if ($partner->getEnableBulkUploadNotificationsEmails()) {
             kFlowHelper::sendBulkUploadNotificationEmail($object, MailType::MAIL_TYPE_BULKUPLOAD_ABORTED, array($partner->getAdminName(), $object->getId(), kFlowHelper::createBulkUploadLogUrl($object)));
         }
         return true;
     }
     if ($object instanceof UserRole && in_array(UserRolePeer::PERMISSION_NAMES, $modifiedColumns)) {
         $filter = new kuserFilter();
         $filter->set('_eq_role_ids', $object->getId());
         kJobsManager::addIndexJob($object->getPartnerId(), IndexObjectType::USER, $filter, false);
         return true;
     }
     if ($object instanceof FileSync) {
         $c = new Criteria();
         $c->add(BatchJobLockPeer::OBJECT_ID, $object->getId());
         $c->add(BatchJobLockPeer::OBJECT_TYPE, BatchJobObjectType::FILE_SYNC);
         $c->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::FILESYNC_IMPORT);
         $c->add(BatchJobLockPeer::STATUS, array(BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING), Criteria::IN);
         $fileSyncImportJobs = BatchJobLockPeer::doSelect($c);
         foreach ($fileSyncImportJobs as $fileSyncImportJob) {
             kJobsManager::abortDbBatchJob(BatchJobPeer::retrieveByPK($fileSyncImportJob->getId()));
         }
         return true;
     }
     if (!$object instanceof flavorAsset || !in_array(assetPeer::STATUS, $modifiedColumns)) {
         return true;
     }
     $entry = entryPeer::retrieveByPKNoFilter($object->getEntryId());
     KalturaLog::info("Asset id [" . $object->getId() . "] isOriginal [" . $object->getIsOriginal() . "] status [" . $object->getStatus() . "]");
     if ($object->getIsOriginal()) {
         return true;
     }
     if ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
         $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
         $offset = $entry->getThumbOffset();
         // entry getThumbOffset now takes the partner DefThumbOffset into consideration
         $syncKey = $object->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
         if (!$fileSync) {
             return true;
         }
         $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
         if ($srcFileSyncLocalPath) {
             kJobsManager::addPostConvertJob(null, $postConvertAssetType, $srcFileSyncLocalPath, $object->getId(), null, $entry->getCreateThumb(), $offset);
         }
     } elseif ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
         // If we get a ready flavor and the entry is in no content
         if ($entry->getStatus() == entryStatus::NO_CONTENT) {
             $entry->setStatus(entryStatus::PENDING);
             // we change the entry to pending
             $entry->save();
         }
     }
     return true;
 }
 /**
 	Will set the 'display_in_search' field according to business-logic per object type
 	// kuser | kshow | entry
 	// for objects that are search worthy - search_text will hold text from relevant columns depending on the object type 
 */
 public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null)
 {
     if ($obj == null) {
         return;
     }
     // update the displayInSearch with the logic above only when the object is new or null
     if ($obj->isNew() || $obj->getDisplayInSearch() === null) {
         $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId());
         $obj_id = $obj->getId();
         if ($obj_id && is_numeric($obj_id)) {
             self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY);
         }
         if ($res) {
             if ($obj instanceof kuser) {
                 // if the status is not
                 self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE);
             } elseif ($obj instanceof kshow) {
                 self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null);
                 // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else
                 // update all entries
                 if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) {
                     $entries = $obj->getentrys();
                     foreach ($entries as $entry) {
                         // run this code for each entry
                         self::setDisplayInSearch($entry, $obj);
                     }
                 }
             } elseif ($obj instanceof entry) {
                 // status=READY , type=MEDIACLIP, view permissions of kshow
                 self::setRes($res, true);
             } else {
                 throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj));
             }
         }
         $obj->setDisplayInSearch($res);
     }
 }