Ejemplo n.º 1
0
 /**
  * @param IRemoteStorageResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  * @throws KalturaErrors::ORIGINAL_FLAVOR_ASSET_NOT_CREATED
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  */
 protected function attachRemoteStorageResource(IRemoteStorageResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     $resources = $resource->getResources();
     $fileExt = $resource->getFileExt();
     $dbEntry->setSource(KalturaSourceType::URL);
     // TODO - move image handling to media service
     if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         foreach ($resources as $currentResource) {
             $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
             $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
         }
         $dbEntry->setStatus(entryStatus::READY);
         $dbEntry->save();
         return null;
     }
     $dbEntry->save();
     $isNewAsset = false;
     if (!$dbAsset) {
         $isNewAsset = true;
         $dbAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId());
     }
     if (!$dbAsset) {
         KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "]");
         if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) {
             $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
             $dbEntry->save();
         }
         throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_NOT_CREATED);
     }
     $syncKey = $dbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     foreach ($resources as $currentResource) {
         $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
         $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
     }
     $dbAsset->setFileExt($fileExt);
     if ($dbAsset instanceof flavorAsset && !$dbAsset->getIsOriginal()) {
         $dbAsset->setStatus(asset::FLAVOR_ASSET_STATUS_READY);
     }
     $dbAsset->save();
     if ($isNewAsset) {
         kEventsManager::raiseEvent(new kObjectAddedEvent($dbAsset));
     }
     kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbAsset));
     if ($dbAsset instanceof flavorAsset && !$dbAsset->getIsOriginal()) {
         kBusinessPostConvertDL::handleConvertFinished(null, $dbAsset);
     }
     return $dbAsset;
 }
 /**
  * @param AttachmentAsset $attachmentAsset
  * @param IRemoteStorageResource $contentResource
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  */
 protected function attachRemoteStorageResource(AttachmentAsset $attachmentAsset, IRemoteStorageResource $contentResource)
 {
     $resources = $contentResource->getResources();
     $attachmentAsset->setFileExt($contentResource->getFileExt());
     $attachmentAsset->incrementVersion();
     $attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_READY);
     $attachmentAsset->save();
     $syncKey = $attachmentAsset->getSyncKey(AttachmentAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     foreach ($resources as $currentResource) {
         $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
         $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param flavorAsset $flavorAsset
  * @param IRemoteStorageResource $contentResource
  * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND
  */
 protected function attachRemoteStorageResource(flavorAsset $flavorAsset, IRemoteStorageResource $contentResource)
 {
     $resources = $contentResource->getResources();
     $flavorAsset->setFileExt($contentResource->getFileExt());
     $flavorAsset->incrementVersion();
     $flavorAsset->save();
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     foreach ($resources as $currentResource) {
         $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId());
         $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile);
     }
     if ($flavorAsset->getIsOriginal()) {
         $flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_QUEUED);
     } else {
         $flavorAsset->setStatusLocalReady();
     }
     $flavorAsset->save();
     kBusinessPostConvertDL::handleConvertFinished(null, $flavorAsset);
 }