/**
  * @return string
  */
 public function getEntryId()
 {
     if ($this->fileSyncObjectType == FileSyncObjectType::ENTRY) {
         return $this->objectId;
     }
     $object = kFileSyncObjectManager::retrieveObject($this->fileSyncObjectType, $this->objectId);
     if (method_exists($object, 'getEntryId')) {
         return $object->getEntryId();
     }
     return null;
 }
 /**
  * @param AttachmentAsset $attachmentAsset
  * @param kFileSyncResource $contentResource
  */
 protected function attachFileSyncResource(AttachmentAsset $attachmentAsset, kFileSyncResource $contentResource)
 {
     $syncable = kFileSyncObjectManager::retrieveObject($contentResource->getFileSyncObjectType(), $contentResource->getObjectId());
     $srcSyncKey = $syncable->getSyncKey($contentResource->getObjectSubType(), $contentResource->getVersion());
     return $this->attachFileSync($attachmentAsset, $srcSyncKey);
 }
Ejemplo n.º 3
0
 /**
  *
  * @param FileSyncKey $sync_key
  * @return ISyncableFile
  */
 public static function retrieveObjectForSyncKey(FileSyncKey $sync_key)
 {
     return kFileSyncObjectManager::retrieveObject($sync_key->object_type, $sync_key->object_id);
 }
Ejemplo n.º 4
0
 /**
  * @param kFileSyncResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset | NULL in case of IMAGE entry
  * @throws KalturaErrors::UPLOAD_ERROR
  * @throws KalturaErrors::INVALID_OBJECT_ID
  */
 protected function attachFileSyncResource(kFileSyncResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     $dbEntry->setSource(entry::ENTRY_MEDIA_SOURCE_KALTURA);
     $dbEntry->save();
     try {
         $syncable = kFileSyncObjectManager::retrieveObject($resource->getFileSyncObjectType(), $resource->getObjectId());
     } catch (kFileSyncException $e) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $resource->getObjectId());
     }
     $srcSyncKey = $syncable->getSyncKey($resource->getObjectSubType(), $resource->getVersion());
     $dbAsset = $this->attachFileSync($srcSyncKey, $dbEntry, $dbAsset);
     //In case the target entry's media type is image no asset is created and the image is set on a entry level file sync
     if (!$dbAsset && $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         return null;
     }
     // Copy the media info from the old asset to the new one
     if ($syncable instanceof asset && $resource->getObjectSubType() == asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET) {
         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($syncable->getId());
         if ($mediaInfo) {
             $newMediaInfo = $mediaInfo->copy();
             $newMediaInfo->setFlavorAssetId($dbAsset->getId());
             $newMediaInfo->save();
         }
         if ($dbAsset->getStatus() == asset::ASSET_STATUS_READY) {
             $dbEntry->syncFlavorParamsIds();
             $dbEntry->save();
         }
     }
     return $dbAsset;
 }
 /**
  * @param kFileSyncResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  * @throws KalturaErrors::UPLOAD_ERROR
  * @throws KalturaErrors::INVALID_OBJECT_ID
  */
 protected function attachFileSyncResource(kFileSyncResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     $dbEntry->setSource(entry::ENTRY_MEDIA_SOURCE_KALTURA);
     $dbEntry->save();
     try {
         $syncable = kFileSyncObjectManager::retrieveObject($resource->getFileSyncObjectType(), $resource->getObjectId());
     } catch (kFileSyncException $e) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $resource->getObjectId());
     }
     $srcSyncKey = $syncable->getSyncKey($resource->getObjectSubType(), $resource->getVersion());
     $dbAsset = $this->attachFileSync($srcSyncKey, $dbEntry, $dbAsset);
     // Copy the media info from the old asset to the new one
     if ($syncable instanceof asset && $resource->getObjectSubType() == asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET) {
         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($syncable->getId());
         if ($mediaInfo) {
             $newMediaInfo = $mediaInfo->copy();
             $newMediaInfo->setFlavorAssetId($dbAsset->getId());
             $newMediaInfo->save();
         }
     }
     return $dbAsset;
 }