Beispiel #1
0
 /**
  * @param kResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  */
 protected function attachResource(kResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     switch ($resource->getType()) {
         case 'kAssetsParamsResourceContainers':
             return $this->attachAssetsParamsResourceContainers($resource, $dbEntry);
         case 'kAssetParamsResourceContainer':
             return $this->attachAssetParamsResourceContainer($resource, $dbEntry, $dbAsset);
         case 'kUrlResource':
             return $this->attachUrlResource($resource, $dbEntry, $dbAsset);
         case 'kLocalFileResource':
             return $this->attachLocalFileResource($resource, $dbEntry, $dbAsset);
         case 'kFileSyncResource':
             return $this->attachFileSyncResource($resource, $dbEntry, $dbAsset);
         case 'kRemoteStorageResource':
         case 'kRemoteStorageResources':
             return $this->attachRemoteStorageResource($resource, $dbEntry, $dbAsset);
         default:
             KalturaLog::err("Resource of type [" . get_class($resource) . "] is not supported");
             $dbEntry->setStatus(entryStatus::ERROR_IMPORTING);
             $dbEntry->save();
             throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($resource));
     }
 }
 /**
  * @param kResource $resource
  */
 protected function setEntryTypeByResource(entry $dbEntry, kResource $resource)
 {
     $fullPath = null;
     switch ($resource->getType()) {
         case 'kAssetParamsResourceContainer':
             return $this->setEntryTypeByResource($dbEntry, $resource->getResource());
         case 'kAssetsParamsResourceContainers':
             return $this->setEntryTypeByResource($dbEntry, reset($resource->getResources()));
         case 'kFileSyncResource':
             $sourceEntry = null;
             if ($resource->getFileSyncObjectType() == FileSyncObjectType::ENTRY) {
                 $sourceEntry = entryPeer::retrieveByPK($resource->getObjectId());
             }
             if ($resource->getFileSyncObjectType() == FileSyncObjectType::FLAVOR_ASSET) {
                 $sourceAsset = assetPeer::retrieveByPK($resource->getObjectId());
                 if ($sourceAsset) {
                     $sourceEntry = $sourceAsset->getentry();
                 }
             }
             if ($sourceEntry) {
                 $dbEntry->setType($sourceEntry->getType());
                 $dbEntry->setMediaType($sourceEntry->getMediaType());
             }
             return;
         case 'kLocalFileResource':
             $fullPath = $resource->getLocalFilePath();
             break;
         case 'kUrlResource':
         case 'kRemoteStorageResource':
             $fullPath = $resource->getUrl();
             break;
         default:
             return;
     }
     if ($fullPath) {
         $this->setEntryTypeByExtension($dbEntry, $fullPath);
     }
 }