public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kAssetParamsResourceContainer(); } if ($this->resource) { $object_to_fill->setResource($this->resource->toObject()); } $object_to_fill->setAssetParamsId($this->assetParamsId); return $object_to_fill; }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (is_null($this->operationAttributes) || !count($this->operationAttributes)) { return $this->resource->toObject(); } if (!$object_to_fill) { $object_to_fill = new kOperationResource(); } $operationAttributes = array(); foreach ($this->operationAttributes as $operationAttributesObject) { $operationAttributes[] = $operationAttributesObject->toObject(); } $object_to_fill->setOperationAttributes($operationAttributes); $object_to_fill->setResource($this->resource->toObject()); return parent::toObject($object_to_fill, $props_to_skip); }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kUrlResource(); } return parent::toObject($object_to_fill, $props_to_skip); }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kLocalFileResource(); } file_put_contents($fname = tempnam(myContentStorage::getFSUploadsPath(), "KFR"), $this->content); $object_to_fill->setLocalFilePath($fname); $object_to_fill->setSourceType(entry::ENTRY_MEDIA_SOURCE_TEXT); return parent::toObject($object_to_fill, $props_to_skip); }
public function validateForUsage($sourceObject, $propertiesToSkip = array()) { parent::validateForUsage($sourceObject, $propertiesToSkip); $dc = $this->getDc(); if ($dc == kDataCenterMgr::getCurrentDcId()) { return; } $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc); if ($remoteDCHost) { kFileUtils::dumpApiRequest($remoteDCHost); } throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc); }
public function validateEntry(entry $dbEntry) { parent::validateEntry($dbEntry); $dc = $this->getDc(); if ($dc == kDataCenterMgr::getCurrentDcId()) { return; } $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc); if ($remoteDCHost) { kFile::dumpApiRequest($remoteDCHost); } throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc); }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kRemoteStorageResources(); } $resources = array(); if ($this->resources) { foreach ($this->resources as $resource) { /* @var $resource KalturaRemoteStorageResource */ $resources[] = $resource->toObject(); } } $object_to_fill->setResources($resources); return parent::toObject($object_to_fill, $props_to_skip); }
public function validateForUsage($sourceObject, $propertiesToSkip = array()) { parent::validateForUsage($sourceObject, $propertiesToSkip); $this->validatePropertyNotNull('assetId'); $srcFlavorAsset = assetPeer::retrieveById($this->assetId); if (!$srcFlavorAsset) { throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $resource->assetId); } $key = $srcFlavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $c = FileSyncPeer::getCriteriaForFileSyncKey($key); $c->addAnd(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_FILE, FileSync::FILE_SYNC_FILE_TYPE_LINK), Criteria::IN); $fileSyncs = FileSyncPeer::doSelect($c); foreach ($fileSyncs as $fileSync) { $fileSync = kFileSyncUtils::resolve($fileSync); if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) { return; } } throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST); }
/** * Update content of caption asset * * @param string $id * @param KalturaContentResource $contentResource * @return KalturaCaptionAsset */ function setContent($id, KalturaContentResource $contentResource) { $kparams = array(); $this->client->addParam($kparams, "id", $id); $this->client->addParam($kparams, "contentResource", $contentResource->toParams()); $this->client->queueServiceActionCall("caption_captionasset", "setContent", $kparams); if ($this->client->isMultiRequest()) { return $this->client->getMultiRequestResult(); } $resultObject = $this->client->doQueue(); $this->client->throwExceptionIfError($resultObject); $this->client->validateObjectType($resultObject, "KalturaCaptionAsset"); return $resultObject; }
/** * 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; }
/** * 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); }
/** * Set content of file asset * * @action setContent * @param string $id * @param KalturaContentResource $contentResource * @return KalturaFileAsset * @throws KalturaErrors::FILE_ASSET_ID_NOT_FOUND * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN * @throws KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND * @throws KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED */ function setContentAction($id, KalturaContentResource $contentResource) { $dbFileAsset = FileAssetPeer::retrieveByPK($id); if (!$dbFileAsset) { throw new KalturaAPIException(KalturaErrors::FILE_ASSET_ID_NOT_FOUND, $id); } $kContentResource = $contentResource->toObject(); $this->attachContentResource($dbFileAsset, $kContentResource); $fileAsset = new KalturaFileAsset(); $fileAsset->fromObject($dbFileAsset, $this->getResponseProfile()); return $fileAsset; }
/** * 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; }
function update($id, KalturaThumbAsset $thumbAsset, KalturaContentResource $contentResource = null) { $kparams = array(); $this->client->addParam($kparams, "id", $id); $this->client->addParam($kparams, "thumbAsset", $thumbAsset->toParams()); if ($contentResource !== null) { $this->client->addParam($kparams, "contentResource", $contentResource->toParams()); } $this->client->queueServiceActionCall("thumbasset", "update", $kparams); if ($this->client->isMultiRequest()) { return null; } $resultObject = $this->client->doQueue(); $this->client->throwExceptionIfError($resultObject); $this->client->validateObjectType($resultObject, "KalturaThumbAsset"); return $resultObject; }
public function fromObject($source_object) { /* @var $source_object kRemoteStorageResources */ parent::fromObject($source_object); $this->resources = KalturaRemoteStorageResourceArray::fromObjectArray($source_object->getResources()); }