コード例 #1
0
 public function entryHandled(entry $dbEntry)
 {
     parent::entryHandled($dbEntry);
     if ($this->resource) {
         $this->resource->entryHandled($dbEntry);
     }
 }
 /**
  * Update content of attachment asset
  *
  * @action setContent
  * @param string $id
  * @param KalturaContentResource $contentResource
  * @return KalturaAttachmentAsset
  * @throws KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  * @throws KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED 
  * @validateUser asset::entry id edit
  */
 function setContentAction($id, KalturaContentResource $contentResource)
 {
     $dbAttachmentAsset = assetPeer::retrieveById($id);
     if (!$dbAttachmentAsset || !$dbAttachmentAsset instanceof AttachmentAsset) {
         throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND, $id);
     }
     $dbEntry = $dbAttachmentAsset->getentry();
     if (!$dbEntry || !in_array($dbEntry->getType(), $this->mediaTypes)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $dbAttachmentAsset->getEntryId());
     }
     $previousStatus = $dbAttachmentAsset->getStatus();
     $contentResource->validateEntry($dbAttachmentAsset->getentry());
     $contentResource->validateAsset($dbAttachmentAsset);
     $kContentResource = $contentResource->toObject();
     $this->attachContentResource($dbAttachmentAsset, $kContentResource);
     $contentResource->entryHandled($dbAttachmentAsset->getentry());
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbAttachmentAsset));
     $newStatuses = array(AttachmentAsset::ASSET_STATUS_READY, AttachmentAsset::ASSET_STATUS_VALIDATING, AttachmentAsset::ASSET_STATUS_TEMP);
     if ($previousStatus == AttachmentAsset::ASSET_STATUS_QUEUED && in_array($dbAttachmentAsset->getStatus(), $newStatuses)) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbAttachmentAsset));
     }
     $attachmentAsset = new KalturaAttachmentAsset();
     $attachmentAsset->fromObject($dbAttachmentAsset);
     return $attachmentAsset;
 }
コード例 #3
0
ファイル: CaptionAssetService.php プロジェクト: panigh/server
 /**
  * Update content of caption asset
  *
  * @action setContent
  * @param string $id
  * @param KalturaContentResource $contentResource
  * @return KalturaCaptionAsset
  * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED
  * @validateUser asset::entry id edit 
  */
 function setContentAction($id, KalturaContentResource $contentResource)
 {
     $dbCaptionAsset = assetPeer::retrieveById($id);
     if (!$dbCaptionAsset || !$dbCaptionAsset instanceof CaptionAsset) {
         throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $id);
     }
     $dbEntry = $dbCaptionAsset->getentry();
     if (!$dbEntry || !in_array($dbEntry->getType(), $this->getEnabledMediaTypes()) || !in_array($dbEntry->getMediaType(), array(KalturaMediaType::VIDEO, KalturaMediaType::AUDIO))) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $dbCaptionAsset->getEntryId());
     }
     $previousStatus = $dbCaptionAsset->getStatus();
     $contentResource->validateEntry($dbCaptionAsset->getentry());
     $contentResource->validateAsset($dbCaptionAsset);
     $kContentResource = $contentResource->toObject();
     $this->attachContentResource($dbCaptionAsset, $kContentResource);
     $contentResource->entryHandled($dbCaptionAsset->getentry());
     $newStatuses = array(CaptionAsset::ASSET_STATUS_READY, CaptionAsset::ASSET_STATUS_VALIDATING, CaptionAsset::ASSET_STATUS_TEMP);
     if ($previousStatus == CaptionAsset::ASSET_STATUS_QUEUED && in_array($dbCaptionAsset->getStatus(), $newStatuses)) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbCaptionAsset));
     } else {
         kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbCaptionAsset));
     }
     $captionAsset = new KalturaCaptionAsset();
     $captionAsset->fromObject($dbCaptionAsset, $this->getResponseProfile());
     return $captionAsset;
 }
 /**
  * Update content of thumbnail asset
  *
  * @action setContent
  * @param string $id
  * @param KalturaContentResource $contentResource
  * @return KalturaThumbAsset
  * @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  * @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED
  * @validateUser asset::entry id edit 
  */
 function setContentAction($id, KalturaContentResource $contentResource)
 {
     $dbThumbAsset = assetPeer::retrieveById($id);
     if (!$dbThumbAsset || !$dbThumbAsset instanceof thumbAsset) {
         throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $id);
     }
     $dbEntry = $dbThumbAsset->getentry();
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $dbThumbAsset->getEntryId());
     }
     $previousStatus = $dbThumbAsset->getStatus();
     $contentResource->validateEntry($dbThumbAsset->getentry());
     $contentResource->validateAsset($dbThumbAsset);
     $kContentResource = $contentResource->toObject();
     $this->attachContentResource($dbThumbAsset, $kContentResource);
     $contentResource->entryHandled($dbThumbAsset->getentry());
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbThumbAsset));
     $newStatuses = array(thumbAsset::ASSET_STATUS_READY, thumbAsset::ASSET_STATUS_VALIDATING, thumbAsset::ASSET_STATUS_TEMP);
     if ($previousStatus == thumbAsset::ASSET_STATUS_QUEUED && in_array($dbThumbAsset->getStatus(), $newStatuses)) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbThumbAsset));
     }
     $thumbAssetsCount = assetPeer::countThumbnailsByEntryId($dbThumbAsset->getEntryId());
     $defaultThumbKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     //If the thums has the default tag or the entry is in no content and this is the first thumb
     if ($dbEntry->getCreateThumb() && ($dbThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB) || $dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT && $thumbAssetsCount == 1 && !kFileSyncUtils::fileSync_exists($defaultThumbKey))) {
         $this->setAsDefaultAction($dbThumbAsset->getId());
     }
     $thumbAsset = new KalturaThumbAsset();
     $thumbAsset->fromObject($dbThumbAsset);
     return $thumbAsset;
 }
コード例 #5
0
 /**
  * Update content of flavor asset
  *
  * @action setContent
  * @param string $id
  * @param KalturaContentResource $contentResource
  * @return KalturaFlavorAsset
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED 
  * @validateUser asset::entry id edit
  */
 function setContentAction($id, KalturaContentResource $contentResource)
 {
     $dbFlavorAsset = assetPeer::retrieveById($id);
     if (!$dbFlavorAsset || !$dbFlavorAsset instanceof flavorAsset) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $id);
     }
     $dbEntry = $dbFlavorAsset->getentry();
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $dbFlavorAsset->getEntryId());
     }
     $contentResource->validateEntry($dbFlavorAsset->getentry());
     $contentResource->validateAsset($dbFlavorAsset);
     $kContentResource = $contentResource->toObject();
     $this->attachContentResource($dbFlavorAsset, $kContentResource);
     $contentResource->entryHandled($dbFlavorAsset->getentry());
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbFlavorAsset));
     $newStatuses = array(asset::ASSET_STATUS_EXPORTING, flavorAsset::FLAVOR_ASSET_STATUS_READY, flavorAsset::FLAVOR_ASSET_STATUS_QUEUED, flavorAsset::FLAVOR_ASSET_STATUS_TEMP);
     if (in_array($dbFlavorAsset->getStatus(), $newStatuses)) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbFlavorAsset));
     }
     $flavorAsset = KalturaFlavorAsset::getInstance($dbFlavorAsset, $this->getResponseProfile());
     return $flavorAsset;
 }
 public function entryHandled(entry $dbEntry)
 {
     $srcEntry = entryPeer::retrieveByPK($this->entryId);
     if ($srcEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
             $dbEntry->setDimensions($srcEntry->getWidth(), $srcEntry->getHeight());
             $dbEntry->setMediaDate($srcEntry->getMediaDate(null));
             $dbEntry->save();
         } else {
             $srcFlavorAsset = null;
             if (is_null($this->flavorParamsId)) {
                 $srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->entryId);
             } else {
                 $srcFlavorAsset = assetPeer::retrieveByEntryIdAndParams($this->entryId, $this->flavorParamsId);
             }
             if ($srcFlavorAsset) {
                 $dbEntry->setDimensions($srcFlavorAsset->getWidth(), $srcFlavorAsset->getHeight());
                 $dbEntry->save();
             }
         }
     }
     return parent::entryHandled($dbEntry);
 }