public function fromObject($source_object)
 {
     /* @var $source_object CaptionAssetItem */
     $ret = parent::fromObject($source_object);
     $this->asset = new KalturaCaptionAsset();
     $this->asset->fromObject($source_object->getAsset());
     $entry = $source_object->getEntry();
     $this->entry = KalturaEntryFactory::getInstanceByType($entry->getType());
     $this->entry->fromObject($entry);
     return $ret;
 }
Exemplo n.º 2
0
 public static function fromEntryArray($arr, $isAdmin = false)
 {
     $newArr = new KalturaBaseEntryArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         $nObj = KalturaEntryFactory::getInstanceByType($obj->getType(), $isAdmin);
         $nObj->fromObject($obj);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
Exemplo n.º 3
0
 public static function fromDbArray(array $arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaDataEntryArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         $nObj = KalturaEntryFactory::getInstanceByType($obj->getType());
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
Exemplo n.º 4
0
 public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $isAdmin = kCurrentContext::$is_admin_session;
     $newArr = new KalturaBaseEntryArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         $nObj = KalturaEntryFactory::getInstanceByType($obj->getType(), $isAdmin);
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
Exemplo n.º 5
0
 public static function updateThumbnailFromFile($dbEntry, $filePath, $fileSyncType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB)
 {
     $dbEntry->setThumbnail(".jpg");
     // this will increase the thumbnail version
     $dbEntry->save();
     $fileSyncKey = $dbEntry->getSyncKey($fileSyncType);
     $fileSync = FileSync::createForFileSyncKey($fileSyncKey);
     kFileSyncUtils::file_put_contents($fileSyncKey, file_get_contents($filePath));
     $wrapper = objectWrapperBase::getWrapperClass($dbEntry);
     $wrapper->removeFromCache("entry", $dbEntry->getId());
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $dbEntry);
     $mediaEntry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $mediaEntry->fromObject($dbEntry);
     self::disableAutoThumbnailCreation($dbEntry->getId());
     return $mediaEntry;
 }
Exemplo n.º 6
0
 /**
  * Get base entry by ID with no filters.
  * 
  * @action get
  * @param string $entryId Entry id
  * @param int $version Desired version of the data
  * @return KalturaBaseEntry The requested entry
  */
 function getAction($entryId, $version = -1)
 {
     $dbEntries = entryPeer::retrieveByPKsNoFilter(array($entryId));
     if (!count($dbEntries)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbEntry = reset($dbEntries);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if ($version !== -1) {
         $dbEntry->setDesiredVersion($version);
     }
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType(), true);
     $entry->fromObject($dbEntry);
     return $entry;
 }
Exemplo n.º 7
0
 public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null)
 {
     /* @var $source_object CaptionAssetItem */
     $ret = parent::doFromObject($source_object, $responseProfile);
     if ($this->shouldGet('asset', $responseProfile)) {
         $this->asset = new KalturaCaptionAsset();
         $this->asset->fromObject($source_object->getAsset());
     }
     if ($this->shouldGet('entry', $responseProfile)) {
         $entry = $source_object->getEntry();
         if ($entry) {
             $this->entry = KalturaEntryFactory::getInstanceByType($entry->getType());
             $this->entry->fromObject($entry);
         }
     }
     return $ret;
 }
 public static function updateThumbnailFromFile(entry $dbEntry, $filePath, $fileSyncType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB)
 {
     $dbEntry->setThumbnail(".jpg");
     // this will increase the thumbnail version
     $dbEntry->setCreateThumb(false);
     $dbEntry->save();
     $dbEntry->reload();
     $fileSyncKey = $dbEntry->getSyncKey($fileSyncType);
     kFileSyncUtils::file_put_contents($fileSyncKey, file_get_contents($filePath));
     try {
         $wrapper = objectWrapperBase::getWrapperClass($dbEntry);
         $wrapper->removeFromCache("entry", $dbEntry->getId());
     } catch (Exception $e) {
         KalturaLog::err($e);
     }
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $dbEntry);
     // TODO - can't use API objects in core
     $mediaEntry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $mediaEntry->fromObject($dbEntry);
     return $mediaEntry;
 }
Exemplo n.º 9
0
 /**
  *Remove push publish configuration from entry
  * 
  * @action removeLiveStreamPushPublishConfiguration
  * @param string $entryId
  * @param KalturaPlaybackProtocol $protocol
  * @return KalturaLiveStreamEntry
  * @throws KalturaErrors::INVALID_ENTRY_ID
  */
 public function removeLiveStreamPushPublishConfigurationAction($entryId, $protocol)
 {
     $this->dumpApiRequest($entryId);
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry || $entry->getType() != entryType::LIVE_STREAM) {
         throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID);
     }
     /* @var $entry LiveEntry */
     $pushPublishConfigurations = $entry->getPushPublishPlaybackConfigurations();
     foreach ($pushPublishConfigurations as $index => $config) {
         /* @var $config kLiveStreamConfiguration */
         if ($config->getProtocol() == $protocol) {
             unset($pushPublishConfigurations[$index]);
         }
     }
     $entry->setPushPublishPlaybackConfigurations($pushPublishConfigurations);
     $entry->save();
     $apiEntry = KalturaEntryFactory::getInstanceByType($entry->getType());
     $apiEntry->fromObject($entry, $this->getResponseProfile());
     return $apiEntry;
 }
 /**
  * @action export
  * Action for manually exporting an entry
  * @param string $entryId
  * @param int $storageProfileId
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @return KalturaBaseEntry The exported entry
  */
 public function exportAction($entryId, $storageProfileId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbStorageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if (!$dbStorageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $storageProfileId);
     }
     kStorageExporter::exportEntry($dbEntry, $dbStorageProfile);
     //TODO: implement export errors
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry);
     return $entry;
 }
Exemplo n.º 11
0
 /**
  * Restore deleted entry.
  *
  * @action restoreDeletedEntry
  * @param string $entryId
  * @return KalturaBaseEntry The restored entry
  */
 public function restoreDeletedEntryAction($entryId)
 {
     $deletedEntry = entryPeer::retrieveByPKNoFilter($entryId);
     if (!$deletedEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $fileSyncKeys = array();
     foreach (self::$fileSyncKeysToRestore as $key) {
         $fileSyncKeys[] = $deletedEntry->getSyncKey($key);
     }
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entryId, Criteria::EQUAL);
     assetPeer::setUseCriteriaFilter(false);
     $deletedAssets = assetPeer::doSelect($c);
     assetPeer::setUseCriteriaFilter(true);
     foreach ($deletedAssets as $deletedAsset) {
         array_push($fileSyncKeys, $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_CONVERT_LOG));
     }
     $fileSyncs = array();
     FileSyncPeer::setUseCriteriaFilter(false);
     foreach ($fileSyncKeys as $fileSyncKey) {
         $fileSyncs = array_merge($fileSyncs, FileSyncPeer::retrieveAllByFileSyncKey($fileSyncKey));
     }
     FileSyncPeer::setUseCriteriaFilter(true);
     if (!$this->validateEntryForRestoreDelete($deletedEntry, $fileSyncs, $deletedAssets)) {
         throw new KalturaAPIException(KalturaAdminConsoleErrors::ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE, $entryId);
     }
     $this->restoreFileSyncs($fileSyncs);
     //restore assets
     foreach ($deletedAssets as $deletedAsset) {
         $deletedAsset->setStatus(asset::ASSET_STATUS_READY);
         $deletedAsset->save();
     }
     //restore entry
     $deletedEntry->setStatusReady();
     $deletedEntry->setThumbnail($deletedEntry->getFromCustomData("deleted_original_thumb"), true);
     $deletedEntry->setData($deletedEntry->getFromCustomData("deleted_original_data"), true);
     //data should be resotred even if it's NULL
     $deletedEntry->save();
     kEventsManager::flushEvents();
     kMemoryManager::clearMemory();
     $entry = KalturaEntryFactory::getInstanceByType($deletedEntry->getType(), true);
     $entry->fromObject($deletedEntry, $this->getResponseProfile());
     return $entry;
 }
Exemplo n.º 12
0
 /**
  * Unregister media server from live entry
  *
  * @action unregisterMediaServer
  * @param string $entryId Live entry id
  * @param string $hostname Media server host name
  * @param KalturaMediaServerIndex $mediaServerIndex Media server index primary / secondary
  * @return KalturaLiveEntry The updated live entry
  *
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::MEDIA_SERVER_NOT_FOUND
  */
 function unregisterMediaServerAction($entryId, $hostname, $mediaServerIndex)
 {
     $this->dumpApiRequest($entryId);
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || !$dbEntry instanceof LiveEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbEntry->unsetMediaServer($mediaServerIndex, $hostname);
     if (!$dbEntry->hasMediaServer() && $dbEntry->getRecordedEntryId()) {
         $dbEntry->setRedirectEntryId($dbEntry->getRecordedEntryId());
     }
     if (count($dbEntry->getMediaServers()) == 0) {
         // Reset currentBroadcastStartTime
         // Note that this value is set in the media-server, at KalturaLiveManager::onPublish()
         if ($dbEntry->getCurrentBroadcastStartTime()) {
             $dbEntry->setCurrentBroadcastStartTime(0);
         }
     }
     $dbEntry->save();
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
Exemplo n.º 13
0
 /**
  * Unregister media server from live entry
  *
  * @action unregisterMediaServer
  * @param string $entryId Live entry id
  * @param string $hostname Media server host name
  * @param KalturaMediaServerIndex $mediaServerIndex Media server index primary / secondary
  * @return KalturaLiveEntry The updated live entry
  *
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::MEDIA_SERVER_NOT_FOUND
  */
 function unregisterMediaServerAction($entryId, $hostname, $mediaServerIndex)
 {
     $this->dumpApiRequest($entryId);
     KalturaLog::debug("Entry [{$entryId}] from mediaServerIndex [{$mediaServerIndex}] with hostname [{$hostname}]");
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || !$dbEntry instanceof LiveEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbEntry->unsetMediaServer($mediaServerIndex, $hostname);
     if (!$dbEntry->hasMediaServer() && $dbEntry->getRecordedEntryId()) {
         $dbEntry->setRedirectEntryId($dbEntry->getRecordedEntryId());
     }
     if (count($dbEntry->getMediaServers()) == 0) {
         if ($dbEntry->getCurrentBroadcastStartTime()) {
             $dbEntry->setCurrentBroadcastStartTime(0);
         }
     }
     $dbEntry->save();
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
Exemplo n.º 14
0
 /**
  * Get base entry by comma separated entry ids.
  * 
  * @action getByIds
  * @param string $entryIds Comma separated string of entry ids
  * @return KalturaBaseEntryArray Array of base entry ids
  */
 function getByIdsAction($entryIds)
 {
     $entryIdsArray = explode(",", $entryIds);
     // remove white spaces
     foreach ($entryIdsArray as &$entryId) {
         $entryId = trim($entryId);
     }
     $list = entryPeer::retrieveByPKs($entryIdsArray);
     $newList = array();
     $ks = $this->getKs();
     $isAdmin = false;
     if ($ks) {
         $isAdmin = $ks->isAdmin();
     }
     foreach ($list as $dbEntry) {
         $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType(), $isAdmin);
         $entry->fromObject($dbEntry);
         $newList[] = $entry;
     }
     return $newList;
 }
Exemplo n.º 15
0
 protected function updateThumbnailForEntryFromSourceEntry($entryId, $sourceEntryId, $timeOffset, $entryType = null, $flavorParamsId = null)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $entryType !== null && $dbEntry->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $sourceDbEntry = entryPeer::retrieveByPK($sourceEntryId);
     if (!$sourceDbEntry || $sourceDbEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $sourceDbEntry);
     }
     // if session is not admin, we should check that the user that is updating the thumbnail is the one created the entry
     if (!$this->getKs() || !$this->getKs()->isAdmin()) {
         if (strtolower($dbEntry->getPuserId()) !== strtolower($this->getKs()->user)) {
             throw new KalturaAPIException(KalturaErrors::PERMISSION_DENIED_TO_UPDATE_ENTRY);
         }
     }
     $updateThumbnailResult = myEntryUtils::createThumbnailFromEntry($dbEntry, $sourceDbEntry, $timeOffset, $flavorParamsId);
     if (!$updateThumbnailResult) {
         throw new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
     }
     try {
         $wrapper = objectWrapperBase::getWrapperClass($dbEntry);
         $wrapper->removeFromCache("entry", $dbEntry->getId());
     } catch (Exception $e) {
         KalturaLog::err($e);
     }
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $dbEntry, $dbEntry->getPartnerId(), $dbEntry->getPuserId(), null, null, $entryId);
     $ks = $this->getKs();
     $isAdmin = false;
     if ($ks) {
         $isAdmin = $ks->isAdmin();
     }
     $mediaEntry = KalturaEntryFactory::getInstanceByType($dbEntry->getType(), $isAdmin);
     $mediaEntry->fromObject($dbEntry, $this->getResponseProfile());
     return $mediaEntry;
 }
Exemplo n.º 16
0
 public static function getInstance($sourceObject, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $object = KalturaEntryFactory::getInstanceByType($sourceObject->getType());
     if (!$object) {
         return null;
     }
     $object->fromObject($sourceObject, $responseProfile);
     return $object;
 }
Exemplo n.º 17
0
 /**
  * @action export
  * Action for manually exporting an entry
  * @param string $entryId
  * @param int $storageProfileId
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @return KalturaBaseEntry The exported entry
  */
 public function exportAction($entryId, $storageProfileId)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbStorageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if (!$dbStorageProfile) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND, $storageProfileId);
     }
     $scope = $dbStorageProfile->getScope();
     $scope->setEntryId($entryId);
     if (!$dbStorageProfile->fulfillsRules($scope)) {
         throw new KalturaAPIException(KalturaErrors::STORAGE_PROFILE_RULES_NOT_FULFILLED, $storageProfileId);
     }
     try {
         kStorageExporter::exportEntry($dbEntry, $dbStorageProfile);
     } catch (kCoreException $e) {
         if ($e->getCode() == kCoreException::PROFILE_STATUS_DISABLED) {
             throw new KalturaAPIException(APIErrors::PROFILE_STATUS_DISABLED, $entryId);
         }
     }
     //TODO: implement export errors
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }