Пример #1
0
 /**
  * General code that replaces given entry resource with a given resource, and mark the original
  * entry as replaced
  * @param KalturaEntry $dbEntry The original entry we'd like to replace
  * @param KalturaResource $resource The resource we'd like to attach
  * @param KalturaEntry $tempMediaEntry The replacing entry
  * @throws KalturaAPIException
  */
 protected function replaceResourceByEntry($dbEntry, $resource, $tempMediaEntry)
 {
     $partner = $this->getPartner();
     if (!$partner->getEnabledService(PermissionName::FEATURE_ENTRY_REPLACEMENT)) {
         throw new KalturaAPIException(KalturaErrors::FEATURE_FORBIDDEN, PermissionName::FEATURE_ENTRY_REPLACEMENT);
     }
     if ($dbEntry->getReplacingEntryId()) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_REPLACEMENT_ALREADY_EXISTS);
     }
     $resource->validateEntry($dbEntry);
     $tempDbEntry = $this->prepareEntryForInsert($tempMediaEntry);
     $tempDbEntry->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
     $tempDbEntry->setPartnerId($dbEntry->getPartnerId());
     $tempDbEntry->setReplacedEntryId($dbEntry->getId());
     $tempDbEntry->setIsTemporary(true);
     $tempDbEntry->save();
     $dbEntry->setReplacingEntryId($tempDbEntry->getId());
     $dbEntry->setReplacementStatus(entryReplacementStatus::NOT_READY_AND_NOT_APPROVED);
     if (!$partner->getEnabledService(PermissionName::FEATURE_ENTRY_REPLACEMENT_APPROVAL)) {
         $dbEntry->setReplacementStatus(entryReplacementStatus::APPROVED_BUT_NOT_READY);
     }
     $dbEntry->save();
     $kResource = $resource->toObject();
     $this->attachResource($kResource, $tempDbEntry);
 }
Пример #2
0
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null, $advancedOptions = null)
 {
     if ($advancedOptions) {
         $dbEntry->setReplacementOptions($advancedOptions->toObject());
         $dbEntry->save();
     }
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT || $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $tempMediaEntry = new KalturaMediaEntry();
         $tempMediaEntry->type = $dbEntry->getType();
         $tempMediaEntry->mediaType = $dbEntry->getMediaType();
         if (!$conversionProfileId) {
             $originalConversionProfileId = $dbEntry->getConversionQuality();
             $conversionProfile = conversionProfile2Peer::retrieveByPK($originalConversionProfileId);
             if (is_null($conversionProfile) || $conversionProfile->getType() != ConversionProfileType::MEDIA) {
                 $defaultConversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId());
                 if (!is_null($defaultConversionProfile)) {
                     $conversionProfileId = $defaultConversionProfile->getId();
                 }
             } else {
                 $conversionProfileId = $originalConversionProfileId;
             }
         }
         if ($conversionProfileId) {
             $tempMediaEntry->conversionProfileId = $conversionProfileId;
         }
         $this->replaceResourceByEntry($dbEntry, $resource, $tempMediaEntry);
     }
     $resource->entryHandled($dbEntry);
 }
 /**
  * Attach content resource to entry in status NO_MEDIA
  *
  * @action addContent
  * @param string $entryId
  * @param KalturaResource $resource
  * @return KalturaBaseEntry
  * @throws KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED
  * @validateUser entry entryId edit
  */
 function addContentAction($entryId, KalturaResource $resource)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $kResource = $resource->toObject();
     if ($dbEntry->getType() == KalturaEntryType::AUTOMATIC || is_null($dbEntry->getType())) {
         $this->setEntryTypeByResource($dbEntry, $kResource);
     }
     $dbEntry->save();
     $resource->validateEntry($dbEntry);
     $this->attachResource($kResource, $dbEntry);
     $resource->entryHandled($dbEntry);
     return $this->getEntry($entryId);
 }
Пример #4
0
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null)
 {
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $tempDocEntry = new KalturaDocumentEntry();
         $tempDocEntry->type = $dbEntry->getType();
         $tempDocEntry->mediaType = $dbEntry->getMediaType();
         $tempDocEntry->documentType = $dbEntry->getDocumentType();
         $tempDocEntry->conversionProfileId = $dbEntry->getConversionQuality();
         if ($conversionProfileId) {
             $tempDocEntry->conversionProfileId = $conversionProfileId;
         }
         $this->replaceResourceByEntry($dbEntry, $resource, $tempDocEntry);
     }
     $resource->entryHandled($dbEntry);
 }
Пример #5
0
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null, $advancedOptions = null)
 {
     if ($advancedOptions) {
         $dbEntry->setReplacementOptions($advancedOptions->toObject());
         $dbEntry->save();
     }
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT || $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $kResource = $resource->toObject();
         if ($kResource instanceof kOperationResource && $this->isResourceKClip($kResource)) {
             $internalResource = $kResource->getResource();
             if ($dbEntry->getIsTrimDisabled() && $internalResource instanceof kFileSyncResource && $dbEntry->getId() == $internalResource->getOriginEntryId()) {
                 throw new KalturaAPIException(KalturaErrors::ENTRY_CANNOT_BE_TRIMMED);
             }
         }
         $tempMediaEntry = new KalturaMediaEntry();
         $tempMediaEntry->type = $dbEntry->getType();
         $tempMediaEntry->mediaType = $dbEntry->getMediaType();
         if (!$conversionProfileId) {
             $originalConversionProfileId = $dbEntry->getConversionQuality();
             $conversionProfile = conversionProfile2Peer::retrieveByPK($originalConversionProfileId);
             if (is_null($conversionProfile) || $conversionProfile->getType() != ConversionProfileType::MEDIA) {
                 $defaultConversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId());
                 if (!is_null($defaultConversionProfile)) {
                     $conversionProfileId = $defaultConversionProfile->getId();
                 }
             } else {
                 $conversionProfileId = $originalConversionProfileId;
             }
         }
         if ($conversionProfileId) {
             $tempMediaEntry->conversionProfileId = $conversionProfileId;
         }
         $this->replaceResourceByEntry($dbEntry, $resource, $tempMediaEntry);
     }
     $resource->entryHandled($dbEntry);
 }
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null)
 {
     if (!$this->getPartner()->getWamsAccountName() || !$this->getPartner()->getWamsAccountKey()) {
         exit;
     }
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT || $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $partner = $this->getPartner();
         if (!$partner->getEnabledService(PermissionName::FEATURE_ENTRY_REPLACEMENT)) {
             KalturaLog::notice("Replacement is not allowed to the partner permission [FEATURE_ENTRY_REPLACEMENT] is needed");
             throw new KalturaAPIException(KalturaErrors::FEATURE_FORBIDDEN, PermissionName::FEATURE_ENTRY_REPLACEMENT);
         }
         if ($dbEntry->getReplacingEntryId()) {
             throw new KalturaAPIException(KalturaErrors::ENTRY_REPLACEMENT_ALREADY_EXISTS);
         }
         $resource->validateEntry($dbEntry);
         $tempMediaEntry = new KalturaMediaEntry();
         $tempMediaEntry->type = $dbEntry->getType();
         $tempMediaEntry->mediaType = $dbEntry->getMediaType();
         $tempMediaEntry->conversionProfileId = $dbEntry->getConversionQuality();
         if ($conversionProfileId) {
             $tempMediaEntry->conversionProfileId = $conversionProfileId;
         }
         $tempDbEntry = $this->prepareEntryForInsert($tempMediaEntry);
         $tempDbEntry->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
         $tempDbEntry->setPartnerId($dbEntry->getPartnerId());
         $tempDbEntry->setReplacedEntryId($dbEntry->getId());
         $tempDbEntry->save();
         $dbEntry->setReplacingEntryId($tempDbEntry->getId());
         $dbEntry->setReplacementStatus(entryReplacementStatus::NOT_READY_AND_NOT_APPROVED);
         if (!$partner->getEnabledService(PermissionName::FEATURE_ENTRY_REPLACEMENT_APPROVAL)) {
             $dbEntry->setReplacementStatus(entryReplacementStatus::APPROVED_BUT_NOT_READY);
         }
         $dbEntry->save();
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $tempDbEntry);
     }
     $resource->entryHandled($dbEntry);
 }